]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: format chart's tooltip's label as friendly string 18769/head
authorYao Zongyou <yaozongyou@vip.qq.com>
Mon, 6 Nov 2017 15:40:00 +0000 (23:40 +0800)
committerYao Zongyou <yaozongyou@vip.qq.com>
Mon, 6 Nov 2017 15:40:00 +0000 (23:40 +0800)
The default tooltip's label is a long number string, so format
the label as a user friendly string.

Signed-off-by: Yao Zongyou <yaozongyou@vip.qq.com>
src/pybind/mgr/dashboard/health.html

index e61c8ef92db667e1941a239496fd189248291713..4859f686da7ba34c9f5cc94caaba7323569ba8b5 100644 (file)
                         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]);
+                                }
+                            }
+                        }
                     }
                 });
 
                     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]);
+                                }
+                            }
+                        }
                     }
                 });
             }