amcharts5
amcharts5 copied to clipboard
in Calculate total process how can we hide the zero value.
In this updated pen. https://codepen.io/team/amcharts/pen/dyJdQjW how can we hide the zero label. because if i want to show the label for each series also there are series that content 0 value. Do please check this out. Related to amcharts5
You must monitor visibility of all series and hide the total series if all are hidden: https://codepen.io/team/amcharts/pen/LYdbBgE
but when i try to toggle all the series and one of the europe field is zero. then it zero label is being shown ?? https://codepen.io/team/amcharts/pen/LYdbBgE
I am sorry, I do not understand, could you clarify?
var data = [{ year: "2021", europe: 0, namerica: 2.5, asia: 1.2, fake: 0 }, { year: "2022", europe: 2.6, namerica: 2.7, asia: 2, fake: 0 }, { year: "2023", europe: 2.8, namerica: 2.9, asia: 1.9, fake: 0 }] like in this data if i toggle off all the legend but only europe one is goinf to be on. then 0 label is getting shown in the first series.
You can use an adapter for bullet:
series.bullets.push(function() {
var label = am5.Label.new(root, {
text: "{valueYTotal}",
fill: am5.color(0x000000),
centerY: am5.p100,
centerX: am5.p50,
populateText: true
});
label.adapters.add("text", function(text, target) {
if (target.dataItem && target.dataItem.get("valueYTotal") == 0) {
return "";
}
return text;
})
return am5.Bullet.new(root, {
locationY: 1,
sprite: label
});
});
https://codepen.io/team/amcharts/pen/LYdbBgE
This issue is stale because it has been open 30 days with no activity. It will be closed in 5 days unless a new comment is added.