VolkovLabs / business-forms

The Business Forms panel is a conceptually new plugin for Grafana. It is the first plugin that allows inserting and updating application data, as well as modifying configuration directly from your Grafana dashboard.
https://docs.volkovlabs.io
Apache License 2.0
86 stars 10 forks source link

Number_slider #349

Closed ShoolamitMints closed 9 months ago

ShoolamitMints commented 9 months ago

I work with grafana I created a query type variable that returns numbers And I want a number indicator to open for me where the minimum value is 1 and the maximum is the number taken from the variable And when you move the slider, it saves the number you’re standing on in another variable I tried to use the data manipulation plugin 2, but in the MAX field you cannot enter a variable, only a number And I can’t take the data from the slider I also thought of going in the direction of a variable design in the form of a number slider Does grafana have such an option?

asimonok commented 9 months ago

@ShoolamitMints thanks for the question. Yes, the max field doesn't support variables. However you can put max value from variable through initial request code. Here is a code example

context.panel.onChangeElements(context.panel.elements.map((element) => {
  if (element.id === 'step') {
    return {
      ...element,
      max: 123 // $var,
    }
  }

  return element;
}))

Please let us know if there is anything else

ShoolamitMints commented 9 months ago

@asimonok Thanks for the feedback The truth is that a few days ago I was able to fix it and I did use a code similar to yours But I have a new question Every time I click send the indicator goes back to 0 And I want him to stay what he was If I stood at 5 for example then after sending it will stay at 5 I tried messing with it In the Initial Action I wrote:

console.log($NumberSlider)
elements.map((element) => { element.value = $NumberSlider})

What's weird is that when printed, it prints the number the cursor is on But it sets the slider to the previous value