Disable Print Chart only from HighCharts

I have a DotNetHighchart with the usual options Print Chart, Download as PDF, etc.

I only need to remove the print chart parameter, which seemed easy in previous versions of highchart with

.SetExporting(new Exporting { Buttons = new ExportingButtons { PrintButton = new ExportingButtonsPrintButton { Enabled = false } } } 

But for reasons beyond my control, the updated highcharts module allows only one class in ExportOpions ...

  .SetExporting(new DotNet.Highcharts.Options.Exporting { Buttons = new DotNet.Highcharts.Options.ExportingButtons { ContextButton = new DotNet.Highcharts.Options.ExportingButtonsContextButton { } } } 

That setting Enabled = False disables ALL menu items that seem silly, which means that this is probably a gap in my own knowledge.

What am I missing here?

+7
javascript jquery c # highcharts dotnethighcharts
source share
1 answer

I'm not sure where you get printButton , but here's how you do it. You create the Highcharts.setOptions javascript block and add the exporting code:

  Highcharts.setOptions({ global: { useUTC: false }, exporting: { buttons: { contextButton: { menuItems: [{ text: 'Export to PNG (small)', onclick: function() { this.exportChart({ width: 250 }); } }, { text: 'Export to PNG (large)', onclick: function() { this.exportChart(); }, separator: false }] } } } }); 

This creates only two export buttons. To change the type of export, please raise the exportChart() code. Then you have the chart code below the page. I would not put setOptions in the section of the finished document. I would put your actual schedule in the document ready. Work fiddle .

Option 2 Suppose you know that the default export menu items will always be in the order in which they are now. Then you can get the export menu items:

 var theExportOptions = Highcharts.getOptions().exporting.buttons.contextButton.menuItems; 

Now delete the "Print" section:

 theExportOptions.splice(0, 1); 

Close, but we still have a weird divider. So now delete it:

 theExportOptions.splice(0, 2); 

It seems OK. But you have to put this bit of code in javascript before loading any chart. I don't like this option because you depend on HighCharts, always having the same order / number of export options.

+4
source share

All Articles