I am creating a financial pie chart using HighCharts that represents asset allocation. My goal is to create a chart that represents the actual allocation values in each slice but inside each slide will show essentially a second data label that displays the target percentage for various investment vehicles. It is important to note that the current asset allocation may not always match up with the targeted allocation value.
I have gotten everything working except for the Target labels inside each slide. See the image below for what I would like to accomplish:
Here is what I have thus far:
var asset_allocation_pie_chart = new Highcharts.Chart({
chart: { renderTo: 'asset_allocation_bottom_left_div' },
title: { text: 'Current Asset Allocation', style: { fontSize: '17px', color: entity_color, fontWeight: 'bold', fontFamily: 'Verdana'} },
subtitle: { text: '(As of ' + effective_date_formatted + ')', style: { fontSize: '15px', color: entity_color, fontFamily: 'Verdana', marginBottom: '10px' }, y: 40 },
tooltip: { pointFormat: '{series.name}: <b>{point.percentage}%</b>', percentageDecimals: 0 },
plotOptions: {
pie: { allowPointSelect: true, cursor: 'pointer', dataLabels: { enabled: true, color: '#000000', connectorWidth: 1, connectorColor: '#000000', formatter: function() { return '<b>' + this.point.name + '</b>:<br/> ' + Math.round(this.percentage) + ' %'; } } }
},
series: [{
type: 'pie',
name: 'Asset Allocation',
data: [['Investment Grade Bonds', InvestmentGradeBondPercentage], ['High Yield Bonds', HighYieldBondPercentage], ['Hedged Equity', HedgedEquityPercentage], ['Global Equity', GlobalEquityPercentage], ['Cash', CashPercentage]]
}],
exporting: { enabled: false },
credits: { enabled: false }
});
Here is the jsfiddle for this and code to show datalabels inside and outside.
To achieve this
size: '80%'
.Code:
Pie chart will be looked like below :
We can set negative value to
distance
attribute withindataLabels
, which will show text inside theslice
DEMO
Output :