最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin0浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论