删除高图表上的导出和打印按钮插件

时间:2012-05-18 12:53:01

标签: javascript asp.net-mvc charts highcharts

我正在使用MVC,目前正在使用highchart

我正在使用Exporting.js,因此用户可以打印或导出高图表。 我在视图中有两个图表,我想在其中一个图表上禁用打印和导出。我怎样才能做到这一点?

Exporting.js自动为这些2个按钮选项提供图表。

感谢dvance

正确的解决方案:

.SetExporting(new Exporting { Enabled = false, EnableImages = false });

4 个答案:

答案 0 :(得分:71)

您可以同时禁用这两个按钮(即整个导出部分),

exporting: {
         enabled: false
}

您也可以禁用其中任何一个或两个,

exporting: {
    buttons: { 
        exportButton: {
            enabled:false
        },
        printButton: {
            enabled:false
        }

    }
}

答案 1 :(得分:10)

有关如何禁用导出,请参阅以下'Exporting module is loaded but disabled'。可以找到所有可修改的导出选项的说明here

修改

看起来您正在使用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
})

答案 2 :(得分:3)

您提到的第一个选项:

exporting: {
         enabled: false
}

如果您在重用html容器的场景中使用它(即刷新数据),则会破坏highcharts对象。

在这种情况下,我唯一可行的选择是结合两者:

  optionsMini.exporting = {
        enabled: false,
        buttons: {
            exportButton: {
                enabled: false
            },
            printButton: {
                enabled: false
            }

        }
    }

答案 3 :(得分:0)

以下适用于MVC 5和Highsoft.Highcharts 我在此行之前添加了它:Title = new Title { Text = "charts" },

Exporting = new Exporting { Enabled = false },