~openerp-dev/openerp-web/trunk-web_pdf_viewer-pga

« back to all changes in this revision

Viewing changes to addons/web_kanban_sparkline/static/src/js/kanban_sparkline.js

  • Committer: Parth Gajjar(Open ERP)
  • Date: 2013-09-16 11:25:36 UTC
  • mfrom: (3781.1.59 openerp-web)
  • Revision ID: pga@tinyerp.com-20130916112536-5b0zi1yf22wgsuij
merged with openerp-web

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
openerp.web_kanban_sparkline = function (instance) {
 
2
 
 
3
/**
 
4
 * Kanban widgets: Sparkline
 
5
 *
 
6
 */
 
7
 
 
8
instance.web_kanban.SparklineBarWidget = instance.web_kanban.AbstractField.extend({
 
9
    className: "oe_sparkline_bar",
 
10
    start: function() {
 
11
        var self = this;
 
12
        var title = this.$node.html() || this.field.string;
 
13
        setTimeout(function () {
 
14
            var value = _.pluck(self.field.value, 'value');
 
15
            var tooltips = _.pluck(self.field.value, 'tooltip');
 
16
            var sparkline_options = _.extend({
 
17
                    type: 'bar',
 
18
                    barWidth: 5,
 
19
                    height: '20px',
 
20
                    barWidth: 4,
 
21
                    barSpacing: 1,
 
22
                    barColor: '#96d854',
 
23
                    tooltipFormat: '{{offset:offset}} {{value}}',
 
24
                    tooltipValueLookups: {
 
25
                        'offset': tooltips
 
26
                    }
 
27
                }, self.options);
 
28
            self.$el.sparkline(value, sparkline_options);
 
29
            self.$el.tipsy({'delayIn': 0, 'html': true, 'title': function(){return title}, 'gravity': 'n'});
 
30
        }, 0);
 
31
    },
 
32
});
 
33
 
 
34
instance.web_kanban.fields_registry.add("sparkline_bar", "instance.web_kanban.SparklineBarWidget");
 
35
 
 
36
 
 
37
}