mirror of
https://github.com/aleleba/chartjs-2-react.git
synced 2025-06-25 00:08:21 -06:00
Se agrega la funcion para que cuando se actualice props se actualice la grafica.
Se sube a version 1.1.2 Se sube a GitHub 1.1.2 Se sube a NPM 1.1.2
This commit is contained in:
@ -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();
|
||||
|
||||
|
11
src/Line.jsx
11
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();
|
||||
|
||||
|
Reference in New Issue
Block a user