Skip to content

Commit 1a132ac

Browse files
jerairrestgor181
authored andcommitted
Dynamic datasets (#72)
fixes #68
1 parent d196167 commit 1a132ac

File tree

5 files changed

+49
-19
lines changed

5 files changed

+49
-19
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,4 @@ MIT Licensed
177177
Copyright (c) 2016 Goran Udosic
178178

179179
## Contributors
180+
Jeremy Ayerst [@jerairrest](https://github.com/jerairrest)

dist/react-chartjs-2.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
3535

3636
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
3737

38+
function _objectWithoutProperties2(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
39+
3840
var ChartComponent = _react2.default.createClass({
3941

4042
displayName: 'ChartComponent',
@@ -116,9 +118,17 @@ var ChartComponent = _react2.default.createClass({
116118
nextData.forEach(function (dataset, sid) {
117119
if (currentData[sid] && currentData[sid].data) {
118120
currentData[sid].data.splice(nextData[sid].data.length);
121+
119122
dataset.data.forEach(function (point, pid) {
120123
currentData[sid].data[pid] = nextData[sid].data[pid];
121124
});
125+
126+
var _data = dataset.data,
127+
otherProps = _objectWithoutProperties2(dataset, ['data']);
128+
129+
currentData[sid] = _extends({
130+
data: currentData[sid].data
131+
}, currentData[sid], otherProps);
122132
} else {
123133
currentData[sid] = nextData[sid];
124134
}

dist/react-chartjs-2.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
3333

3434
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
3535

36+
function _objectWithoutProperties2(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
37+
3638
var ChartComponent = _react2.default.createClass({
3739

3840
displayName: 'ChartComponent',
@@ -114,9 +116,17 @@ var ChartComponent = _react2.default.createClass({
114116
nextData.forEach(function (dataset, sid) {
115117
if (currentData[sid] && currentData[sid].data) {
116118
currentData[sid].data.splice(nextData[sid].data.length);
119+
117120
dataset.data.forEach(function (point, pid) {
118121
currentData[sid].data[pid] = nextData[sid].data[pid];
119122
});
123+
124+
var _data = dataset.data,
125+
otherProps = _objectWithoutProperties2(dataset, ['data']);
126+
127+
currentData[sid] = _extends({
128+
data: currentData[sid].data
129+
}, currentData[sid], otherProps);
120130
} else {
121131
currentData[sid] = nextData[sid];
122132
}

0 commit comments

Comments
 (0)