|
1 | 1 | module.exports = { |
2 | | - createClass: function(chartType, methodNames) { |
| 2 | + createClass: function(chartType, methodNames, dataKey) { |
3 | 3 | var classData = { |
4 | 4 | displayName: chartType + 'Chart', |
5 | 5 | getInitialState: function() { return {}; }, |
@@ -40,7 +40,8 @@ module.exports = { |
40 | 40 | chart.destroy(); |
41 | 41 | this.initializeChart(nextProps); |
42 | 42 | } else { |
43 | | - updatePoints(nextProps, chart); |
| 43 | + dataKey = dataKey || dataKeys[chart.name]; |
| 44 | + updatePoints(nextProps, chart, dataKey); |
44 | 45 | chart.update(); |
45 | 46 | } |
46 | 47 | }; |
@@ -82,15 +83,14 @@ var dataKeys = { |
82 | 83 | 'Bar': 'bars' |
83 | 84 | }; |
84 | 85 |
|
85 | | -var updatePoints = function(nextProps, chart) { |
| 86 | +var updatePoints = function(nextProps, chart, dataKey) { |
86 | 87 | var name = chart.name; |
87 | 88 |
|
88 | 89 | if (name === 'PolarArea' || name === 'Pie' || name === 'Doughnut') { |
89 | 90 | nextProps.data.forEach(function(segment, segmentIndex) { |
90 | 91 | chart.segments[segmentIndex].value = segment.value; |
91 | 92 | }); |
92 | 93 | } else { |
93 | | - var dataKey = dataKeys[name]; |
94 | 94 | nextProps.data.datasets.forEach(function(set, setIndex) { |
95 | 95 | set.data.forEach(function(val, pointIndex) { |
96 | 96 | chart.datasets[setIndex][dataKey][pointIndex].value = val; |
|
0 commit comments