From 8ff98e77b7cbbaf6ca53677e2807bf88f48f581a Mon Sep 17 00:00:00 2001 From: stockiNail Date: Sat, 2 Feb 2019 19:31:39 +0100 Subject: [PATCH] Add datasetIndex and chart instances to render and fontColor function object To implement a customization on rendering and coloring you could need of information based on other elements of chart (not only dataset item). Furthermore 'index' represent the value inside the dataset but not the dataset index. Therefore I suggest to add 'datasetIndex' and 'chart' into the object to pass as argument to callbacks. --- src/chartjs-plugin-labels.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/chartjs-plugin-labels.js b/src/chartjs-plugin-labels.js index 7a646d7..bcf08dd 100644 --- a/src/chartjs-plugin-labels.js +++ b/src/chartjs-plugin-labels.js @@ -197,7 +197,9 @@ value: dataset.data[index], percentage: this.getPercentage(dataset, element, index), dataset: dataset, - index: index + index: index, + datasetIndex: element._datasetIndex, + chart: this.chart }); } else { switch (this.options.render) { @@ -233,7 +235,9 @@ percentage: this.getPercentage(dataset, element, index), backgroundColor: dataset.backgroundColor[index], dataset: dataset, - index: index + index: index, + datasetIndex: element._datasetIndex, + chart: this.chart }); } else if (typeof fontColor !== 'string') { fontColor = fontColor[index] || this.chart.config.options.defaultFontColor;