From 895e746bd56782987e154e2e94f80b4b70d372d5 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Mon, 6 Jan 2020 17:49:36 -0500 Subject: [PATCH] Update tooltip docs with working example (#6918) --- docs/configuration/tooltip.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/configuration/tooltip.md b/docs/configuration/tooltip.md index 7c662b288..d57568b7f 100644 --- a/docs/configuration/tooltip.md +++ b/docs/configuration/tooltip.md @@ -121,7 +121,7 @@ All functions are called with the same arguments: a [tooltip item](#tooltip-item ### Label Callback -The `label` callback can change the text that displays for a given data point. A common example to round data values; the following example rounds the data to two decimal places. +The `label` callback can change the text that displays for a given data point. A common example to show a unit. The example below puts a `'$'` before every row. ```javascript var chart = new Chart(ctx, { @@ -136,7 +136,9 @@ var chart = new Chart(ctx, { if (label) { label += ': '; } - label += Math.round(tooltipItem.value * 100) / 100; + if (!helpers.isNullOrUndef(tooltipItem.value)) { + label += '$' + tooltipItem.value; + } return label; } } -- 2.47.2