Skip to main content

Draw json fields with graphs.

Project description

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:

info = {
    "type": "line",
    "data": {"datasets": [], "labels": []},
    "options": {
        "scales": {
            "yAxes": [
                {
                    "ticks": {"beginAtZero": True, "stacked": False},
                    "scaleLabel": {"display": True, "labelString": "Quantity"},
                }
            ],
            "xAxes": [
                {
                    "scaleLabel": {"display": True, "labelString": "Date"},
                }
            ],
        },
        "elements": {"point": {"radius": 3}},
        "legend": {"labels": {"usePointStyle": True}},
        "tooltips": {"intersect": False, "axis": "xy", "mode": "index"},
    },
}
self.field_text_json = json.dumps(info)

For example:

plot_dataset = [1, 2, 3, 4, 3, 2]
labels = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"]
info = {
    "type": "line",
    "data": {"datasets": plot_dataset, "labels": labels},
    "options": {
        "scales": {
            "yAxes": [
                {
                    "ticks": {"beginAtZero": True, "stacked": False},
                    "scaleLabel": {"display": True, "labelString": "Quantity"},
                }
            ],
            "xAxes": [
                {
                    "scaleLabel": {"display": True, "labelString": "Date"},
                }
            ],
        },
        "elements": {"point": {"radius": 3}},
        "legend": {"labels": {"usePointStyle": True}},
        "tooltips": {"intersect": False, "axis": "xy", "mode": "index"},
    },
}
self.values_data = json.dumps(info)

For more information, please see Chart Js Documentation <https://www.chartjs.org/docs/2.9.4/>.

Known issues / Roadmap

  • None

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 maintainers:

luisg123v frahikLV

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

File details

Details for the file odoo_addon_web_widget_json_graph-15.0.1.0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for odoo_addon_web_widget_json_graph-15.0.1.0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 cc1fb739487a0cedc8614e3f4067977925baa0fad96e7ed17df71a089979c540
MD5 70334419e2fa5979bf1bb55fde8fa168
BLAKE2b-256 b92c8a362fccb75c63c6b1e4a0fed63b59592a01241831f761e966d0c0e82310

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page