mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[12.0][NEW] web_widget_plotly_chart
This commit is contained in:
24
web_widget_plotly_chart/readme/USAGE.rst
Normal file
24
web_widget_plotly_chart/readme/USAGE.rst
Normal file
@@ -0,0 +1,24 @@
|
||||
To insert a Plotly chart in a view proceed as follows:
|
||||
|
||||
#. Declare a text computed field like this::
|
||||
|
||||
plotly_chart = fields.Text(
|
||||
string='Plotly Chart',
|
||||
compute='_compute_plotly_chart',
|
||||
)
|
||||
|
||||
#. In its computed method do::
|
||||
|
||||
def _compute_plotly_chart(self):
|
||||
for rec in self:
|
||||
data = [{'x': [1, 2, 3], 'y': [2, 3, 4]}]
|
||||
rec.plotly_chart = plotly.offline.plot(data,
|
||||
include_plotlyjs=False,
|
||||
output_type='div')
|
||||
|
||||
#. In the view, add something like this wherever you want to display your
|
||||
plotly chart::
|
||||
|
||||
<div>
|
||||
<field name="plotly_chart" widget="plotly_chart" nolabel="1"/>
|
||||
</div>
|
||||
Reference in New Issue
Block a user