Use legend as x-axis

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

  $__timeGroupAlias(up.created,$__interval), as 'Plan',
  count(*) as 'Count'
FROM plans_userplan up
INNER JOIN plans_plan p ON = up.plan_id
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', 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
Screen Shot 2022-05-25 at 8.36.06 AM

but in Grafana, it is combining both count and plan columns to create new columns.