Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Enable graph update by series data replacement #211

Open
wants to merge 1 commit into from

5 participants

@dannypurcell

Allows for updating the graph by replacing the series data.
EX: setInterval( function() {
dataText = httpGet("http://myhost/getSeriesData");
seriesDataArr = JSON.parse(dataText);

graph.setSeries(seriesDataArr);
graph.update();
}, 15000 );

@dannypurcell dannypurcell Added setSeries to Rickshaw.Graph.js
Allows for updating the graph by replacing the series data.
EX: setInterval( function() {
	dataText = httpGet("http://myhost/getSeriesData");
	seriesDataArr = JSON.parse(dataText);		
	graph.setSeries(seriesDataArr);
	graph.update();
}, 15000 );
59e0d64
@dchester
Owner

Thanks -- It's more complicated when you may be removing or adding lines to the legend, etc. We now have preliminary support for this in the dynamic-series branch

@jooldesign

Could you create a minified version of Rickshaw.js with all the changes in?

@nh2

Any update on this? This feature is both very basic and super useful.

@ghost Unknown referenced this pull request
Open

Dynamic Series Branch, Rebased #341

@kikito

While we get this (or other) solution merged into rickshaw, here's a dirty hack to update the whole series - keep using the same series, and replace each element with the new values, and call graph.update():

series = getInitialSeries() # can be []
graph = new Rickshaw.Graph(
  element: elem,
  series: series
)
updatedSeries = getUpdatedSeries()

# override series with updatedSeries
for item,i in newSeries
  series[i] = newSeries[i]
series.pop() while series.length > newSeries.length

#update the graph
graph.update()

Ugly, but it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 27, 2013
  1. @dannypurcell

    Added setSeries to Rickshaw.Graph.js

    dannypurcell authored
    Allows for updating the graph by replacing the series data.
    EX: setInterval( function() {
    	dataText = httpGet("http://myhost/getSeriesData");
    	seriesDataArr = JSON.parse(dataText);		
    	graph.setSeries(seriesDataArr);
    	graph.update();
    }, 15000 );
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 0 deletions.
  1. +6 −0 src/js/Rickshaw.Graph.js
View
6 src/js/Rickshaw.Graph.js
@@ -247,6 +247,12 @@ Rickshaw.Graph = function(args) {
.attr('width', this.width)
.attr('height', this.height);
}
+
+ this.setSeries = function(seriesdata){
+ this.validateSeries(seriesdata);
+ seriesdata.active = self.series.active;
+ self.series = seriesdata;
+ }
this.initialize(args);
};
Something went wrong with that request. Please try again.