Legend appears twice ... when I have data sources on one graph?

Hi,

I am very new to Grafana, I have created a chart with one data source and the legend is shown correctly.

I then created another chart with 2 data sources and now the legend shows … Electric Electric … it should only show Electric once. It may be my query is wrong or is there something in Grafana I need to change ?

OR it maybe I use 2 separate queries for the graph, like this …

select json_extract( value, ‘$.Gas_reading’ ) as Gas, json_extract( value, ‘$.iso’) as time from DATABASE, json_tree( DATABASE.data, ‘$.IP15’ ) where type = ‘object’ and json_extract( value, ‘$.Gas_reading’ );

select json_extract( value, ‘$.Electricity_reading’ ) as Electicity, json_extract( value, ‘$.iso’) as time from DATABASE, json_tree( DATABASE.data, ‘$.IP22’ ) where type = ‘object’ and json_extract( value, ‘$.Electricity_reading’ );

Ithink they should be one query, but how ?

Thanks Gaz

Try to Change it from Tables to Time Series

Hi,
It is already set to Time series.
I am using a JSON SQlite databse and I do not seem to have your choices of queries shown above or do i need to add or change something ?

thanks Gaz

Where is it set as such? Let me try to spin up a sqllite db locally and test it
Which SQLLite plugin are you using?

Maybe you can use transform tab to change it into a time series ?

Hi yosiasz

I am using
07

1 Like

while I get that spun up, what happens if you removed the alias

as Electricity

also what version of grafana are you on?

10

grafana 9.0.7

If this helps …
My Database setup

03

and the objects that are in the above Database DATA table.

1 Like

you want me to retype all of that :stuck_out_tongue_winking_eye:
Please post as text and not as an image?

ha ha yes i did think of that just now … here you are

{
“IP15”: [
{
“Gas_reading”: 0,
“iso”: “2022-08-19T14:40:55.069Z”,
“location”: “Garage”,
“timestamp”: 1660920055
}
]
}

and the other

{
“IP22”: [
{
“Electricity_reading”: 2.787,
“iso”: “2022-08-19T14:41:31.765Z”,
“location”: “Garage”,
“timestamp”: 1660920092
}
]
}

Hi again,

I have just found this … follow the link

The reply is from the man that wrote the addon.

I cannot find the … Grafana visualization configuration.

Where would that be ?

Thanks Gaz

sorry got stuck in python trying to import your data :frowning:

Hi yosiasz,

Thanks for your help I finally found out what the problem was you have to change …

then you get

13

Easy when you find the answer :disappointed_relieved:

anyway thanks for your help and have a great day

Gaz

1 Like

that sounds hard to maintain if a new reading type comes in. this should be done dynamically
using Merge I get the following

image

without merge (double vision) :eyes:

and it makes sense cause without merge you have 2 frames of data. So it is being helpful to differentiate one from the other.

Also I would go for 1 query approach with maybe a pivot.

You shouldn’t have to add an “override” but just use the regular “display name” setting.
This works pretty well in my opinion.

Version 3.1.1 of the plugin will have a bit better naming here but the core issue of more information added to the legend is due to Grafana (especially if using multiple lines in a chart).

Some more information can also be found here: Legend appears twice · Issue #96 · fr-ser/grafana-sqlite-datasource · GitHub

1 Like