Highcharts Demo
author(s):
Torstein Hønsi
HTML
<script src="http://code.highcharts.com/highcharts.js"></script>
<div id="container" style="height: 300px; width: 900px;"></div>
JavaScript
var weightChart;
var weightData = [];
$(function () {
var json = {"ibw":175,"max_weight":300,"min_weight":175,"weights":[{"date":1232521200,"weight":300},{"date":1245218400,"weight":300},{"date":1313042400,"weight":290},{"date":1319522400,"weight":270},{"date":1330498800,"weight":200},{"date":1342591200,"weight":250},{"date":1365141600,"weight":235}]};
weightJson = json;
minWeight = weightJson.min_weight;
maxWeight = weightJson.max_weight;
$.each(weightJson.weights, function(i, item) {
weightData.push([item.date, item.weight]);
});
displayGraph();
});
function displayGraph() {
//graph
weightChart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'spline',
zoomType: 'xy',
height: 113
},
credits: {
enabled: false
},
title: {
text: ''
},
tooltip: {
xDateFormat: '%b %d, %Y',
headerFormat: 'Date: <b>{point.key}</b><br />',
pointFormat: 'Weight: <b>{point.y}</b>'
},
xAxis: {
type: 'datetime',
dateTimeLabelFormats: { // don't display the dummy year
month: '%e. %b',
year: '%b'
},
labels: {
enabled: false
}
},
yAxis: {
title: {
text: ''
},
plotLines: [{
color: '#FF0000',
width: 2,
value: 125
}],
...