grafana / scenes

Build Grafana dashboards directly in your Grafana app plugins.
https://grafana.com/developers/scenes
Apache License 2.0
137 stars 20 forks source link

Override implementation in PanelBuilders.table() for dashed lines #623

Open korinekgergely opened 7 months ago

korinekgergely commented 7 months ago

Please someone help me, write me the exact implementation of the override attached below. I need it in a PanelBuilders.table() Because I have searched the source files, I found this everywhere:

`/**

Monosnap Edit panel - Template Dashboard !!!! DO NOT DELETE !!!! - Dashboards - Grafana 2024-02-27 15-12-48

Or as json: "overrides": [ { "matcher": { "id": "byName", "options": "CRITICAL" }, "properties": [ { "id": "custom.lineStyle", "value": { "dash": [ 10, 10 ], "fill": "dash" } }, { "id": "custom.fillOpacity", "value": 0 }, { "id": "color", "value": { "fixedColor": "dark-red", "mode": "fixed" } }, { "id": "custom.hideFrom", "value": { "legend": true, "tooltip": false, "viz": false } } ] }, { "matcher": { "id": "byName", "options": "WARNING" }, "properties": [ { "id": "custom.lineStyle", "value": { "dash": [ 10, 10 ], "fill": "dash" } }, { "id": "custom.fillOpacity", "value": 0 }, { "id": "color", "value": { "fixedColor": "yellow", "mode": "fixed" } }, { "id": "custom.hideFrom", "value": { "legend": true, "tooltip": false, "viz": false } } ] } ]

I have a try but I don't find the implementation of the dashed lines. I am not sure if it is a good start: .setOverrides((critical: any) => critical .matchFieldsWithName('CRITICAL') .overrideColor({ mode: 'fixed', fixedColor: 'red' }) Thank you in advance.

torkelo commented 7 months ago

The screenshot is for overrides for the time series visualization, not table.

So confused

korinekgergely commented 7 months ago

Of course, sorry, my fault. This is a timeseries()

korinekgergely commented 7 months ago

But the question remains, rightly in the case of timeseries.

korinekgergely commented 7 months ago

@torkelo This is the goal, this is what it should look like. Dashboards - Grafana 2024-02-28 07-50-04

torkelo commented 7 months ago

and the 90% red line and yellow lines are time series?

korinekgergely commented 7 months ago

@torkelo Yes, the same time series as the others. I just want to display certain Field names as dashed. What appears as a dashed line will typically be a straight line for us, but not necessarily. Sorry for the late reply. The question is just as interesting and important.

So again, to briefly summarize the question: how can I change the style of a time series to dotted by identifying it by field name (as shown in the top image)? PanelBuilders.timeseries() I suspect that an .override... is needed, but I couldn't find a lineStyle in the documentation. Maybe there is a different way.

korinekgergely commented 7 months ago

Found the solution: .setOverrides((a: any) => a .matchFieldsWithName('nameBlaBla') .overrideCustomFieldConfig('lineStyle', { "dash": [ 10, 10 ], "fill": "dash" })

bperel commented 2 weeks ago

Thank you for the solution @korinekgergely , I can confirm that it works, however the Typescript types don't seem to be up to date since I get an error in the IDE. Image