Created
June 1, 2012 12:53
-
-
Save sharpred/2851934 to your computer and use it in GitHub Desktop.
howrwe json callback
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*global $ Highcharts */ | |
$(function () { | |
$(document).ready(function () { | |
$.ajax({ | |
url: 'http://www.stepupsoftware.co.uk/howrwe.json', | |
method: 'GET', | |
async: false, | |
success: function (chartvalues) { | |
var chart = new Highcharts.Chart({ | |
chart: { | |
renderTo: 'container', | |
type: 'bar' | |
}, | |
tooltip: { | |
formatter: function () { | |
var that = this.points; | |
that = that.reverse(); //reverse the order as per the legend | |
var s = '<b>' + this.x + '</b>'; | |
var total = 0; | |
$.each(that, function (i, point) { | |
s += '<br/>' + point.series.name + ': ' + point.y; | |
total += point.y; | |
}); | |
s += '<br/>' + chartvalues.totalText + ': ' + total; | |
return s; | |
}, | |
shared: true | |
}, | |
title: { | |
text: chartvalues.title, | |
style: { | |
fontSize: '16px', | |
fontFamily: 'arial, sans-serif', | |
color: chartvalues.chartColor | |
} | |
}, | |
subtitle: { | |
text: chartvalues.subtitle, | |
style: { | |
fontSize: '13px', | |
fontFamily: 'arial, sans-serif', | |
color: chartvalues.chartColor | |
} | |
}, | |
credits: { | |
enabled: false | |
}, | |
legend: { | |
reversed: true, | |
itemStyle: { | |
fontSize: '13px', | |
fontFamily: 'arial, sans-serif', | |
color: chartvalues.chartColor | |
}, | |
verticalAlign: 'top', | |
y: 50 | |
}, | |
xAxis: { | |
categories: chartvalues.categories, | |
labels: { | |
formatter: function () { | |
var returnDay = new Date(this.value); | |
var weekDay = returnDay.getUTCDay(); | |
var day = returnDay.getUTCDate(); | |
var mon = returnDay.getUTCMonth() + 1; | |
return chartvalues.weekdays[weekDay] + ' ' + day + '/' + mon; | |
}, | |
style: { | |
fontSize: '12px', | |
fontFamily: 'arial, sans-serif', | |
color: chartvalues.chartColor | |
} | |
} | |
}, | |
yAxis: { | |
title: '', | |
min: 0, | |
max: 12, | |
tickInterval: 1, | |
labels: { | |
style: { | |
fontSize: '12px', | |
fontFamily: 'arial, sans-serif', | |
color: chartvalues.chartColor | |
} | |
} | |
}, | |
plotOptions: { | |
series: { | |
stacking: 'normal' | |
} | |
}, | |
series: chartvalues.series | |
}); | |
}, | |
dataType: 'jsonp' | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment