(c3.js) 如何捕获列状态,无论它是否显示在图表中?

(c3.js) how to capture a column state, wheter it's shown or not in the graph?

我希望 shown 是一些 boolean 类型 return,所以我可以这样写:

if(!(chart.data('data1').shown)){ //if it's not (!) showing
    d3.select("elementID").text(""); //hide the matching text (see picture)
}

image link (the graph i'm working on)

它不起作用,但控制台没有显示任何错误,这有点奇怪。

在 c3.js 文件上添加个人更改是唯一的解决方案吗?

谢谢:)

如你所愿,只需将.shown用作函数即可:

if(!(chart.data.shown('data1'))){
    d3.select("elementID").text("");
}

有关详细信息,请参阅 docs