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
SELECT
$__timeGroupAlias(up.created,$__interval),
p.name as 'Plan',
count(*) as 'Count'
FROM plans_userplan up
INNER JOIN plans_plan p ON p.id = up.plan_id
WHERE
$__timeFilter(up.created)
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:
https://play.grafana.org/d/ktMs4D6Mk/5-bar-charts-and-pie-charts?orgId=1
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
SELECT
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 count
and plan
columns to create new columns.