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

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?