[12.0][NEW] web_widget_plotly_chart

This commit is contained in:
Roberto Fichera
2019-09-10 11:40:22 +02:00
parent bc466c1365
commit ea54bc6209
13 changed files with 712 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
* Roberto Fichera <roberto.fichera@levelprime.com>
* Michele Zaccheddu <michele.zaccheddu@levelprime.com>

View File

@@ -0,0 +1,4 @@
* This module uses the library `Plotly.js <https://github.com/plotly/plotly.js>`__
which is under the open-source MIT License.
Copyright (c) 2019 Plotly, Inc
* Odoo Community Association (OCA)

View File

@@ -0,0 +1,14 @@
This module add the possibility to insert Plotly charts into Odoo standard views.
.. image:: /web_widget_plotly_chart/static/description/example.png
:alt: Plotly Chart inserted into an Odoo view
:width: 600 px
`Plotly <https://plot.ly/>`__ is a Python interactive visualization
library built on top of d3.js and stack.gl, plotly.js is a high-level,
declarative charting library. plotly.js ships with over 40 chart types,
including scientific charts, 3D graphs, statistical charts, SVG maps, financial
charts, and more.
If you want to see some samples of plotly's capabilities follow this `link
<https://github.com/plotly/plotly.py#overview>`_.

View File

@@ -0,0 +1,3 @@
You need to install the python plotly library::
pip3 install plotly==4.1.0

View 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>