Highchart出口

时间:2017-11-14 09:09:41

标签: javascript facebook highcharts

我正在尝试导出Highchart。我想在Facebook上分享我的高图作为图像,因此我试图生成我打算在Facebook上发布的高图链接作为图像。我的代码是:

TokenMismatchException

我收到以下错误:TypeError:图表未定义

我哪里错了?

更新 我创建了一个javascript函数来获取我的高图。我获取高级图的代码如下:

<script type="text/javascript">
     function createURL(activeTab){
var obj = {};
    var chart;

chart = $(activeTab).highcharts();
obj.svg = chart.getSVG();
obj.type = 'image/png';
obj.width = 450;
obj.async = true;


$.ajax({
    type: 'post',
    url: chart.options.exporting.url,
    data: obj,
    success: function (data) {
        var exportUrl = this.url;
        urlToExport = exportUrl+data;
        FB.ui(
        {
        method: 'feed',
        name: 'This is the content of the "name" field.',
        link: urlToExport,
        message: ''
        });
    }
});


     }

2 个答案:

答案 0 :(得分:0)

try {
    if (Highcharts.getOptions().exporting) {
        let contextButton = Highcharts.getOptions().exporting.buttons.contextButton;

        contextButton.menuItems = contextButton.menuItems.filter((item) => {
            console.log(item)
            return item.textKey === 'downloadCSV' || item.textKey === 'downloadPNG';
        });
    }

} catch (e) {
    console.log(e)
}

Try this code inside your function

答案 1 :(得分:0)

我已经为您创建了一个jsfiddle解决方案。请看一下,给我竖起大拇指。我认为主要问题是您命名了错误的图表,现在已在此处更正:

chart = $(containerPrice).highcharts();

http://jsfiddle.net/jxcf5mgq/3/