Hide the legend and tooltip for all-null or all-zero series in panel from grafana

What Grafana version and what operating system are you using?

  • Grafana version: Grafana v9.3.6 (978237e7cb)
  • Operating system: Windows
  • Browser: Chrome

What are you trying to achieve?
I query a database and each column that is returned is an item in the legend. All data is grouped by a name attribute (that’s why the names are repeated in the legend). However, data represented by blue, yellow, and red colors may return null.

When the series of these data is null, I would like their legend not to be displayed and that they also not appear in the tooltip.

Information to take into consideration: the name of the legends is the same as I need all the series that have the same name to be displayed when clicking to filter in the legend. For example, assuming there is no null data, if I click on any AAA legend, all AAA series should be on the chart. Like the following picture:

How are you trying to achieve it?
Reading documentation and forums. But I didn’t find any solution unfortunately.

I’ve also tried adding a hidden override property to the blue AAA legend, for example. I added a new override, selected “Fields with name” and selected AAA. Then I added a property “Series > Hide in area” and marked “legend”. However, in this case, the filter by legend stopped working as I described earlier.

Does anyone know how I can hide the legend and tooltip data when the series is totally null?


What is your datasource? Can you eliminate bringing them from data source when data is null?


My datasource is a MYSQL database.
I make a SQL query like this:

  tableA.timestamp AS "time",
  tableA.moisture AS "moisture",
  tableB.board_id AS "sensor",
  tableC.name AS "talhão",
  tableD.fc AS "CC",
  tableD.pwp AS "PMP",
  tableD.moisture_critical AS "UC"
FROM tableA
RIGHT JOIN tableE ON tableA.sensor_id = tableE.id
LEFT JOIN tableD ON tableE.id = tableD.sensor_id AND (${parametros_solo:doublequote}) = "SIM"
LEFT JOIN tableB ON tableE.id = tableB.sensor_id
LEFT JOIN tableC ON tableE.plot_id = tableC.id
RIGHT JOIN tableF ON tableC.farm_id = tableF.id
  tableF.name in(${Fazenda:doublequote}) AND
  tableE.deleted_at IS NULL AND
  tableA.timestamp IS NOT NULL
GROUP BY time, sensor

So each column in the SQL projection is a legend item. I don’t know if there would be a way when the column is completely null it doesn’t return in SQL. That would solve the problem.
Currently the return looks like this:


Hi @nadine3,

Welcome to the :grafana: community support forums !!

We are excited that you joined our OSS community. Please read about some of the FAQs in the community :slight_smile:

Not sure but worth a try. I saw this post yesterday where the issue was related to the repeated labels in the panel and via Transformation was able to hide it.

Maybe it could help you?

Another way to hide the null values is to use the "Special Value Mapping "

Hi @usman.ahmad!

Sadly it doesn’t seem to work for me.

My time series is “composite”. That is, a blue line, a yellow line, a red line and a purple line belong to the same data that I am filtering.

So I needed only one caption to appear for these 4 lines. Where to click on this subtitle to filter these 4 lines.

Eventually, the blue, yellow and red line may not be present by the panel’s “Soil Parameters” filter. And even if the lines are not visible because they are null values, the repeated names still appear in the legend.

I don’t know how to explain it, I hope I made myself understood.

Could you help me with that?

Thanks for the more detailed reply. Unfortunately, I do not know how to achieve it.

Maybe some other community member might be able to help you out

1 Like

I had a similar Problem and found a solution. There was added a new feature in March to solve this problem. There is a video in the issue for this feature:

It’s really easy now, go on overrides and choose “Fields with values”. Here you can choose “All Zeros” or “All Nulls”, so it matches with series where all values are zeros or nulls.

Now you can add the property “Series > Hide in Area” and klick there on all fields where you want to hide this series (legend, tooltip and vizualisation).