Custom Highcharts Context Menu Button Appearing in Every Chart on Page

前端 未结 4 1523
执笔经年
执笔经年 2021-01-12 10:37

I have a page with several charts, and I need to be able to add specific options to the exporting context menu for each chart. This is the code I am using:

         


        
4条回答
  •  遥遥无期
    2021-01-12 11:02

    I found another possiblity to add it only to one chart. Add following to the chart where you want to extend the context menu

           exporting: {
                buttons: {
                    contextButton: {
                        menuItems: [
    
                        ]
                    }
                }
            },
    

    . Now you are able to extend the chart dynamicly with a method like

     function (button) {
        var userMenu = this.chart.userOptions.exporting.buttons.contextButton.menuItems;
        if (userMenu.length === 0) {
            var menuItems = Highcharts.getOptions().exporting.buttons.contextButton.menuItems;
            for (var itemIndex in menuItems) {
                userMenu.push(menuItems[itemIndex]);
            }
        }
        userMenu.push(button);
    };
    

    . Where this.chart points to the chart which context menu should be extended

提交回复
热议问题