|
@@ -0,0 +1,390 @@
|
|
|
+function DashboardChart3(widget) {
|
|
|
+ "use strict";
|
|
|
+
|
|
|
+ var model = openerp;
|
|
|
+
|
|
|
+ widget.DashboardChartWidget3 = widget.Base.extend({
|
|
|
+ BuildLineChart: function (name,label,data,CurrencyBase,linecolor,backgroundColor) {
|
|
|
+ var self = this;
|
|
|
+ Chart.scaleService.updateScaleDefaults('linear', {
|
|
|
+ ticks: {
|
|
|
+ callback: function(tick) {
|
|
|
+ return tick.toLocaleString('de-DE');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ Chart.defaults.global.tooltips.callbacks.label = function(tooltipItem, data) {
|
|
|
+ var dataset = data.datasets[tooltipItem.datasetIndex];
|
|
|
+ var datasetLabel = dataset.label || '';
|
|
|
+ return datasetLabel + dataset.data[tooltipItem.index].toLocaleString('de-DE');
|
|
|
+ };
|
|
|
+ var chart = new Chart($(name), {
|
|
|
+ type: 'line',
|
|
|
+ data: {
|
|
|
+ labels: label,
|
|
|
+ datasets: [
|
|
|
+ {
|
|
|
+ label: false,
|
|
|
+ data: data,
|
|
|
+ backgroundColor: backgroundColor,
|
|
|
+ borderColor: linecolor,
|
|
|
+ borderWidth: 2,
|
|
|
+ fill: false,
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ options: {
|
|
|
+ responsive: true,
|
|
|
+ responsiveAnimationDuration:10,
|
|
|
+ maintainAspectRatio:false,
|
|
|
+ title: {
|
|
|
+ display: false,
|
|
|
+ },
|
|
|
+ hover: {
|
|
|
+ mode: 'nearest',
|
|
|
+ intersect: true
|
|
|
+ },
|
|
|
+ legend: {
|
|
|
+ display: false,
|
|
|
+ },
|
|
|
+ layout: {
|
|
|
+ padding: {
|
|
|
+ top: 0,
|
|
|
+ bottom: 0,
|
|
|
+ left : 0,
|
|
|
+ rigth: 0,
|
|
|
+ }
|
|
|
+ },
|
|
|
+ events: ['click'],
|
|
|
+ tooltips: {
|
|
|
+ callbacks: {
|
|
|
+ label: function(tooltipItem, data) {
|
|
|
+ var label = data.datasets[tooltipItem.datasetIndex].label || '';
|
|
|
+
|
|
|
+ if (label) {
|
|
|
+ label += ': ';
|
|
|
+ }
|
|
|
+ label += accounting.formatMoney(tooltipItem.yLabel, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator);
|
|
|
+ return label;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ BuildBalanceLineChart: function (name,label,bodySale,bodyPurchase,bodyExpense,CurrencyBase) {
|
|
|
+ var self = this;
|
|
|
+ Chart.scaleService.updateScaleDefaults('linear', {
|
|
|
+ ticks: {
|
|
|
+ callback: function(tick) {
|
|
|
+ return tick.toLocaleString('de-DE');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ Chart.defaults.global.tooltips.callbacks.label = function(tooltipItem, data) {
|
|
|
+ var dataset = data.datasets[tooltipItem.datasetIndex];
|
|
|
+ var datasetLabel = dataset.label || '';
|
|
|
+ return datasetLabel + dataset.data[tooltipItem.index].toLocaleString('de-DE');
|
|
|
+ };
|
|
|
+ var chartData = {
|
|
|
+ labels: label,
|
|
|
+ datasets: [ {
|
|
|
+ type: 'bar',
|
|
|
+ label: 'Ventas',
|
|
|
+ borderColor: '#43a047',
|
|
|
+ backgroundColor: '#43a047',
|
|
|
+ borderWidth: 2,
|
|
|
+ data: bodySale,
|
|
|
+ fill: false,
|
|
|
+ }, {
|
|
|
+ type: 'bar',
|
|
|
+ label: 'Compras',
|
|
|
+ borderColor: '#f9a825',
|
|
|
+ backgroundColor: '#f9a825',
|
|
|
+ data: bodyPurchase,
|
|
|
+ borderWidth: 2,
|
|
|
+ fill: false,
|
|
|
+ }, {
|
|
|
+ type: 'bar',
|
|
|
+ label: 'Gastos',
|
|
|
+ borderColor: '#ef6c00',
|
|
|
+ backgroundColor: '#ef6c00',
|
|
|
+ data: bodyExpense,
|
|
|
+ borderWidth: 2,
|
|
|
+ fill: false,
|
|
|
+ }]
|
|
|
+ };
|
|
|
+ var chart = new Chart($(name),{
|
|
|
+ type: 'bar',
|
|
|
+ data: chartData,
|
|
|
+ options: {
|
|
|
+ responsive: true,
|
|
|
+ responsiveAnimationDuration:10,
|
|
|
+ maintainAspectRatio:false,
|
|
|
+ title: {
|
|
|
+ display: false,
|
|
|
+ },
|
|
|
+ hover: {
|
|
|
+ mode: 'nearest',
|
|
|
+ intersect: true
|
|
|
+ },
|
|
|
+ legend: {
|
|
|
+ display: true,
|
|
|
+ },
|
|
|
+ layout: {
|
|
|
+ padding: {
|
|
|
+ top: 0,
|
|
|
+ bottom: 0,
|
|
|
+ left : 0,
|
|
|
+ rigth: 0,
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // events: ['click'],
|
|
|
+ tooltips: {
|
|
|
+ callbacks: {
|
|
|
+ label: function(tooltipItem, data) {
|
|
|
+ var label = data.datasets[tooltipItem.datasetIndex].label || '';
|
|
|
+
|
|
|
+ if (label) {
|
|
|
+ label += ': ';
|
|
|
+ }
|
|
|
+ label += accounting.formatMoney(tooltipItem.yLabel, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator);
|
|
|
+ return label;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ BuildDoughnutChart: function (name,label,data,CurrencyBase) {
|
|
|
+ var self = this;
|
|
|
+ Chart.scaleService.updateScaleDefaults('linear', {
|
|
|
+ ticks: {
|
|
|
+ callback: function(tick) {
|
|
|
+ return tick.toLocaleString('de-DE');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ Chart.defaults.global.tooltips.callbacks.label = function(tooltipItem, data) {
|
|
|
+ var dataset = data.datasets[tooltipItem.datasetIndex];
|
|
|
+ var datasetLabel = dataset.label || '';
|
|
|
+ return datasetLabel + dataset.data[tooltipItem.index].toLocaleString('de-DE');
|
|
|
+ };
|
|
|
+ var color = [];
|
|
|
+ color.push('#BCCEF4');
|
|
|
+ color.push('#A9E5E3');
|
|
|
+ color.push('#A0D995');
|
|
|
+ color.push('#C5D084');
|
|
|
+ color.push('#FAE187');
|
|
|
+ color.push('#FFBD82');
|
|
|
+ color.push('#FFA8B8');
|
|
|
+ color.push('#E5BEDD');
|
|
|
+ color.push('#C4ABFE');
|
|
|
+ color.push('#D8D8D8');
|
|
|
+ var myBar = new Chart($(name), {
|
|
|
+ type: 'doughnut',
|
|
|
+ data: {
|
|
|
+ labels: label,
|
|
|
+ datasets: [{
|
|
|
+ backgroundColor: color,
|
|
|
+ fill: true,
|
|
|
+ label:false,
|
|
|
+ data: data,
|
|
|
+ }],
|
|
|
+ },
|
|
|
+ options: {
|
|
|
+ responsive: true,
|
|
|
+ responsiveAnimationDuration:10,
|
|
|
+ maintainAspectRatio:false,
|
|
|
+ hover: {
|
|
|
+ mode: 'nearest',
|
|
|
+ intersect: true
|
|
|
+ },
|
|
|
+ title: {
|
|
|
+ display: false,
|
|
|
+ },
|
|
|
+ legend: {
|
|
|
+ display: false,
|
|
|
+ position: 'right',
|
|
|
+ },
|
|
|
+ layout: {
|
|
|
+ padding: {
|
|
|
+ top: 0,
|
|
|
+ bottom: 0,
|
|
|
+ left : 0,
|
|
|
+ rigth: 0,
|
|
|
+ }
|
|
|
+ },
|
|
|
+ tooltips: {
|
|
|
+ callbacks: {
|
|
|
+ label: function(tooltipItem, data) {
|
|
|
+ var label = data.labels[tooltipItem.index] || '';
|
|
|
+ if (label) {
|
|
|
+ label += ': ';
|
|
|
+ }
|
|
|
+ label += accounting.formatMoney(data.datasets[0].data[tooltipItem.index],{
|
|
|
+ symbol: CurrencyBase.symbol,
|
|
|
+ format: "%s%v",
|
|
|
+ precision: CurrencyBase.decimal_places,
|
|
|
+ thousand: CurrencyBase.thousands_separator,
|
|
|
+ decimal: CurrencyBase.decimal_separator,
|
|
|
+ });
|
|
|
+ return label;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ BuildHorizontalBarChart: function (name,CurrencyBase,label,body) {
|
|
|
+ var self = this;
|
|
|
+ Chart.scaleService.updateScaleDefaults('linear', {
|
|
|
+ ticks: {
|
|
|
+ callback: function(tick) {
|
|
|
+ return tick.toLocaleString('de-DE');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ Chart.defaults.global.tooltips.callbacks.label = function(tooltipItem, data) {
|
|
|
+ var dataset = data.datasets[tooltipItem.datasetIndex];
|
|
|
+ var datasetLabel = dataset.label || '';
|
|
|
+ return datasetLabel + dataset.data[tooltipItem.index].toLocaleString('de-DE');
|
|
|
+ };
|
|
|
+
|
|
|
+ // var color = [];
|
|
|
+ // color.push('#BCCEF4');
|
|
|
+ // color.push('#A9E5E3');
|
|
|
+ // color.push('#A0D995');
|
|
|
+ // color.push('#C5D084');
|
|
|
+ // color.push('#FAE187');
|
|
|
+ // color.push('#FFBD82');
|
|
|
+ // color.push('#FFA8B8');
|
|
|
+ // color.push('#E5BEDD');
|
|
|
+ // color.push('#C4ABFE');
|
|
|
+ // color.push('#D8D8D8');
|
|
|
+
|
|
|
+ var chart = new Chart($(name), {
|
|
|
+ type: 'horizontalBar',
|
|
|
+ data: {
|
|
|
+ labels: label,
|
|
|
+ datasets: [
|
|
|
+ {
|
|
|
+ data: body,
|
|
|
+ // backgroundColor: '#43a047',
|
|
|
+ backgroundColor: '#bbdefb',
|
|
|
+ fill: true,
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ options: {
|
|
|
+ responsive: true,
|
|
|
+ responsiveAnimationDuration:10,
|
|
|
+ maintainAspectRatio:false,
|
|
|
+ title: {
|
|
|
+ display: false,
|
|
|
+ },
|
|
|
+ hover: {
|
|
|
+ mode: 'nearest',
|
|
|
+ intersect: true
|
|
|
+ },
|
|
|
+ legend: {
|
|
|
+ display: false,
|
|
|
+ },
|
|
|
+ layout: {
|
|
|
+ padding: {
|
|
|
+ top: 0,
|
|
|
+ bottom: 0,
|
|
|
+ left : 0,
|
|
|
+ rigth: 0,
|
|
|
+ }
|
|
|
+ },
|
|
|
+ tooltips: {
|
|
|
+ callbacks: {
|
|
|
+ label: function(tooltipItem, data) {
|
|
|
+ var label = data.datasets[tooltipItem.datasetIndex].label || '';
|
|
|
+
|
|
|
+ if (label) {
|
|
|
+ label += ': ';
|
|
|
+ }
|
|
|
+ label += accounting.formatMoney(tooltipItem.xLabel, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator);
|
|
|
+ return label;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // events: ['click'],
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ BuildBarChart: function (name,CurrencyBase,label,body) {
|
|
|
+ var self = this;
|
|
|
+ Chart.scaleService.updateScaleDefaults('linear', {
|
|
|
+ ticks: {
|
|
|
+ callback: function(tick) {
|
|
|
+ return tick.toLocaleString('de-DE');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ Chart.defaults.global.tooltips.callbacks.label = function(tooltipItem, data) {
|
|
|
+ var dataset = data.datasets[tooltipItem.datasetIndex];
|
|
|
+ var datasetLabel = dataset.label || '';
|
|
|
+ return datasetLabel + dataset.data[tooltipItem.index].toLocaleString('de-DE');
|
|
|
+ };
|
|
|
+ var chart = new Chart($(name), {
|
|
|
+ type: 'bar',
|
|
|
+ data: {
|
|
|
+ labels: label,
|
|
|
+ datasets: [
|
|
|
+ {
|
|
|
+ data: body,
|
|
|
+ backgroundColor: '#bbdefb',
|
|
|
+ fill: true,
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ options: {
|
|
|
+ responsive: true,
|
|
|
+ responsiveAnimationDuration:10,
|
|
|
+ maintainAspectRatio:false,
|
|
|
+ title: {
|
|
|
+ display: false,
|
|
|
+ },
|
|
|
+ hover: {
|
|
|
+ mode: 'nearest',
|
|
|
+ intersect: true
|
|
|
+ },
|
|
|
+ legend: {
|
|
|
+ display: false,
|
|
|
+ },
|
|
|
+ layout: {
|
|
|
+ padding: {
|
|
|
+ top: 0,
|
|
|
+ bottom: 0,
|
|
|
+ left : 0,
|
|
|
+ rigth: 0,
|
|
|
+ }
|
|
|
+ },
|
|
|
+ tooltips: {
|
|
|
+ callbacks: {
|
|
|
+ label: function(tooltipItem, data) {
|
|
|
+ var label = data.datasets[tooltipItem.datasetIndex].label || '';
|
|
|
+
|
|
|
+ if (label) {
|
|
|
+ label += ': ';
|
|
|
+ }
|
|
|
+ label += accounting.formatMoney(tooltipItem.yLabel, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator);
|
|
|
+ return label;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // events: ['click'],
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ });
|
|
|
+}
|