Skip to content
This repository has been archived by the owner on Jul 19, 2019. It is now read-only.

Commit

Permalink
Merge pull request #129 from strawbrary/master
Browse files Browse the repository at this point in the history
Fix: unknown prop 'redraw' warning in React v15.2
  • Loading branch information
austinpray authored Jul 14, 2016
2 parents 7b5f7d8 + 23c3d45 commit 602f861
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
17 changes: 16 additions & 1 deletion dist/react-chartjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ return /******/ (function(modules) { // webpackBootstrap

module.exports = {
createClass: function(chartType, methodNames, dataKey) {
var excludedProps = ['data', 'options', 'redraw'];
var classData = {
displayName: chartType + 'Chart',
getInitialState: function() { return {}; },
Expand All @@ -92,7 +93,7 @@ return /******/ (function(modules) { // webpackBootstrap
};
for (var name in this.props) {
if (this.props.hasOwnProperty(name)) {
if (name !== 'data' && name !== 'options') {
if (excludedProps.indexOf(name) === -1) {
_props[name] = this.props[name];
}
}
Expand Down Expand Up @@ -127,7 +128,10 @@ return /******/ (function(modules) { // webpackBootstrap
updatePoints(nextProps, chart, dataKey);
if (chart.scale) {
chart.scale.xLabels = nextProps.data.labels;

if (chart.scale.calculateXLabelRotation){
chart.scale.calculateXLabelRotation();
}
}
chart.update();
}
Expand Down Expand Up @@ -188,6 +192,17 @@ return /******/ (function(modules) { // webpackBootstrap
while(nextProps.data.length < chart.segments.length) {
chart.removeData();
}
} else if (name === "Radar") {
chart.removeData();
nextProps.data.datasets.forEach(function(set, setIndex) {
set.data.forEach(function(val, pointIndex) {
if (typeof(chart.datasets[setIndex][dataKey][pointIndex]) == "undefined") {
addData(nextProps, chart, setIndex, pointIndex);
} else {
chart.datasets[setIndex][dataKey][pointIndex].value = val;
}
});
});
} else {
while (chart.scale.xLabels.length > nextProps.data.labels.length) {
chart.removeData();
Expand Down
2 changes: 1 addition & 1 deletion dist/react-chartjs.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var ReactDOM = require('react-dom');

module.exports = {
createClass: function(chartType, methodNames, dataKey) {
var excludedProps = ['data', 'options', 'redraw'];
var classData = {
displayName: chartType + 'Chart',
getInitialState: function() { return {}; },
Expand All @@ -12,7 +13,7 @@ module.exports = {
};
for (var name in this.props) {
if (this.props.hasOwnProperty(name)) {
if (name !== 'data' && name !== 'options') {
if (excludedProps.indexOf(name) === -1) {
_props[name] = this.props[name];
}
}
Expand Down

0 comments on commit 602f861

Please sign in to comment.