Offline exporting a Highcharts chart using an exte

2019-03-04 23:05发布

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

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:

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'
            });
      });

标签: highcharts
1条回答
趁早两清
2楼-- · 2019-03-04 23:44

Try to using exportChartLocal()

   $( "#exp" ).click(function() {
    alert( "Handler for .click() called." );
    var chart = $('#container').highcharts();
        chart.exportChartLocal({
            type: 'image/png',
            filename: 'theimage'
        });
  });
查看更多
登录 后发表回答