tradingview / lightweight-charts

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

Render the zero line in a darker color and wider width #857

Closed jonluca closed 2 years ago

jonluca commented 3 years ago

Is your feature request related to a problem? Please describe.

No

Describe the solution you'd like

All x axis grid lines are the same color. It would be nice if we could have the zero line be a different color, and a different width, so it's clear when the values cross the 0 line.

Additional context

N/A

timocov commented 3 years ago

What's about something like this https://jsfiddle.net/cfn30ovL/ ?

jonluca commented 3 years ago

Yes this works great, thanks @timocov!

Do we need to clean up the pricelines individually before we call removeSeries, or will they be cleaned up automatically?

ie do we need to do

const barSeries = chart.addBarSeries({
  thinBars: true,
  downColor: '#000',
  upColor: '#000',
});

const line = barSeries.createPriceLine({ price: 0, color: 'red', axisLabelVisible: false, lineStyle: LightweightCharts.LineStyle.Solid });

...

barSeries.removePriceLine(line)
chart.removeSeries(barSeries)

or can we just call

chart.removeSeries(barSeries)

and that will clean up the price line as well

timocov commented 3 years ago

Do we need to clean up the pricelines individually before we call removeSeries, or will they be cleaned up automatically?

All lines attached (or created within) to a series will be removed when the series is removed.

and that will clean up the price line as well

Yes, it will work as expected.