Highcharts's Graph Widget

by
Odoo

10.13

v 13.0 Third Party 1
Technical Name highcharts_widget
Also available in version v 10.0
You bought this module and need support? Click here!
Technical Name highcharts_widget
Also available in version v 10.0

Highcharts Graph Widget

To include highcharts's graph into forms's views...

How to use

In your model you need create a function that return a valid Highchart's graph data, for example:

# -*- coding: utf-8 -*-

from odoo import api, models


class TestGraph(models.Model):
    _name = 'highcharts_widget.test_graph'
    _description = 'Testing graph feature...'

    @api.multi
    def compute_graph_data(self):
        self.ensure_one()
        return {
            'chart': {
                'plotBackgroundColor': 'white',
                'plotBorderWidth': '0',
            },
            'title': {
                'text': 'Browser market shares at a specific website, 2014'
            },
            'tooltip': {
                'pointFormat': '{series.name}: {point.percentage:.1f}%'
            },
            'plotOptions': {
                'pie': {
                    'allowPointSelect': 'true',
                    'cursor': 'pointer',
                    'dataLabels': {
                        'enabled': 'false'
                    },
                    'showInLegend': 'true'
                }
            },
            'series': [{
                'type': 'pie',
                'name': 'Browser share',
                'data': [
                    ['Firefox',   45.0],
                    ['IE',       26.8],
                    {
                        'name': 'Chrome',
                        'y': 12.8,
                        'sliced': 'true',
                        'selected': 'true'
                    },
                    ['Safari',    8.5],
                    ['Opera',     6.2],
                    ['Others',   0.7]
                ]
            }]
        }
                

In the xml definition you should write something like that:

<?xml version="1.0" encoding="UTF-8"?>

<odoo>
    <data>
        <record id="highcharts_widget_test_form_view" model="ir.ui.view">
            <field name="name">highcharts_widget_test_form_view</field>
            <field name="model">highcharts_widget.test_graph</field>
            <field name="arch" type="xml">
                <form>
                    <sheet>
                        
                        <widget id="test_model_graph"
                                model="highcharts_widget.test_graph"
                                method="compute_graph_data"
                                class="oe_read_only"
                                name="graph_widget"
                        />
                        
                    </sheet>
                </form>
            </field>
        </record>

        <record id="highcharts_widget_test_action" model="ir.actions.act_window">
            <field name="name">Graph Test</field>
            <field name="res_model">highcharts_widget.test_graph</field>
            <field name="view_type">form</field>
            <field name="view_mode">form</field>
        </record>

        <menuitem name="Graph Test"
                  id="highcharts_widget_test_menu_item"
                  action="highcharts_widget_test_action"
                  sequence="1"
        />
    </data>
</odoo>
                
Alejandro Cora Gonzalez
alek.cora.glez@gmail.com

Please log in to comment on this module

  • The author can leave a single reply to each comment.
  • This section is meant to ask simple questions or leave a rating. Every report of a problem experienced while using the module should be addressed to the author directly (refer to the following point).
  • If you want to start a discussion with the author or have a question related to your purchase, please use the support page.