Skip to content

Instantly share code, notes, and snippets.

@icco
Created July 20, 2010 00:14
Show Gist options
  • Save icco/482248 to your computer and use it in GitHub Desktop.
Save icco/482248 to your computer and use it in GitHub Desktop.
/*
* builds the nice little chart for the user profile page.
* @author Nat Welch
*/
function buildGraph(graphData) {
chart = new Highcharts.Chart({
chart: {
renderTo: 'activity-graph',
// zoomType: 'x',
margin: [10, 10, 20, 50],
borderColor: '#fff'
},
credits: {
enabled: false
},
colors: ['#febc3e'],
title: {
text: null
},
subtitle: {
text: null
},
xAxis: {
type: 'datetime',
dateTimeLabelFormats: {
month: '%B %Y'
},
title: {
text: null
}
},
yAxis: {
title: {
style: {
color: '#5A5B5E'
},
text: null
},
allowDecimals: false,
min: 1,
startOnTick: false,
showFirstLabel: false
},
tooltip: {
formatter: function() {
// Uses Mootools Date to format...
var d = new Date(this.x);
return d.format('%B %d') + '<br/>'+ this.y +' reputation';
}
},
legend: {
enabled: false
},
plotOptions: {
area: {
lineWidth: 1,
marker: {
enabled: false,
states: {
hover: {
enabled: true,
radius: 3
}
}
},
shadow: false,
states: {
hover: {
lineWidth: 1
}
}
}
},
series: [{
data: graphData,
type: 'area'
}]
});
}
window.addEvent('domready', function() {
new Request.AjaxIO('buildGraph', {
onSuccess: function(graphData) {
if (graphData.length > 1) {
$('activity-graph').setStyles({
height: 300
});
buildGraph(graphData);
}
}.bind(this)
}).send($('userid').get('text'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment