Juha Syrjälä
Juha Syrjälä

Reputation: 34281

Adding data points to existing graph with Dygraphs

I have an existing graph created with Dygraphs based on a JavaScript array. I also have a process that generates new values, say once per second, as JavaScript array.

Is it possible to add the new values to the existing graph? I'd like to avoid redrawing the whole graph each time a new value is created.

var data = [[1,99,42],[2,98,52]]
var graph = new Dygraph(element, data, {});
// now graph is created and visible

// how to add newPoint to existing graph?
var newPoint = [3,100,20];

Upvotes: 0

Views: 1224

Answers (1)

Juha Syrjälä
Juha Syrjälä

Reputation: 34281

You can use option file for all kinds of data, not just for CSV files.

data.push(newPoint);
graph.updateOptions({file: data});

Upvotes: 2

Related Questions