Odoo Help

2

1
5 Answers
3
Avatar

Axel Mendoza Cuba

--Axel Mendoza--
13936
| 8 8 10
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full-time employee trying to understand what to do and how

Reach me at aekroft@gmail.com

Axel Mendoza Cuba
12/8/16, 11:01 PM

Chandni

You just need to extend the proper widget class using include, like:

var GraphWidget = require('web.GraphWidget');
GraphWidget.include({
    display_bar: function () {
        // prepare data for bar chart
        var data, values,
            measure = this.fields[this.measure].string;

        // zero groupbys
        if (this.groupbys.length === 0) {
            data = [{
                values: [{
                    x: measure,
                    y: this.data[0].value}],
                key: measure
            }];
        } 
        // one groupby
        if (this.groupbys.length === 1) {
            values = this.data.map(function (datapt) {
                return {x: datapt.labels, y: datapt.value};
            });
            data = [
                {
                    values: values,
                    key: measure,
                }
            ];
        }
        if (this.groupbys.length > 1) {
            var xlabels = [],
                series = [],
                label, serie, value;
            values = {};
            for (var i = 0; i < this.data.length; i++) {
                label = this.data[i].labels[0];
                serie = this.data[i].labels[1];
                value = this.data[i].value;
                if ((!xlabels.length) || (xlabels[xlabels.length-1] !== label)) {
                    xlabels.push(label);
                }
                series.push(this.data[i].labels[1]);
                if (!(serie in values)) {values[serie] = {};}
                values[serie][label] = this.data[i].value;
            }
            series = _.uniq(series);
            data = [];
            var current_serie, j;
            for (i = 0; i < series.length; i++) {
                current_serie = {values: [], key: series[i]};
                for (j = 0; j < xlabels.length; j++) {
                    current_serie.values.push({
                        x: xlabels[j],
                        y: values[series[i]][xlabels[j]] || 0,
                    });
                }
                data.push(current_serie);
            }
        }
        var svg = d3.select(this.$el[0]).append('svg');
        svg.datum(data);

        svg.transition().duration(0);

        var chart = nv.models.multiBarChart();
        var maxVal = _.max(values, function(v) {return v.y})
        chart.options({
          margin: {left: 12 * String(maxVal && maxVal.y || 0).length},
          delay: 250,
          transition: 10,
          showLegend: _.size(data) <= MAX_LEGEND_LENGTH,
          showXAxis: true,
          showYAxis: true,
          rightAlignYAxis: false,
          stacked: this.stacked,
          reduceXTicks: false,
          rotateLabels: 40,
          showControls: (this.groupbys.length > 1)
        });
        chart.yAxis.tickFormat(function(d) { return formats.format_value(d, { type : 'float' });});

        chart(svg);
        this.to_remove = chart.update;
        nv.utils.onWindowResize(chart.update);
    }
});

Hope this help you

2 Comments
Sprint IT, Chandni Gandhi Finland
12/9/16, 8:55 AM

Hi Axel,

Thanks for your Quick response. I have already did this n it is resolved now. Thank u so much.

Do u know where is the code for the abbreviation of Months and Date everywhere in ODOO?

I am searching but could not find exact.

I tried this:

chart.xAxis.tickFormat(function (d) { return d3.time.format('%b')(new Date(d)); });

Just after the YAXIS, but it only returns the date everytime. It wont work with other values. ONly works When I filter group_by Months n Date.

Sprint IT, Chandni Gandhi Finland
12/9/16, 9:39 AM

I have added as an Answer. Please look into that.

0
Nemwel Keoro Kenya
3/24/17, 5:36 AM

Hi,

How did you get it to work?

I am trying Chandni's answer but when I put the code in my js file it fails to load other modules. I am on version 9.

openerp.route_manager = function(instance, local) {
var _t = instance.web._t,
_lt = instance.web._lt;
var QWeb = instance.web.qweb;

var GraphWidget = require('web.GraphWidget');
GraphWidget.include({display_bar: function (){....}});
};
What am I not getting or failing to do
The error I keep getting is
"error: Some modules could not be started Failed modules:..."
0
Avatar

Chandni Gandhi Finland

--Chandni Gandhi--

8606
| 6 2 6
Helsinki, Finland
--Chandni Gandhi--


Chandni Gandhi Finland
12/9/16, 9:38 AM

Hi,

I want Abbreviation for this: Months and Year. 

Ask a Question
Writer
Keep Informed
0 follower(s)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now