Javascript 删除 highchart 图表上的导出和打印按钮插件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10653037/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Remove Export and print button plugin on highchart chart
提问by Obsivus
I am using MVC and currently working with highchart
我正在使用 MVC,目前正在使用 highchart
I am using the Exporting.js so users can print or export the highchart chart. I have two charts in a view and I would like to disable print and export on one of the chart. How can I do that?
我正在使用 Exporting.js,因此用户可以打印或导出 highchart 图表。我在一个视图中有两个图表,我想在其中一个图表上禁用打印和导出。我怎样才能做到这一点?
Exporting.js is automaticly giving charts these 2 button options.
Exporting.js 会自动为图表提供这 2 个按钮选项。
Thanks in dvance
提前致谢
Correct solution:
正确的解决方法:
.SetExporting(new Exporting { Enabled = false, EnableImages = false });
采纳答案by Linger
See the following 'Exporting module is loaded but disabled'for how to disable exporting. An explanation of all of the modifiable options for exporting can be found here.
有关如何禁用导出的信息,请参阅以下“导出模块已加载但已禁用”。可在此处找到所有可修改的导出选项的说明。
EDIT
编辑
It looks like you are using DotNet.Highcharts. Here is an example on how to use and set the exporting features:
看起来您正在使用 DotNet.Highcharts。以下是有关如何使用和设置导出功能的示例:
.SetExporting(new Exporting
{
Buttons = new ExportingButtons
{
ExportButton = new ExportingButtonsExportButton
{
Align = HorizontalAligns.Right,
//BackgroundColor <-- Don't know how to set yet
BorderColor = Color.Black,
BorderRadius = 3,
BorderWidth = 1,
Enabled = true,
Height = 35,
HoverBorderColor = Color.Red,
HoverSymbolFill = Color.Black,
HoverSymbolStroke = Color.Black,
//Onclick
//MenuItems
SymbolSize = 25,
SymbolX = 18,
SymbolY = 18,
VerticalAlign = VerticalAligns.Top,
Width = 35,
Y = 10,
X = -50
},
PrintButton = new ExportingButtonsPrintButton
{
Align = HorizontalAligns.Right,
//BackgroundColor <-- Don't know how to set yet
BorderColor = Color.Black,
BorderRadius = 3,
BorderWidth = 1,
Enabled = true,
Height = 35,
HoverBorderColor = Color.Red,
HoverSymbolFill = Color.Black,
HoverSymbolStroke = Color.Black,
//Onclick
//MenuItems
SymbolStroke = Color.Teal,
SymbolSize = 25,
SymbolX = 18,
SymbolY = 18,
VerticalAlign = VerticalAligns.Top,
Width = 35,
Y = 10,
X = -15
}
},
Enabled = true,
EnableImages = true,
Filename = "HomeChart",
Type = "image/png",
Url = "http://export.highcharts.com",
Width = 800
})
回答by Jashwant
You can disable both the buttons (i.e. the whole exporting section) simulataneously by,
您可以同时禁用两个按钮(即整个导出部分),
exporting: {
enabled: false
}
You can also disable any one or both of them like this,
您也可以像这样禁用任何一个或两个,
exporting: {
buttons: {
exportButton: {
enabled:false
},
printButton: {
enabled:false
}
}
}
回答by XaviGuardia
The first option that you mention:
您提到的第一个选项:
exporting: {
enabled: false
}
breaks the highcharts object, if you are using it in a scenario in which you reuse the html container (ie refreshing data).
如果您在重用 html 容器(即刷新数据)的场景中使用它,则会破坏 highcharts 对象。
the only viable option for me in that scenario is combining both:
在这种情况下,我唯一可行的选择是将两者结合起来:
optionsMini.exporting = {
enabled: false,
buttons: {
exportButton: {
enabled: false
},
printButton: {
enabled: false
}
}
}
回答by twc
The below works for the MVC 5 and Highsoft.Highcharts
I added it before this line: Title = new Title { Text = "charts" },
以下适用于我在此行之前添加的 MVC 5 和 Highsoft.Highcharts: Title = new Title { Text = "charts" },
Exporting = new Exporting { Enabled = false },