[17.0][MIG] Migrate web_widget_plotly_chart

This commit is contained in:
Roberto Fichera
2024-05-03 16:02:55 +02:00
parent 7392a9f5bc
commit 0a1432d18b
19 changed files with 185 additions and 154 deletions

View File

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

View File

@@ -1,2 +0,0 @@
* 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

@@ -1,4 +0,0 @@
* 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,13 @@
This module add the possibility to insert Plotly charts into Odoo
standard views.
![Plotly Chart inserted into an Odoo view](../static/description/example.png)
[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

@@ -1,14 +0,0 @@
This module add the possibility to insert Plotly charts into Odoo standard views.
.. image:: ../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:
pip install plotly==5.22.0

View File

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

View File

@@ -0,0 +1,28 @@
To insert a Plotly chart in a view proceed as follows:
1. Import plotly:
import plotly
2. Declare a text computed field like this:
plotly_chart = fields.Text(
string='Plotly Chart',
compute='_compute_plotly_chart',
)
3. 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')
4. 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>

View File

@@ -1,24 +0,0 @@
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>