请查看此屏幕截图
有人可以分享任何React JS解决方案来触发外部过滤器选择图例和饼图的方法吗?
答案 0 :(得分:0)
您需要在与特定按钮相关的系列上使用setVisible
方法:
handleClick(e) {
const series = this.internalChart.series;
series[e.currentTarget.attributes.index.value].setVisible();
}
render() {
return (
<div>
<HighchartsReact
highcharts={Highcharts}
options={this.state.chartOptions}
callback={this.afterChartCreated}
/>
<h2>custom legend</h2>
<div>Series 1
<input
type="checkbox"
index="0"
onChange={this.handleClick.bind(this)}
defaultChecked={true}
/>
...
</div>
</div>
);
}
实时演示: https://codesandbox.io/s/91opxqwn1r
API参考: https://api.highcharts.com/class-reference/Highcharts.Series#setVisible
文档: https://github.com/highcharts/highcharts-react/blob/master/README.md