Remove Export and print button plugin on highchart

2020-05-22 06:05发布

I am using MVC and currently working with 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 is automaticly giving charts these 2 button options.

Thanks in dvance

Correct solution:

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

4条回答
做个烂人
2楼-- · 2020-05-22 06:33

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:

.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
})
查看更多
倾城 Initia
3楼-- · 2020-05-22 06:45

The below works for the MVC 5 and Highsoft.Highcharts I added it before this line: Title = new Title { Text = "charts" },

Exporting = new Exporting { Enabled = false },
查看更多
Root(大扎)
4楼-- · 2020-05-22 06:46

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
        }

    }
}
查看更多
甜甜的少女心
5楼-- · 2020-05-22 06:50

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).

the only viable option for me in that scenario is combining both:

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

        }
    }
查看更多
登录 后发表回答