本文介绍了使用外部按钮离线导出Highcharts图表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在此Highcharts图表中的目标是使用外部的按钮进行离线导出图表.

In this Highcharts chart the objective is to offline export using a button external to the chart.

我遇到的问题是,甚至当我单击Offline Export按钮时连接到Internet时,甚至以为我已将offline-exporting.js文件添加到我的应用程序中错误,提示它无法访问URL export.highcharts.com.

The problem that I have is that even thought I added the offline-exporting.js file to my application, if I'm not connected to the Internet when I click the Offline Export button I get an error saying it cannot access the URL export.highcharts.com.

如何解决此错误并离线导出?

How to fix this error and export offline?

HTML

  <button id="exp" >Offline Export</button>
  <div id="container" style="height: 400px; width: 500px"></div>

JavaScript:

Javascript:

var settings =  
        {
         "chart": {
           "type":"line"
        },
       "xAxis": { 
          "endOnTick":true
       },
       "series":[
           {"name":"series1","data":[[1,1200],[2,2200],[3,3200],[4,1800],[5,1500]]},
           {"name":"series2","data":[[1,1050],[2,2050],[3,1650],[4,1450],[5,1350]]},
           {"name":"series3","data":[[1,1250],[2,2250],[3,1850],[4,1650],[5,1550]]}]
       }


    var chart = $('#container').highcharts(settings);


    $( "#exp" ).click(function() {
        alert( "Handler for .click() called." );
        var chart = $('#container').highcharts();
            chart.exportChart({
                type: 'image/png',
                filename: 'theimage'
            });
      });

推荐答案

尝试使用exportChartLocal()

Try to using exportChartLocal()

   $( "#exp" ).click(function() {
    alert( "Handler for .click() called." );
    var chart = $('#container').highcharts();
        chart.exportChartLocal({
            type: 'image/png',
            filename: 'theimage'
        });
  });

这篇关于使用外部按钮离线导出Highcharts图表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 16:11