Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Web Widget JSON Graph

Beta License: LGPL-3 OCA/web Translate me on Weblate Try me on Runboat

This module allows to load a line graph per ordered pair from an One2many or Many2many field.

Widget in action

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.

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 to smash it by providing a detailed and welcomed feedback.

Do not contact contributors directly about support or help with technical issues.

Credits

Authors

  • Vauxoo

Contributors

Other credits

Vauxoo

Maintainers

This module is maintained by the OCA.

Odoo Community Association

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.

Current maintainer:

luisg123v

This module is part of the OCA/web project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

Metadata

Release files for odoo12-addon-web-widget-json-graph 12.0.1.0.0.99.dev7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for odoo12-addon-web-widget-json-graph 12.0.1.0.0.99.dev7
File Interpreter ABI Platform
odoo12_addon_web_widget_json_graph-12.0.1.0.0.99.dev7-py3-none-any.whl Python 3 none any Details

Release files / odoo12_addon_web_widget_json_graph-12.0.1.0.0.99.dev7-py3-none-any.whl

Download URL odoo12_addon_web_widget_json_graph-12.0.1.0.0.99.dev7-py3-none-any.whl
Size 353.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
454d497f473a793946c94ed389f52c4fea8151c85ac4bcaf55c3737fcacb2218
BLAKE2b-256 checksum
How to use checksums
3767028559fb46023f395deb89c82e052d4b2c04a40779465829699346bf9a20
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.10
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page