nline/nline-plotlyjs-panel

layout property doesn't seem to be accepting grafana variables for title.text property

Closed this issue · 7 comments

The layout section is currently:

paper_bgcolor: rgba(0,0,0,0)
plot_bgcolor: rgba(150,150,150,0)
margin:
  t: 5
  r: 20
  b: 40
  l: 20
yaxis:
  automargin: true
  autorange: true
  color: rgba(150,150,150, 1)
  gridcolor: rgba(150,150,150, 0.2)
  range:
    - -0.00004907501471212626
    - 0.0009324252795303988
  showgrid: false
  showspikes: false
  type: linear
xaxis:
  autorange: true
  color: rgba(150,150,150, 1)
  gridcolor: rgba(150,150,150, 0.2)
  range:
    - 0
    - 2014.418722987175
  showgrid: false
  title:
    text: Hz
  type: linear

You see the x-axis has a title of Hz. The y-axis is either acceleration(g) or velocity(mm/s) data depending on a variable, varSpectrumType. What I'd like to do is add;

  title:
    text: variables.varSpectrumType

To the y-axis but, unfortunately, it just displays the text without doing the variable substitution.

I tried using __from (the grafana global variable) but it just displays "__from" as well.

Is there any chance this could be added as an enhancement?

For now you could add this within the script panel which does have access to those variables. The data, layout and config sections are meant for static JSON/YAML configs. It might be possible to do some substitution there, I can look into it. A PR is also welcome!

This is resolved in 1.5.0. If you want you can try it out with:

grafana-cli --insecure \
--pluginUrl https://github.com/nline/nline-plotlyjs-panel/releases/download/v1.5.0/nline-plotlyjs-panel-v1.5.0.zip \
plugins install nline-plotlyjs-panel

I'll close this once it gets released to the marketplace.

@apellew I would try this now. It should work with version 1.5.0. Let me know if it doesn't.

Hi, I have grafana 9.5.2, with plugin nline-plotlyjs-panel 1.5.0.

xaxis:
  type: linear
  autorange: true
  automargin: true
 ...
  title:
    font:
      color: '#24292e'
      family: '''Inter'', ''Helvetica'', ''Arial'', ''sans-serif'''
      size: 12
      weight: 400
    text: variables.bp_yaxis_name

where the variable bp_yaxis_name is defined as constant (just for test). However, the variable seems not to be accepted

image

Any idea? Thanks!

Hi, thanks for addressing this. The variables var is exclusive to working with the JavaScript fields. In the static JSON/YAML configs you can use the standard Grafana variable reference syntax $bp_yaxis_name.

oh thanks. In the static JSON/YAML the $bp_yaxis_name does indeed work

Great, just going to close this for now since this issue has been resolved.