I'm able to use lightweight-charts to display price and volume just fine. When the data is for multiple days, I want the chart to also show session break vertical lines (like it does in TradingView app). I looked through the Chart Options and API documentation and cannot find how to draw session breaks. Please advice.
Asked
Active
Viewed 357 times
2 Answers
4
Well, while exactly speaking you can not draw a vertical line, but you can substitute that with a histogram series having a data item on each session start. That series should be configured to have 100% height and should be semi-transparent so the candle behind that is not hidden.
The code should look similar to this:
verticalSeries = chart.addHistogramSeries({
priceScaleId: 'vertical',
color: 'rgba(128, 128, 255, 0.25)',
scaleMargins: { top: 0, bottom: 0 }
})
verticalSeries.setData(opens.map(open => ({ time: open, value: 1 })))

Dmitry Sokurenko
- 6,042
- 4
- 32
- 53
-
1Thank you! This worked quite well. I had tried adding a second histogram earlier but was using priceFormat as 'volume' so it caused all volume bars to rise up too. This method of using 'priceScaleId' worked quite well. – Curious101 Jan 04 '23 at 04:57
2
As of version 3.8 it is not possible to draw vertical lines on the chart. There are a few feature requests for this on the issues page for the library so it is possible that this may be added as a new feature in an upcoming release.

SlicedSilver
- 381
- 1
- 4