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 #6 from pghalliday/peer-dependency
Browse files Browse the repository at this point in the history
add chart.js to peer dependencies and require it in core
  • Loading branch information
jhudson8 committed Feb 8, 2015
2 parents e740cb6 + ff15b2b commit 049c0f7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
51 changes: 25 additions & 26 deletions lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,36 +23,35 @@ module.exports = {
};
}

if (global.Chart) {
classData.componentDidMount = function() {
this.initializeChart(this.props);
};
classData.componentDidMount = function() {
this.initializeChart(this.props);
};

classData.componentWillUnmount = function() {
var chart = this.state.chart;
chart.destroy();
};
classData.componentWillUnmount = function() {
var chart = this.state.chart;
chart.destroy();
};

classData.componentWillReceiveProps = function(nextProps) {
var chart = this.state.chart;
chart.destroy();
this.initializeChart(nextProps);
};
classData.componentWillReceiveProps = function(nextProps) {
var chart = this.state.chart;
chart.destroy();
this.initializeChart(nextProps);
};

classData.initializeChart = function(nextProps) {
var el = this.getDOMNode();
var ctx = el.getContext("2d");
var chart = new Chart(ctx)[chartType](nextProps.data, nextProps.options || {});
this.state.chart = chart;
};
classData.initializeChart = function(nextProps) {
var Chart = require('chart.js');
var el = this.getDOMNode();
var ctx = el.getContext("2d");
var chart = new Chart(ctx)[chartType](nextProps.data, nextProps.options || {});
this.state.chart = chart;
};

var i;
for (i=0; i<extras.length; i++) {
extra(extras[i]);
}
for (i=0; i<methodNames.length; i++) {
extra(methodNames[i]);
}
var i;
for (i=0; i<extras.length; i++) {
extra(extras[i]);
}
for (i=0; i<methodNames.length; i++) {
extra(methodNames[i]);
}

var React = require('react');
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
},
"homepage": "https://github.com/jhudson8/react-chartjs",
"peerDependencies": {
"react": "*"
"react": "*",
"chart.js": "*"
},
"devDependencies": {
"uglify-js": "^2.4.16",
Expand Down

0 comments on commit 049c0f7

Please sign in to comment.