0

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

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

4

2 回答 2

5

Here is a example on how to do what you are asking. The part does the subtitle manipulation is:

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

EDIT:

Sedondary option

You could remove the Highcharts generated print and export buttons. Then create your own print and export buttons along with a drop down for selecting the export type. Then if the export button is clicked, check the type and export as the type and without the sub title. Here is an example. Here is the code that handles the export and print button clicks:

$('#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' });
});
于 2012-10-18T14:58:19.393 回答
1

如果有人在他们的页面上有翻译并想要打印图表,我做了另一个保留字幕的示例。只需在@Linger 答案上添加一个变量:

var subtitle = this.options.subtitle.text;
chart.setTitle(null, { text: ' ' });
        chart.print();
        chart.setTitle(null, { text: subtitle });                        

此处的示例代码:http: //jsfiddle.net/pb6tbx7u/

于 2015-06-10T16:17:35.267 回答