diff --git a/package.json b/package.json index ec2c326..3ff000d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chartjs-2-react", - "version": "1.1.1", + "version": "1.1.2", "description": "Libreria de chart.js para React.js", "author": "aleleba", "license": "MIT", diff --git a/src/Bar.jsx b/src/Bar.jsx index 446300b..50fe7e8 100644 --- a/src/Bar.jsx +++ b/src/Bar.jsx @@ -71,6 +71,15 @@ class BarComponent extends Component { render(){ if (this.state.chart !== null) { + + if((this.props.config !== undefined) && (this.props.config.data !== undefined)){ + this.state.chart.data.labels = this.props.config.data.labels + this.state.chart.data.datasets = this.props.config.data.datasets + } + + if((this.props.config !== undefined) && (this.props.config.options !== undefined)){ + this.state.chart.options = this.props.config.options + } this.state.chart.update(); diff --git a/src/Line.jsx b/src/Line.jsx index f7a4603..4f9b70c 100644 --- a/src/Line.jsx +++ b/src/Line.jsx @@ -70,8 +70,17 @@ class LineComponent extends Component { } render(){ - + if (this.state.chart !== null) { + + if((this.props.config !== undefined) && (this.props.config.data !== undefined)){ + this.state.chart.data.labels = this.props.config.data.labels + this.state.chart.data.datasets = this.props.config.data.datasets + } + + if((this.props.config !== undefined) && (this.props.config.options !== undefined)){ + this.state.chart.options = this.props.config.options + } this.state.chart.update();