graphTooltip does not get applied when set in scripted dashboard


#1

Hello people :slight_smile:

I am having an issue when trying to set graphTooltip to 1 (shared crosshair).

Here’s the relevant code and the object as returned by the script:

But even though the object contains the value, it is not set in the dashboard json:

Any idea what I might be doing wrong?

Thanks in advance. Cheers!
Sakis


#2

Any info on this would be greatly appreciated. :slight_smile:


#3

I could recreate this. Digging into why it does not work.


#4

Ok, figured it out. Grafana has a dashboard migration that upgrades dashboards from previous versions of Grafana to the current version. As you don’t set a schemaVersion in the script (and it is also missing from the examples) then it gets schemaVersion 0.

Then the migration for schemaVersion 14 tries to migrate the old sharedCrosshair property to the new graphTooltip property but in this case succeeds in resetting it to zero.

    if (oldVersion < 14) {
      this.dashboard.graphTooltip = old.sharedCrosshair ? 1 : 0;
    }

Solution - Add a schemaVersion:

dashboard.schemaVersion = 16;

16 is the latest schemaVersion for Grafana 5.0 beta. 14 is the schemaVersion for Grafana 4.6.3.


#5

Thanks a lot for sharing this!

Great job on figuring it out!