From 55be827a4796f149f64e8ea8c15bc2a3ff0e06e6 Mon Sep 17 00:00:00 2001 From: Doug Brunner Date: Wed, 15 Dec 2021 14:34:41 -0800 Subject: [PATCH 1/2] Docs/clarify usage of ticks callback (#9991) --- docs/axes/labelling.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/axes/labelling.md b/docs/axes/labelling.md index 83c36580768..18a556bc353 100644 --- a/docs/axes/labelling.md +++ b/docs/axes/labelling.md @@ -55,6 +55,13 @@ const chart = new Chart(ctx, { }); ``` +Keep in mind that overriding `ticks.callback` means that you are responsible for all formatting of the label. Depending on your use case, you may want to call the default formatter and then modify its output. In the example above, that would look like: + +```javascript + // call the default formatter, forwarding `this` + return '$' + Chart.Ticks.formatters.numeric.apply(this, [value, index, ticks]); +``` + Related samples: * [Tick configuration sample](../samples/scale-options/ticks) From 1d42eb6bd0cf19d1eca95334310145e3b5e2fae3 Mon Sep 17 00:00:00 2001 From: Doug Brunner Date: Wed, 15 Dec 2021 17:22:46 -0800 Subject: [PATCH 2/2] Docs/Fixed inconsistent variable names (#9991) --- docs/axes/labelling.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/axes/labelling.md b/docs/axes/labelling.md index 18a556bc353..9ab75ffaba0 100644 --- a/docs/axes/labelling.md +++ b/docs/axes/labelling.md @@ -45,7 +45,7 @@ const chart = new Chart(ctx, { y: { ticks: { // Include a dollar sign in the ticks - callback: function(value, index, values) { + callback: function(value, index, ticks) { return '$' + value; } }