0
votes

I'm trying to do a tooltip similar to this:

https://codepen.io/team/amcharts/pen/dyyaxLr

But when a series is disabled via the legend (i.e. "cars"), I also want to remove the value in the tooltip.

I guess there should be a way to format the series.tooltipText with an adapter like this:

series.adapter.add("tooltipText", function (text, target) {
   // generate text dynamically
   // ...
          
   return text;
});

But I can't figure out how to get only the data for the visible series and format the string accordingly.

Is something like this possible?

1

1 Answers

0
votes

I found the following solution:

series.adapter.add("tooltipText", function (ev) {
     var text = "[bold]{dateX}[/]\n";
     x.series.each(function (item) {
       if (!item.isHidden)
         text +=
           "[" +
           item.stroke.hex +
           "]●[/] " +
           item.name +
           ": {" +
           item.dataFields.valueY +
           "}\n";
     });
    return text;
});