You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
798 B

  1. To insert a Bokeh chart in a view proceed as follows:
  2. #. Declare a text computed field like this::
  3. bokeh_chart = fields.Text(
  4. string='Bokeh Chart',
  5. compute='_compute_bokeh_chart',
  6. )
  7. #. In its computed method do::
  8. def _compute_bokeh_chart(self):
  9. for rec in self:
  10. # Design your bokeh figure:
  11. p = figure() # import that as `from bokeh.plotting import figure`
  12. line = p.line([0, 2], [1, 8], line_width=5)
  13. # (...)
  14. # `p.html.data` contains both markup and the script of a chart.
  15. rec.bokeh_chart = p.html.data
  16. #. In the view, add something like this wherever you want to display your
  17. bokeh chart::
  18. <div>
  19. <field name="bokeh_chart" widget="bokeh_chart" nolabel="1"/>
  20. </div>