我需要从高级图表上下文菜单中删除“查看数据表”选项。我在流程页面的一个堆栈中找到了2个解决方案。 solution1正在为我工作。但是solution2无法正常工作。在我的代码中,我只需要使用solution2。
try {
String solution1 = "function(chart) {"
+ "var arr =
Highcharts.defaultOptions.exporting.buttons.contextButton.menuItems;"
+ "var index = arr.indexOf('viewData');"
+ "if (index !== -1) arr.splice(index, 1);}";
String solution2 = "exporting: {buttons: {contextButton: {menuItems: ['printChart','separator','downloadPNG','downloadJPEG','downloadPDF','downloadSVG','separator','downloadCSV','downloadXLS','openInCloud']}}}";
String js = MessageFormat
.format("Highcharts.chart('chartview',{0});", data
.processChartData().toString() + "," + solution2);
response.render(OnDomReadyHeaderItem.forScript(js));
}