mirror of https://github.com/OCA/web.git
[MIG] web_widget_bokeh_chart: Migration to 11.0
parent
321d690082
commit
53b2940f1b
|
@ -0,0 +1,2 @@
|
||||||
|
# web_widget_bokeh_chart
|
||||||
|
bokeh==0.12.7
|
|
@ -38,19 +38,19 @@ To insert a Bokeh chart in a view proceed as follows:
|
||||||
|
|
||||||
bokeh_chart = fields.Text(
|
bokeh_chart = fields.Text(
|
||||||
string='Bokeh Chart',
|
string='Bokeh Chart',
|
||||||
compute=_compute_bokeh_chart)
|
compute='_compute_bokeh_chart',
|
||||||
|
)
|
||||||
|
|
||||||
#. In its computed method do::
|
#. In its computed method do::
|
||||||
|
|
||||||
def _compute_bokeh_chart(self):
|
def _compute_bokeh_chart(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
# Design your bokeh figure:
|
# Design your bokeh figure:
|
||||||
p = figure()
|
p = figure() # import that as `from bokeh.plotting import figure`
|
||||||
line = p.line([0, 2], [1, 8], line_width=5)
|
line = p.line([0, 2], [1, 8], line_width=5)
|
||||||
# (...)
|
# (...)
|
||||||
# Get the html components and convert them to string into the field.
|
# `p.html.data` contains both markup and the script of a chart.
|
||||||
script, div = components(p)
|
rec.bokeh_chart = p.html.data
|
||||||
rec.bokeh_chart = '%s%s' % (div, script)
|
|
||||||
|
|
||||||
#. In the view, add something like this wherever you want to display your
|
#. In the view, add something like this wherever you want to display your
|
||||||
bokeh chart::
|
bokeh chart::
|
||||||
|
@ -80,6 +80,7 @@ Contributors
|
||||||
|
|
||||||
* Jordi Ballester Alomar <jordi.ballester@eficent.com>
|
* Jordi Ballester Alomar <jordi.ballester@eficent.com>
|
||||||
* Lois Rilo Antelo <lois.rilo@eficent.com>
|
* Lois Rilo Antelo <lois.rilo@eficent.com>
|
||||||
|
* Artem Kostyuk <a.kostyuk@mobilunity.com>
|
||||||
|
|
||||||
Maintainer
|
Maintainer
|
||||||
----------
|
----------
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
|
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).#
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).#
|
||||||
|
|
||||||
|
@ -8,7 +7,7 @@
|
||||||
"summary": "This widget allows to display charts using Bokeh library.",
|
"summary": "This widget allows to display charts using Bokeh library.",
|
||||||
"author": "Eficent, "
|
"author": "Eficent, "
|
||||||
"Odoo Community Association (OCA)",
|
"Odoo Community Association (OCA)",
|
||||||
"version": "10.0.1.0.0",
|
"version": "11.0.1.0.0",
|
||||||
"website": "https://github.com/OCA/web",
|
"website": "https://github.com/OCA/web",
|
||||||
"depends": ["web"],
|
"depends": ["web"],
|
||||||
"data": [
|
"data": [
|
||||||
|
|
|
@ -1,20 +1,16 @@
|
||||||
odoo.define('web_widget_bokeh_chart', function (require) {
|
odoo.define('web_widget_bokeh_chart', function (require) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var core = require('web.core');
|
var fieldRegistry = require('web.field_registry');
|
||||||
var form_common = require('web.form_common');
|
var AbstractField = require('web.AbstractField');
|
||||||
var formats = require('web.formats');
|
|
||||||
var Model = require('web.Model');
|
|
||||||
|
|
||||||
var QWeb = core.qweb;
|
var BokehChartWidget = AbstractField.extend({
|
||||||
|
start: function() {
|
||||||
var BokehChartWidget = form_common.AbstractField.extend({
|
var val = this.value;
|
||||||
render_value: function() {
|
|
||||||
var val = this.get('value');
|
|
||||||
this.$el.html(val);
|
this.$el.html(val);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
core.form_widget_registry.add('bokeh_chart', BokehChartWidget);
|
fieldRegistry.add('bokeh_chart', BokehChartWidget);
|
||||||
return {
|
return {
|
||||||
BokehChartWidget: BokehChartWidget
|
BokehChartWidget: BokehChartWidget
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue