在数据更新时重置 amcharts3-react 的缩放
Resetting zoom on amchart3-react at data update
如何在数据更新时重置图表缩放。我正在使用 amcharts 并作出反应:
https://github.com/amcharts/amcharts3-react
我正在重新整理图表:
<div className='row' id={this.props.tileid} style={{height: '80%', width: '100%'}} >
<AmCharts ref={`chart_${this.props.tileid}`} {...this.chart} dataProvider={this.props.data()} />
</div>
我的数据道具被分割成 include/exclude 数据。在数据包含上,数据呈现在模具图表中,但是图表仍然在之前的级别缩放,用户必须在所选数据可见之前缩小。我只想在数据更新时将缩放级别最大程度地缩小。
我有:
this.chart.zoomOutOnDataUpdate = true;
但这没有效果..
谢谢。
为了实现这一点,我在反应组件中添加了以下内容:
componentWillReceiveProps(nextprops){
if(this.props.data !== nextprops.data){
this.setState({zoomoutflag: true})
}else{
this.setState({zoomoutflag: false})
}
if(nextprops)
this.chart = this.initChart(nextprops);
}
componentDidUpdate(){
if(this.refs.chartref && this.state.zoomoutflag){
if(this.refs.chartref.state.chart){
this.refs.chartref.state.chart.zoomOut();
}
}
}
这对我来说效果很好,现在每次通过过滤器更改更新数据时,都会设置 zoomoutflag 并将图表设置为缩小状态。
如何在数据更新时重置图表缩放。我正在使用 amcharts 并作出反应: https://github.com/amcharts/amcharts3-react
我正在重新整理图表:
<div className='row' id={this.props.tileid} style={{height: '80%', width: '100%'}} >
<AmCharts ref={`chart_${this.props.tileid}`} {...this.chart} dataProvider={this.props.data()} />
</div>
我的数据道具被分割成 include/exclude 数据。在数据包含上,数据呈现在模具图表中,但是图表仍然在之前的级别缩放,用户必须在所选数据可见之前缩小。我只想在数据更新时将缩放级别最大程度地缩小。
我有:
this.chart.zoomOutOnDataUpdate = true;
但这没有效果..
谢谢。
为了实现这一点,我在反应组件中添加了以下内容:
componentWillReceiveProps(nextprops){
if(this.props.data !== nextprops.data){
this.setState({zoomoutflag: true})
}else{
this.setState({zoomoutflag: false})
}
if(nextprops)
this.chart = this.initChart(nextprops);
}
componentDidUpdate(){
if(this.refs.chartref && this.state.zoomoutflag){
if(this.refs.chartref.state.chart){
this.refs.chartref.state.chart.zoomOut();
}
}
}
这对我来说效果很好,现在每次通过过滤器更改更新数据时,都会设置 zoomoutflag 并将图表设置为缩小状态。