hicharts options for post summary
let companies = []
companies = companies.filter(company => company.counts.length)
const pieChartData = []
const barChartData = []
let total = 0
for(const company of companies){
let pieDataPoint = {y : 0 , name: company.name}
for(const item of company.counts){
pieDataPoint.y += item.count
total += item.count
const postType = item.postType.name
const barChartItem = barChartData.find(item => item.name === postType)
if(barChartItem){
barChartItem.y += item.count
}
else{
barChartData.push({y: item.count, name:postType})
}
}
pieChartData.push(pieDataPoint)
}
Highcharts.chart('container', {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
},
title: {
text: `Daily post analyss by company`
},
subtitle :{
text : `Total of ${total} post were posted.`
},
tooltip: {
pointFormat: '<b>{point.name}</b>: {point.y} posts.'
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
format: '<b>{point.name}</b>: {point.y} posts.'
}
}
},
series: [{
type: 'pie',
name: 'Posts',
colorByPoint: true,
data: pieChartData,
}]
});
Highcharts.chart('container2', {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
},
xAxis: {
type: 'category'
},
yAxis:{
title :{
enabled: false
}
},
title: {
text: 'Number of posts by type'
},
tooltip: {
pointFormat: '<b>{point.name}</b>: {point.y} posts.'
},
series: [{
type: 'column',
name: 'Post Types',
data: barChartData,
}]
});