def chart(self, options=None, *,
highchart=None, javascript='', javascript_after='', **kwargs):
""" Populate the webview with a new Highcharts JS chart.
Parameters
----------
options, highchart, javascript, **kwargs:
The parameters are the same as for the object constructor.
javascript_after: str
Same as `javascript`, except that the code is evaluated
after the chart, available as ``window.chart``, is created.
Notes
-----
Passing ``{ series: [{ data: some_data }] }``, if ``some_data`` is
a numpy array, it is **more efficient** to leave it as numpy array
instead of converting it ``some_data.tolist()``, which is done
implicitly.
"""
options = (options or {}).copy()
if not isinstance(options, MutableMapping):
raise ValueError('options must be dict')
if kwargs:
_merge_dicts(options, _kwargs_options(kwargs))
self.exposeObject('pydata', options)
highchart = highchart or self.highchart or 'Chart'
self.evalJS('''
{javascript};
window.chart = new Highcharts.{highchart}(pydata); 0;
{javascript_after};
'''.format(javascript=javascript,
javascript_after=javascript_after,
highchart=highchart,))
评论列表
文章目录