grafana-plotly-panel icon indicating copy to clipboard operation
grafana-plotly-panel copied to clipboard

Auto Multiple Line Chart Possible for Non Time Series?

Open hc128168 opened this issue 4 years ago • 5 comments

Hi,

I wonder whether plotly panel can automatically create "trace"s based on the unique value of a column in the SQL result.

For example, let's say my SQL result is like this

x_axis|y_axis|trace

1 | 1 | trace1 2 | 2 | trace1 3 | 3 | trace1 4 | 4 | trace1 5 | 5 | trace1 0 | 1 | trace2 1 | 2 | trace2 2 | 3 | trace2 3 | 4 | trace2 4 | 5 | trace2

I want to have two lines in the graph.

Currently, I have to two queries configured -- one with "where trace = 'trace1'" and another "where trace = 'trace2'" to get those two lines displayed

This doesn't scale well as I add more unique "trace"s to the DB.

Grafana's come with "graph" plugin and it will take a column named "metric" as the "trace" to provide a multiline chart. Tho, it doesn't work for non time series, that's why I am trying plotly here.

Seems like there was a ticket for mutliline chart for time series: https://github.com/NatelEnergy/grafana-plotly-panel/issues/9

So maybe non-time-series multiline chart isn't supported?

Any pointer is appreciated.

hc128168 avatar May 13 '20 06:05 hc128168

This is similar to the feature request in #95

Bubbu17 avatar May 25 '20 12:05 Bubbu17

image something like this?

Bubbu17 avatar May 25 '20 13:05 Bubbu17

image something like this?

For time series, it is possible to get multiple line chart with Grafana's built-in plugin "Graph".

hc128168 avatar May 26 '20 00:05 hc128168

For non-time series, it is also possible to use Grafana's builtin Graph, encode the non-time measure into year component of date (has highest usable range), and display it as a time series. Then fix the date range for the dashboard. This is an extremely roundabout way of doing it, but so far the only one I have discovered - for cumulative histograms (with percentiles on the X axis) from PostgreSQL data source, with X axis from year 2000 to 2100, this works "well enough". :man_shrugging:

mjerabek avatar May 26 '20 09:05 mjerabek

@mjerabek appreciate your suggestion -- yes, I noticed that workaround too. Tho, it is kind of sad to tweak the data to fit the frontend. And then when I change the frontend, I have to tweak the data again...

That's why I opened this ticket.

hc128168 avatar May 26 '20 09:05 hc128168