Highcharts Stock Demo
author(s):
Torstein Hønsi
HTML
<div id="container" style="height: 400px; min-width: 600px"></div>
<script src="http://code.highcharts.com/stock/highstock.js"></script>
<script src="http://code.highcharts.com/stock/modules/exporting.js"></script>
<script type="text/javascript" src="http://www.highcharts.com/samples/data/usdeur.js"></script>
JavaScript
$(function() {
var chart = new Highcharts.StockChart({
chart: {
renderTo: 'container'
},
xAxis: {
events: {
afterSetExtremes: function(event){
if((event.max - event.min) <=30 * 24 * 3600 * 1000)
//alert("date range less than 5 day.");
{
//alert(chart.xAxis[0].options.tickInterval);
chart.xAxis[0].options.tickInterval = 24 * 3600 * 1000;
}
else
chart.xAxis[0].options.tickInterval = null;
}
}
},
tooltip: {
formatter: function() {
console.log(this);
var s = Highcharts.dateFormat('%A, %b %e, %H:%M', this.x);
var unit = '',
color = '';
if (this.points)
$.each(this.points, function(i, point) {
if ((point.series.name == "PRESSURE") || (point.series.name == "TEMPERATURE")) {
unit = 'x';
color = '#DE4977';
decimal = ' ';
if (i < 2) s += '<br/><span style="font-size:12px;font-weight:bold;color:' + color + '">' + point.series.name + ':</span><strong> ' + point.y.toFixed(decimal) + unit + '</strong>';
}
});
return s;
}
},
rangeSelector: {
selected: 1
},
series: [{
name: 'USD to EUR',
id: 'dataseries',
data: usdeur},
{
events: {
click: function() {
alert('I\' m here!');
}
},
type: 'flags',
data: [{
x: Date.UTC(2011, 3, 25),
...