Giter Site home page Giter Site logo

Comments (6)

z0rzi avatar z0rzi commented on August 13, 2024 2

I faced the same issue, and found a solution after poking around in the code:

The function executed when you click gets 3 arguments, as you can see here:

var f = new Function('data', 'getLocationSrv', 'getTemplateSrv', this.props.options.onclick);
f(data, getLocationSrv, getTemplateSrv);

data, getLocationSrv and getTemplateSrv.

And from the Grafana Docs, you can find how to update a variable from the LocationSrv.


So TL;DR, simply use:

getLocationSrv().update({
  query: {
    'var-service': 'billing',
  },
  partial: true,
  replace: true,
});

from ae3e-plotly-panel.

fifofonix avatar fifofonix commented on August 13, 2024 1

Apologies. User error. I had inadvertently pinned the time range of a panel. The standard from and to work as expected with this workaround. Thanks again!

from ae3e-plotly-panel.

fifofonix avatar fifofonix commented on August 13, 2024

This is a good workaround for user-defined variables but seemingly cannot be used to control the timerange of the main window by updating 'from' and 'to' in the query map, as was possible in Grafana < 8.0 with the windowUpdateVariables option. Does anyone have a solution for updating these?

from ae3e-plotly-panel.

z0rzi avatar z0rzi commented on August 13, 2024

Hum.. Not even with the __from and __to notations? (with the underscores)

from ae3e-plotly-panel.

kkevvai avatar kkevvai commented on August 13, 2024

Hello,
Trying to get a minimal example to work but having a hard time ...
I'm using Grafana 8.4.6 & Plotly panel 0.5.0.
Using the example provided here as a starting point, I'm trying to get the click script to update the 'project' dashboard variable. With the click script that comes with this example panel, the console reports the same error as @KengHzou was seeing. Changing it to (as suggested by @z0rzi)

getLocationSrv().update({
  query: {
    'var-service': 'billing',
  },
  partial: true,
  replace: true,
});

results in another error (Uncaught ReferenceError: getLocationSrv is not defined).
image

Any help on how this should be modified would be greatly appreciated!

from ae3e-plotly-panel.

CliveUnger avatar CliveUnger commented on August 13, 2024

So as I understand, the window.updateVariables() is deprecated? Therefore the default value that is populated in the click data field should be updated?

from ae3e-plotly-panel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.