Highcharts Stock Demo
author(s):
Torstein Hønsi
HTML
<div id="container" style="height: 400px; min-width: 600px"></div>
<script src="https://code.highcharts.com/stock/5.0.0/highstock.js"></script>
<script src="https://code.highcharts.com/stock/5.0.0/modules/exporting.js"></script>
<script src="https://www.highcharts.com/samples/data/usdeur.js"></script>
JavaScript
$(function() {
//custom handles
(function(HC) {
HC.Navigator.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 elements
if (!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',
...