Search 1.9 billion lines of Odoo code on GitHub

web_widget_mpld3_chart

Author: ForgeFlow, Odoo Community Association (OCA)
License: LGPL-3
Branch: 15.0
Repository: AITIC/web
Dependencies: web
Languages: HTML (399, 2.2%), JavaScript (17287, 96.8%), PO File (11, 0.1%), Python (44, 0.2%), and reStructuredText (111, 0.6%)
Other branches: 12.0, 12.0-ocabot-merge-pr-1613-by-legalsylvain-bump-patch, 13.0, 13.0_sh, and 14.0
Other repositories: 001101/web-1, 965714601/web-1, ACCOMODATA-BVBA/web, Abdulrahman3282/web, AntoniRomera/web, AyoubZahid/web, BADEP/web, BS-creator/web, Bochelly/web, CB-Gran-Canaria/web, ChanFeei/web, Change2improve/web, ClancyQiao/web, Cy-Ghost/web, Darknroses/web, Decikingship/web, Digital5-Odoo/web, Dobtor-OCA/web, ELMARDI0107/web, ERPLibre/web, Ecnart/web, ForgeFlow/web, GSLabIt/web, Gabinete-Digital/web, GlodoUK/oca-web, HirenDangar/web, Ingeos/web, Jarsa/web, JohnmarkEnriquez/web, KENLYLST/web, KKamaa/web, KonaERP/web, LevelPrime/web, Martronic-SA/web, MaxyMoos/web, MindAndGo/web, NL66278/web, NeatNerdPrime/web, Netsoro/web, NextERP-Romania/web, OCA-MUK/web, OCA/web, Paul98isep/web, SanteLibre/web, SequarSrl/web, SeuMarco/web, SimoRubi/web, SirumTME/web, StefanRijnhart/web, Studio73/web, Syci-Consulting/web, TDu/web, TRESCLOUD/web, Tecnativa/web, VanMoof/web, Vauxoo/web, WilldooIT/web, aaltinisik/web, acsone/web, adhoc-dev/web, agrista/odoo-web, ahmedgenina/web, akloptim/web, akretion/web, alan80080/web, androettop/web, anhvu-sg/web, ansinaesmejor/web, antilhue/web, arkyalpyae/web, asphaltzipper/web, aurestic/web, bizzappdev/web, blooparksystems/web, bmya/web, boskowski/web, brain-tec/web, brian10048/web, bud-e/web, camptocamp/web, conandark/web, coopiteasy/web, diggy128/web, dingguijin/web, druidoo-dev/web, dvalladares66/web, eLBati/web, ecosoft-odoo/web, ehsu0407/web, enmasys/web, essamcis/web, factorlibre/web, fallewi/web, farinoire/web, fjouatte/web, focusate/web-oca, foramaktiv/web, gab-net/web, gastonfeng/web, gfcapalbo/web, grindtildeath/web, gtorresemmanuel/web, guewen/web, hbrunn/web, i-vyshnevska/web, ibudgie/web, ideaspositivas-group/web, initOS/web, jans23/web, janverb/web, jcdrubay/web, jeroen7s/web, jguerriat/web, khanvuthy88/web, kkasing11/web, kmee/web, kos94ok-3D/web, leanhtuan1996/web, legalsylvain/web, lideritjnma/web, lincoln6delta/web, liunux4odoo/web, lubw/web, luisrodriguez-e2e/web, mashanz/web, mhadi12/web, mharenz/web, mingkongz/web, mochammadrizanaufal/web, modoolar/oca-web, mohamedhagag/web, multidadosti-erp/web, newtratip/web, nikul-serpentcs/web, niulinlnc/web, noorealam96/web, odoogap/web, onurugur/web, onyanga/web, orlandosorio/web, paraita/web, petrus-v/web, phuctranerp/web, pnajman-modoolar/web-1, popsolutions/web, praxigento/oca-web, presenceverte/web, qgzhiguo/web, raizs/web, richard-willdooit/web, ristecona/web, robertsvx27/web, rven/web, sahil-navadiya/web, samsagaz/web, sanube/web, sergiocorato/web, sgheller/web, sodexis/web, solvosci/web, steingabelgaard/web, stuti135/web, sudhir-erpharbor/web, sunflowerit/web, syci/web, szellmark20/web, takinobori/oca-web, tarteo/web, tegin/web, tirix/web, tirma-sa/web, tpa-odoo/web, trevi-software/web, trionoharjadi/web, trobz/web, tvtma/web, unitek-solusi/OCA-web, ursais/web, vasiljevicmarko/web, versada/web, vertelab/web, vialaurea/OCA-web, vnsofthe/web, wahello/oca-web, waveFuncjs/web, xcgd/web, xiaoyi-yanqing/web, zarumaru/web, zcyuefan/web, and zeroheure/web

<h1 class="title">Web Widget mpld3 Chart</h1> <p><a class="reference external" 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" 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" href="https://github.com/OCA/web/tree/15.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" href="https://translation.odoo-community.org/projects/web-15-0/web-15-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" href="https://runbot.odoo-community.org/runbot/162/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-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 mpld3's 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"> <li><a class="reference internal" href="#installation" id="id1">Installation</a></li> <li><a class="reference internal" href="#usage" id="id2">Usage</a></li> <li><a class="reference internal" href="#bug-tracker" id="id3">Bug Tracker</a></li> <li><a class="reference internal" href="#credits" id="id4">Credits</a><ul> <li><a class="reference internal" href="#authors" id="id5">Authors</a></li> <li><a class="reference internal" href="#contributors" id="id6">Contributors</a></li> <li><a class="reference internal" href="#other-credits" id="id7">Other credits</a></li> <li><a class="reference internal" href="#maintainers" id="id8">Maintainers</a></li> </ul> </li> </ul> </div> <a name="installation"></a> <h2><a class="toc-backref" href="#id1">Installation</a></h2> <p>You need to install the python mpld3 library:</p> <pre> <code>pip install mpld3</code> </pre> <a name="usage"></a> <h2><a class="toc-backref" href="#id2">Usage</a></h2> <p>To insert a mpld3 chart in a view proceed as follows:</p> <ol class="arabic"> <li><p class="first">You should inherit from abstract class abstract.mpld3.parser:</p> <pre> <code>_name = 'res.partner' _inherit = ['res.partner', 'abstract.mpld3.parser']</code> </pre> </li> <li><p class="first">Import the required libraries:</p> <pre> <code>import matplotlib.pyplot as plt</code> </pre> </li> <li><p class="first">Declare a text computed field like this:</p> <pre> <code>mpld3_chart = fields.Text( string='Mpld3 Chart', compute='_compute_mpld3_chart', )</code> </pre> </li> <li><p class="first">In its computed method do:</p> <pre> <code>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)</code> </pre> </li> <li><p class="first">In the view, add something like this wherever you want to display your mpld3 chart:</p> <pre> <code>&lt;div&gt; &lt;field name=&quot;mpld3_chart&quot; widget=&quot;mpld3_chart&quot; nolabel=&quot;1&quot;/&gt; &lt;/div&gt;</code> </pre> </li> </ol> <a name="bug-tracker"></a> <h2><a class="toc-backref" href="#id3">Bug Tracker</a></h2> <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 smashing 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:%2015.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> <a name="credits"></a> <h2><a class="toc-backref" href="#id4">Credits</a></h2> <a name="authors"></a> <h3><a class="toc-backref" href="#id5">Authors</a></h3> <ul class="simple"> <li>ForgeFlow</li> </ul> <a name="contributors"></a> <h3><a class="toc-backref" href="#id6">Contributors</a></h3> <ul class="simple"> <li>Jordi Ballester Alomar &lt;<a class="reference external" href="mailto:jordi.ballester&#64;forgeflow.com">jordi.ballester&#64;forgeflow.com</a>&gt;</li> <li>Christopher Ormaza &lt;<a class="reference external" href="mailto:chris.ormaza&#64;forgeflow.com">chris.ormaza&#64;forgeflow.com</a>&gt;</li> </ul> <a name="other-credits"></a> <h3><a class="toc-backref" href="#id7">Other credits</a></h3> <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 &quot;New&quot; or &quot;Revised&quot; 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> <a name="maintainers"></a> <h3><a class="toc-backref" href="#id8">Maintainers</a></h3> <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> <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" href="https://github.com/JordiBForgeFlow"><img alt="JordiBForgeFlow" src="https://github.com/JordiBForgeFlow.png?size=40px" /></a> <a class="reference external" 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/15.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>