[IMP] web_widget_mpld3_chart: pre-commit execution

pull/3140/head
Franco Leyes 2024-11-23 17:28:10 -03:00 committed by ThiagoMForgeFlow
parent 80c5fe2c27
commit e75cfb6cf6
14 changed files with 139 additions and 119 deletions

View File

@ -17,22 +17,23 @@ Web Widget mpld3 Chart
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github
:target: https://github.com/OCA/web/tree/16.0/web_widget_mpld3_chart
:target: https://github.com/OCA/web/tree/17.0/web_widget_mpld3_chart
:alt: OCA/web
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/web-16-0/web-16-0-web_widget_mpld3_chart
:target: https://translation.odoo-community.org/projects/web-17-0/web-17-0-web_widget_mpld3_chart
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=16.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=17.0
:alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5|
This module adds the possibility to insert mpld3 charts into Odoo standard views.
This is an interactive D3js-based viewer which brings matplotlib graphics to the browser.
This module adds the possibility to insert mpld3 charts into Odoo
standard views. This is an interactive D3js-based viewer which brings
matplotlib graphics to the browser.
If you want to see some samples of mpld3's capabilities follow this `link
<http://mpld3.github.io/>`_.
If you want to see some samples of mpld3's capabilities follow this
`link <http://mpld3.github.io/>`__.
**Table of contents**
@ -42,46 +43,58 @@ If you want to see some samples of mpld3's capabilities follow this `link
Installation
============
You need to install the python mpld3 library::
You need to install the python mpld3 library:
pip install mpld3
::
pip install mpld3
Usage
=====
To insert a mpld3 chart in a view proceed as follows:
#. You should inherit from abstract class abstract.mpld3.parser::
1. You should inherit from abstract class abstract.mpld3.parser:
_name = 'res.partner'
_inherit = ['res.partner', 'abstract.mpld3.parser']
::
#. Import the required libraries::
_name = 'res.partner'
_inherit = ['res.partner', 'abstract.mpld3.parser']
import matplotlib.pyplot as plt
2. Import the required libraries:
#. Declare a json computed field like this::
::
mpld3_chart = fields.Json(
string='Mpld3 Chart',
compute='_compute_mpld3_chart',
)
import matplotlib.pyplot as plt
#. In its computed method do::
3. Declare a json computed field like this:
def _compute_mpld3_chart(self):
for rec in self:
# Design your mpld3 figure:
plt.scatter([1, 10], [5, 9])
figure = plt.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::
mpld3_chart = fields.Json(
string='Mpld3 Chart',
compute='_compute_mpld3_chart',
)
<div>
<field name="mpld3_chart" widget="mpld3_chart" nolabel="1"/>
</div>
4. In its computed method do:
::
def _compute_mpld3_chart(self):
for rec in self:
# Design your mpld3 figure:
plt.scatter([1, 10], [5, 9])
figure = plt.figure()
rec.mpld3_chart = self.convert_figure_to_json(figure)
5. In the view, add something like this wherever you want to display
your mpld3 chart:
::
<div>
<field name="mpld3_chart" widget="mpld3_chart" nolabel="1"/>
</div>
Bug Tracker
===========
@ -89,7 +102,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_widget_mpld3_chart%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_widget_mpld3_chart%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
@ -97,30 +110,30 @@ Credits
=======
Authors
~~~~~~~
-------
* ForgeFlow
Contributors
~~~~~~~~~~~~
------------
* Jordi Ballester Alomar <jordi.ballester@forgeflow.com>
* Christopher Ormaza <chris.ormaza@forgeflow.com>
- Jordi Ballester Alomar <jordi.ballester@forgeflow.com>
- Christopher Ormaza <chris.ormaza@forgeflow.com>
Other credits
~~~~~~~~~~~~~
-------------
* 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)
- 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)
Maintainers
~~~~~~~~~~~
-----------
This module is maintained by the OCA.
@ -143,6 +156,6 @@ Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:
|maintainer-JordiBForgeFlow| |maintainer-ChrisOForgeFlow|
This module is part of the `OCA/web <https://github.com/OCA/web/tree/16.0/web_widget_mpld3_chart>`_ project on GitHub.
This module is part of the `OCA/web <https://github.com/OCA/web/tree/17.0/web_widget_mpld3_chart>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -11,12 +11,11 @@ _logger = logging.getLogger(__name__)
try:
import mpld3
from bs4 import BeautifulSoup
except (ImportError, IOError) as err:
except (OSError, ImportError) as err:
_logger.debug(err)
class AbstractMpld3Parser(models.AbstractModel):
_name = "abstract.mpld3.parser"
_description = "Utility to parse ploot figure to json data for widget Mpld3"

View File

@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"

View File

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

View File

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

View File

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

@ -0,0 +1,6 @@
This module adds the possibility to insert mpld3 charts into Odoo
standard views. This is an interactive D3js-based viewer which brings
matplotlib graphics to the browser.
If you want to see some samples of mpld3's capabilities follow this
[link](http://mpld3.github.io/).

View File

@ -1,5 +0,0 @@
This module adds the possibility to insert mpld3 charts into Odoo standard views.
This is an interactive D3js-based viewer which brings matplotlib graphics to the browser.
If you want to see some samples of mpld3's capabilities follow this `link
<http://mpld3.github.io/>`_.

View File

@ -0,0 +1,3 @@
You need to install the python mpld3 library:
pip install mpld3

View File

@ -1,3 +0,0 @@
You need to install the python mpld3 library::
pip install mpld3

View File

@ -0,0 +1,33 @@
To insert a mpld3 chart in a view proceed as follows:
1. You should inherit from abstract class abstract.mpld3.parser:
_name = 'res.partner'
_inherit = ['res.partner', 'abstract.mpld3.parser']
2. Import the required libraries:
import matplotlib.pyplot as plt
3. Declare a json computed field like this:
mpld3_chart = fields.Json(
string='Mpld3 Chart',
compute='_compute_mpld3_chart',
)
4. In its computed method do:
def _compute_mpld3_chart(self):
for rec in self:
# Design your mpld3 figure:
plt.scatter([1, 10], [5, 9])
figure = plt.figure()
rec.mpld3_chart = self.convert_figure_to_json(figure)
5. In the view, add something like this wherever you want to display
your mpld3 chart:
<div>
<field name="mpld3_chart" widget="mpld3_chart" nolabel="1"/>
</div>

View File

@ -1,33 +0,0 @@
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
#. Declare a json computed field like this::
mpld3_chart = fields.Json(
string='Mpld3 Chart',
compute='_compute_mpld3_chart',
)
#. In its computed method do::
def _compute_mpld3_chart(self):
for rec in self:
# Design your mpld3 figure:
plt.scatter([1, 10], [5, 9])
figure = plt.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::
<div>
<field name="mpld3_chart" widget="mpld3_chart" nolabel="1"/>
</div>

View File

@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
@ -9,10 +8,11 @@
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
@ -275,7 +275,7 @@ pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ;
margin-right: 2em }
pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@ -301,7 +301,7 @@ span.option {
span.pre {
white-space: pre }
span.problematic {
span.problematic, pre.problematic {
color: red }
span.section-subtitle {
@ -369,10 +369,12 @@ ul.auto-toc {
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:a74d15907ff4678410ffd1913b2f75b5c7d818852dc75f13bba0311a6ffeda6e
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/web/tree/16.0/web_widget_mpld3_chart"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/web-16-0/web-16-0-web_widget_mpld3_chart"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/web&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module adds the possibility to insert mpld3 charts into Odoo standard views.
This is an interactive D3js-based viewer which brings matplotlib graphics to the browser.</p>
<p>If you want to see some samples of mpld3s capabilities follow this <a class="reference external" href="http://mpld3.github.io/">link</a>.</p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/web/tree/17.0/web_widget_mpld3_chart"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/web-17-0/web-17-0-web_widget_mpld3_chart"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/web&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module adds the possibility to insert mpld3 charts into Odoo
standard views. This is an interactive D3js-based viewer which brings
matplotlib graphics to the browser.</p>
<p>If you want to see some samples of mpld3s capabilities follow this
<a class="reference external" href="http://mpld3.github.io/">link</a>.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
@ -428,8 +430,8 @@ def _compute_mpld3_chart(self):
rec.mpld3_chart = self.convert_figure_to_json(figure)
</pre>
</li>
<li><p class="first">In the view, add something like this wherever you want to display your
mpld3 chart:</p>
<li><p class="first">In the view, add something like this wherever you want to display
your mpld3 chart:</p>
<pre class="literal-block">
&lt;div&gt;
&lt;field name=&quot;mpld3_chart&quot; widget=&quot;mpld3_chart&quot; nolabel=&quot;1&quot;/&gt;
@ -443,7 +445,7 @@ mpld3 chart:</p>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_widget_mpld3_chart%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_widget_mpld3_chart%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
@ -464,25 +466,28 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<div class="section" id="other-credits">
<h2><a class="toc-backref" href="#toc-entry-7">Other credits</a></h2>
<ul class="simple">
<li>This module uses the library <a class="reference external" href="https://github.com/mpld3/mpld3">mpld3</a>
which is under the open-source BSD 3-clause “New” or “Revised” License.
Copyright (c) 2013, Jake Vanderplas</li>
<li>This module uses the library <a class="reference external" href="https://pypi.org/project/beautifulsoup4/">BeautifulSoup 4</a>
which is under the open-source MIT License.
Copyright (c) 2014, Leonard Richardson</li>
<li>This module uses the library
<a class="reference external" href="https://github.com/mpld3/mpld3">mpld3</a> which is under the
open-source BSD 3-clause “New” or “Revised” License. Copyright (c)
2013, Jake Vanderplas</li>
<li>This module uses the library <a class="reference external" href="https://pypi.org/project/beautifulsoup4/">BeautifulSoup
4</a> which is under the
open-source MIT License. Copyright (c) 2014, Leonard Richardson</li>
<li>Odoo Community Association (OCA)</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainers</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/JordiBForgeFlow"><img alt="JordiBForgeFlow" src="https://github.com/JordiBForgeFlow.png?size=40px" /></a> <a class="reference external image-reference" href="https://github.com/ChrisOForgeFlow"><img alt="ChrisOForgeFlow" src="https://github.com/ChrisOForgeFlow.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/16.0/web_widget_mpld3_chart">OCA/web</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/17.0/web_widget_mpld3_chart">OCA/web</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>