Browse Source

[FIX] Cambiar Grafico de torta a barra

adrielso 7 years ago
parent
commit
c9db4216b6

+ 14 - 12
static/src/js/widgets/ranking_sales_partner.js

@@ -127,32 +127,34 @@ function ranking_sales_partner (widget) {
             }
 
             var chart = new Chart(this.$el.find(".widget-content").find('canvas'), {
-                type: 'pie',
+                type: 'bar',
                 data: {
                     labels: label,
                     datasets: [
                         {
                             backgroundColor: [  '#EF5350', '#F06292', '#AB47BC', '#7E57C2', '#5C6BC0', '#42A5F5', '#26C6DA', '#26A69A', '#66BB6A', '#9CCC65'],
-                            borderWidth	:0,
                             data: body,
                         }
                     ]
                 },
                 options: {
-                    animation: {
-                        animateScale: true,
-                        animateRotate: true
-                    },
-                    maintainAspectRatio: false,
+                   scales: {
+                       xAxes: [{ stacked: true }],
+                       yAxes: [{ stacked: true }],
+                   },
+                   legend: {
+                       display: false,
+                   },
                     layout: {
-                        padding: 20
-                    },
-                    legend: {
-                        display: false,
+                        padding:{
+                            top: 20,
+                            bottom:0,
+                            left : 0,
+                            rigth:0,
+                        }
                     },
                 }
             });
-
         },
         // llamar a la lista
         showCustomers: function (e) {

+ 19 - 16
static/src/js/widgets/ranking_sales_product.js

@@ -144,7 +144,8 @@ function ranking_sales_product (widget) {
             var label = [];
             var body = [];
             var item;
-            var rank = 5;
+            var rank = 7;
+
             if (ranking.length < rank)
                 rank= ranking.length;
 
@@ -152,37 +153,39 @@ function ranking_sales_product (widget) {
                 if (ranking[i]){
                     item = ranking[i];
                 }
+                var name=item.product.split(' ');
 
-                label.push(item.product);
+                label.push(name[0]+"("+name[name.length-1]+")");
                 body.push(item.qty);
             }
             var chart = new Chart(this.$el.find(".widget-content").find('canvas'), {
-                type: 'pie',
+                // type: 'pie',
+                type: 'bar',
                 data: {
                     labels: label,
                     datasets: [
                         {
                             backgroundColor: [  '#EF5350', '#EC407A', '#AB47BC', '#7E57C2', '#5C6BC0', '#42A5F5', '#26C6DA', '#26A69A', '#66BB6A', '#9CCC65'],
-                            borderWidth	:0,
                             data: body,
                         }
                     ]
                 },
                 options: {
-                    animation: {
-                        animateScale: true,
-                        animateRotate: true
-                    },
-                    maintainAspectRatio: false,
+                   scales: {
+                       xAxes: [{ stacked: true }],
+                       yAxes: [{ stacked: true }],
+                   },
+                   legend: {
+                       display: false,
+                   },
                     layout: {
-                        padding: 20
-                    },
-                    legend: {
-                        display: false,
+                        padding:{
+                            top: 20,
+                            bottom:0,
+                            left : 0,
+                            rigth:0,
+                        }
                     },
-                    tooltips:{
-                        titleFontSize:7,
-                    }
                 }
             });
         },