Expected Behavior
When I set chart.precision(5) I expect a 5 digits number be shown in the line legend
Current Behaviour
Even when I set the precision I always see a 2 digits number instead.
I've made a temporal fix by changing:
this.legendItemFormat(s.value,t.precision)
by
this.legendItemFormat(s.value,this.handler.precision)
But I'm not sure if this is the "right" fix and this fix also depends on this PR to me merged #500
Reproducible Example
import pandas as pd
from lightweight_charts import Chart
def calculate_sma(df, period: int = 50):
return pd.DataFrame({
'time': df['date'],
f'SMA {period}': df['close'].rolling(window=period).mean()
}).dropna()
if __name__ == '__main__':
chart = Chart()
line = chart.create_line(name='SMA 50')
df = pd.read_csv('ohlcv.csv')
sma_df = calculate_sma(df, period=50)
chart.precision(5)
chart.legend(visible=True)
chart.set(df)
line.set(sma_df)
chart.show(block=True)
Environment
- OS: Windows and Mac
- Library: 2.1
Expected Behavior
When I set
chart.precision(5)I expect a 5 digits number be shown in the line legendCurrent Behaviour
Even when I set the precision I always see a 2 digits number instead.
I've made a temporal fix by changing:
this.legendItemFormat(s.value,t.precision)by
this.legendItemFormat(s.value,this.handler.precision)But I'm not sure if this is the "right" fix and this fix also depends on this PR to me merged #500
Reproducible Example
Environment