将源添加到Highcharts导出CSV [英] Add Source to Highcharts Export CSV

查看:45
本文介绍了将源添加到Highcharts导出CSV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在导出的CSV文件的末尾添加一行,其中包含一个带有下载数据源引用的字符串.

I'd like to add a row at the end of the exported CSV file that contains a string with the source citation for the downloaded data.

这可能吗?

推荐答案

您可以扩展Highcharts 并包装 getCSV 函数,或编辑单击 Download CSV 菜单项时发生的情况.

You could extend Highcharts and wrap the getCSV function, or edit what happens when you click the Download CSV menu item.

编辑单击菜单项时发生的情况的示例( JSFiddle ):

An example of editing what happens when you click the menu item (JSFiddle):

menuItems: [{
    textKey: 'downloadCSV',
    onclick: function () {
        var csv = this.getCSV(true);
        csv += '\n"My source 1","My source 2","My source 3"';
        this.fileDownload(
            'data:text/csv,\uFEFF' + encodeURIComponent(csv),
            'csv',
            csv,
            'text/csv'
        );
    }
}]

扩展Highcharts的示例( JSFiddle ):

An example of extending Highcharts (JSFiddle):

(function (H) {
    H.wrap(H.Chart.prototype, 'getCSV', function (proceed, useLocalDecimalPoint) {
        // Run the original proceed method
        result = proceed.apply(this, Array.prototype.slice.call(arguments, 1));
        result += '\n"My source 1","My source 2","My source 3"';
        return result;
    });
}(Highcharts));

这篇关于将源添加到Highcharts导出CSV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆