removechild - dimple js : How to hide the last legend item? - Stack Overflow

admin2025-04-16  2

I have a graph with yearly series like "2023, 2024, 2025, 2025 forecast".

In the legend, I would like to hide the last item (i.e. 2025 forecast), but the serie to remain printed. How can I remove it from the legend, either when the legend is being built, or afterwards?


Things tried so far:

A) Setting the series explicitely when creating the legend didn't worked for me.

myChart.addLegend(300, 40, 600, 20, "left", [2023, 2024, 2025]);

B) Attempting to access last element of existing legend to remove it, I could not find how to reach the last item (serie or shape?) to detach it from the legend or alter its CSS style.

myChart.addLegend(300, 40, 600, 20);

myLegend = myChart.legends[0];
console.log(myLegend.series);
// Then, what to do?

// Tried and not working
//myShapes = myLegend.shapes[0];
//console.log(myShapes);

I found this thread, but I am lost with the complexity of the answer, and I am even not sure that it is relevant for what I want to achieve.

转载请注明原文地址:http://anycun.com/QandA/1744788211a87632.html