mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[15.0][MIG] web_widget_mpld3_chart
This commit is contained in:
committed by
Lois Rilo
parent
04c4e4fb46
commit
0f02e29462
@@ -0,0 +1,31 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import basicFields from "web.basic_fields";
|
||||
import fieldRegistry from "web.field_registry";
|
||||
|
||||
const Mpld3ChartWidget = basicFields.FieldChar.extend({
|
||||
jsLibs: [
|
||||
"/web_widget_mpld3_chart/static/src/lib/d3/d3.v5.js",
|
||||
"/web_widget_mpld3_chart/static/src/lib/mpld3/mpld3.v0.5.7.js",
|
||||
],
|
||||
_renderReadonly: function () {
|
||||
try {
|
||||
const val = JSON.parse(this.value);
|
||||
const new_div = document.createElement("div");
|
||||
new_div.setAttribute("id", val.div);
|
||||
this.$el.html(new_div);
|
||||
this.$el.ready(function () {
|
||||
const script = document.createElement("script");
|
||||
script.setAttribute("type", "text/javascript");
|
||||
if ("textContent" in script) script.textContent = val.script;
|
||||
else script.text = val.script;
|
||||
$("head").append(script);
|
||||
});
|
||||
} catch (error) {
|
||||
return this._super(...arguments);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
fieldRegistry.add("mpld3_chart", Mpld3ChartWidget);
|
||||
export default Mpld3ChartWidget;
|
||||
@@ -1,17 +0,0 @@
|
||||
odoo.define("web_widget_mpld3_chart", function (require) {
|
||||
"use strict";
|
||||
|
||||
var fieldRegistry = require("web.field_registry");
|
||||
var AbstractField = require("web.AbstractField");
|
||||
|
||||
var Mpld3ChartWidget = AbstractField.extend({
|
||||
start: function () {
|
||||
var val = this.value;
|
||||
this.$el.html(val);
|
||||
},
|
||||
});
|
||||
fieldRegistry.add("mpld3_chart", Mpld3ChartWidget);
|
||||
return {
|
||||
Mpld3ChartWidget: Mpld3ChartWidget,
|
||||
};
|
||||
});
|
||||
File diff suppressed because one or more lines are too long
18568
web_widget_mpld3_chart/static/src/lib/d3/d3.v5.js
vendored
Normal file
18568
web_widget_mpld3_chart/static/src/lib/d3/d3.v5.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
2079
web_widget_mpld3_chart/static/src/lib/mpld3/mpld3.v0.5.7.js
Normal file
2079
web_widget_mpld3_chart/static/src/lib/mpld3/mpld3.v0.5.7.js
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user