MySQL Query How to change the legend display

Hello,
I need some help with Grafana and MySQL. I want to display my project_titles as the Legend Values for my Legend and display it in the panel with different colors for each value just as I did it in plotly. I’m not really sure how to do it and looked over some other Topics but I could not find a solution. I found things like $__cell_0 for the Display but that doesn’t really help eather (https://community.grafana.com/t/bar-gauge-how-to-show-series-name-from-a-querys-row-value-mysql/17809/16). Maybe someone could help me with this problem.

It should look like my plot which looks like this:

But I am only able to get it to work like this:

All advice is welcome

Thanks!

Welcome to the Grafana forum.

Can you post a small snapshot table of your data? Does each project_title have just one timestamp associated with it?

Hello,

First of all, thanks for the reply. I did some changes to my table (changed the project_title to city names) and now I have got the bar chart like the one from plotly, but the problem with the legend still exists. It looks like this now:

For the table data I would have provided a csv file but unfortunatetly you can’t upload csv files here is there another way to do that? But I can say for each date in my table in the row ‘datum’ there is one city with cpuh. So for example there is:

Dresden | 562115 | 2020-01-01 01:00:00
Dresden | 493259 | 2020-01-02 01:00:00
Dresden | 557615 | 2020-01-03 01:00:00

But it is also possible that for some days there is no data for each city. In the screenshot you can also see how the table looks like.

And sorry for the late response.

If I understand correctly, the only problem you have now is the legend in Grafana does not display the name of the city, correct? If yes, how about using overrides? You will have to set up a lot of them (one for each city), but probably < 15 minutes work for 60 cities.
BEFORE:

AFTER (changed backend_01 to Karlsruhe):

You are right, I just wanna display the city names in the legend. But I only have one with the name ‘cpuh’ so I only can override this one entry, if I add more overrides it only changes the name of the first override to the second one. Grafana recognizes that there is more than one entry for each date but in the end it only shows that there is only ‘cpuh’. I’m not really sure how to do it and I also tried to create a variable which gives me a list for the cities but I am still not able to get more entries.

Update: I finally managed it to work like I did in my python plot.
Result looks like this now:

1 Like

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