[15.0][MIG] web_widget_mpld3_chart

This commit is contained in:
Christopher Ormaza
2022-01-07 15:27:54 -05:00
committed by Lois Rilo
parent 04c4e4fb46
commit 0f02e29462
17 changed files with 20775 additions and 1602 deletions

View File

@@ -1 +1,2 @@
* Jordi Ballester Alomar <jordi.ballester@forgeflow.com>
* Christopher Ormaza <chris.ormaza@forgeflow.com>

View File

@@ -1,4 +1,8 @@
* This module uses the library `mpld3 <https://github.com/mpld3/mpld3>`__
which is under the open-source BSD 3-clause "New" or "Revised" License.
Copyright (c) 2013, Jake Vanderplas
* This module uses the library `BeautifulSoup 4 <https://pypi.org/project/beautifulsoup4/>`__
which is under the open-source MIT License.
Copyright (c) 2014, Leonard Richardson
* Odoo Community Association (OCA)

View File

@@ -1,8 +1,13 @@
To insert a mpld3 chart in a view proceed as follows:
#. You should inherit from abstract class abstract.mpld3.parser::
_name = 'res.partner'
_inherit = ['res.partner', 'abstract.mpld3.parser']
#. Import the required libraries::
import matplotlib.pyplot as plt, mpld3
import matplotlib.pyplot as plt
#. Declare a text computed field like this::
@@ -18,7 +23,7 @@ To insert a mpld3 chart in a view proceed as follows:
# Design your mpld3 figure:
plt.scatter([1, 10], [5, 9])
figure = plt.figure()
rec.mpld3_chart = mpld3.fig_to_html(figure)
rec.mpld3_chart = self.convert_figure_to_json(figure)
#. In the view, add something like this wherever you want to display your
mpld3 chart::