Skip to content

Commit b35844f

Browse files
committed
Improvement - VueUiStackbar - Enable usage of dataLabels.hideUnderPercentage in value mode
1 parent 64c16ce commit b35844f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/components/vue-ui-stackbar.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,13 +870,23 @@ function selectTimeLabel(label, relativeIndex) {
870870
});
871871
}
872872
873+
const maxCurrentValue = computed(() => {
874+
return Math.max(...formattedDataset.value.flatMap(ds => ds.series))
875+
})
876+
873877
function isLabelDisplayed(value, proportion) {
874878
if (FINAL_CONFIG.value.style.chart.bars.showDistributedPercentage && FINAL_CONFIG.value.style.chart.bars.distributed) {
875879
if (!canHideSmallPercentages.value) {
876880
return FINAL_CONFIG.value.style.chart.bars.dataLabels.hideEmptyPercentages ? proportion > 0 : true;
877881
}
878882
return proportion * 100 >= FINAL_CONFIG.value.style.chart.bars.dataLabels.hideUnderPercentage;
879883
} else {
884+
if (canHideSmallPercentages.value) {
885+
if (canHideSmallValues.value) {
886+
console.warn('Vue Data UI - VueUiStackbar - You cannot set both dataLabels.hideUnderPercentage and dataLabels.hideUnderValue. Note that dataLabels.hideUnderPercentage takes precedence in this case.')
887+
}
888+
return value > maxCurrentValue.value * FINAL_CONFIG.value.style.chart.bars.dataLabels.hideUnderPercentage / 100;
889+
}
880890
if (!canHideSmallValues.value) {
881891
return FINAL_CONFIG.value.style.chart.bars.dataLabels.hideEmptyValues ? value !== 0 : true
882892
}

0 commit comments

Comments
 (0)