From 73fae00b63eb242dbbb688b179bf0e1a393e29c5 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Sun, 30 May 2021 04:59:51 +0200 Subject: [PATCH] Improved Y axes readness in Bar Chart. --- .../htmlize/charts/BarChartView.java | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/fr/devinsy/statoolinfos/htmlize/charts/BarChartView.java b/src/fr/devinsy/statoolinfos/htmlize/charts/BarChartView.java index 6505145..5fe83a5 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/charts/BarChartView.java +++ b/src/fr/devinsy/statoolinfos/htmlize/charts/BarChartView.java @@ -101,21 +101,26 @@ public class BarChartView lines.append(" {\n"); lines.append(" xAxes:\n"); lines.append(" [{\n"); - lines.append(" ticks: \n"); - lines.append(" {\n"); - lines.append(" beginAtZero: true\n"); - lines.append(" },\n"); - lines.append(" stacked: ").append(chart.isStacked()).appendln(","); + lines.append(" ticks:\n"); + lines.append(" {\n"); + lines.append(" beginAtZero: true\n"); + lines.append(" },\n"); + lines.append(" stacked: ").append(chart.isStacked()).appendln(","); lines.append(" }],\n"); lines.append(" yAxes:\n"); lines.append(" [{\n"); - lines.append(" ticks: \n"); + lines.append(" ticks:\n"); + lines.append(" {\n"); + lines.append(" beginAtZero: true,\n"); + lines.append(" suggestedMax: 10,\n"); + lines.append(" precision: 0,\n"); + lines.append(" callback: function(value, index, values)"); lines.append(" {\n"); - lines.append(" beginAtZero: true,\n"); - lines.append(" suggestedMax: 10,\n"); - lines.append(" precision: 0\n"); - lines.append(" },\n"); - lines.append(" stacked: ").append(chart.isStacked()).appendln(","); + lines.append( + " if (value > 1000000000) return value/1000000000 + 'G'; else if (value > 1000000) return value/1000000 + 'M'; else if (value > 1000) return value/1000 + 'k';else return value;\n"); + lines.append(" }\n"); + lines.append(" },\n"); + lines.append(" stacked: ").append(chart.isStacked()).appendln(","); lines.append(" }]\n"); lines.append(" },\n"); lines.append(" animation:\n");