Skip to content

Latest commit

 

History

History
117 lines (92 loc) · 3.44 KB

README.rst

File metadata and controls

117 lines (92 loc) · 3.44 KB

Multi Value Dimension

This module allows load a line graph per ordered pair in a x2many field.

Screenshot

Usage

Use this widget by saying:

<field name="field_text_json" widget="json_graph" />

Use of widget 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)

JSON 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 use always 100% of the width, pending the css dynamic attribute.
  • The height is wired.

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed feedback here.

Credits

Contributors

Maintainer

Odoo Community Association

This module is maintained by the OCA.

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

To contribute to this module, please visit http://odoo-community.org.