How To Style Navigator Dragging Handles , Highstock
Appart from colors, is it possible to style the navigator handles(like shape, height, width, border radius, background, etc..). From he API doc: http://api.highcharts.com/highstock
Solution 1:
Update: Since v6.0.0 the handles are customizable through API options - https://api.highcharts.com/highstock/navigator.handles.symbols
Legacy solution below
It is possible to extend Highcharts and override Highcharts.Scroller.prototype.drawHandle
function with a custom one. You could base your code on existing one and add more options and elements like in this example: http://jsfiddle.net/kuos06o5/1/ (for original question when Highstock version was 4.2.5)
$(function() {
//custom handles
(function(HC) {
HC.Scroller.prototype.drawHandle = function(x, index) {
var scroller = this,
chart = scroller.chart,
renderer = chart.renderer,
elementsToDestroy = scroller.elementsToDestroy,
handles = scroller.handles,
handlesOptions = scroller.navigatorOptions.handles,
radius = handlesOptions.radius,
attr = {
fill: handlesOptions.backgroundColor,
stroke: handlesOptions.borderColor,
'stroke-width': 1
},
tempElem,
innerLinesOptions = handlesOptions.innerLines,
h = innerLinesOptions.height;
// create the elementsif (!scroller.rendered) {
// the group
handles[index] = renderer.g('navigator-handle-' + ['left', 'right'][index])
.css({
cursor: 'ew-resize'
})
.attr({
zIndex: 10 - index
})
.add();
// cirlce
tempElem = renderer.circle(0, 0, radius)
.attr(attr)
.add(handles[index]);
elementsToDestroy.push(tempElem);
// inner lines
tempElem = renderer.path([
'M', -1.5, -h / 2,
'L', -1.5, h / 2,
'M', 1.5, -h / 2,
'L', 1.5, h / 2
])
.attr({
stroke: innerLinesOptions.color,
'stroke-width': 1
})
.add(handles[index]);
elementsToDestroy.push(tempElem);
}
// Place it
handles[index][chart.isResizing ? 'animate' : 'attr']({
translateX: scroller.scrollerLeft + scroller.scrollbarHeight + parseInt(x, 10),
translateY: scroller.top + scroller.height / 2
});
};
})(Highcharts);
$('#container').highcharts('StockChart', {
navigator: {
handles: {
backgroundColor: 'white',
borderColor: 'grey',
radius: 8,
innerLines: {
color: 'blue',
height: 6
}
}
},
rangeSelector: {
selected: 1
},
series: [{
name: 'USD to EUR',
data: usdeur
}]
});
});
In newer versions (4.2.6, 4.2.7 and 5.0.0 - current newest) drawHandle was moved, so the wrapper should start with:
HC.Navigator.prototype.drawHandle = function(x, index) {
Post a Comment for "How To Style Navigator Dragging Handles , Highstock"