feat: added percentage to pie chart
This commit is contained in:
parent
b1a3e56d04
commit
a37277759c
1 changed files with 9 additions and 2 deletions
|
@ -242,7 +242,7 @@ public class DashboardView extends Div {
|
||||||
}
|
}
|
||||||
data.setCharAt(data.length() - 1, ']'); // Replace last comma with closing bracket
|
data.setCharAt(data.length() - 1, ']'); // Replace last comma with closing bracket
|
||||||
|
|
||||||
// Generate JavaScript initialization
|
// Generate JavaScript initialization with percentage tooltip
|
||||||
return "Highcharts.chart('pieChart', {" +
|
return "Highcharts.chart('pieChart', {" +
|
||||||
"chart: {" +
|
"chart: {" +
|
||||||
"type: 'pie'" +
|
"type: 'pie'" +
|
||||||
|
@ -250,9 +250,16 @@ public class DashboardView extends Div {
|
||||||
"title: {" +
|
"title: {" +
|
||||||
"text: 'Expenses by Category for " + Year.now().getValue() + "'" +
|
"text: 'Expenses by Category for " + Year.now().getValue() + "'" +
|
||||||
"}," +
|
"}," +
|
||||||
|
"tooltip: {" + // Tooltip configuration to show percentage
|
||||||
|
"pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b> ({point.y:.2f})'" +
|
||||||
|
"}," +
|
||||||
"plotOptions: {" +
|
"plotOptions: {" +
|
||||||
"pie: {" +
|
"pie: {" +
|
||||||
"size: '80%'" + // Adjust size to make the pie chart larger
|
"size: '80%'," + // Adjust size to make the pie chart larger
|
||||||
|
"dataLabels: {" + // Enable data labels
|
||||||
|
"enabled: true," +
|
||||||
|
"format: '{point.name}: {point.percentage:.1f}%'" + // Show percentage next to each slice
|
||||||
|
"}" +
|
||||||
"}" +
|
"}" +
|
||||||
"}," +
|
"}," +
|
||||||
"series: [{" +
|
"series: [{" +
|
||||||
|
|
Loading…
Reference in a new issue