Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/384.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Highcharts-导出时隐藏字幕_Javascript_Highcharts - Fatal编程技术网

Javascript Highcharts-导出时隐藏字幕

Javascript Highcharts-导出时隐藏字幕,javascript,highcharts,Javascript,Highcharts,我有一张带有时间序列和缩放的图表。如果在图表导出为pdf或图像时,为了理解如何缩放而非常有用的副标题(“单击并拖动绘图区域以放大”)不出现,则会更好 所以我想知道是否有办法隐藏它。这里有一个关于如何做你所要求的事情的例子。进行字幕操作的部分是: exporting: { buttons: { exportButton: { menuItems: null, onclick: function() { chart.exp

我有一张带有时间序列和缩放的图表。如果在图表导出为pdf或图像时,为了理解如何缩放而非常有用的副标题(“单击并拖动绘图区域以放大”)不出现,则会更好

所以我想知道是否有办法隐藏它。

这里有一个关于如何做你所要求的事情的例子。进行字幕操作的部分是:

exporting: {
   buttons: {
      exportButton: {
         menuItems: null,
         onclick: function() {
            chart.exportChart(null, {subtitle: {text:''}});
         }  
      },
      printButton: {
         onclick: function() {
            chart.setTitle(null, { text: ' ' });
            chart.print();
            chart.setTitle(null, { text: 'Click and drag in the plot area to zoom in' });
         }
      }
   }
},
编辑:

辅助选项

您可以删除Highcharts生成的打印和导出按钮。然后创建您自己的打印和导出按钮以及用于选择导出类型的下拉列表。然后,如果单击“导出”按钮,则选中类型并导出为类型,且不包含子标题。这是一个例子。以下是处理导出和打印按钮单击的代码:

$('#buttonExport').click(function() {
    var e = document.getElementById("ExportOption");
    var ExportAs = e.options[e.selectedIndex].value;   

    if(ExportAs == 'PNG')
    {
        chart.exportChart({type: 'image/png', filename: 'my-png'}, {subtitle: {text:''}});
    }
    if(ExportAs == 'JPEG')
    {
        chart.exportChart({type: 'image/jpeg', filename: 'my-jpg'}, {subtitle: {text:''}});
    }
    if(ExportAs == 'PDF')
    {
        chart.exportChart({type: 'application/pdf', filename: 'my-pdf'}, {subtitle: {text:''}});
    }
    if(ExportAs == 'SVG')
    {
        chart.exportChart({type: 'image/svg+xml', filename: 'my-svg'}, {subtitle: {text:''}});
    }
}); 

$('#buttonPrint').click(function() {
     chart.setTitle(null, { text: ' ' });
     chart.print();
     chart.setTitle(null, { text: 'Click and drag in the plot area to zoom in' });
});
下面是一个关于如何做你所要求的事情的例子。进行字幕操作的部分是:

exporting: {
   buttons: {
      exportButton: {
         menuItems: null,
         onclick: function() {
            chart.exportChart(null, {subtitle: {text:''}});
         }  
      },
      printButton: {
         onclick: function() {
            chart.setTitle(null, { text: ' ' });
            chart.print();
            chart.setTitle(null, { text: 'Click and drag in the plot area to zoom in' });
         }
      }
   }
},
编辑:

辅助选项

您可以删除Highcharts生成的打印和导出按钮。然后创建您自己的打印和导出按钮以及用于选择导出类型的下拉列表。然后,如果单击“导出”按钮,则选中类型并导出为类型,且不包含子标题。这是一个例子。以下是处理导出和打印按钮单击的代码:

$('#buttonExport').click(function() {
    var e = document.getElementById("ExportOption");
    var ExportAs = e.options[e.selectedIndex].value;   

    if(ExportAs == 'PNG')
    {
        chart.exportChart({type: 'image/png', filename: 'my-png'}, {subtitle: {text:''}});
    }
    if(ExportAs == 'JPEG')
    {
        chart.exportChart({type: 'image/jpeg', filename: 'my-jpg'}, {subtitle: {text:''}});
    }
    if(ExportAs == 'PDF')
    {
        chart.exportChart({type: 'application/pdf', filename: 'my-pdf'}, {subtitle: {text:''}});
    }
    if(ExportAs == 'SVG')
    {
        chart.exportChart({type: 'image/svg+xml', filename: 'my-svg'}, {subtitle: {text:''}});
    }
}); 

$('#buttonPrint').click(function() {
     chart.setTitle(null, { text: ' ' });
     chart.print();
     chart.setTitle(null, { text: 'Click and drag in the plot area to zoom in' });
});

我做了另一个例子,如果有人在他们的页面上有翻译并且想要打印图表,我会保留副标题。只需在@Linger answer上添加一个变量:

var subtitle = this.options.subtitle.text;
chart.setTitle(null, { text: ' ' });
        chart.print();
        chart.setTitle(null, { text: subtitle });                        
此处的示例代码:

我做了另一个例子,如果有人在他们的页面上有翻译并且想要打印图表,我会保留副标题。只需在@Linger answer上添加一个变量:

var subtitle = this.options.subtitle.text;
chart.setTitle(null, { text: ' ' });
        chart.print();
        chart.setTitle(null, { text: subtitle });                        
此处的示例代码:

谢谢,但我想保留不同的导出选项(PNG、JPEG、PDF、SVG)。我尝试了这个方法,但没有成功:onclick:function(){this.exportChart(null,{subtitle:{text:'},键入:“image/jpeg”};}我已经更新了我的答案,以显示如何选择导出类型以及删除子标题。再次感谢。你的解决方案很有用。尽管如此,由于我已经有了一些用于其他功能的自定义按钮,我宁愿使用现有的按钮来避免图表过载。我知道我问了很多:)。谢谢,但我想保留不同的导出选项(PNG、JPEG、PDF、SVG)。我尝试了这个方法,但没有成功:onclick:function(){this.exportChart(null,{subtitle:{text:'},键入:“image/jpeg”};}我已经更新了我的答案,以显示如何选择导出类型以及删除子标题。再次感谢。你的解决方案很有用。尽管如此,由于我已经有了一些用于其他功能的自定义按钮,我宁愿使用现有的按钮来避免图表过载。我知道我问了很多:)。