samber / chartjs-plugin-datasource-prometheus

📊 Chart.js plugin for Prometheus
https://www.npmjs.com/package/chartjs-plugin-datasource-prometheus
MIT License
109 stars 20 forks source link

How to clear and draw another graph? #13

Closed stokito closed 1 year ago

stokito commented 2 years ago

Should I do something like:

myChart.clear()
myChart.options.prometheus.query = "new query"
myChart.draw()

?

mnutt commented 1 year ago

You can do something like:

chart.options.plugins['datasource-prometheus'].query = "new query";
chart.update({});

You can also update just the start/end range:

chart.options.plugins['datasource-prometheus'].timeRange.start = startTime;
chart.update({});
stokito commented 1 year ago

interesting, thank you @mnutt

samber commented 1 year ago

I made an update in the README

stokito commented 1 year ago

thank you. Could you please also merge the #33