Javascript 如何删除图例并向LightningChart js添加新图例? 手动删除图例并将其添加到LightiningChart JS的方法 删除PointSeries并将其添加到LightiningChart JS的方法

Javascript 如何删除图例并向LightningChart js添加新图例? 手动删除图例并将其添加到LightiningChart JS的方法 删除PointSeries并将其添加到LightiningChart JS的方法,javascript,lightningchart,Javascript,Lightningchart,1。手动删除图例并将其添加到LightiningChart JS的方法 您可以使用dispose方法手动删除legendBox中的条目 // Add legend box to the chart const lb = chart.addLegendBox() // Add all Series in a chart to the legendBox, and cache the entries const entries = lb.add(chart) // Remove an entry f

1。手动删除图例并将其添加到LightiningChart JS的方法

您可以使用dispose方法手动删除legendBox中的条目

// Add legend box to the chart
const lb = chart.addLegendBox()
// Add all Series in a chart to the legendBox, and cache the entries
const entries = lb.add(chart)
// Remove an entry from the legendBox; this will remove the checkbox and the title of the series that was removed
entries[2].dispose()
请注意,即使组中没有剩余条目,处理条目也不会删除组标题

目前,无法将删除的条目恢复到legendBox,但您可以将该系列再次添加到legendBox。如果给定相同的标题,legendBox将自动将新条目与同一组中的其他条目分组

//参数1:要添加的系列。
//参数2:布尔值,如果在单击复选框时应释放附加到此条目的对象。
//参数3:此条目应附加到的组。如果为空,条目将附加到“未定义组”。
lb.add(系列,true,“组名”)
2。删除PointSeries并将其添加到LightiningChart JS的方法

如果要在图表中删除和添加相同的PointSeries,可以分别调用dispose()和restore()方法

//向图表中添加一个新的点系列,其中点的形状为三角形。
常量pointSeries=chartXY.addPointSeries({pointShape:pointShape.Triangle})
//从图表中删除点系列。
pointSeries.dispose()
//将点序列添加回图表。
pointSeries.restore()

只要您还有对该系列的引用,就可以将已处理的系列还原到图表中。

非常感谢您提供的详细信息Info@LearnerChartXY将系列存储在下面的集合中。连续访问特定系列的最佳方式是在创建时存储它。