I want to display a bar graph with name of plans on x-axis and their value on y-axis with filter based on the time.
This is the query I used
p.name as 'Plan',
count(*) as 'Count'
FROM plans_userplan up
INNER JOIN plans_plan p ON p.id = up.plan_id
GROUP BY p.name
ORDER BY $__timeGroup(up.created,$__interval)
But it says Data is missing string field
On changing to Table view, the Plan is displayed as a column
How can I have the
plan name on the x-axis and their count on the y-axis?
it looks like you might want to use the Bar Chart, which uses arbitrary strings on the x axis:
See the docs for the data model that you will need to fit:
Thanks, @mattabrams I tried using Transform to change the data type of the field, but in my case, all data is showing as a new field (column)
While as from the SQL query
now() as 'time',
p.name AS 'Plan',
count(*) AS 'Count'
Plan should appear as a column, having the plan names as row values.
The same result in MySQL looks like
but in Grafana, it is combining both
plan columns to create new columns.