Time for bed

This commit is contained in:
nikolark committed 2012-04-15 03:03:21 +02:00
1 parent d112e1b195
commit 598e2a8e57
4 files changed
+101 -70

No files matched your search

+62 -53
View File
@@ -1,62 +1,71 @@
var charts;
$(document).ready(function() {
// define the options
var options = {
credits: {
enabled: false
},
chart: {
renderTo: 'order_chart',
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},
title: {
text: 'Antall ordre per bruker'
},
tooltip: {
formatter: function() {
return '<b>'+ this.point.name +'</b>: '+ Highcharts.numberFormat(this.percentage, 1) +' %';
}
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
color: '#000000',
connectorColor: '#000000',
var charts = [];
var products_url = '/products';
/* drink beer and... */
$.getJSON(products_url, function(data) {
var graph_mappings = [
{
'url' : '/stats/orders',
'render_to' : 'order_chart'
}];
var products = data;
for(i in products) {
var mapping = {
'url' : '/stats/product/' + products[i].id,
'info_url' : '/products/' + products[i].id,
'render_to' : 'product_chart' + products[i].id
};
graph_mappings.push(mapping);
}
for(i in graph_mappings) {
// define the options
var options = {
credits: {
enabled: false
},
chart: {
/* TODO this is not updated right.
* ie. how to get ajax-callback to update the right options-object?
* */
renderTo: graph_mappings[i].render_to,
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},
title: {
text: 'Antall ordre per bruker'
},
tooltip: {
formatter: function() {
return '<b>'+ this.point.name +'</b>: '+ Highcharts.numberFormat(this.percentage, 1) +' %';
}
}
}
},
series: [{
type: 'pie',
name: 'Orders',
data: [],
}]
}
var products_url = '/stats/products';
/* drink beer and */
$.getJSON(products_url, function(data) {
var graph_mappings = [
['/stats/orders', 'order_chart']
];
var products = data;
for(i in products) {
var mapping = ['/stats/product/'+products[i].id, 'product_chart'+products[i].id];
graph_mappings.push(mapping);
}
/* TODO merere her */
for(i in graph_mappings) {
$.getJSON(graph_mappings, function(data) {
options.series[0].data = data;
options.chart.renderTo = graph_mappings[i][1];
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
color: '#000000',
connectorColor: '#000000',
formatter: function() {
return '<b>'+ this.point.name +'</b>: '+ Highcharts.numberFormat(this.percentage, 1) +' %';
}
}
}
},
series: [{
type: 'pie',
name: 'Orders',
data: []
}]
};
$.getJSON(graph_mappings[i].url, function(data) {
options.series[0].data = data,
charts.push(new Highcharts.Chart(options));
});
}
console.log(charts);
});
});