Search code examples
javascriptchartslegendlineserieslightningchart

How to fix the position of LegendBox in the chart?


I am using LightningChartJS to create chart. Currently the position of legend box can be changed by dragging it. How can I fix the position of the legend box? ​


const legend = chart.addLegendBox()
.setOrigin(UIOrigins.RightTop)
.setPosition({ x: 90, y: 90 })
.setMargin({ left: 10, right: 10, top: 10, bottom: 10 })
legend.add(chart)


Solution

  • Dragging can be disabled with

    legend.setDraggingMode( UIDraggingModes.notDraggable )