ae3e / ae3e-plotly-panel

Plotly panel for Grafana
Apache License 2.0
94 stars 24 forks source link

Applying same 'data' template to multiple series #34

Closed korunekosama closed 3 years ago

korunekosama commented 3 years ago

Hello, Sorry i f my question seems trivial to you.

I am trying to display several series simultaneously on a scatter graph with the same template. I manage to display the series but the template specified in data (type: scatter; mode: markers) only applies to the first one. The other series are displayed in line mode which seems to be the default mode.

The 'Data' bloc containing the following code : [ { "type": "scatter", "mode": "markers", "line": { "color": "red", "width": 2 } } ]

The script bloc containing the following code : console.log(data)

let x1 = data.series[0].fields[1].values.buffer let y1 = data.series[1].fields[1].values.buffer let serie1 = { x : x1, y : y1, name : 'M1' }

let x2 = data.series[2].fields[1].values.buffer let y2 = data.series[3].fields[1].values.buffer let serie2 = { x : x2, y : y2, name : 'M2' }

return { data:[serie1,serie2], layout:{title:'My Chart'} };

image M1 is displayed correctly, not M2.

I also try to display the different series in a different color; in order to distinguish them. I imagine this should be done in the script block; but the 'data' output does not seem to allow the passing of certain parameters found in the dedicated 'data' block.

Any help would be appreciate.

Thanks !

ae3e commented 3 years ago

There's 2 ways to do it :

let x2 = data.series[2].fields[1].values.buffer let y2 = data.series[3].fields[1].values.buffer let serie2 = { x : x2, y : y2, name : 'M2', mode : 'lines', line : { color : 'blue' } }



Hope it helps
korunekosama commented 3 years ago

Thank you very much, that's exactly what I need !