我有一个带有时间序列和缩放的图表。如果在将图表导出为pdf或图像时不显示副标题(“在绘图区中单击并拖动以放大”),这对于理解如何缩放非常有用,那就更好了。
所以我想知道有没有办法隐藏它。
发布于 2012-10-18 22:58:19
这是一个关于如何做你所要求的事情的。执行字幕操作的部分是:
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' });
});发布于 2015-06-11 00:17:35
我做了另一个例子,如果有人在他们的页面上有翻译并想要打印图表,就保留副标题。只需在@Linger答案上添加一个变量:
var subtitle = this.options.subtitle.text;
chart.setTitle(null, { text: ' ' });
chart.print();
chart.setTitle(null, { text: subtitle }); https://stackoverflow.com/questions/12953105
复制相似问题