Skip to content

Instantly share code, notes, and snippets.

@tony1223
Created August 13, 2012 02:51
Show Gist options
  • Select an option

  • Save tony1223/3336518 to your computer and use it in GitHub Desktop.

Select an option

Save tony1223/3336518 to your computer and use it in GitHub Desktop.
<script type="text/javascript">
$(function () {
var chart;
function initChart(series){
return new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'line',
marginRight: 130,
marginBottom: 25
},
title: {
text: 'Monthly Average Temperature',
x: -20 //center
},
subtitle: {
text: 'Source: WorldClimate.com',
x: -20
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
yAxis: {
title: {
text: 'Temperature (째C)'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+
this.x +': '+ this.y +'째C';
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -10,
y: 100,
borderWidth: 0
},
series: series
});
}
function random(number){
return (Math.random() * number );
}
function getDataSource(){
return [{
name: 'Tokyo',
data: [random(25),random(25),random(25),random(25),random(25),random(25),random(25),random(25),random(25),random(25),random(25),random(25)]
}, {
name: 'New York',
data: [random(25),random(25),random(25),random(25),random(25),random(25),random(25),random(25),random(25),random(25),random(25),random(25)]
}, {
name: 'Berlin',
data: [random(25),random(25),random(25),random(25),random(25),random(25),random(25),random(25),random(25),random(25),random(25),random(25)]
}, {
name: 'London',
data: [random(25),random(25),random(25),random(25),random(25),random(25),random(25),random(25),random(25),random(25),random(25),random(25)]
}];
}
var chart;
$(document).ready(function() {
chart = initChart(getDataSource());
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment