Hi,
I’m having a problem building an array to display in HighCharts; Can you help me? thanks in advance!
Here is the HighCharts example code for a Pie Chart:
‘’’
return {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},
title: {
text: "Number of Customers by Billing Plan"
},
tooltip: {
pointFormat: '<b>{point.percentage:.1f}%</b>'
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
format: '<b>{point.name}</b>: {point.y:.0f}',
style: {
color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
},
showInLegend: true,
connectorColor: 'silver'
}
}
},
credits: {
enabled: false
},
series: [{
type: 'pie',
name: 'customers',
data:
[
["One", 1],
['Two', 2],
['Three', 0],
['Four', 4],
['Five', 7],
['Six', 19],
['Seven', 50]
]
}]
};
‘’’
I am replacing the data section with the following and receving ‘slice’ in the pie chart
‘’’
EndUserPieChart()
{
id = Session.get(‘id’);
var endUserPieChart = [];
var codes = Codes.find({}).map( function(p){ return p._id });
AreaArray = Codes.find({}).map( function(p){ return p.code });
//Get Code Array
for (i = 0; i < codes.length; i++) {
Area = AreaArray[i];
Area = Area.toString();
Meteor.call('CountEndUsersByCode', codes[i], function(error, result){
if(error){
console.log(error);
}else{
endUserPieChart[endUserPieChart.length] = [Area, result];
}
});
}
return {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},
title: {
text: "End Users By Area"
},
tooltip: {
pointFormat: '<b>{point.percentage:.1f}%</b>'
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
format: '<b>{point.name}</b>: {point.y:.0f}',
style: {
color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
},
showInLegend: true,
connectorColor: 'silver'
}
}
},
credits: {
enabled: false
},
series: [{
type: 'pie',
name: 'end users',
data:
[
endUserPieChart
]
}]
};
}
‘’’