Commit 19f8bfa3 authored by Sebastien Robin's avatar Sebastien Robin

erp5_officejs: make graph charts similar to other gadget fields : change gadget reference

make all graph gadget names like gadget_field_graph_plotly.html/js . We should not have any more "officejs" or "erp5" in name, since theses gadgets could be used for any kind of application.
parent 2c74e408
......@@ -4,7 +4,7 @@
<title>Graph Interface</title>
</head>
<body>
<h1>widget_graph_interface</h1>
<h1>field_graph_interface</h1>
<h3>A graph gadget allows to display various types of graph (lines, bars, 3D, etc)</h3>
<dl>
<dt>render</dt>
......@@ -12,7 +12,7 @@
<dl>
<dt data-parameter-required="required" data-parameter-type="object">option_dict</dt>
<dd>
Schema available here : <a href="gadget_officejs_interface_widget_graph_html_schema.json">gadget_officejs_interface_widget_graph_html_schema.json</a><br>
Schema available here : <a href="gadget_field_graph_interface_html_schema.json">gadget_field_graph_interface_html_schema.json</a><br>
<code style="display:block;white-space:pre-wrap">
Generic graph gadget. The purpose of this gadget is to provide an unique
......
......@@ -83,7 +83,7 @@
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_officejs_interface_widget_graph.html</string> </value>
<value> <string>gadget_field_graph_interface.html</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -111,7 +111,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Graph Interface</string> </value>
<value> <string>Field Graph Interface</string> </value>
</item>
<item>
<key> <string>version</string> </key>
......@@ -242,7 +242,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>958.33138.49196.3857</string> </value>
<value> <string>961.20698.64270.36761</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,8 +260,8 @@
</tuple>
<state>
<tuple>
<float>1491493841.53</float>
<string>UTC</string>
<float>1502370917.57</float>
<string>GMT+2</string>
</tuple>
</state>
</object>
......
......@@ -6,7 +6,7 @@
<title>ERP5 Widget Graph</title>
<!-- interfaces -->
<link rel="http://www.renderjs.org/rel/interface" href="gadget_officejs_interface_widget_graph.html">
<link rel="http://www.renderjs.org/rel/interface" href="gadget_field_graph_interface.html">
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
......@@ -15,7 +15,7 @@
<script src="chart.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_officejs_widget_graph_chart.js" type="text/javascript"></script>
<script src="gadget_field_graph_chart.js" type="text/javascript"></script>
</head>
<body>
......
......@@ -83,7 +83,7 @@
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_officejs_widget_graph_chart.html</string> </value>
<value> <string>gadget_field_graph_chart.html</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -111,7 +111,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>OfficeJS Widget Graph With Chart.js HTML</string> </value>
<value> <string>Field Graph With Chart.js HTML</string> </value>
</item>
<item>
<key> <string>version</string> </key>
......@@ -242,7 +242,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>958.22701.7358.1774</string> </value>
<value> <string>961.20699.46746.19319</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,8 +260,8 @@
</tuple>
<state>
<tuple>
<float>1491487541.41</float>
<string>UTC</string>
<float>1502442080.86</float>
<string>GMT+2</string>
</tuple>
</state>
</object>
......
......@@ -10,7 +10,7 @@
var getGraphDataAndParameterFromConfiguration = function (configuration_dict) {
var graph_data_and_parameter = {},
data = configuration_dict.data || [],
data,
trace,
trace_type,
type_list = [],
......@@ -19,14 +19,17 @@
dataset_list = [],
dataset,
i, j,
layout = configuration_dict.layout || {},
title = layout.title,
layout,
title,
type = 'bar',
x_label, y_label;
if (configuration_dict.constructor === String) {
configuration_dict = JSON.parse(configuration_dict);
}
data = configuration_dict.data || [];
layout = configuration_dict.layout || {};
title = layout.title;
/* title seems to be ignored by Chart.js, so do not handle it for now */
......@@ -97,17 +100,23 @@
.declareMethod('render', function (option_dict) {
var gadget = this;
//delegate rendering to onStateChange to avoid redrawing the graph
//every time render is called (a form might call render every time
//some other fields needs update
gadget.changeState({value: option_dict.value});
})
.onStateChange(function (modification_dict) {
var gadget = this,
container,
graph_data_and_parameter,
chart;
container = gadget.element.querySelector(".graph-content");
graph_data_and_parameter = getGraphDataAndParameterFromConfiguration(option_dict.value);
graph_data_and_parameter = getGraphDataAndParameterFromConfiguration(modification_dict.value);
console.log("graph_data_and_parameter", graph_data_and_parameter);
chart = new Chart(container, graph_data_and_parameter);
gadget.property_dict.chart = chart;
});
......
......@@ -79,7 +79,7 @@
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_officejs_widget_graph_chart.js</string> </value>
<value> <string>gadget_field_graph_chart.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -109,7 +109,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>OfficeJS Widget Graph With Chart.js JS</string> </value>
<value> <string>Field Graph With Chart.js JS</string> </value>
</item>
<item>
<key> <string>version</string> </key>
......@@ -242,7 +242,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>958.33098.23392.23722</string> </value>
<value> <string>961.21870.15852.42137</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,8 +260,8 @@
</tuple>
<state>
<tuple>
<float>1491491186.21</float>
<string>UTC</string>
<float>1502452731.55</float>
<string>GMT+2</string>
</tuple>
</state>
</object>
......
......@@ -6,7 +6,7 @@
<title>ERP5 Widget Graph</title>
<!-- interfaces -->
<link rel="http://www.renderjs.org/rel/interface" href="gadget_officejs_interface_widget_graph.html">
<link rel="http://www.renderjs.org/rel/interface" href="gadget_field_graph_interface.html">
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
......@@ -15,7 +15,7 @@
<script src="dygraph.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_officejs_widget_graph_dygraph.js" type="text/javascript"></script>
<script src="gadget_field_graph_dygraph.js" type="text/javascript"></script>
</head>
<body>
......
......@@ -83,7 +83,7 @@
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_officejs_widget_graph_dygraph.html</string> </value>
<value> <string>gadget_field_graph_dygraph.html</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -111,7 +111,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>OfficeJS Widget Graph With Dygraph</string> </value>
<value> <string>Field Graph With Dygraph</string> </value>
</item>
<item>
<key> <string>version</string> </key>
......@@ -236,7 +236,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>958.28489.56960.4983</string> </value>
<value> <string>961.20695.23642.40482</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -254,8 +254,8 @@
</tuple>
<state>
<tuple>
<float>1491487527.75</float>
<string>UTC</string>
<float>1502370959.51</float>
<string>GMT+2</string>
</tuple>
</state>
</object>
......
......@@ -10,8 +10,8 @@
var getGraphDataAndParameterFromConfiguration = function (configuration_dict) {
var graph_data_and_parameter = {},
layout = configuration_dict.layout || {},
data = configuration_dict.data || [],
layout,
data,
x_label, y_label,
label_list = [],
trace_value_dict,
......@@ -31,7 +31,8 @@
if (configuration_dict.constructor === String) {
configuration_dict = JSON.parse(configuration_dict);
}
layout = configuration_dict.layout || {};
data = configuration_dict.data || [];
axis_dict = layout.axis_dict || {};
x_label = (axis_dict[0] || {}).title;
y_label = (axis_dict[1] || {}).title;
......@@ -148,13 +149,20 @@
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod('render', function (option_dict) {
var gadget = this;
//delegate rendering to onStateChange to avoid redrawing the graph
//every time render is called (a form might call render every time
//some other fields needs update
gadget.changeState({value: option_dict.value});
})
.onStateChange(function (modification_dict) {
var gadget = this,
container,
graph_data_and_parameter;
container = gadget.element.querySelector(".graph-content");
graph_data_and_parameter = getGraphDataAndParameterFromConfiguration(option_dict.value);
graph_data_and_parameter = getGraphDataAndParameterFromConfiguration(modification_dict.value);
gadget.property_dict.graph = new Dygraph(container,
graph_data_and_parameter.dygraph_data,
graph_data_and_parameter.dygraph_parameter_dict);
......
......@@ -79,7 +79,7 @@
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_officejs_widget_graph_dygraph.js</string> </value>
<value> <string>gadget_field_graph_dygraph.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -109,7 +109,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>OfficeJS Widget Graph Dygraph JS</string> </value>
<value> <string>Field Graph Dygraph JS</string> </value>
</item>
<item>
<key> <string>version</string> </key>
......@@ -236,7 +236,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>958.33028.31012.14387</string> </value>
<value> <string>961.22065.145.58026</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -254,8 +254,8 @@
</tuple>
<state>
<tuple>
<float>1491491239.36</float>
<string>UTC</string>
<float>1502453287.3</float>
<string>GMT+2</string>
</tuple>
</state>
</object>
......
......@@ -6,7 +6,7 @@
<title>ERP5 Widget Graph</title>
<!-- interfaces -->
<link rel="http://www.renderjs.org/rel/interface" href="gadget_officejs_interface_widget_graph.html">
<link rel="http://www.renderjs.org/rel/interface" href="gadget_field_graph_interface.html">
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
......@@ -16,7 +16,7 @@
<script src="plotly.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_officejs_widget_graph_plotly.js" type="text/javascript"></script>
<script src="gadget_field_graph_plotly.js" type="text/javascript"></script>
</head>
<body>
......
......@@ -83,7 +83,7 @@
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_officejs_widget_graph_plotly.html</string> </value>
<value> <string>gadget_field_graph_plotly.html</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -111,7 +111,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>OfficeJS Widget Graph With plotly.js HTML</string> </value>
<value> <string>Field Graph With plotly.js HTML</string> </value>
</item>
<item>
<key> <string>version</string> </key>
......@@ -242,7 +242,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>958.44543.29683.48588</string> </value>
<value> <string>961.20697.17932.14216</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,8 +260,8 @@
</tuple>
<state>
<tuple>
<float>1492178387.52</float>
<string>UTC</string>
<float>1502370931.02</float>
<string>GMT+2</string>
</tuple>
</state>
</object>
......
......@@ -10,7 +10,7 @@
var getGraphDataAndParameterFromConfiguration = function (configuration_dict) {
var graph_data_and_parameter = {},
given_data_list = configuration_dict.data,
given_data_list,
current_data,
given_data,
axis_mapping_id_dict,
......@@ -25,8 +25,9 @@
if (configuration_dict.constructor === String) {
configuration_dict = JSON.parse(configuration_dict);
}
given_data_list = configuration_dict.data;
console.log("getGraphDataAndParameterFromConfiguration 1");
console.log("getGraphDataAndParameterFromConfiguration 1 configuration_dict", configuration_dict);
graph_data_and_parameter.data_list = [];
graph_data_and_parameter.layout = {modeBarButtonsToRemove: ['sendDataToCloud']};
......@@ -37,7 +38,7 @@
current_data[axis_id] = axis_value_list;
}
console.log("getGraphDataAndParameterFromConfiguration 2");
console.log("given_data_list", given_data_list);
console.log("plotly given_data_list", given_data_list);
function setAxisLayout(axis_mapping) {
var axis_id = AXIS_MAPPING_DICT[axis_mapping[0]],
axis_identifier = axis_mapping[1],
......@@ -122,7 +123,13 @@
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod('render', function (option_dict) {
var gadget = this;
//delegate rendering to onStateChange to avoid redrawing the graph
//every time render is called (a form might call render every time
//some other fields needs update
gadget.changeState({value: option_dict.value});
})
.onStateChange(function (modification_dict) {
var gadget = this,
container,
......@@ -133,12 +140,9 @@
container = gadget.element.querySelector(".graph-content");
gadget.property_dict.container = container;
console.log("container inside iframe");
graph_value = option_dict.value;
if (graph_value.constructor === String) {
graph_value = JSON.parse(graph_value);
}
graph_value = modification_dict.value;
graph_data_and_parameter = getGraphDataAndParameterFromConfiguration(graph_value);
console.log("graph_data_and_parameter", graph_data_and_parameter);
console.log("plotly graph_data_and_parameter", graph_data_and_parameter);
if (gadget.property_dict.already_rendered === true) {
Plotly.purge(container);
}
......@@ -147,9 +151,4 @@
});
}(window, rJS, RSVP, Plotly));
}(window, rJS, RSVP, Plotly));
\ No newline at end of file
......@@ -79,7 +79,7 @@
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_officejs_widget_graph_plotly.js</string> </value>
<value> <string>gadget_field_graph_plotly.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -109,7 +109,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>OfficeJS Widget Graph With plotly.js</string> </value>
<value> <string>Field Graph With plotly.js</string> </value>
</item>
<item>
<key> <string>version</string> </key>
......@@ -242,7 +242,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>958.51689.48609.58572</string> </value>
<value> <string>961.22061.49603.52480</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1492606750.55</float>
<float>1502453333.98</float>
<string>GMT+2</string>
</tuple>
</state>
......
......@@ -62,6 +62,10 @@
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
......@@ -129,7 +133,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: {\'graph_gadget\': \'unsafe/gadget_officejs_widget_graph_dygraph.html\'}</string> </value>
<value> <string>python: {\'graph_gadget\': \'unsafe/gadget_field_graph_dygraph.html\'}</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -133,7 +133,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: {\'graph_gadget\': \'unsafe/gadget_officejs_widget_graph_plotly.html\'}</string> </value>
<value> <string>python: {\'graph_gadget\': \'unsafe/gadget_field_graph_plotly.html\'}</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -128,7 +128,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: "unsafe/gadget_officejs_widget_graph_chart.html"</string> </value>
<value> <string>python: "unsafe/gadget_field_graph_chart.html"</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -128,7 +128,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: "unsafe/gadget_officejs_widget_graph_dygraph.html"</string> </value>
<value> <string>python: "unsafe/gadget_field_graph_dygraph.html"</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -128,7 +128,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: "unsafe/gadget_officejs_widget_graph_plotly.html"</string> </value>
<value> <string>python: "unsafe/gadget_field_graph_plotly.html"</string> </value>
</item>
</dictionary>
</pickle>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment