How can highcharts linear scale or log scale button enabel and zoom in or out full page

萝らか妹 提交于 2021-01-29 10:55:17

问题


I create a highchart but some functionality is not enable in highchart.

  1. linear scale button
  2. log scale button
  3. zoom button(zoom like when i click zoom button its cover full screen )

like this image

This image has 3 manor buttons.


回答1:


You can add additional buttons to your chart by exporting buttons configuration. To change axis scale, use update method with proper axis type. To apply full screen view, you can toggle some CSS class.

Highcharts.stockChart('container', {
    exporting: {
        buttons: {
            customButton: {
                text: 'Linear',
                onclick: function() {
                    this.yAxis[0].update({
                        type: 'linear'
                    });
                }
            },
            customButton2: {
                text: 'Logarithmic',
                onclick: function() {
                    this.yAxis[0].update({
                        type: 'logarithmic'
                    });
                }
            },
            customButton3: {
                text: 'Zoom',
                onclick: function() {
                    $('#container').toggleClass('modal');
                    this.reflow();
                }
            }
        }
    },
    rangeSelector: {
        inputPosition: {
            align: 'left'
        }
    },
    series: [{
        data: [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]
    }]
});

Live demo: https://jsfiddle.net/BlackLabel/w5Laobgc/

API Reference:

https://api.highcharts.com/class-reference/Highcharts.Axis#update

https://api.highcharts.com/highstock/exporting.buttons



来源:https://stackoverflow.com/questions/51839509/how-can-highcharts-linear-scale-or-log-scale-button-enabel-and-zoom-in-or-out-fu

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!