This snippet shows both original OHLC and adjusted OHLC data in separate plots:
<html>
<head>
<title>
How to show original values in tooltip?
</title>
<script src="https://code.highcharts.com/stock/highstock.js"></script>
<script src="https://code.highcharts.com/modules/data.js"></script>
</head>
<body>
<div id="chart-container" style="width: 100%; height: 100%; margin: 0 auto"></div>
<pre id="csv" style="display: none">
date,open,high,low,close,volume,ex_dividend,split_ratio,adj_open,adj_high,adj_low,adj_close,adj_volume
2014-05-30,637.98,644.17,628.9,633.0,20143600.0,0.0,1.0,85.783881043984,86.616199022075,84.562968727173,85.114261733663,141005200.0
2014-06-02,633.96,634.83,622.5,628.65,13191100.0,0.0,1.0,85.243344974207,85.36032666095,83.702413790213,84.529353299948,92337700.0
2014-06-03,628.46,638.74,628.25,637.54,10453900.0,0.0,1.0,84.503805575257,85.886071942748,84.475568616388,85.724717892068,73177300.0
2014-06-04,637.44,647.89,636.11,644.82,11981500.0,0.0,1.0,85.711271721178,87.116396579183,85.532437648341,86.70359913286,83870500.0
2014-06-05,646.2,649.3699,642.61,647.35,10850200.0,0.0,1.0,86.889156291142,87.315386462184,86.406438756191,87.043787256377,75951400.0
2014-06-06,649.9,651.26,644.47,645.57,12497800.0,0.0,1.0,87.386664614072,87.569532538176,86.656537534745,86.804445414535,87484600.0
2014-06-09,92.7,93.88,91.75,93.7,75414997.0,0.0,7.0,87.252202905172,88.362856620685,86.358032540987,88.193434867471,75414997.0
2014-06-10,94.73,95.05,93.57,94.25,62777000.0,0.0,1.0,89.16290378864,89.464098016576,88.071074712372,88.711112446736,62777000.0
2014-06-11,94.13,94.76,93.47,93.86,45681000.0,0.0,1.0,88.59816461126,89.191140747509,87.976951516142,88.344031981439,45681000.0
2014-06-12,94.04,94.12,91.9,92.29,54749000.0,0.0,1.0,88.513453734653,88.588752291637,86.499217335332,86.866297800629,54749000.0
2014-06-13,92.2,92.44,90.88,91.28,54525000.0,0.0,1.0,86.781586924022,87.007482594974,85.539160733786,85.915653518706,54525000.0
2014-06-16,91.51,92.75,91.45,92.2,35561000.0,0.0,1.0,86.132136870035,87.299264503287,86.075662952297,86.781586924022,35561000.0
</pre>
<script type="text/javascript">
Highcharts.stockChart('chart-container', {
title: {
text: 'Plot Title',
align: 'left',
floating: false
},
exporting: {
enabled: true,
sourceWidth: 900,
sourceHeight: 600
},
legend: {
enabled: false,
floating: true,
verticalAlign: 'top',
align:'center'
},
rangeSelector: {
buttons: [{
type: 'month',
count: 6,
text: '6m'
}, {
type: 'year',
count: 1,
text: '1y'
}, {
type: 'year',
count: 2,
text: '2y'
}, {
type: 'year',
count: 3,
text: '3y'
}, {
type: 'year',
count: 4,
text: '4y'
}, {
type: 'all',
text: 'All'
}],
selected: 3
},
credits: {
enabled: false
},
plotOptions: {
series: {
visible: false,
turboThreshold: 0 // Comment out this code to display error
},
ohlc: {
color: 'black'
}
},
data: {
csv: document.getElementById('csv').innerHTML,
firstRowAsNames: false,
startRow: 1,
seriesMapping: [{
x: 0,
open: 1,
high: 2,
low: 3,
close: 4
}, {
x: 0,
open: 8,
high: 9,
low: 10,
close: 11
}, {
x: 0,
y: 9
}, {
x: 0,
y: 10
}]
},
series: [{
name: 'Values',
type: 'ohlc', // bars
visible: true,
// set color in plotOptions
tooltip: {
// set tooltip options here
}
}, {
name: 'Adj_Values',
type: 'ohlc', // bars
visible: true,
// set color in plotOptions
tooltip: {
// set tooltip options here
}
}, {
name: 'Adj_High',
type: 'line', // high
visible: false,
color: 'blue'
}, {
name: 'Adj_Low',
type: 'line', // low
visible: false,
color: 'gray'
}]
});
</script>
</body>
</html>
If possible I want to (1) make the original OHLC plot invisible; (2) plot only the adjusted OHLC bars; and (3) show the original OHLC values in the tooltip attached to the adjusted OHLC bars shown in the plot.
I can find examples of a shared tooltip but no information on the options that would replace the adjusted OHLC with original OHLC data. Alternatively I might want to add original OHLC data to show both original and adjusted in the tooltip associated with the adjusted data plot.
You can disable visible property for the first series and use tooltip's formatter function to find a matched point from the hidden series and show it's values.
tooltip: {
formatter: function(tooltip) {
const originalFormat = tooltip.defaultFormatter.call(this, tooltip);
const point = this.points[0].point;
const originalPoint = tooltip.chart.series[0].points.find(
p => p.x === point.x
);
originalFormat[1] = `<span style="color:black">●</span> <b> ${point.series.name}</b><br/>Open: ${originalPoint.open}<br/>High: ${originalPoint.high}<br/>Low: ${originalPoint.low}<br/>Close: ${originalPoint.close}<br/>`;
return originalFormat;
}
},
series: [{
name: 'Values',
type: 'ohlc',
visible: false
}, {
name: 'Adj_Values',
type: 'ohlc',
visible: true
}, ...]
Live demo: http://jsfiddle.net/BlackLabel/k2mhvdp6/
API Reference: https://api.highcharts.com/highcharts/tooltip.formatter
I am trying to add anchor tag in tooltip of highstock flags.
I am facing couple of problems with that:
Anchor tags are not displayed in tooltip.
When I try to hover over the tooltip, the tooltip disappears.
My code looks like:
$.getJSON('https://cdn.rawgit.com/highcharts/highcharts/057b672172ccc6c08fe7dbb27fc17ebca3f5b770/samples/data/usdeur.json', function (data) {
var year = new Date(data[data.length - 1][0]).getFullYear(); // Get year of last data point
// Create the chart
Highcharts.stockChart('container', {
rangeSelector: {
selected: 4
},
title: {
text: 'USD to EUR exchange rate'
},
yAxis: {
title: {
text: 'Exchange rate'
}
},
series: [{
name: 'USD to EUR',
data: data,
id: 'dataseries',
tooltip: {
valueDecimals: 4
}
},{
type: 'flags',
data: [{
x: Date.UTC(year, 11, 1),
title: 'B',
text: 'make me clickable'
}, {
x: Date.UTC(year, 11, 1),
title: 'B',
text: '<a>make me clickable</a>'
}],
shape: 'circlepin',
onSeries: 'dataseries',
width: 16,
tooltip: {
pointFormat: '{point.text}'
} ,
style:{
border:'1px solid green'
}
}]
});
});
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://code.highcharts.com/stock/highstock.js"></script>
<script src="https://code.highcharts.com/stock/modules/exporting.js"></script>
<div id="container" style="height: 400px"></div>
What am I doing wrong?
You have to set useHTML to true for the tooltip. To easier hover on tooltip, increase hideDelay value and disable stickyTracking on series:
tooltip: {
useHTML: true,
hideDelay: 5000
}
Live demo: http://jsfiddle.net/BlackLabel/ncrgwvzu/
API:
https://api.highcharts.com/highstock/series.line.stickyTracking
https://api.highcharts.com/highstock/tooltip.useHTML
I want to set navigator's position and range programmably in Highstock candlestick chart. By default, navigator's end(left) side indicate end of data series. And also width of navigator is seems like fixed some number of data.
In this picture, I want to set navigator to yellow position. How can I do this?
You need to set the xAxis min and max, to show a specific area on chart load. Can be done like this:
xAxis: {
min: 1330764400000,
max: 1330774400000
},
$.getJSON('https://cdn.rawgit.com/highcharts/highcharts/057b672172ccc6c08fe7dbb27fc17ebca3f5b770/samples/data/large-dataset.json', function (data) {
// Create a timer
var start = +new Date();
// Create the chart
Highcharts.stockChart('container', {
chart: {
events: {
load: function () {
if (!window.TestController) {
this.setTitle(null, {
text: 'Built chart in ' + (new Date() - start) + 'ms'
});
}
}
},
zoomType: 'x'
},
rangeSelector: {
buttons: [{
type: 'day',
count: 3,
text: '3d'
}, {
type: 'week',
count: 1,
text: '1w'
}, {
type: 'month',
count: 1,
text: '1m'
}, {
type: 'month',
count: 6,
text: '6m'
}, {
type: 'year',
count: 1,
text: '1y'
}, {
type: 'all',
text: 'All'
}],
selected: 3
},
yAxis: {
title: {
text: 'Temperature (°C)'
}
},
xAxis: {
min: 1330764400000,
max: 1330774400000
},
title: {
text: 'Hourly temperatures in Vik i Sogn, Norway, 2009-2017'
},
subtitle: {
text: 'Built chart in ...' // dummy text to reserve space for dynamic subtitle
},
series: [{
name: 'Temperature',
data: data.data,
pointStart: data.pointStart,
pointInterval: data.pointInterval,
tooltip: {
valueDecimals: 1,
valueSuffix: '°C'
}
}]
});
});
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://code.highcharts.com/stock/highstock.js"></script>
<script src="https://code.highcharts.com/stock/modules/exporting.js"></script>
<div id="container" style="height: 400px; min-width: 310px"></div>
Working JSFiddle example: https://jsfiddle.net/ewolden/axrce6j3/2/
If you want to show a specific area after the chart has been drawn, you can use the setExtremes function like this:
chart.xAxis[0].setExtremes(1330764400000, 1330774400000, true);
API Reference: Axis.setExtremes()
$.getJSON('https://cdn.rawgit.com/highcharts/highcharts/057b672172ccc6c08fe7dbb27fc17ebca3f5b770/samples/data/large-dataset.json', function (data) {
// Create a timer
var start = +new Date();
// Create the chart
Highcharts.stockChart('container', {
chart: {
events: {
load: function () {
if (!window.TestController) {
this.setTitle(null, {
text: 'Built chart in ' + (new Date() - start) + 'ms'
});
}
}
},
zoomType: 'x'
},
rangeSelector: {
buttons: [{
type: 'day',
count: 3,
text: '3d'
}, {
type: 'week',
count: 1,
text: '1w'
}, {
type: 'month',
count: 1,
text: '1m'
}, {
type: 'month',
count: 6,
text: '6m'
}, {
type: 'year',
count: 1,
text: '1y'
}, {
type: 'all',
text: 'All'
}],
selected: 3
},
yAxis: {
title: {
text: 'Temperature (°C)'
}
},
xAxis: {
min: 1330764400000,
max: 1330774400000
},
title: {
text: 'Hourly temperatures in Vik i Sogn, Norway, 2009-2017'
},
subtitle: {
text: 'Built chart in ...' // dummy text to reserve space for dynamic subtitle
},
series: [{
name: 'Temperature',
data: data.data,
pointStart: data.pointStart,
pointInterval: data.pointInterval,
tooltip: {
valueDecimals: 1,
valueSuffix: '°C'
}
}]
});
});
$('#setExtremeButton').click(function() {
$('#container').highcharts().xAxis[0].setExtremes(1330774400000,1350974400000, true)
})
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://code.highcharts.com/stock/highstock.js"></script>
<script src="https://code.highcharts.com/stock/modules/exporting.js"></script>
<div id="container" style="height: 400px; min-width: 310px"></div>
<button id="setExtremeButton">
Set new min/max
</button>
Working example: https://jsfiddle.net/ewolden/axrce6j3/12/
I'm going to prepare a stacked column charts report using highcharts. The problem is my data types are different.
Please, view image example
Could you help me create a chart like image. please
You can achieve this using Stacked Group in Highchart by handling data section properly.
Here, I tried to build same chart as you required. You can handle legend and other of the chart.
This should help you. I also created fiddle demo which you can access using below link.
Fiddle Demo: http://jsfiddle.net/t4u8b8co/1/
Highcharts.chart('container', {
chart: {
type: 'column'
},
title: {
text: ''
},
legend: {
enabled: false
},
xAxis: {
categories: [
['19603', '19666'], '19603', '19603'
]
},
yAxis: {
title: {
text: 'Good or Bad'
}
},
plotOptions: {
column: {
stacking: 'percent'
}
},
series: [{
name: 'Jane',
data: [244, 23, 4],
stack: '19603'
}, {
name: 'John',
data: [306, 522, 546],
stack: '19603'
}, {
name: 'Jane',
data: [376],
stack: 'female'
}, {
name: 'Janet',
data: [174],
stack: 'female'
}]
});
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
I have a page with multiple charts. When I scroll down to print a chart, the page returns focus to the top of the page, not the chart I just printed. Haven't found anything on the boards related to this, so hoping someone has encountered this and has a suggestion.
Here is an example: http://jsfiddle.net/ND5xf/
Scroll down to the third chart and choose to print. You can either print it or cancel the window. The page will return focus to the first chart.
HTML:
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<div id="container1" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
<div id="container2" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
<div id="container3" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
Javascript:
$(function () {
$('#container1').highcharts({
chart: {
type: 'line'
},
title: {
text: 'Line Chart'
},
xAxis: {
categories: ['Category 1', 'Category 2', 'Category 3']
},
series: [{
data: [7.0, 6.9, 9.5]
}, {
data: [-0.2, 0.8, 5.7]
}]
});
});
$(function () {
$('#container2').highcharts({
chart: {
type: 'bar'
},
title: {
text: 'Bar Chart'
},
xAxis: {
categories: ['Category 1', 'Category 2', 'Category 3']
},
series: [{
data: [107, 31, 635]
}, {
data: [133, 156, 947]
}]
});
});
$(function () {
$('#container3').highcharts({
chart: {
type: 'column'
},
title: {
text: 'Column Chart'
},
xAxis: {
categories: ['Category 1', 'Category 2', 'Category 3']
},
series: [{
data: [49.9, 71.5, 106.4]
}, {
data: [83.6, 78.8, 98.5]
}]
});
});
Highcharts prints a single chart by hiding everything else on the page and then printing. It looks like that in this shuffle of DOM elements a potential scroll bar is forgotten. The only fix I can see (without modifying the source) is to take control of the printing yourself and reset the scroll position.
exporting: {
buttons: {
contextButton: {
menuItems: [{
text: 'Print Chart',
onclick: function() {
var scrollPos = $(document).scrollTop();
this.print();
setTimeout(function(){
$(document).scrollTop(scrollPos)
}, 1001); // Highcharts has a 1s delay before display elements again
}
}]
}
}
}
See fiddle here (try the 3rd chart).