简体   繁体   English

Highcharts 导出 SVG 与数据预选

[英]Highcharts exporting SVG with data pre-selected

I'm trying to export a Highcharts sankey diagram to SVG, and I would like to have several different vector files with different parts of the diagram highlighted selected (clicked on), so I can fade between them in a pre-recorded presentation.我正在尝试将 Highcharts 桑基图导出到 SVG,并且我希望选择几个不同的矢量文件,并突出显示图表的不同部分(单击),因此我可以在预先录制的演示文稿中淡入淡出它们之间。 I can't figure out any way to make the Export module export an SVG that has been highlighted by clicking on it—-it exports only the “plain” graph.我想不出任何办法让导出模块导出一个 SVG,通过单击它突出显示它——它只导出“普通”图形。 Can anyone help?任何人都可以帮忙吗?

I've attached screenshots of what I'm after, since I can't figure out how to get them to export as vector files.我附上了我所追求的截图,因为我不知道如何让它们导出为矢量文件。 No matter what, the data is always exported looking like the first diagram:无论如何,数据总是像第一张图一样导出: 平面图

But I would also like it exported as the following two diagrams with various parts of the data selected:但我也希望它导出为以下两个图表,并选择了数据的各个部分: 选择了一个点 选择了另一个点

Here is my idea how to achieve it with using the exporting.menuItemDefinition feature.这是我的想法,如何使用exporting.menuItemDefinition功能来实现它。

  • create the global flag for each node, like customSVGExport1 ,为每个节点创建全局标志,例如customSVGExport1
  • create the custom export menu buttons with functionality which changes the flag to true and trigger the SVG downloading (and chart rendering once again),创建具有将标志更改为 true 并触发 SVG 下载(并再次绘制图表)的功能的自定义导出菜单按钮,

     onclick: function() { customSVGExport1 = true; this.exportChart({ type: 'image/svg+xml' }); },
    • below function will be triggered:下面 function 将被触发:

       chart: { events: { render() { let chart = this; if (customSVGExport1) { // Trigger point hover event chart.series[0].nodes[0].onMouseOver(); // Hide tooltip for export chart.tooltip.label.hide(); // Set flag back to false; customSVGExport = false; } else if (customSVGExport2) { chart.series[0].nodes[1].onMouseOver(); chart.tooltip.label.hide(); customSVGExport = false; } } } },

Demo: https://jsfiddle.net/BlackLabel/x67jwsmo/演示: https://jsfiddle.net/BlackLabel/x67jwsmo/

API: https://api.highcharts.com/highcharts/exporting.menuItemDefinitions API: https://api.highcharts.com/highcharts/exporting.menuItemDefinitions

API: https://api.highcharts.com/highcharts/chart.events.render API: https://api.highcharts.com/highcharts/chart.events.render

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM