[IMP]Container added for tooltip.
[odoo/odoo.git] / addons / web_kanban_sparkline / static / src / js / kanban_sparkline.js
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                     chartRangeMin: 0,
24                     tooltipFormat: '{{offset:offset}} {{value}}',
25                     tooltipValueLookups: {
26                         'offset': tooltips
27                     }
28                 }, self.options);
29             self.$el.sparkline(value, sparkline_options);
30             self.$el.tooltip({'html': true, 'title': function(){return title}, 'placement': 'bottom', 'container': 'body'});
31         }, 0);
32     },
33 });
34
35 instance.web_kanban.fields_registry.add("sparkline_bar", "instance.web_kanban.SparklineBarWidget");
36
37
38 }