diff --git a/lightweight_charts/abstract.py b/lightweight_charts/abstract.py
index 2e31555..76a1199 100644
--- a/lightweight_charts/abstract.py
+++ b/lightweight_charts/abstract.py
@@ -150,7 +150,7 @@ class SeriesCommon:
"""
Clears the markers displayed on the data.\n
"""
- self.run_script(f'''{self.id}.markers = []; {self.id}.series.setMarkers([]])''')
+ self.run_script(f'''{self.id}.markers = []; {self.id}.series.setMarkers([])''')
def clear_horizontal_lines(self):
"""
@@ -666,8 +666,8 @@ class LWC(SeriesCommon):
return
lines_code = ''
for i, line in enumerate(self._lines):
- lines_code += f'''finalString += `
▨{f' {line.name}'} :
- ${{legendItemFormat(param.seriesData.get({line.id}.series).value)}}`;'''
+ lines_code += f'''finalString += `▨{f' {line.name}'} :
+ ${{legendItemFormat(param.seriesData.get({line.id}.series).value)}}
`;'''
self.run_script(f'''
{f"{self.id}.legend.style.color = '{color}'" if color else ''}
@@ -677,16 +677,19 @@ class LWC(SeriesCommon):
{self.id}.chart.subscribeCrosshairMove((param) => {{
if (param.time){{
let data = param.seriesData.get({self.id}.series);
- if (!data) {{return}}
- let ohlc = `O ${{legendItemFormat(data.open)}}
- | H ${{legendItemFormat(data.high)}}
- | L ${{legendItemFormat(data.low)}}
- | C ${{legendItemFormat(data.close)}} `
- let percentMove = ((data.close-data.open)/data.open)*100
- let percent = `| ${{percentMove >= 0 ? '+' : ''}}${{percentMove.toFixed(2)}} %`
let finalString = ''
- {'finalString += ohlc' if ohlc else ''}
- {'finalString += percent' if percent else ''}
+ if (data) {{
+ let ohlc = `O ${{legendItemFormat(data.open)}}
+ | H ${{legendItemFormat(data.high)}}
+ | L ${{legendItemFormat(data.low)}}
+ | C ${{legendItemFormat(data.close)}} `
+ let percentMove = ((data.close-data.open)/data.open)*100
+ let percent = `| ${{percentMove >= 0 ? '+' : ''}}${{percentMove.toFixed(2)}} %`
+
+ {'finalString += ohlc' if ohlc else ''}
+ {'finalString += percent' if percent else ''}
+ {'finalString += "
"' if ohlc or percent else ''}
+ }}
{lines_code if lines else ''}
{self.id}.legend.innerHTML = finalString+''
}}