From: Evert Timberg Date: Mon, 6 Jan 2020 22:49:36 +0000 (-0500) Subject: Update tooltip docs with working example (#6918) X-Git-Tag: v3.0.0-alpha~151 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=895e746bd56782987e154e2e94f80b4b70d372d5;p=thirdparty%2FChart.js.git Update tooltip docs with working example (#6918) --- 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; } }