amcharts5 icon indicating copy to clipboard operation
amcharts5 copied to clipboard

in Calculate total process how can we hide the zero value.

Open shanqq opened this issue 1 year ago • 5 comments

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

shanqq avatar Jul 21 '22 05:07 shanqq

You must monitor visibility of all series and hide the total series if all are hidden: https://codepen.io/team/amcharts/pen/LYdbBgE

zeroin avatar Jul 21 '22 07:07 zeroin

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

shanqq avatar Jul 21 '22 08:07 shanqq

I am sorry, I do not understand, could you clarify?

zeroin avatar Jul 21 '22 11:07 zeroin

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.

shanqq avatar Jul 21 '22 11:07 shanqq

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

martynasma avatar Jul 21 '22 12:07 martynasma

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.

github-actions[bot] avatar Aug 21 '22 00:08 github-actions[bot]