如何在 Odoo 框架中集成 D3 图表?
How to Integrate the D3 charts in Odoo Framework?
我是 Stack 的新手,我在 odoo 中遇到了问题,我需要在 odoo 表单视图中为我的模型集成 d3 图表。提前致谢。
试试这个,
我们需要在 view.xml 文件的表单视图字段中配置小部件。
view.xml
<form string="Graph">
<field name="name" widget="test"/>
</form>
需要创建一个js文件然后我们需要像这样扩展class-openerp.web.form.FieldChar.extend,
D3_chart.js
openerp.transform_organization_chart = function(openerp) {
openerp.web.form.widgets.add('test','openerp.web.form.test');
openerp.web.form.test = openerp.web.form.FieldChar.extend(
{
template: 'test-button',
init: function () {
this._super.apply(this, arguments);
this._start = null;
},
start: function() {
console.log('START');
this.Myfunction();
},
Myfunction: function()
{
}
});
}
为我们的图表创建 template.xml 文件,这里我们需要写 html template.Both 模板 ID 和扩展字段字符名称应该相同。
template.xml
<template id="test-button">
<script type="text/javascript" src="/transform_organization_chart/static/src/js/d3.js"></script>
<div t-name="test-button">
<div id="orgChartContainer">
<div id="orgChart"></div>
</div>
<div id="consoleOutput"></div>
</div>
</template>
我是 Stack 的新手,我在 odoo 中遇到了问题,我需要在 odoo 表单视图中为我的模型集成 d3 图表。提前致谢。
试试这个, 我们需要在 view.xml 文件的表单视图字段中配置小部件。
view.xml
<form string="Graph">
<field name="name" widget="test"/>
</form>
需要创建一个js文件然后我们需要像这样扩展class-openerp.web.form.FieldChar.extend,
D3_chart.js
openerp.transform_organization_chart = function(openerp) {
openerp.web.form.widgets.add('test','openerp.web.form.test');
openerp.web.form.test = openerp.web.form.FieldChar.extend(
{
template: 'test-button',
init: function () {
this._super.apply(this, arguments);
this._start = null;
},
start: function() {
console.log('START');
this.Myfunction();
},
Myfunction: function()
{
}
});
}
为我们的图表创建 template.xml 文件,这里我们需要写 html template.Both 模板 ID 和扩展字段字符名称应该相同。
template.xml
<template id="test-button">
<script type="text/javascript" src="/transform_organization_chart/static/src/js/d3.js"></script>
<div t-name="test-button">
<div id="orgChartContainer">
<div id="orgChart"></div>
</div>
<div id="consoleOutput"></div>
</div>
</template>