forked from Techsystech/web
[IMP] web_widget_json_graph: black, isort, prettier
parent
dd30b9b249
commit
b9c1cae096
|
@ -0,0 +1 @@
|
||||||
|
../../../../web_widget_json_graph
|
|
@ -0,0 +1,6 @@
|
||||||
|
import setuptools
|
||||||
|
|
||||||
|
setuptools.setup(
|
||||||
|
setup_requires=['setuptools-odoo'],
|
||||||
|
odoo_addon=True,
|
||||||
|
)
|
|
@ -1,52 +1,45 @@
|
||||||
odoo.define('web.web_widget_json_graph', function (require) {
|
odoo.define("web.web_widget_json_graph", function (require) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var AbstractField = require('web.AbstractField');
|
var AbstractField = require("web.AbstractField");
|
||||||
var field_registry = require('web.field_registry');
|
var field_registry = require("web.field_registry");
|
||||||
|
|
||||||
var JSONGraphWidget = AbstractField.extend({
|
var JSONGraphWidget = AbstractField.extend({
|
||||||
template: 'JSONGraph',
|
template: "JSONGraph",
|
||||||
cssLibs: [
|
cssLibs: ["/web/static/lib/nvd3/nv.d3.css"],
|
||||||
'/web/static/lib/nvd3/nv.d3.css'
|
|
||||||
],
|
|
||||||
jsLibs: [
|
jsLibs: [
|
||||||
'/web/static/lib/nvd3/d3.v3.js',
|
"/web/static/lib/nvd3/d3.v3.js",
|
||||||
'/web/static/lib/nvd3/nv.d3.js',
|
"/web/static/lib/nvd3/nv.d3.js",
|
||||||
'/web/static/src/js/libs/nvd3.js'
|
"/web/static/src/js/libs/nvd3.js",
|
||||||
],
|
],
|
||||||
_render: function () {
|
_render: function () {
|
||||||
var info = JSON.parse(this.value);
|
var info = JSON.parse(this.value);
|
||||||
/*jsl:ignore*/
|
/* Jsl:ignore*/
|
||||||
/*
|
/*
|
||||||
Ignoring lint erros caused by nv and d3 variables from NVD3.js
|
Ignoring lint erros caused by nv and d3 variables from NVD3.js
|
||||||
*/
|
*/
|
||||||
if (info) {
|
if (info) {
|
||||||
nv.addGraph(function () {
|
nv.addGraph(function () {
|
||||||
var chart = nv.models.lineChart()
|
var chart = nv.models.lineChart().useInteractiveGuideline(true);
|
||||||
.useInteractiveGuideline(true);
|
chart.xAxis.axisLabel(info.label_x).tickFormat(d3.format(",r"));
|
||||||
chart.xAxis
|
|
||||||
.axisLabel(info.label_x)
|
|
||||||
.tickFormat(d3.format(',r'));
|
|
||||||
|
|
||||||
chart.yAxis
|
chart.yAxis.axisLabel(info.label_y).tickFormat(d3.format(".02f"));
|
||||||
.axisLabel(info.label_y)
|
|
||||||
.tickFormat(d3.format('.02f'));
|
|
||||||
|
|
||||||
d3.select('.nv_content svg')
|
d3.select(".nv_content svg")
|
||||||
.datum(info.data)
|
.datum(info.data)
|
||||||
.transition().duration(500)
|
.transition()
|
||||||
|
.duration(500)
|
||||||
.call(chart);
|
.call(chart);
|
||||||
nv.utils.windowResize(chart.update);
|
nv.utils.windowResize(chart.update);
|
||||||
|
|
||||||
return chart;
|
return chart;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/*jsl:end*/
|
/* Jsl:end*/
|
||||||
},
|
},
|
||||||
_destroy: function () {
|
_destroy: function () {
|
||||||
return this._super();
|
return this._super();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
field_registry.add('json_graph', JSONGraphWidget);
|
field_registry.add("json_graph", JSONGraphWidget);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
stroke-width: 1.5px;
|
stroke-width: 1.5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.oe_list_content>tbody>tr>td.oe_list_field_cell {
|
.oe_list_content > tbody > tr > td.oe_list_field_cell {
|
||||||
white-space: normal;
|
white-space: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<odoo>
|
<odoo>
|
||||||
<t t-name="JSONGraph">
|
<t t-name="JSONGraph">
|
||||||
<div class="oe_form_field_json_graph">
|
<div class="oe_form_field_json_graph">
|
||||||
<div class="nv_content">
|
<div class="nv_content">
|
||||||
<svg/>
|
<svg />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</t>
|
</t>
|
||||||
|
|
|
@ -1,10 +1,21 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<odoo>
|
<odoo>
|
||||||
|
|
||||||
<template id="assets_backend" name="web_widget_json_graph assets" inherit_id="web.assets_backend">
|
<template
|
||||||
|
id="assets_backend"
|
||||||
|
name="web_widget_json_graph assets"
|
||||||
|
inherit_id="web.assets_backend"
|
||||||
|
>
|
||||||
<xpath expr="." position="inside">
|
<xpath expr="." position="inside">
|
||||||
<script type="text/javascript" src="/web_widget_json_graph/static/src/js/web_widget_json_graph.js"></script>
|
<script
|
||||||
<link rel="stylesheet" type="text/scss" href="/web_widget_json_graph/static/src/scss/web_widget_json_graph.scss"/>
|
type="text/javascript"
|
||||||
|
src="/web_widget_json_graph/static/src/js/web_widget_json_graph.js"
|
||||||
|
/>
|
||||||
|
<link
|
||||||
|
rel="stylesheet"
|
||||||
|
type="text/scss"
|
||||||
|
href="/web_widget_json_graph/static/src/scss/web_widget_json_graph.scss"
|
||||||
|
/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue