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:
parent
60cae61ef1
commit
af8bee047b
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "chartjs-2-react",
|
"name": "chartjs-2-react",
|
||||||
"version": "1.1.1",
|
"version": "1.1.2",
|
||||||
"description": "Libreria de chart.js para React.js",
|
"description": "Libreria de chart.js para React.js",
|
||||||
"author": "aleleba",
|
"author": "aleleba",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
@ -72,6 +72,15 @@ class BarComponent extends Component {
|
|||||||
|
|
||||||
if (this.state.chart !== null) {
|
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();
|
this.state.chart.update();
|
||||||
|
|
||||||
return <canvas id={`${this.state.id}`} />
|
return <canvas id={`${this.state.id}`} />
|
||||||
|
@ -73,6 +73,15 @@ class LineComponent extends Component {
|
|||||||
|
|
||||||
if (this.state.chart !== null) {
|
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();
|
this.state.chart.update();
|
||||||
|
|
||||||
return <canvas id={`${this.state.id}`} />
|
return <canvas id={`${this.state.id}`} />
|
||||||
|
Loading…
Reference in New Issue
Block a user