Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions example/src/components/mix.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ const options = {
}
};

const plugins = [{
afterDraw: (chartInstance, easing) => {
const ctx = chartInstance.chart.ctx;
ctx.fillText("This text drawn by a plugin", 100, 100);
}
}];

export default React.createClass({
displayName: 'MixExample',

Expand All @@ -89,6 +96,7 @@ export default React.createClass({
<Bar
data={data}
options={options}
plugins={plugins}
/>
</div>
);
Expand Down
11 changes: 9 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class ChartComponent extends React.Component {
legend: PropTypes.object,
onElementsClick: PropTypes.func,
options: PropTypes.object,
plugins: PropTypes.arrayOf(PropTypes.object),
redraw: PropTypes.bool,
type: PropTypes.oneOf(['doughnut', 'pie', 'line', 'bar', 'horizontalBar', 'radar', 'polarArea', 'bubble']),
width: PropTypes.number
Expand Down Expand Up @@ -56,6 +57,7 @@ class ChartComponent extends React.Component {
redraw,
type,
options,
plugins,
legend,
height,
width
Expand All @@ -81,6 +83,10 @@ class ChartComponent extends React.Component {
return true;
}

if (!isEqual(plugins, nextProps.plugins)) {
return true;
}

const nextData = this.transformDataProp(nextProps)
return !isEqual(this.shadowDataProp, nextData);
}
Expand Down Expand Up @@ -174,14 +180,15 @@ class ChartComponent extends React.Component {
}

renderChart() {
const {options, legend, type, redraw} = this.props;
const {options, legend, type, redraw, plugins} = this.props;
const node = ReactDOM.findDOMNode(this);
const data = this.memoizeDataProps();

this.chart_instance = new Chart(node, {
type,
data,
options
options,
plugins
});
}

Expand Down