Define KPI graphs using altair
auto_awesome What this module does
AI-generated from the code · Odoo 12.0Adds an "Altair" widget type to KPI dashboard items, letting users build interactive charts with the Altair/Vega-Lite library and display them on Odoo dashboards.
This module extends the KPI dashboard feature so that a KPI can be shown as an Altair chart instead of the standard widget types.
- On a KPI record (
kpi.kpi) a new option "Altair" appears in the widget selector. - When that option is chosen, the Python code that computes the KPI receives extra objects (
json,altairandpandas) so the chart can be built with Altair and returned as JSON. - On the dashboard, the chart is rendered inside the widget area using the Vega, Vega-Lite and Vega-Embed JavaScript libraries, which are loaded in the backend assets.
- The chart automatically resizes to fit the widget's width and height, and the Vega action menu is hidden.
- A demo KPI and dashboard item are included to show a bar chart example.
The module requires the Python altair library (and pandas) to be installed on the server. It depends on kpi_dashboard and only touches the kpi.kpi model and the dashboard rendering assets.
Depends on
Models and fields (1)
- kpi.kpi · extends an existing modelwidget
Text generated by AI (DeepSeek) from reading the Odoo 12.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-03Confirmation status: 1 confirmed, 8 with no information of 9 versions.
Sources · Odoo 12.0
Confirmed on 2026-11-03 in branch 12.0 of OCA/reporting-engine.
terminal Installation and usage
OCA documentation · Odoo 12.0Configuration
Source · Odoo 12.0Configure KPIs
#. Access `Dashboards > Configuration > KPI Dashboards > Configure KPI`
#. Create a new kpi with widget `altair`
You need to define a function like::
import pandas
import altair
class Kpi(models.Model):
_inherit = 'kpi.kpi'
def test_demo_altair(self):
source = pandas.DataFrame(
{
"a": ["A", "B", "C", "D", "E", "F", "G", "H", "I"],
"b": [28, 55, 43, 91, 81, 53, 19, 87, 52],
}
)
chart = altair.Chart(source).mark_bar().encode(x="a", y="b")
return {"altair": json.loads(chart.to_json())}
You can use `code` in a similar way, as `pandas` and `altair` are already defined
when using `code` on an `altair` widget.
.. image:: ../static/description/config.pngNo verified information in OCA: Installation, Usage.
Installation instructions, the distribution package, dependencies and configuration steps are not shown because they have not yet been verified in the module documentation for any version.
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.