可以在此处描述功能:save chart button of stock tool chart not working in highcharts是否同时保存当前选定的范围选择器?
gwbalxhn1#
最简单的解决方案似乎是覆盖默认的saveChart按钮功能。在下面的例子中,保存所有指标和x轴极值应该可以正常工作。
saveChart
const savedOptions = localStorage.getItem(['highcharts-chart']); const baseOptions = {...}; H.stockChart('container', H.merge({ navigation: { bindings: { saveChart: { init: function(button) { var navigation = this, chart = navigation.chart, annotations = [], series = [], xAxis = [], yAxis = []; annotations = chart.annotations.map(annotation => annotation.userOptions); chart.series.forEach(s => { if (!s.options.isInternal) { series.push(s.userOptions); } }); chart.yAxis.forEach(axis => { if (axis.userOptions.className !== 'highcharts-navigator-yaxis') { yAxis.push(axis.userOptions); } }); chart.xAxis.forEach((axis, index) => { if (!axis.options.isInternal) { xAxis.push(axis.userOptions); xAxis[index].min = axis.userMin; xAxis[index].max = axis.userMax; } }); H.win.localStorage.setItem('highcharts-chart', JSON.stringify({ series, annotations, yAxis, xAxis })); H.fireEvent(this, 'deselectButton', { button }); } } } } }, savedOptions ? JSON.parse(savedOptions) : baseOptions));
1条答案
按热度按时间gwbalxhn1#
最简单的解决方案似乎是覆盖默认的
saveChart
按钮功能。在下面的例子中,保存所有指标和x轴极值应该可以正常工作。