diff --git a/kpi_dashboard_bokeh/__manifest__.py b/kpi_dashboard_bokeh/__manifest__.py index 9bf5d2f47..1a1b273d1 100644 --- a/kpi_dashboard_bokeh/__manifest__.py +++ b/kpi_dashboard_bokeh/__manifest__.py @@ -8,7 +8,7 @@ "version": "12.0.1.0.0", "license": "AGPL-3", "author": "Creu Blanca,Odoo Community Association (OCA)", - "website": "https://github.com/OCA/reporting-engine ", + "website": "https://github.com/OCA/reporting-engine", "depends": ["web_widget_bokeh_chart", "kpi_dashboard"], "data": ["views/webclient_templates.xml"], "qweb": ["static/src/xml/dashboard.xml"], diff --git a/kpi_dashboard_bokeh/demo/demo_dashboard.xml b/kpi_dashboard_bokeh/demo/demo_dashboard.xml index 2187080ab..6ff0fc1cd 100644 --- a/kpi_dashboard_bokeh/demo/demo_dashboard.xml +++ b/kpi_dashboard_bokeh/demo/demo_dashboard.xml @@ -13,13 +13,12 @@ result = {"bokeh": "%s%s" % (div, script)} - + Bokeh - - + + 2 10 4 diff --git a/kpi_dashboard_bokeh/models/kpi_kpi.py b/kpi_dashboard_bokeh/models/kpi_kpi.py index d397e332f..375ea53f3 100644 --- a/kpi_dashboard_bokeh/models/kpi_kpi.py +++ b/kpi_dashboard_bokeh/models/kpi_kpi.py @@ -1,14 +1,15 @@ # Copyright 2020 Creu Blanca # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import fields, models import logging +from odoo import fields, models + _logger = logging.getLogger(__name__) try: + from bokeh.embed import components from bokeh.plotting import figure from bokeh.themes import Theme - from bokeh.embed import components except ImportError as e: _logger.error(e) @@ -20,31 +21,36 @@ class KpiKpi(models.Model): widget = fields.Selection(selection_add=[("bokeh", "Bokeh")]) def _get_bokeh_theme(self): - return Theme(json={ - "attrs": { - "Figure": { - "background_fill_alpha": 0, - "border_fill_alpha": 0, - "outline_line_alpha": 0, - }, - "Legend": { - "border_line_alpha": 0, - "background_fill_alpha": 0, - }, - "ColorBar": { - "bar_line_alpha": 0, - "background_fill_alpha": 0, - }, + return Theme( + json={ + "attrs": { + "Figure": { + "background_fill_alpha": 0, + "border_fill_alpha": 0, + "outline_line_alpha": 0, + }, + "Legend": { + "border_line_alpha": 0, + "background_fill_alpha": 0, + }, + "ColorBar": { + "bar_line_alpha": 0, + "background_fill_alpha": 0, + }, + } } - }) + ) def _get_code_input_dict(self): res = super()._get_code_input_dict() - if self.widget == 'bokeh': - res.update({ - 'figure': figure, - 'components': components, - 'simple_components': lambda r: components( - r, theme=self._get_bokeh_theme()) - }) + if self.widget == "bokeh": + res.update( + { + "figure": figure, + "components": components, + "simple_components": lambda r: components( + r, theme=self._get_bokeh_theme() + ), + } + ) return res diff --git a/kpi_dashboard_bokeh/static/src/js/bokeh_widget.js b/kpi_dashboard_bokeh/static/src/js/bokeh_widget.js index 4b68f7da8..e3bb04c7c 100644 --- a/kpi_dashboard_bokeh/static/src/js/bokeh_widget.js +++ b/kpi_dashboard_bokeh/static/src/js/bokeh_widget.js @@ -1,20 +1,19 @@ -odoo.define('kpi_dashboard.BokehWidget', function (require) { +odoo.define("kpi_dashboard.BokehWidget", function (require) { "use strict"; - var AbstractWidget = require('kpi_dashboard.AbstractWidget'); - var registry = require('kpi_dashboard.widget_registry'); - + var AbstractWidget = require("kpi_dashboard.AbstractWidget"); + var registry = require("kpi_dashboard.widget_registry"); var BokehWidget = AbstractWidget.extend({ - template: 'kpi_dashboard.bokeh', + template: "kpi_dashboard.bokeh", fillWidget: function (values) { var val = values.value.bokeh; var widget = this.$el.find('[data-bind="value"]'); - widget.css('height', this.widget_size_y - 90); + widget.css("height", this.widget_size_y - 90); widget.html(val); }, }); - registry.add('bokeh', BokehWidget); + registry.add("bokeh", BokehWidget); return BokehWidget; }); diff --git a/kpi_dashboard_bokeh/static/src/xml/dashboard.xml b/kpi_dashboard_bokeh/static/src/xml/dashboard.xml index c862e1a77..554b8caf0 100644 --- a/kpi_dashboard_bokeh/static/src/xml/dashboard.xml +++ b/kpi_dashboard_bokeh/static/src/xml/dashboard.xml @@ -2,7 +2,7 @@