export-csv for HighCharts
这是我正在尝试使用的方法: Chart.getCSV()
注意我没有使用HighCharts丑陋的菜单下拉功能 . 他们的 chart.options.exporting.enabled
在我们的应用程序中设置为 false
. 我们有另一个按钮存在于另一个组件中,其目的是从图表创建CSV .
根据文档,我需要的是在图表对象本身上调用 .getCSV()
.
return priceLine
.then(alertSeries)
.then(tagLine)
.then(renderChart(chart))
.then((chart) => {
// const pricelineData = chart.get('series-priceline').data;
// chart.options.navigator.series.data = pricelineData;
const csv = chart.getCSV();
const array = csv.split(',');
console.log(csv)
console.log('array', array)
ChartExport.storeChart(chart);
this.chartLoading = false;
return chart;
});
Chart对象:https://gist.github.com/leongaban/62ae997e45a697002f699ae0515a1321
但是,当我这样做时,我看到的是一个长字符串,如果我做getTable()我在注销HTML中看到它,你会如何将其转换为CSV?然后下载它?:
https://gist.github.com/leongaban/0edc8fb40b500a40a06e548b35a2adf7
array const array = csv.split(',')
:
https://gist.github.com/leongaban/9110d2e9df9e1bf469e7909e962ef315
他们的 .getTable()
将在console.log中生成这个HTML有一种简单的方法将其转换为可下载的CSV文件吗?
https://gist.github.com/leongaban/f60ea104b2528e7d5721dafc7be1c391
1 回答
啊,所以在他们的文档中没有帮助如何做到这一点,但我看了他们的源代码,发现这个:
甜!所以现在我所要做的就是调用这两个函数:
现在我需要做的就是清空空系列并修复时间格式并重命名文件 .