I created some charts in the Highcharts Cloud Editor and want to implement it now into my Jupyter notebook.
However, the transfer does not seem to work as expected. Anything I could do to make the chart render?
Code: Select all
from highcharts import Highstock
chart = Highstock()
chart.set_dict_options({"chart":{"type":"column","inverted":True,"polar":False},"plotOptions":{"series":{"stacking":"normal","dataLabels":{"enabled":True},"animation":False}},"title":{"text":"Commitment of Traders Net Positions"},"subtitle":{"text":"Options only"},"series":[{"name":"Net Hedging","turboThreshold":0,"_colorIndex":0,"marker":{"enabled":False},"colorByPoint":False},{"name":"Net Speculation","turboThreshold":0,"_colorIndex":1}],"yAxis":{"title":{"text":"Net open interest ('000)"}},"xAxis":{},"data":{"csv":"\"Commodity\";\"Net Hedging\";\"Net Speculation\"\n\"Crude oil\";-2.66;66.58\n\"Natural gas\";-6.28;6.4\n\"Gold\";-28.33;31.48\n\"Silver\";-8.6;7.16\n\"Corn\";-18.79;-27.98\n\"Soybeans\";-5.04;6.93"},"pane":{"background":[]},"responsive":{"rules":[]},"legend":{}})
chart
Code: Select all
from highcharts import Highstock
chart = Highstock()
chart.set_dict_options({
"chart": {
"type": "column",
"inverted": True,
"polar": False
},
"plotOptions": {
"series": {
"stacking": "normal",
"dataLabels": {
"enabled": True
},
"animation": False
}
},
"title": {
"text": "Commitment of Traders Net Positions"
},
"subtitle": {
"text": "Options only"
},
"series": [
{
"name": "Net Hedging",
"turboThreshold": 0,
"_colorIndex": 0,
"marker": {
"enabled": False
},
"colorByPoint": False
},
{
"name": "Net Speculation",
"turboThreshold": 0,
"_colorIndex": 1
}
],
"yAxis": {
"title": {
"text": "Net open interest ('000)"
}
},
"xAxis": {},
"data": {
"csv": "\"Commodity\";\"Net Hedging\";\"Net Speculation\"\n\"Crude oil\";-2.66;66.58\n\"Natural gas\";-6.28;6.4\n\"Gold\";-28.33;31.48\n\"Silver\";-8.6;7.16\n\"Corn\";-18.79;-27.98\n\"Soybeans\";-5.04;6.93"
},
"pane": {
"background": []
},
"responsive": {
"rules": []
},
"legend": {}
})
chart
The error is:
Even if I get rid of legend:{} etc, it complains about the csv line which includes the data, with the same error.---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-2-ef65b41151e9> in <module>()
54 "rules": []
55 },
---> 56 "legend": {}
57 })
58 chart
~/jupyter/ve/lib/python3.6/site-packages/highcharts/highstock/highstock.py in set_dict_options(self, options)
286 if isinstance(options, dict):
287 for key, option_data in options.items():
--> 288 self.set_options(key, option_data)
289 else:
290 raise OptionTypeError("Not An Accepted Input Format: %s. Must be Dictionary" %type(options))
~/jupyter/ve/lib/python3.6/site-packages/highcharts/highstock/highstock.py in set_options(self, option_type, option_dict, force_options)
277 self.setOptions[option_type].update_dict(**option_dict)
278 else:
--> 279 self.options[option_type].update_dict(**option_dict)
280
281
TypeError: update_dict() argument after ** must be a mapping, not list
Thanks in advance!