首页 > 解决方案 > Highcharts 在旧版本中查看全屏

问题描述

我正在使用 highcharts 版本 6.1.0,我看到查看全屏选项仅在 highcharts 版本 7 0r 7+ 中可用。有没有办法在之前的版本中获得这个全屏视图功能?提前致谢。

标签: highcharts

解决方案


您可以使用以下功能定义自己的上下文菜单按钮onclick

exporting: {
    menuItemDefinitions: {
        viewFullscreen: {
            onclick: function() {
                var container = this.renderTo;

                if (container.requestFullscreen) {
                    container.requestFullscreen();
                } else if (container.mozRequestFullScreen) {
                    container.mozRequestFullScreen();
                } else if (container.webkitRequestFullscreen) {
                    container.webkitRequestFullscreen();
                } else if (container.msRequestFullscreen) {
                    container.msRequestFullscreen();
                }
            },
            text: 'View in full screen'
        }
    },
    buttons: {
        contextButton: {
            menuItems: ["viewFullscreen", "printChart", "separator", "downloadPNG", "downloadJPEG", "downloadPDF", "downloadSVG"]
        }
    }
}

现场演示:http: //jsfiddle.net/BlackLabel/oyz836v7/

API 参考: https ://api.highcharts.com/highcharts/exporting.menuItemDefinitions


推荐阅读