lorenwest / monitor-dashboard

Dashboards for the Node.js monitor project
https://lorenwest.github.com/monitor-dashboard
MIT License
204 stars 28 forks source link

How to dynamically set probe data to charts(pie chart) #30

Open aaswan opened 9 years ago

aaswan commented 9 years ago

Here is what I have tried till now: I have connected to my localhost server using the Inspect probe I checked that I am getting the updated values for my probe using the alert(monitor.get('value')) in the JS onInit box. When I load the PieChart I can see my updated values in the alert. But I don't know how to bind this data to Data Series?

lorenwest commented 9 years ago

It sounds like you're really close. Examine how the default data gets into the chart, and change that to provide data based on your probe. This may require some understanding of the underlying graphics system.

begeeben commented 8 years ago

You can put something similar to this in the on init textarea. I use it in the Gauge component. Perhaps this is not the best solution but it does the job:

setInterval(function() {
    var process = monitor.toProbeJSON();
    view.chart.series[0].addPoint(100*process.freemem/process.totalmem, true, true);
}, 1000);