Time series, zoomable
author(s): Torstein Hønsi
by Pawan Jadhav
HTML
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/data.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<script src="https://code.highcharts.com/modules/accessibility.js"></script>
<figure class="highcharts-figure">
<div id="container"></div>
<p class="highcharts-description">
Highcharts has extensive support for time series, and will adapt
intelligently to the input data. Click and drag in the chart to zoom in
and inspect the data.
</p>
</figure>
CSS
.highcharts-figure, .highcharts-data-table table {
min-width: 360px;
margin: 1em auto;
}
.highcharts-data-table table {
font-family: Verdana, sans-serif;
border-collapse: collapse;
border: 1px solid #EBEBEB;
margin: 10px auto;
text-align: center;
width: 100%;
max-width: 500px;
}
.highcharts-data-table caption {
padding: 1em 0;
font-size: 1.2em;
color: #555;
}
.highcharts-data-table th {
font-weight: 600;
padding: 0.5em;
}
.highcharts-data-table td, .highcharts-data-table th, .highcharts-data-table caption {
padding: 0.5em;
}
.highcharts-data-table thead tr, .highcharts-data-table tr:nth-child(even) {
background: #f8f8f8;
}
.highcharts-data-table tr:hover {
background: #f1f7ff;
}
JavaScript
var data = [[1420050600000,123],
[1422729000000,455],
[1425148200000,677],
[1427826600000,234],
[1430418600000,687],
[1433097000000,789],
[1435689000000,123],
[1438367400000,678],
[1441045800000,89],
[1443637800000,234],
[1446316200000,567],
[1448908200000,213],
[1451586600000,678],
[1454265000000,123],
[1456770600000,896],
[1459449000000,123],
[1462041000000,456],
[1464719400000,789],
[1467311400000,456],
[1469989800000,678],
[1472668200000,244],
[1475260200000,234],
[1477938600000,567],
[1480530600000,789],
[1483209000000,234],
[1485887400000,567],
[1488306600000,345],
[1490985000000,457],
[1493577000000,768],
[1496255400000,123],
[1498847400000,456],
[1501525800000,873],
[1504204200000,455],
[1506796200000,677],
[1509474600000,234],
[1512066600000,687],
[1514745000000,789],
[1517423400000,123],
[1519842600000,678],
[1522521000000,89],
[1525113000000,234],
[1527791400000,567],
[1530383400000,213],
[1533061800000,678],
[1535740200000,123],
[1538332200000,896],
[1541010600000,123],
[1543602600000,456],
[1546281000000,789],
[1548959400000,456],
[1551378600000,678],
[1554057000000,244],
[1556649000000,234],
[1559327400000,567],
[1561919400000,789],
[1564597800000,234],
[1567276200000,455],
[1569868200000,677],
[1572546600000,234],
[1575138600000,687],
[1577817000000,789],
[1580495400000,123],
[1583001000000,678],
[1585679400000,89],
[1588271400000,234]];
Highcharts.chart('container', {
chart: {
zoomType: 'x'
},
title: {
text: 'USD to EUR exchange rate over time'
},
xAxis: {
type: 'datetime',
dateTimeLabelFormats:{
millisecond: '%H:%M:%S.%L',
second: '%H:%M:%S',
minute: '%H:%M',
hour: '%H:%M',
day: '%e. %b',
week: '%e. %b',
month: 'AA %b \'%y',
year: 'AA %Y'
}
},
yAxis: {
title: {
text: 'Exchange rate'
}
...