11<script setup>
22import { ref , computed , onMounted } from " vue" ;
33import { useConfig } from " ../useConfig" ;
4- import { convertCustomPalette , createUid , palette , themePalettes , sumSeries , convertColorToHex , XMLNS , calculateNiceScale , dataLabel , adaptColorToBackground , isFunction , opacity , lightenHexColor , functionReturnsString , objectIsEmpty , getMissingDatasetAttributes , error , createCsvContent , downloadCsv } from " ../lib" ;
4+ import {
5+ adaptColorToBackground ,
6+ applyDataLabel ,
7+ calculateNiceScale ,
8+ convertColorToHex ,
9+ convertCustomPalette ,
10+ createCsvContent ,
11+ createUid ,
12+ dataLabel ,
13+ downloadCsv ,
14+ error ,
15+ functionReturnsString ,
16+ getMissingDatasetAttributes ,
17+ isFunction ,
18+ lightenHexColor ,
19+ objectIsEmpty ,
20+ opacity ,
21+ palette ,
22+ sumSeries ,
23+ themePalettes ,
24+ XMLNS ,
25+ } from " ../lib" ;
526import { useNestedProp } from " ../useNestedProp" ;
627import { throttle } from " ../canvas-lib" ;
728import { useResponsive } from " ../useResponsive" ;
@@ -290,21 +311,31 @@ const totalLabels = computed(() => {
290311});
291312
292313
293- function barDataLabel (val ) {
294- return dataLabel ({
295- p: FINAL_CONFIG .value .style .chart .bars .dataLabels .prefix ,
296- v: val,
297- s: FINAL_CONFIG .value .style .chart .bars .dataLabels .suffix ,
298- r: FINAL_CONFIG .value .style .chart .bars .dataLabels .rounding ,
299- });
314+ function barDataLabel (val , datapoint , index , dpIndex ) {
315+ return applyDataLabel (
316+ FINAL_CONFIG .value .style .chart .bars .dataLabels .formatter ,
317+ val,
318+ dataLabel ({
319+ p: FINAL_CONFIG .value .style .chart .bars .dataLabels .prefix ,
320+ v: val,
321+ s: FINAL_CONFIG .value .style .chart .bars .dataLabels .suffix ,
322+ r: FINAL_CONFIG .value .style .chart .bars .dataLabels .rounding ,
323+ }),
324+ { datapoint, seriesIndex: index, datapointIndex: dpIndex }
325+ )
300326}
301327
302- function barDataLabelPercentage (val ) {
303- return dataLabel ({
304- v: val,
305- s: ' %' ,
306- r: FINAL_CONFIG .value .style .chart .bars .dataLabels .rounding ,
307- });
328+ function barDataLabelPercentage (val , datapoint , index , dpIndex ) {
329+ return applyDataLabel (
330+ FINAL_CONFIG .value .style .chart .bars .dataLabels .formatter ,
331+ val,
332+ dataLabel ({
333+ v: val,
334+ s: ' %' ,
335+ r: FINAL_CONFIG .value .style .chart .bars .dataLabels .rounding ,
336+ }),
337+ { datapoint, seriesIndex: index, datapointIndex: dpIndex }
338+ )
308339}
309340
310341function selectDatapoint (index ) {
@@ -726,7 +757,7 @@ defineExpose({
726757 : font- weight= " FINAL_CONFIG.style.chart.bars.dataLabels.bold ? 'bold' : 'normal'"
727758 text- anchor= " middle"
728759 >
729- {{ FINAL_CONFIG .style .chart .bars .showDistributedPercentage && FINAL_CONFIG .style .chart .bars .distributed ? barDataLabelPercentage (dp .proportions [j] * 100 ) : barDataLabel (dp .series [j]) }}
760+ {{ FINAL_CONFIG .style .chart .bars .showDistributedPercentage && FINAL_CONFIG .style .chart .bars .distributed ? barDataLabelPercentage (dp .proportions [j] * 100 , dp, i, j ) : barDataLabel (dp .series [j], dp, i, j ) }}
730761 < / text>
731762 < / g>
732763
@@ -741,7 +772,7 @@ defineExpose({
741772 : font- weight= " FINAL_CONFIG.style.chart.bars.totalValues.bold ? 'bold' : 'normal'"
742773 : fill= " FINAL_CONFIG.style.chart.bars.totalValues.color"
743774 >
744- {{ barDataLabel (total .value ) }}
775+ {{ barDataLabel (total .value , total, i ) }}
745776 < / text>
746777 < / g>
747778 < / template>
0 commit comments