I am using highstock charts and wish to move the zoom buttons (1m,2m,etc) to a different position.
I checked their API and there doesn't seem to be an option to do that currently. Also the source code suggests that this location is hardcoded and hence i don't think I can easily inject the position using some undocumented property
Highcharts.RangeSelector.prototype.render = function (min, max) {
...
rangeSelector.zoomText = renderer.text(lang.rangeSelectorZoom, plotLeft, chart.plotTop - 10)
.css(options.labelStyle)
.add();
// button starting position
buttonLeft = plotLeft + rangeSelector.zoomText.getBBox().width + 5;
...
}
This can be done by overriding the current render method and then moving the boxes after calling the actual render method to a position desired
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;
}
};
This code needs to be run before creating any chart
Positioning Zoom buttons | Highchart & Highstock @ jsFiddle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With