$ 29.00
Web Widget JSON Graph
This module allows to load a line graph per ordered pair from an One2many or Many2many field.
Table of contents
Usage
Use this widget by including:
<field name="field_text_json" widget="json_graph" />
For example:
<field name="values_data" widget="json_graph"/>
The JSON needs to be like:
fields = ['field1', 'field2', 'field3', ...]
field_x = 'field_x'
dictionary = self.value_ids.sorted(field_x).read(fields)
color = {
'field1': HEXCOLOR1,
'field2': '#FFBB78',
'field3': '#1F77B4',
...
}
dictionary = self.value_ids.sorted(field_x).read(fields)
content = {}
data = []
for field in fields:
if field != field_x:
content[field] = []
for rec in dictionary:
content[field].append({'x': rec[field_x], 'y': rec[field]})
if field in color:
data.append({'values': content[field], 'key': field,
'color': color[field]})
continue
data.append({'values': content[field], 'key': field})
info = {
'label_x': 'X Label',
'label_y': 'Y label',
'data': data
}
self.field_text_json = json.dumps(info)
For example:
fields = ['sequence', 'value', 'sma', 'cma']
field_x = 'sequence'
dictionary = self.value_ids.sorted(field_x).read(fields)
color = {
'value': '#2CA02C',
'sma': '#FFBB78'
}
dictionary = self.value_ids.sorted(field_x).read(fields)
content = {}
data = []
for field in fields:
if field != field_x:
content[field] = []
for rec in dictionary:
content[field].append({'x': rec[field_x], 'y': rec[field]})
if field in color:
data.append({'values': content[field], 'key': field,
'color': color[field]})
continue
data.append({'values': content[field], 'key': field})
info = {
'label_x': 'Sequence',
'label_y': '',
'data': data
}
self.values_data = json.dumps(info)
Known issues / Roadmap
- nolabel is ignored, this image will never bring a label, by default simply use an extra separator.
- A graph will always use 100% of the width, pending the css dynamic attribute.
- Height is harcoded.
| Technical name | web_widget_json_graph |
|---|---|
| Module version | 12.0.1.0.0 |
| Tulio versions | 1.0 |
| Category | Tools |
| Publisher | Contaura LLC
Ported to Tulio, tested and supported by Contaura LLC. |
| Original authors | Vauxoo, OCA |
| License | LGPL-3
Open source: you may use, change and share
this module under its license. The price covers the Tulio port, its testing on Tulio
1.0 and the download. |
| Requires (Tulio core) | web |
| Lines of code | 113 |
| Downloads | 0 |
| Released | 12/06/2026 |