How can I use the script to manipulate the legends in the apexcharts in ignition perspective

Scripts to remove the legends that are not present in the graphs right now:

var elements = document.querySelectorAll('.apexcharts-legend-series');
elements.forEach(function(element) {
    var seriesName = element.getAttribute('seriesname');
    if (!seriesName) {
        element.remove();
    }
});

After applying script from console:

I don’t know of a way to filter legend entries with ApexCharts.

However, my Chart.js component does have this ability through its options.plugins.legend.labels.filter scriptable property.

1 Like

juding from your js, this can probably be done with css.

which chart is this, could you share the view (with bindings disabled)

I'm using rangeBar in ApexChart

This is from a seprate module than?

You'll have to send me a copy of the html of the chart

but my first guess is something like this, judging from the js

.apexcharts-legend-series[seriesname=""]{
    display:none;
}

you can add this in the advanded stylesheet

2 Likes

Thanks, it's working!

1 Like