highcharts-for-python/highcharts-stock

CandlestickData fails to serialize the ``.open`` property to JS literal

Closed this issue · 0 comments

NOTE: Reported on StackOverflow

It would seem that following the recent (v.1.4.0) update, that CandlestickData does not serialize proper serialization to JS literal. In particular, the .open property gets set, but when serialized to a JS literal it is serialized as null for some reason:

from highcharts_stock.chart import Chart
ohlcv = [[1665504000000, 20, 21, 19, 20, 322],
         [1665590400000, 21, 23, 21, 22, 168]]
chart = Chart.from_array(ohlcv, series_type='candlestick')

print(chart.options.series[0].data)
# Output: [CandlestickData(open = 20, close = 20, high = 21, low = 19, x = 1665504000000),
# CandlestickData(open = 21, close = 22, high = 23, low = 21, x = 1665590400000)]

js_lit = chart.to_js_literal()
print(js_lit[js_lit.find("data:"):js_lit.find(']]') + 2].replace('\n', ''))
# Output: data: [[1665504000000, null, 21, 19, 20], [1665590400000, null, 23, 21, 22]]