Bar chart Grouped grafana 8

In the new release of Grafana 8 there is now a grouped bar chart. Looks like it was in beta on Grafana 7.
In the whats new page for grafana 8 it shows two examples.
https://grafana.com/docs/grafana/latest/whatsnew/whats-new-in-v8-0/

The second example is exactly what I am trying to accomplish. I cannot find any information on how to actually make it though.

I know there is a plugin for grouped bar chart but since it should be possible in this version I would like to stick with the built in graph.

This is what I have, data is added below:

I am trying to get something like what is shown on the grafana 8 whats new page:
Day on the bottom, series by customer, quantity on the axis.
image

Can someone show how the chart on the whats new page was created. I cannot find examples anywhere.

  • What Grafana version and what operating system are you using?
    Grafana 8

  • What are you trying to achieve?
    Grouped bar chart

  • How are you trying to achieve it?
    using Bar Chart

  • What happened?
    picked a quantity per day

  • What did you expect to happen?
    grouped quantity per day by customer

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    No errors

  • Did you follow any online instructions? If so, what is the URL?
    Couldnt find any

4 Likes

Hi @pbrink231

Here is that same query you want to replicate, but visualized using the table panel:

This is what you want to replicate. A collection of values associated with a string.

Here is what I do when playing with the categorical bar charts:

  • I make sure the TestData DB that is built-in with Grafana is added as a datasource.
  • I create new panel and choose TestData DB and then choose CSV Content from the Scenario dropdown.
  • add this to the text box:
Library, Github Stars, Forks, Watchers
React.js, 169000, 34000, 6700
Vue, 184000, 29100, 6300

You’ve now mocked out that data and can fiddle with it. Then you can take it to the next step and link it to GoogleSheets or pull in CSV data using the CSV plugin, BigQuery, or others:

Hi there,

Thanks for this information. I’m wondering how I can do this with a MySQL query. Perhaps it’s just that I don’t have enough experience writing queries, but I don’t understand how to make thousands of records into a form similar to what’s shown above. It seems like I would have to pivot the results into column headers.

Thank you,

Nick

hope I understand your issue correctly
and hope this help
image
the idea is to select the category (age) and then the series (male, female)

result:

Hi @bferdinandes,

Thank you. Yes, that makes sense, but my series names are dynamic. I’d like to select client names as the category, tickets per technician name would be the series (I think).

So, using the CSV example originally posted, what I’d like to get is something like this:

This is my current query:

SELECT COUNT(ticket_id), S.firstname AS Tech, O.name AS Client
FROM tickets T
	JOIN staff S ON T.staff_id = S.staff_id
    JOIN user U ON T.user_id = U.id
    JOIN organization O ON U.org_id = O.id
GROUP BY Client, Tech
ORDER BY Client

I think I need to transform the query somehow and I’m just not experienced enough with SQL, I think.

Thank you for your help!

Nick

sorry cant think of a way if you want the series to be dynamic…

1 Like

Hey @bferdinandes, quick question: are there any other adjustments i have to make to get rid of the error of “bar chart requires a string field” besides adding AS string values for the query?

Here is my query:

SELECT
SUM(x.buying_price_per_unit * x.quantity) as “Revenue”,
count(y.id) AS “Sales”,
$__timeGroupAlias(created_date,1h)
FROM y
INNER JOIN x ON x.order_id = y.id
GROUP BY created_date
ORDER BY $__timeGroup(created_date,1h)SELECT

@pbrink231 , are u able to find a solution for this ?

What i noticed is this grouped chart works well for csv data. But when it comes to sql queries this is not working.

1 Like

This topic was automatically closed after 365 days. New replies are no longer allowed.