tradingview / lightweight-charts

Performant financial charts built with HTML5 canvas
https://www.tradingview.com/lightweight-charts/
Apache License 2.0
9.1k stars 1.57k forks source link

Months / days disappear on timescale sometimes #1654

Open 0x33dm opened 1 month ago

0x33dm commented 1 month ago

Sometimes the time days / months on the time scale will disappear after being rendered.

I'm not sure why tough, the candles are always in there, but time time sometimes disappear.

other than candles i have lines and a baseLineSeries, the baseLine series and price lines are removed / added sometimes could that be the reason?

image

this is how it renders generally:

image

0x33dm commented 1 month ago

Apparently, it has to do with setting data on my baseline series and only specifying 2-time data points ( which is all you need to draw a rectangle on the chart ).

I wouldn't expect to remove labels from my Time Axis in any instance since the candles are never removed from the Time Axis, and they have all the time data points should always be there the same way the Price Axis is always there as well.

Also, I have the impression this wasn't happening before, as I have been using this code for some time, I'm not sure if it has to do with new updates on the library or if I just got lucky before.


Here is how i created it:

baselineSeriesRef.current = chart.addBaselineSeries({
  lastValueVisible: false,
  baseValue: { type: 'price', price: conversionLines[1] },
  topLineColor: healthColors.lineColor,
  topFillColor1: healthColors.bottomFillColor1,
  topFillColor2: healthColors.bottomFillColor2,
  bottomLineColor: 'rgba(0, 0, 0, 0)',
  bottomFillColor1: 'rgba(0, 0, 0, 0)',
  bottomFillColor2: 'rgba(0, 0, 0, 0)'
} as BaselineSeriesPartialOptions)

And here is how i update it:


// remove old data, doesn't seem to create issues
baselineSeriesRef.current?.setData([])

const areaData = [
  {
    time: candles[0].time,
    value: conversionLines[0]
  },
  {
    time: candles[candles.length - 1].time,
    value: conversionLines[0]
  }
]

// updates with new data
baselineSeriesRef.current.setData(areaData)