OdooWiki OCA HUB

Web Widget mpld3 Chart

web_widget_mpld3_chart folder_open OCA/web open_in_new
Hidden License: LGPL-3

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.

auto_awesome What this module does

AI-generated from the code · Odoo 18.0

Adds a new field widget that displays interactive matplotlib charts (converted with mpld3) inside Odoo views. Developers can use the `mpld3_chart` widget on a field to render a chart from JSON data.

This module provides a new field widget called mpld3_chart that can be used in Odoo views to display interactive charts generated with the mpld3 library. The widget is registered in the web client and loads the necessary D3.js and mpld3 JavaScript libraries when a view is opened.

The module also includes a utility model abstract.mpld3.parser with a method convert_figure_to_json that converts a matplotlib figure into JSON data containing HTML and script parts. This JSON is then used by the widget to render the chart.

When a field using this widget is displayed, the widget injects the chart's HTML and executes its script, making the chart interactive. The widget is available for use in any Odoo view, but it is primarily intended for developers who need to embed mpld3 charts.

No menus or user-facing screens are added by this module; it only adds a technical widget for use in custom developments. The module depends on the web module and requires the Python packages mpld3 and beautifulsoup4 to be installed.

Depends on

web
Models and fields (1)
  • abstract.mpld3.parser · new model

Text generated by AI (DeepSeek) from reading the Odoo 18.0 code on GitHub; it may contain mistakes, so check the code before deciding. View the code on GitHub

Availability by version

Reviewed: 2026-11-03
Confirmed (verified in repository and branch) Estimated (unverified) No information

Confirmation status: 7 confirmed, 2 with no information of 9 versions.

terminal Installation and usage

OCA documentation · Odoo 18.0

You need to install the python mpld3 library:

pip install mpld3

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:

No verified information in OCA: Configuration.

info

Data imported from GitHub: this sheet reflects the latest catalog review, not a live lookup. Always check the module documentation and staging before installing in production.