From 32e4920bdac32cc0bde6befe5b3de925cf273842 Mon Sep 17 00:00:00 2001 From: Kevin Yu Date: Wed, 23 Nov 2016 09:47:52 -0800 Subject: [PATCH 1/4] add new props: nextPoints and stream for stream chart --- lib/core.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/core.js b/lib/core.js index b39d67b..b1a3f38 100644 --- a/lib/core.js +++ b/lib/core.js @@ -3,7 +3,7 @@ var ReactDOM = require('react-dom'); module.exports = { createClass: function(chartType, methodNames, dataKey) { - var excludedProps = ['data', 'options', 'redraw']; + var excludedProps = ['data', 'options', 'redraw', 'nextPoints', 'stream']; var classData = { displayName: chartType + 'Chart', getInitialState: function() { return {}; }, @@ -43,6 +43,9 @@ module.exports = { if (nextProps.redraw) { chart.destroy(); this.initializeChart(nextProps); + } else if (nextProps.stream) { + chart.addData(nextProps.nextPoints.values, nextProps.nextPoints.label); + chart.removeData(); } else { dataKey = dataKey || dataKeys[chart.name]; updatePoints(nextProps, chart, dataKey); From edf9866d7cae685d4693a1615ace528f46c8369b Mon Sep 17 00:00:00 2001 From: Kevin Yu Date: Wed, 23 Nov 2016 09:47:52 -0800 Subject: [PATCH 2/4] add new props: nextPoints and stream to support stream chart --- lib/core.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/core.js b/lib/core.js index b39d67b..b1a3f38 100644 --- a/lib/core.js +++ b/lib/core.js @@ -3,7 +3,7 @@ var ReactDOM = require('react-dom'); module.exports = { createClass: function(chartType, methodNames, dataKey) { - var excludedProps = ['data', 'options', 'redraw']; + var excludedProps = ['data', 'options', 'redraw', 'nextPoints', 'stream']; var classData = { displayName: chartType + 'Chart', getInitialState: function() { return {}; }, @@ -43,6 +43,9 @@ module.exports = { if (nextProps.redraw) { chart.destroy(); this.initializeChart(nextProps); + } else if (nextProps.stream) { + chart.addData(nextProps.nextPoints.values, nextProps.nextPoints.label); + chart.removeData(); } else { dataKey = dataKey || dataKeys[chart.name]; updatePoints(nextProps, chart, dataKey); From 613c9a406d7237e4227bd58eaf4da59bcdae2e42 Mon Sep 17 00:00:00 2001 From: Kevin Yu Date: Thu, 24 Nov 2016 09:38:27 -0800 Subject: [PATCH 3/4] Move nextPoints into chartData --- lib/core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core.js b/lib/core.js index b1a3f38..7c031c9 100644 --- a/lib/core.js +++ b/lib/core.js @@ -44,7 +44,7 @@ module.exports = { chart.destroy(); this.initializeChart(nextProps); } else if (nextProps.stream) { - chart.addData(nextProps.nextPoints.values, nextProps.nextPoints.label); + chart.addData(nextProps.data.nextPoints.values, nextProps.data.nextPoints.label); chart.removeData(); } else { dataKey = dataKey || dataKeys[chart.name]; From 47cb89352d3942561534d8945a088e65965ad7f3 Mon Sep 17 00:00:00 2001 From: Kevin Yu Date: Fri, 16 Dec 2016 16:49:41 -0800 Subject: [PATCH 4/4] check if has nextProps.data.nextPoints to avoid type error at initialization --- lib/core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core.js b/lib/core.js index 7c031c9..34ed124 100644 --- a/lib/core.js +++ b/lib/core.js @@ -43,7 +43,7 @@ module.exports = { if (nextProps.redraw) { chart.destroy(); this.initializeChart(nextProps); - } else if (nextProps.stream) { + } else if (nextProps.stream && nextProps.data.nextPoints) { chart.addData(nextProps.data.nextPoints.values, nextProps.data.nextPoints.label); chart.removeData(); } else {