如果在highcharts导出中使用{symbol:' url(...)'},则libURL无效

时间:2018-01-31 14:11:11

标签: highcharts highstock

<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/offline-exporting.js"></script>

,不使用图片按钮

exporting : {  
  libURL:contextPathGlobal+'/scripts/lib/highcharts/',
  enabled: true,
  buttons: {customButton: {symbol: 'round'})
}

使用上面的snipet下载.pdf格式时,

jspdf svg2pdf 从客户端serverexport中成功下载libURL和.pdf格式的已定义路径

使用按钮中的网址{customButton:{symbol:&#39; url&#39;}}

exporting : {  
  libURL:contextPathGlobal+'/scripts/lib/highcharts/',
  enabled: true,
  buttons: {customButton: {symbol: 'url(https://cdn2.iconfinder.com/data/icons/inverticons-stroke-vol-3/32/share_export-16.png)})
}

但在自定义按钮中使用 url 可能会导致用于导出pdf格式的highcharts服务器

想要在符号

中使用url时在客户端导出中导出pdf格式

1 个答案:

答案 0 :(得分:0)

此问题已经在我们的开发人员处报告:

解决方法

// Override to always force basic local export
Highcharts.Chart.prototype.exportChartLocal = function(exportingOptions, chartOptions) {
  var chart = this,
    options = Highcharts.merge(chart.options.exporting, exportingOptions);

  chart.getSVGForLocalExport(
    options,
    chartOptions,
    function() {
      console.error("Something went wrong");
    },
    function(svg) {
      Highcharts.downloadSVGLocal(
        svg,
        options,
        function() {
          console.error("Something went wrong");
        }
      );
    }
  );
};

演示: