2017-10-04 58 views
0

In this Highcharts chart目標是使用圖表外部的按鈕離線導出。使用外部按鈕離線導出Highcharts圖表

,我的問題是,即便想到我添加了offline-exporting.js文件到我的應用程序,如果我連接到Internet時,我點擊Offline Export按鈕,我得到一個錯誤說,它不能訪問的URL export.highcharts.com

如何解決此錯誤並導出離線?

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

這可能會對你有所幫助。 https://stackoverflow.com/questions/25630811/export-highcharts-to-pdf-using-javascript-and-local-server-no-internet-connec。 (2)https://www.highcharts.com(1)https://www.highcharts.com/docs/export-module/client-side-export (2)https://www.highcharts.com(1)https://www.highcharts.com/docs/export-module/client-side-export (2)https://www.highcharts.com /組件/內容/文章/ 2-新聞/ 52-服務器側生成的,圖表 – TechnoCrat

回答

2

嘗試()使用exportChartLocal

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