I use React, so I don't want to import JQuery to increase the bundle size,
I need to trigger the legend click event of multiple charts at the same time when the button is clicked outside the Highchart
Is there any way to trigger the legend click event using chart object like below
let chart = Highcharts.chart('id', { ...options });
chart.legend.allItems[0].legendItem.click(); //not work
Please check this approach how to toggle series visibility on a custom button using the Highcharts-react wrapper.
Demo: https://stackblitz.com/edit/react-uyubam?file=index.js
const updateSeries = () => {
visibility = !visibility;
setChartOptions({
series: [{ visible: visibility }]
});
setChartOptions1({
series: [{ visible: visibility }]
});
};
API: https://api.highcharts.com/highcharts/series.line.visible
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.