简体   繁体   English

是否可以将缩放按钮定位在highcharts / highstock中?

[英]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. 正如标题所示,我们有一些图表在左侧有两个y轴,因此如果屏幕变小,则缩放按钮与范围输入重叠。

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 我无法在API中找到任何可能的建议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 检查: 如何在Highstock的自定义坐标上定位RangeSelector / zoom按钮

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 . http://api.highcharts.com/highstock#rangeSelector.inputPosition

Parhaps you can move the input boxes to the left hand side, or remove them altogether ? 您是否可以将输入框移动到左侧,或者将它们完全删除?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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