Highcharts's Graph Widget

by
Odoo          
v 10.0 Third Party 8
Download for 10.0 series Deploy on Odoo.sh
You bought this module and need support ? Click here !
Technical name highcharts_widget

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"
                                type="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, please use the developer contact information. They can usually be found in the description.
Please choose a rating from 1 to 5 for this module.