From e74c7f84c0156bbf136100e29a547e916d611533 Mon Sep 17 00:00:00 2001 From: Yao Zongyou Date: Mon, 6 Nov 2017 23:40:00 +0800 Subject: [PATCH] mgr/dashboard: format chart's tooltip's label as friendly string The default tooltip's label is a long number string, so format the label as a user friendly string. Signed-off-by: Yao Zongyou --- src/pybind/mgr/dashboard/health.html | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/pybind/mgr/dashboard/health.html b/src/pybind/mgr/dashboard/health.html index e61c8ef92db..4859f686da7 100644 --- a/src/pybind/mgr/dashboard/health.html +++ b/src/pybind/mgr/dashboard/health.html @@ -168,7 +168,15 @@ center_text: raw_usage_text, responsive: true, legend: {display: false}, - animation: {duration: 0} + animation: {duration: 0}, + tooltips: { + callbacks: { + label: function(tooltipItem, chart) { + return chart.labels[tooltipItem.index] + ": " + + rivets.formatters.dimless_binary(chart.datasets[0].data[tooltipItem.index]); + } + } + } } }); @@ -202,7 +210,15 @@ options: { responsive: true, legend: {display: false}, - animation: {duration: 0} + animation: {duration: 0}, + tooltips: { + callbacks: { + label: function(tooltipItem, chart) { + return chart.labels[tooltipItem.index] + ": " + + rivets.formatters.dimless_binary(chart.datasets[0].data[tooltipItem.index]); + } + } + } } }); } -- 2.39.5