简体   繁体   中英

Is it possible to position the zoom buttons in highcharts/highstock?

As the title says, we have some charts that have two y axis on the left, and as a consequence if the screen is made smaller then the zoom buttons overlap the range inputs.

Ideally I would want the zoom buttons to always align to the left of the chart (including axis)

Thanks

在此输入图像描述

I can't find anything in the API to suggest it's possible http://api.highcharts.com/highstock#rangeSelector

By default, the scale reset button located on the right. You can change position by using this code, for example:

...
chart: {
    zoomType: 'x, y',
    resetZoomButton: {
        position: {
            align: 'left', // right by default
            verticalAlign: 'top', 
            x: 10,
            y: 10
        },
        relativeTo: 'chart'
    }
}    
...

Live demo .

Check this: How to position RangeSelector / zoom buttons at custom co-ordinates in Highstock

var orgHighchartsRangeSelectorPrototypeRender = Highcharts.RangeSelector.prototype.render;
Highcharts.RangeSelector.prototype.render = function (min, max) {
    orgHighchartsRangeSelectorPrototypeRender.apply(this, [min, max]);
    var leftPosition = this.chart.plotLeft,
        topPosition = this.chart.plotTop+5,
        space = 2;
    this.zoomText.attr({
        x: leftPosition,
        y: topPosition + 15
    });
    leftPosition += this.zoomText.getBBox().width;
    for (var i = 0; i < this.buttons.length; i++) {
        this.buttons[i].attr({
            x: leftPosition,
            y: topPosition 
        });
        leftPosition += this.buttons[i].width + space;
    }
};

I can't find any options to move the buttons, but you can move the range inputs using:

        rangeSelector: {
            inputPosition: {
                x: 100
            }
        },

http://api.highcharts.com/highstock#rangeSelector.inputPosition .

Parhaps you can move the input boxes to the left hand side, or remove them altogether ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM