diff --git a/.gitignore b/.gitignore index 75bb2042901930f807a588241612a29dd75e34d5..818770fb1bdc0a144e924c9a5940f0b035df8a0d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,75 @@ -.* -*.pyc -!.gitignore +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +/.venv +/.pytest_cache + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +bin/ +build/ +develop-eggs/ +dist/ +eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg +*.eggs + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.cache +nosetests.xml +coverage.xml + +# Translations +*.mo + +# Pycharm +.idea + +# Eclipse +.settings + +# Visual Studio cache/options directory +.vs/ +.vscode + +# OSX Files +.DS_Store + +# Django stuff: +*.log + +# Mr Developer +.mr.developer.cfg +.project +.pydevproject + +# Rope +.ropeproject + +# Sphinx documentation +docs/_build/ + +# Backup files +*~ +*.swp + +# OCA rules +!static/lib/ diff --git a/README.rst b/README.rst old mode 100755 new mode 100644 index 6caa06a698b1ba08edd7507e7a3973da06fe6133..9cf555fd40b0249ca7f218d861e2b53e449b7322 --- a/README.rst +++ b/README.rst @@ -33,4 +33,3 @@ Maintainer :target: https://le-filament.com This module is maintained by Le Filament - diff --git a/__init__.py b/__init__.py index e352eeb90b1ca31078563924292ce9240f8b436c..957992f377d7ce8942a87238397684babc5eb305 100644 --- a/__init__.py +++ b/__init__.py @@ -1,4 +1,4 @@ # Copyright 2021 Le Filament (<http://www.le-filament.com>) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from . import models \ No newline at end of file +from . import models diff --git a/__manifest__.py b/__manifest__.py old mode 100755 new mode 100644 index 1bddc3929a3deded82ba93ed1611cd15ebaba973..c08f61fa39a9e856b51af573a07e6541dee24996 --- a/__manifest__.py +++ b/__manifest__.py @@ -1,26 +1,24 @@ { - 'name': "ACC - Gestion des CDC", - 'summary': "Gestion des Courbes de charges", - 'author': "Le Filament", - 'website': "https://www.le-filament.com", - 'version': '14.0.1.0.1', - 'license': "AGPL-3", - 'depends': [ - 'acc_operation', 'acc_enedis_api' - ], - 'data': [ + "name": "ACC - Gestion des CDC", + "summary": "Gestion des Courbes de charges", + "author": "Le Filament", + "website": "https://www.le-filament.com", + "version": "14.0.1.0.1", + "license": "AGPL-3", + "depends": ["acc_operation", "acc_enedis_api"], + "data": [ "security/ir.model.access.csv", # datas # wizard # views - 'views/acc_operation_views.xml', - 'views/acc_operation_templates.xml', + "views/acc_operation_views.xml", + "views/acc_operation_templates.xml", # 'views/res_partner_views.xml', # views menu ], - 'qweb': [ + "qweb": [ # "static/src/xml/*.xml", ], - 'installable': True, - 'auto_install': False, + "installable": True, + "auto_install": False, } diff --git a/models/__init__.py b/models/__init__.py index dc150385cc796f27b0fa78c9f7c7a04d9e49f32f..571b67b6796fc6c177fa989f337c5697aef29a42 100644 --- a/models/__init__.py +++ b/models/__init__.py @@ -3,4 +3,5 @@ from . import acc_operation from . import acc_operation_graph + # from . import acc_counter diff --git a/models/acc_counter.py b/models/acc_counter.py index 06047222e5db0afc6a50306e854ecfcb8a8f3acc..c4d72a3ab19aaf893ea08353f60e048e09bb91fb 100644 --- a/models/acc_counter.py +++ b/models/acc_counter.py @@ -1,13 +1,13 @@ # Copyright 2021 Le Filament (<http://www.le-filament.com>) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import _, models +from odoo import models DEFAULT_MONTH_RANGE = 3 class AccCounter(models.Model): - _inherit = 'acc.counter' + _inherit = "acc.counter" # ------------------------------------------------------ # Actions @@ -18,17 +18,20 @@ class AccCounter(models.Model): :return: Vue Qweb """ self.ensure_one() - counter_id = self.env['acc.counter'].browse(self.env.context.get('default_counter_id')) + counter_id = self.env["acc.counter"].browse( + self.env.context.get("default_counter_id") + ) action = self.env["ir.actions.actions"]._for_xml_id( - "acc_cdc.acc_operation_action_client_courbes") - action['params'] = { - 'operation_ids': self.operation_id.id, - 'acc_counter_id': counter_id.id + "acc_cdc.acc_operation_action_client_courbes" + ) + action["params"] = { + "operation_ids": self.operation_id.id, + "acc_counter_id": counter_id.id, } - action['context'] = { - 'active_id': self.operation_id.id, - 'active_ids': self.operation_id.ids, - 'search_default_name': self.operation_id.name, - 'search_default_acc_delivery_operation_ids': counter_id.name, + action["context"] = { + "active_id": self.operation_id.id, + "active_ids": self.operation_id.ids, + "search_default_name": self.operation_id.name, + "search_default_acc_delivery_operation_ids": counter_id.name, } - return action \ No newline at end of file + return action diff --git a/models/acc_operation_graph.py b/models/acc_operation_graph.py index 88ab67e65af84901c670239397e9109e847fab54..ecd798388bbed201812a15804721d0c98f7e902b 100644 --- a/models/acc_operation_graph.py +++ b/models/acc_operation_graph.py @@ -1,13 +1,13 @@ # Copyright 2021 Le Filament (<http://www.le-filament.com>) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import _, models +from odoo import models DEFAULT_MONTH_RANGE = 3 class AccOperation(models.Model): - _inherit = 'acc.operation' + _inherit = "acc.operation" def _qweb_prepare_qcontext(self, view_id, domain): values = super()._qweb_prepare_qcontext(view_id, domain) @@ -20,52 +20,67 @@ class AccOperation(models.Model): def _plan_prepare_values(self): values = {} - date_day_start, date_day_end = self.get_last_day('day') + date_day_start, date_day_end = self.get_last_day("day") last_day = date_day_start.strftime("%d %B %Y") date_day_start = date_day_start.strftime("%Y-%m-%d") date_day_end = date_day_end.strftime("%Y-%m-%d") - date_week_start, date_week_end = self.get_last_day('week') - last_week = date_week_start.strftime("%d %B %Y") + '-' + date_week_end.strftime("%d %B %Y") + date_week_start, date_week_end = self.get_last_day("week") + last_week = ( + date_week_start.strftime("%d %B %Y") + + "-" + + date_week_end.strftime("%d %B %Y") + ) date_week_start = date_week_start.strftime("%Y-%m-%d") date_week_end = date_week_end.strftime("%Y-%m-%d") - date_month_start, date_month_end = self.get_last_day('month') - last_month = date_month_start.strftime("%d %B %Y") + '-' + date_month_end.strftime("%d %B %Y") + date_month_start, date_month_end = self.get_last_day("month") + last_month = ( + date_month_start.strftime("%d %B %Y") + + "-" + + date_month_end.strftime("%d %B %Y") + ) date_month_start = date_month_start.strftime("%Y-%m-%d") date_month_end = date_month_end.strftime("%Y-%m-%d") # range_date = date_start.strftime("%d/%m/%Y") + ' - ' + date_end.strftime("%d/%m/%Y") - date_semestre_start, date_semestre_end = self.get_last_day('semestre') - last_semester = date_semestre_start.strftime("%d %B %Y") + '-' + date_semestre_end.strftime("%d %B %Y") + date_semestre_start, date_semestre_end = self.get_last_day("semestre") + last_semester = ( + date_semestre_start.strftime("%d %B %Y") + + "-" + + date_semestre_end.strftime("%d %B %Y") + ) date_semestre_start = date_semestre_start.strftime("%Y-%m-%d") date_semestre_end = date_semestre_end.strftime("%Y-%m-%d") - date_year_start, date_year_end = self.get_last_day('year') - last_year = date_year_start.strftime("%d %B %Y") + '- ' + date_year_end.strftime("%d %B %Y") + date_year_start, date_year_end = self.get_last_day("year") + last_year = ( + date_year_start.strftime("%d %B %Y") + + "- " + + date_year_end.strftime("%d %B %Y") + ) date_year_start = date_year_start.strftime("%Y-%m-%d") date_year_end = date_year_end.strftime("%Y-%m-%d") data_values = { - 'last_day': last_day, - 'last_week': last_week, - 'last_month': last_month, - 'last_semestre': last_semester, - 'last_year': last_year, + "last_day": last_day, + "last_week": last_week, + "last_month": last_month, + "last_semestre": last_semester, + "last_year": last_year, # 'range_date': range_date, - 'date_day_start': date_day_start, - 'date_day_end': date_day_end, - 'date_week_start': date_week_start, - 'date_week_end': date_week_end, - 'date_month_start': date_month_start, - 'date_month_end': date_month_end, - 'date_semestre_start': date_semestre_start, - 'date_semestre_end': date_semestre_end, - 'date_year_start': date_year_start, - 'date_year_end': date_year_end, - + "date_day_start": date_day_start, + "date_day_end": date_day_end, + "date_week_start": date_week_start, + "date_week_end": date_week_end, + "date_month_start": date_month_start, + "date_month_end": date_month_end, + "date_semestre_start": date_semestre_start, + "date_semestre_end": date_semestre_end, + "date_year_start": date_year_start, + "date_year_end": date_year_end, } - values['data_values'] = data_values - return values \ No newline at end of file + values["data_values"] = data_values + return values diff --git a/security/ir.model.access.csv b/security/ir.model.access.csv old mode 100755 new mode 100644 index 2b833a80f0a533b27ca704afcec5ef272828c599..5863e109fe822aa044330be060a78c7d7194f4c2 --- a/security/ir.model.access.csv +++ b/security/ir.model.access.csv @@ -1,2 +1,2 @@ id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink -access_acc_enedis_cdc_portal,acc.enedis.cdc.portal,acc_operation.model_acc_enedis_cdc,base.group_portal,1,0,0,0 \ No newline at end of file +access_acc_enedis_cdc_portal,acc.enedis.cdc.portal,acc_operation.model_acc_enedis_cdc,base.group_portal,1,0,0,0 diff --git a/static/src/js/operation_graph.js b/static/src/js/operation_graph.js index e0b7ff7b1bcf9b72566d6d7ef4e55c7074faba0e..6cc7e9087cf9c7cf4ca6362dee24c03e7b4b10ee 100644 --- a/static/src/js/operation_graph.js +++ b/static/src/js/operation_graph.js @@ -1,15 +1,14 @@ -odoo.define('acc_cdc.operation_graph', function (require) { +odoo.define("acc_cdc.operation_graph", function (require) { "use strict"; - var qweb = require('web.qweb'); - var viewRegistry = require('web.view_registry'); - var core = require('web.core'); - var QWeb = core.qweb; + var qweb = require("web.qweb"); + var viewRegistry = require("web.view_registry"); + var core = require("web.core"); let chartValues; const Renderer = qweb.Renderer.extend({ - events:_.extend({}, qweb.Renderer.prototype.events, { - 'click .o_acc_button': '_onChartClicked', + events: _.extend({}, qweb.Renderer.prototype.events, { + "click .o_acc_button": "_onChartClicked", }), _render: async function () { @@ -21,111 +20,110 @@ odoo.define('acc_cdc.operation_graph', function (require) { var chart_histo_conso; var chart_histo_prod; - if (chart_line_conso != undefined){ + if (chart_line_conso != undefined) { chart_line_conso.destroy(); } - if (chart_line_prod != undefined){ + if (chart_line_prod != undefined) { chart_line_prod.destroy(); } - if (chart_donuts_conso != undefined){ + if (chart_donuts_conso != undefined) { chart_donuts_conso.destroy(); } - if (chart_donuts_prod != undefined){ + if (chart_donuts_prod != undefined) { chart_donuts_prod.destroy(); } - if (chart_histo_conso != undefined){ + if (chart_histo_conso != undefined) { chart_histo_conso.destroy(); } - if (chart_histo_prod != undefined){ + if (chart_histo_prod != undefined) { chart_histo_prod.destroy(); } await this._super(...arguments); var result = self.state.chartValues; - var line_conso = self.$el.find('#line_chart_conso'); - var donuts_conso = self.$el.find('#donuts_chart_conso'); - var histo_conso = self.$el.find('#histo_chart_conso'); - var line_prod = self.$el.find('#line_chart_prod'); - var donuts_prod = self.$el.find('#donuts_chart_prod'); - var histo_prod = self.$el.find('#histo_chart_prod'); + var line_conso = self.$el.find("#line_chart_conso"); + var donuts_conso = self.$el.find("#donuts_chart_conso"); + var histo_conso = self.$el.find("#histo_chart_conso"); + var line_prod = self.$el.find("#line_chart_prod"); + var donuts_prod = self.$el.find("#donuts_chart_prod"); + var histo_prod = self.$el.find("#histo_chart_prod"); - if (result.scale != 'week' && result.scale != 'day'){ + if (result.scale != "week" && result.scale != "day") { line_conso.hide(); line_prod.hide(); } - if (result.scale == 'week' || result.scale == 'day'){ + if (result.scale == "week" || result.scale == "day") { chart_line_conso = new Chart( line_conso, Object.assign({}, result.line_chart_conso_line) ); } - chart_donuts_conso = new Chart( - donuts_conso, - Object.assign({}, result.donuts_chart_conso) - ); -// chart_donuts_conso.config.options.plugins = -// { -// color: "#1f4e56", -// font: { -// weight: "bold", -// size: 16 -// }, -// formatter: (value) => { -// return value + "%"; -// } -// }; -// console.log(chart_donuts_conso); - - chart_histo_conso = new Chart( - histo_conso, - Object.assign({}, result.histo_chart_conso) - ); - - if (result.scale == 'week' || result.scale == 'day'){ + chart_donuts_conso = new Chart( + donuts_conso, + Object.assign({}, result.donuts_chart_conso) + ); + // Chart_donuts_conso.config.options.plugins = + // { + // color: "#1f4e56", + // font: { + // weight: "bold", + // size: 16 + // }, + // formatter: (value) => { + // return value + "%"; + // } + // }; + // console.log(chart_donuts_conso); + + chart_histo_conso = new Chart( + histo_conso, + Object.assign({}, result.histo_chart_conso) + ); + + if (result.scale == "week" || result.scale == "day") { chart_line_prod = new Chart( line_prod, Object.assign({}, result.line_chart_prod_line) ); } - chart_donuts_prod = new Chart( - donuts_prod, - Object.assign({}, result.donuts_chart_prod) - ); + chart_donuts_prod = new Chart( + donuts_prod, + Object.assign({}, result.donuts_chart_prod) + ); - chart_histo_prod = new Chart( - histo_prod, - Object.assign({}, result.histo_chart_prod) - ); - this.$el.find('.o_acc_button').removeClass('active'); + chart_histo_prod = new Chart( + histo_prod, + Object.assign({}, result.histo_chart_prod) + ); + this.$el.find(".o_acc_button").removeClass("active"); if (this.state.scale) { - var $but = this.$el.find('.o_acc_button[data-mode="' + this.state.scale + '"]') - } - else { - var $but = this.$el.find('.o_acc_button[data-mode="month"]') + var $but = this.$el.find( + '.o_acc_button[data-mode="' + this.state.scale + '"]' + ); + } else { + var $but = this.$el.find('.o_acc_button[data-mode="month"]'); } - $but.addClass('active'); - + $but.addClass("active"); }, _onChartClicked: function (e) { e.preventDefault(); var $action = $(e.currentTarget); - $action.addClass('active'); - var context = JSON.parse($action.attr('context').replace(/'/g, '"')); + $action.addClass("active"); + var context = JSON.parse($action.attr("context").replace(/'/g, '"')); var first_day = context.first_day; var last_day = context.last_day; - this.trigger_up('chart_open_action', { - action_name: $action.attr('name'), - action_context: $action.attr('context'), + this.trigger_up("chart_open_action", { + action_name: $action.attr("name"), + action_context: $action.attr("context"), action_first_day: first_day, action_last_day: last_day, }); }, - }); const Model = qweb.Model.extend({ @@ -153,7 +151,7 @@ odoo.define('acc_cdc.operation_graph', function (require) { * @returns {Promise} */ __load: function (params) { - if ('scales' in params) { + if ("scales" in params) { this.scales = params.scales; this.first_day = params.first_day; this.last_day = params.last_day; @@ -165,7 +163,7 @@ odoo.define('acc_cdc.operation_graph', function (require) { * @returns {Promise} */ __reload: function (handle, params) { - if ('scales' in params) { + if ("scales" in params) { this.scales = params.scales; this.first_day = params.first_day; this.last_day = params.last_day; @@ -178,24 +176,30 @@ odoo.define('acc_cdc.operation_graph', function (require) { * @param {Promise} super_def a promise that resolves with a dataPoint id * @returns {Promise -> string} resolves to the dataPoint id */ - _loadChart: function (super_def, params) { + _loadChart: function (super_def) { var self = this; - var acc_counter_id = self._state.context.search_default_acc_delivery_operation_ids - var domain = self._state.domain + var acc_counter_id = + self._state.context.search_default_acc_delivery_operation_ids; + var domain = self._state.domain; var chart_def = this._rpc({ - model: 'acc.operation', - method: 'graph_view', - args: [domain, this.scales, this.first_day, this.last_day, acc_counter_id], + model: "acc.operation", + method: "graph_view", + args: [ + domain, + this.scales, + this.first_day, + this.last_day, + acc_counter_id, + ], context: this._state.context, }); - return Promise.all([super_def, chart_def]).then(function(results) { + return Promise.all([super_def, chart_def]).then(function (results) { var id = results[0]; chartValues = results[1]; self.chartValues[id] = chartValues; return id; }); - }, setScale: function (scale) { @@ -206,13 +210,12 @@ odoo.define('acc_cdc.operation_graph', function (require) { this.first_day = first_day; this.last_day = last_day; }, - }); const Controller = qweb.Controller.extend({ custom_events: _.extend({}, qweb.Controller.prototype.custom_events, { - chart_open_action: '_onChartClicked', - cal_open_action: '_onCalClicked', + chart_open_action: "_onChartClicked", + cal_open_action: "_onCalClicked", }), init: function (parent, model, renderer, params) { @@ -230,10 +233,9 @@ odoo.define('acc_cdc.operation_graph', function (require) { this.model.setScale(e.data.action_name); this.model.setDate(e.data.action_first_day, e.data.action_last_day); var state = this.model.get(); - state.scale = e.data.action_name - var context = e.data.action_context - state.first_day = e.data.action_first_day - state.last_day = e.data.action_last_day + state.scale = e.data.action_name; + state.first_day = e.data.action_first_day; + state.last_day = e.data.action_last_day; this.reload(); }, @@ -242,19 +244,20 @@ odoo.define('acc_cdc.operation_graph', function (require) { * @param {OdooEvent} e */ _onCalClicked: function (e) { - state.date_start = e.data.date_start - state.date_end = e.data.date_end + var state = this.model.get(); + state.date_start = e.data.date_start; + state.date_end = e.data.date_end; this.reload(); }, }); var OperationGraph = qweb.View.extend({ withSearchBar: true, - searchMenuTypes: ['filter', 'favorite'], + searchMenuTypes: ["filter", "favorite"], jsLibs: [ - '/web/static/lib/Chart/Chart.js', - '/acc_cdc/static/src/lib/chartjs-plugin-datalabels/chartjs-plugin-datalabels.min.js', - '/web/static/lib/moment/moment.js', + "/web/static/lib/Chart/Chart.js", + "/acc_cdc/static/src/lib/chartjs-plugin-datalabels/chartjs-plugin-datalabels.min.js", + "/web/static/lib/moment/moment.js", ], config: _.extend({}, qweb.View.prototype.config, { Model: Model, @@ -264,15 +267,14 @@ odoo.define('acc_cdc.operation_graph', function (require) { init: function (viewInfo, params) { this._super.apply(this, arguments); - this.controllerParams.scales = 'month'; - this.loadParams.scales = 'month'; - this.controllerParams.first_day = ''; - this.controllerParams.last_day = ''; - this.loadParams.first_day = ''; - this.loadParams.last_day = ''; + this.controllerParams.scales = "month"; + this.loadParams.scales = "month"; + this.controllerParams.first_day = ""; + this.controllerParams.last_day = ""; + this.loadParams.first_day = ""; + this.loadParams.last_day = ""; }, - }); - viewRegistry.add('operation_graph', OperationGraph); + viewRegistry.add("operation_graph", OperationGraph); }); diff --git a/static/src/lib/chartjs-plugin-datalabels/chartjs-plugin-datalabels.min.js b/static/src/lib/chartjs-plugin-datalabels/chartjs-plugin-datalabels.min.js index 867126cbaa3ba6e55b206a3ce96fe421ea063799..e27a91318cd70e39f6a6f0405825d1d428ffebb4 100644 --- a/static/src/lib/chartjs-plugin-datalabels/chartjs-plugin-datalabels.min.js +++ b/static/src/lib/chartjs-plugin-datalabels/chartjs-plugin-datalabels.min.js @@ -1,7 +1,860 @@ -/*! +/* ! * chartjs-plugin-datalabels v1.0.0 * https://chartjs-plugin-datalabels.netlify.app * (c) 2017-2021 chartjs-plugin-datalabels contributors * Released under the MIT license */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("chart.js")):"function"==typeof define&&define.amd?define(["chart.js"],e):(t="undefined"!=typeof globalThis?globalThis:t||self).ChartDataLabels=e(t.Chart)}(this,(function(t){"use strict";function e(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var r=e(t),n=r.default.helpers,a=function(){if("undefined"!=typeof window){if(window.devicePixelRatio)return window.devicePixelRatio;var t=window.screen;if(t)return(t.deviceXDPI||1)/(t.logicalXDPI||1)}return 1}(),i={toTextLines:function(t){var e,r=[];for(t=[].concat(t);t.length;)"string"==typeof(e=t.pop())?r.unshift.apply(r,e.split("\n")):Array.isArray(e)?t.push.apply(t,e):n.isNullOrUndef(t)||r.unshift(""+e);return r},toFontString:function(t){return!t||n.isNullOrUndef(t.size)||n.isNullOrUndef(t.family)?null:(t.style?t.style+" ":"")+(t.weight?t.weight+" ":"")+t.size+"px "+t.family},textSize:function(t,e,r){var n,a=[].concat(e),i=a.length,o=t.font,l=0;for(t.font=r.string,n=0;n<i;++n)l=Math.max(t.measureText(a[n]).width,l);return t.font=o,{height:i*r.lineHeight,width:l}},parseFont:function(t){var e=r.default.defaults.global,a=n.valueOrDefault(t.size,e.defaultFontSize),o={family:n.valueOrDefault(t.family,e.defaultFontFamily),lineHeight:n.options.toLineHeight(t.lineHeight,a),size:a,style:n.valueOrDefault(t.style,e.defaultFontStyle),weight:n.valueOrDefault(t.weight,null),string:""};return o.string=i.toFontString(o),o},bound:function(t,e,r){return Math.max(t,Math.min(e,r))},arrayDiff:function(t,e){var r,n,a,i,o=t.slice(),l=[];for(r=0,a=e.length;r<a;++r)i=e[r],-1===(n=o.indexOf(i))?l.push([i,1]):o.splice(n,1);for(r=0,a=o.length;r<a;++r)l.push([o[r],-1]);return l},rasterize:function(t){return Math.round(t*a)/a}};function o(t,e){var r=e.x,n=e.y;if(null===r)return{x:0,y:-1};if(null===n)return{x:1,y:0};var a=t.x-r,i=t.y-n,o=Math.sqrt(a*a+i*i);return{x:o?a/o:0,y:o?i/o:-1}}function l(t,e,r){var n=0;return t<r.left?n|=1:t>r.right&&(n|=2),e<r.top?n|=8:e>r.bottom&&(n|=4),n}function s(t,e){var r,n,a=e.anchor,i=t;return e.clamp&&(i=function(t,e){for(var r,n,a,i=t.x0,o=t.y0,s=t.x1,u=t.y1,d=l(i,o,e),f=l(s,u,e);d|f&&!(d&f);)8&(r=d||f)?(n=i+(s-i)*(e.top-o)/(u-o),a=e.top):4&r?(n=i+(s-i)*(e.bottom-o)/(u-o),a=e.bottom):2&r?(a=o+(u-o)*(e.right-i)/(s-i),n=e.right):1&r&&(a=o+(u-o)*(e.left-i)/(s-i),n=e.left),r===d?d=l(i=n,o=a,e):f=l(s=n,u=a,e);return{x0:i,x1:s,y0:o,y1:u}}(i,e.area)),"start"===a?(r=i.x0,n=i.y0):"end"===a?(r=i.x1,n=i.y1):(r=(i.x0+i.x1)/2,n=(i.y0+i.y1)/2),function(t,e,r,n,a){switch(a){case"center":r=n=0;break;case"bottom":r=0,n=1;break;case"right":r=1,n=0;break;case"left":r=-1,n=0;break;case"top":r=0,n=-1;break;case"start":r=-r,n=-n;break;case"end":break;default:a*=Math.PI/180,r=Math.cos(a),n=Math.sin(a)}return{x:t,y:e,vx:r,vy:n}}(r,n,t.vx,t.vy,e.align)}var u=function(t,e){var r=(t.startAngle+t.endAngle)/2,n=Math.cos(r),a=Math.sin(r),i=t.innerRadius,o=t.outerRadius;return s({x0:t.x+n*i,y0:t.y+a*i,x1:t.x+n*o,y1:t.y+a*o,vx:n,vy:a},e)},d=function(t,e){var r=o(t,e.origin),n=r.x*t.radius,a=r.y*t.radius;return s({x0:t.x-n,y0:t.y-a,x1:t.x+n,y1:t.y+a,vx:r.x,vy:r.y},e)},f=function(t,e){var r=o(t,e.origin),n=t.x,a=t.y,i=0,l=0;return t.horizontal?(n=Math.min(t.x,t.base),i=Math.abs(t.base-t.x)):(a=Math.min(t.y,t.base),l=Math.abs(t.base-t.y)),s({x0:n,y0:a+l,x1:n+i,y1:a,vx:r.x,vy:r.y},e)},c=function(t,e){var r=o(t,e.origin);return s({x0:t.x,y0:t.y,x1:t.x,y1:t.y,vx:r.x,vy:r.y},e)},h=r.default.helpers,x=i.rasterize;function y(t){var e=t._model.horizontal,r=t._scale||e&&t._xScale||t._yScale;if(!r)return null;if(void 0!==r.xCenter&&void 0!==r.yCenter)return{x:r.xCenter,y:r.yCenter};var n=r.getBasePixel();return e?{x:n,y:null}:{x:null,y:n}}function v(t,e,r){var n=t.shadowBlur,a=r.stroked,i=x(r.x),o=x(r.y),l=x(r.w);a&&t.strokeText(e,i,o,l),r.filled&&(n&&a&&(t.shadowBlur=0),t.fillText(e,i,o,l),n&&a&&(t.shadowBlur=n))}var b=function(t,e,r,n){var a=this;a._config=t,a._index=n,a._model=null,a._rects=null,a._ctx=e,a._el=r};h.extend(b.prototype,{_modelize:function(t,e,n,a){var o,l=this,s=l._index,x=h.options.resolve,v=i.parseFont(x([n.font,{}],a,s)),b=x([n.color,r.default.defaults.global.defaultFontColor],a,s);return{align:x([n.align,"center"],a,s),anchor:x([n.anchor,"center"],a,s),area:a.chart.chartArea,backgroundColor:x([n.backgroundColor,null],a,s),borderColor:x([n.borderColor,null],a,s),borderRadius:x([n.borderRadius,0],a,s),borderWidth:x([n.borderWidth,0],a,s),clamp:x([n.clamp,!1],a,s),clip:x([n.clip,!1],a,s),color:b,display:t,font:v,lines:e,offset:x([n.offset,0],a,s),opacity:x([n.opacity,1],a,s),origin:y(l._el),padding:h.options.toPadding(x([n.padding,0],a,s)),positioner:(o=l._el,o instanceof r.default.elements.Arc?u:o instanceof r.default.elements.Point?d:o instanceof r.default.elements.Rectangle?f:c),rotation:x([n.rotation,0],a,s)*(Math.PI/180),size:i.textSize(l._ctx,e,v),textAlign:x([n.textAlign,"start"],a,s),textShadowBlur:x([n.textShadowBlur,0],a,s),textShadowColor:x([n.textShadowColor,b],a,s),textStrokeColor:x([n.textStrokeColor,b],a,s),textStrokeWidth:x([n.textStrokeWidth,0],a,s)}},update:function(t){var e,r,n,a=this,o=null,l=null,s=a._index,u=a._config,d=h.options.resolve([u.display,!0],t,s);d&&(e=t.dataset.data[s],r=h.valueOrDefault(h.callback(u.formatter,[e,t]),e),(n=h.isNullOrUndef(r)?[]:i.toTextLines(r)).length&&(l=function(t){var e=t.borderWidth||0,r=t.padding,n=t.size.height,a=t.size.width,i=-a/2,o=-n/2;return{frame:{x:i-r.left-e,y:o-r.top-e,w:a+r.width+2*e,h:n+r.height+2*e},text:{x:i,y:o,w:a,h:n}}}(o=a._modelize(d,n,u,t)))),a._model=o,a._rects=l},geometry:function(){return this._rects?this._rects.frame:{}},rotation:function(){return this._model?this._model.rotation:0},visible:function(){return this._model&&this._model.opacity},model:function(){return this._model},draw:function(t,e){var r,n=t.ctx,a=this._model,o=this._rects;this.visible()&&(n.save(),a.clip&&(r=a.area,n.beginPath(),n.rect(r.left,r.top,r.right-r.left,r.bottom-r.top),n.clip()),n.globalAlpha=i.bound(0,a.opacity,1),n.translate(x(e.x),x(e.y)),n.rotate(a.rotation),function(t,e,r){var n=r.backgroundColor,a=r.borderColor,i=r.borderWidth;(n||a&&i)&&(t.beginPath(),h.canvas.roundedRect(t,x(e.x)+i/2,x(e.y)+i/2,x(e.w)-i,x(e.h)-i,r.borderRadius),t.closePath(),n&&(t.fillStyle=n,t.fill()),a&&i&&(t.strokeStyle=a,t.lineWidth=i,t.lineJoin="miter",t.stroke()))}(n,o.frame,a),function(t,e,r,n){var a,i=n.textAlign,o=n.color,l=!!o,s=n.font,u=e.length,d=n.textStrokeColor,f=n.textStrokeWidth,c=d&&f;if(u&&(l||c))for(r=function(t,e,r){var n=r.lineHeight,a=t.w,i=t.x;return"center"===e?i+=a/2:"end"!==e&&"right"!==e||(i+=a),{h:n,w:a,x:i,y:t.y+n/2}}(r,i,s),t.font=s.string,t.textAlign=i,t.textBaseline="middle",t.shadowBlur=n.textShadowBlur,t.shadowColor=n.textShadowColor,l&&(t.fillStyle=o),c&&(t.lineJoin="round",t.lineWidth=f,t.strokeStyle=d),a=0,u=e.length;a<u;++a)v(t,e[a],{stroked:c,filled:l,w:r.w,x:r.x,y:r.y+r.h*a})}(n,a.lines,o.text,a),n.restore())}});var _=r.default.helpers,p=Number.MIN_SAFE_INTEGER||-9007199254740991,g=Number.MAX_SAFE_INTEGER||9007199254740991;function m(t,e,r){var n=Math.cos(r),a=Math.sin(r),i=e.x,o=e.y;return{x:i+n*(t.x-i)-a*(t.y-o),y:o+a*(t.x-i)+n*(t.y-o)}}function w(t,e){var r,n,a,i,o,l=g,s=p,u=e.origin;for(r=0;r<t.length;++r)a=(n=t[r]).x-u.x,i=n.y-u.y,o=e.vx*a+e.vy*i,l=Math.min(l,o),s=Math.max(s,o);return{min:l,max:s}}function k(t,e){var r=e.x-t.x,n=e.y-t.y,a=Math.sqrt(r*r+n*n);return{vx:(e.x-t.x)/a,vy:(e.y-t.y)/a,origin:t,ln:a}}var M=function(){this._rotation=0,this._rect={x:0,y:0,w:0,h:0}};function S(t,e,r){var n=e.positioner(t,e),a=n.vx,i=n.vy;if(!a&&!i)return{x:n.x,y:n.y};var o=r.w,l=r.h,s=e.rotation,u=Math.abs(o/2*Math.cos(s))+Math.abs(l/2*Math.sin(s)),d=Math.abs(o/2*Math.sin(s))+Math.abs(l/2*Math.cos(s)),f=1/Math.max(Math.abs(a),Math.abs(i));return u*=a*f,d*=i*f,u+=e.offset*a,d+=e.offset*i,{x:n.x+u,y:n.y+d}}_.extend(M.prototype,{center:function(){var t=this._rect;return{x:t.x+t.w/2,y:t.y+t.h/2}},update:function(t,e,r){this._rotation=r,this._rect={x:e.x+t.x,y:e.y+t.y,w:e.w,h:e.h}},contains:function(t){var e=this,r=e._rect;return!((t=m(t,e.center(),-e._rotation)).x<r.x-1||t.y<r.y-1||t.x>r.x+r.w+2||t.y>r.y+r.h+2)},intersects:function(t){var e,r,n,a=this._points(),i=t._points(),o=[k(a[0],a[1]),k(a[0],a[3])];for(this._rotation!==t._rotation&&o.push(k(i[0],i[1]),k(i[0],i[3])),e=0;e<o.length;++e)if(r=w(a,o[e]),n=w(i,o[e]),r.max<n.min||n.max<r.min)return!1;return!0},_points:function(){var t=this,e=t._rect,r=t._rotation,n=t.center();return[m({x:e.x,y:e.y},n,r),m({x:e.x+e.w,y:e.y},n,r),m({x:e.x+e.w,y:e.y+e.h},n,r),m({x:e.x,y:e.y+e.h},n,r)]}});var $={prepare:function(t){var e,r,n,a,i,o=[];for(e=0,n=t.length;e<n;++e)for(r=0,a=t[e].length;r<a;++r)i=t[e][r],o.push(i),i.$layout={_box:new M,_hidable:!1,_visible:!0,_set:e,_idx:r};return o.sort((function(t,e){var r=t.$layout,n=e.$layout;return r._idx===n._idx?n._set-r._set:n._idx-r._idx})),this.update(o),o},update:function(t){var e,r,n,a,i,o=!1;for(e=0,r=t.length;e<r;++e)a=(n=t[e]).model(),(i=n.$layout)._hidable=a&&"auto"===a.display,i._visible=n.visible(),o|=i._hidable;o&&function(t){var e,r,n,a,i,o;for(e=0,r=t.length;e<r;++e)(a=(n=t[e]).$layout)._visible&&(i=n.geometry(),o=S(n._el._model,n.model(),i),a._box.update(o,i,n.rotation()));(function(t,e){var r,n,a,i;for(r=t.length-1;r>=0;--r)for(a=t[r].$layout,n=r-1;n>=0&&a._visible;--n)(i=t[n].$layout)._visible&&a._box.intersects(i._box)&&e(a,i)})(t,(function(t,e){var r=t._hidable,n=e._hidable;r&&n||n?e._visible=!1:r&&(t._visible=!1)}))}(t)},lookup:function(t,e){var r,n;for(r=t.length-1;r>=0;--r)if((n=t[r].$layout)&&n._visible&&n._box.contains(e))return t[r];return null},draw:function(t,e){var r,n,a,i,o,l;for(r=0,n=e.length;r<n;++r)(i=(a=e[r]).$layout)._visible&&(o=a.geometry(),l=S(a._el._view,a.model(),o),i._box.update(l,o,a.rotation()),a.draw(t,l))}},C=r.default.helpers,z={align:"center",anchor:"center",backgroundColor:null,borderColor:null,borderRadius:0,borderWidth:0,clamp:!1,clip:!1,color:void 0,display:!0,font:{family:void 0,lineHeight:1.2,size:void 0,style:void 0,weight:null},formatter:function(t){if(C.isNullOrUndef(t))return null;var e,r,n,a=t;if(C.isObject(t))if(C.isNullOrUndef(t.label))if(C.isNullOrUndef(t.r))for(a="",n=0,r=(e=Object.keys(t)).length;n<r;++n)a+=(0!==n?", ":"")+e[n]+": "+t[e[n]];else a=t.r;else a=t.label;return""+a},labels:void 0,listeners:{},offset:4,opacity:1,padding:{top:4,right:4,bottom:4,left:4},rotation:0,textAlign:"start",textStrokeColor:void 0,textStrokeWidth:0,textShadowBlur:0,textShadowColor:void 0},A=r.default.helpers,O="$default";function D(t,e,r){if(e){var n,a=r.$context,i=r.$groups;e[i._set]&&(n=e[i._set][i._key])&&!0===A.callback(n,[a])&&(t.$datalabels._dirty=!0,r.update(a))}}function N(t,e){var r,n,a=t.$datalabels,i=a._listeners;if(i.enter||i.leave){if("mousemove"===e.type)n=$.lookup(a._labels,e);else if("mouseout"!==e.type)return;r=a._hovered,a._hovered=n,function(t,e,r,n){var a,i;(r||n)&&(r?n?r!==n&&(i=a=!0):i=!0:a=!0,i&&D(t,e.leave,r),a&&D(t,e.enter,n))}(t,i,r,n)}}return r.default.defaults.global.plugins.datalabels=z,{id:"datalabels",beforeInit:function(t){t.$datalabels={_actives:[]}},beforeUpdate:function(t){var e=t.$datalabels;e._listened=!1,e._listeners={},e._datasets=[],e._labels=[]},afterDatasetUpdate:function(t,e,r){var n,a,i,o,l,s,u,d,f=e.index,c=t.$datalabels,h=c._datasets[f]=[],x=t.isDatasetVisible(f),y=t.data.datasets[f],v=function(t,e){var r,n,a,i=t.datalabels,o=[];return!1===i?null:(!0===i&&(i={}),e=A.merge({},[e,i]),n=e.labels||{},a=Object.keys(n),delete e.labels,a.length?a.forEach((function(t){n[t]&&o.push(A.merge({},[e,n[t],{_key:t}]))})):o.push(e),r=o.reduce((function(t,e){return A.each(e.listeners||{},(function(r,n){t[n]=t[n]||{},t[n][e._key||O]=r})),delete e.listeners,t}),{}),{labels:o,listeners:r})}(y,r),_=e.meta.data||[],p=t.ctx;for(p.save(),n=0,i=_.length;n<i;++n)if((u=_[n]).$datalabels=[],x&&u&&!u.hidden&&!u._model.skip)for(a=0,o=v.labels.length;a<o;++a)s=(l=v.labels[a])._key,(d=new b(l,p,u,n)).$groups={_set:f,_key:s||O},d.$context={active:!1,chart:t,dataIndex:n,dataset:y,datasetIndex:f},d.update(d.$context),u.$datalabels.push(d),h.push(d);p.restore(),A.merge(c._listeners,v.listeners,{merger:function(t,r,n){r[t]=r[t]||{},r[t][e.index]=n[t],c._listened=!0}})},afterUpdate:function(t,e){t.$datalabels._labels=$.prepare(t.$datalabels._datasets,e)},afterDatasetsDraw:function(t){$.draw(t,t.$datalabels._labels)},beforeEvent:function(t,e){if(t.$datalabels._listened)switch(e.type){case"mousemove":case"mouseout":N(t,e);break;case"click":!function(t,e){var r=t.$datalabels,n=r._listeners.click,a=n&&$.lookup(r._labels,e);a&&D(t,n,a)}(t,e)}},afterEvent:function(t){var e,n,a,o,l,s,u,d=t.$datalabels,f=d._actives,c=d._actives=t.lastActive||[],h=i.arrayDiff(f,c);for(e=0,n=h.length;e<n;++e)if((l=h[e])[1])for(a=0,o=(u=l[0].$datalabels||[]).length;a<o;++a)(s=u[a]).$context.active=1===l[1],s.update(s.$context);(d._dirty||h.length)&&($.update(d._labels),function(t){if(!t.animating){for(var e=r.default.animationService.animations,n=0,a=e.length;n<a;++n)if(e[n].chart===t)return;t.render({duration:1,lazy:!0})}}(t)),delete d._dirty}}})); +!(function (t, e) { + typeof exports === "object" && typeof module !== "undefined" + ? (module.exports = e(require("chart.js"))) + : typeof define === "function" && define.amd + ? define(["chart.js"], e) + : ((t = + typeof globalThis !== "undefined" + ? globalThis + : t || self).ChartDataLabels = e(t.Chart)); +})(this, function (t) { + "use strict"; + function e(t) { + return t && typeof t === "object" && "default" in t ? t : {default: t}; + } + var r = e(t), + n = r.default.helpers, + a = (function () { + if (typeof window !== "undefined") { + if (window.devicePixelRatio) return window.devicePixelRatio; + var t = window.screen; + if (t) return (t.deviceXDPI || 1) / (t.logicalXDPI || 1); + } + return 1; + })(), + i = { + toTextLines: function (t) { + var e, + r = []; + for (t = [].concat(t); t.length; ) + typeof (e = t.pop()) === "string" + ? r.unshift.apply(r, e.split("\n")) + : Array.isArray(e) + ? t.push.apply(t, e) + : n.isNullOrUndef(t) || r.unshift(String(e)); + return r; + }, + toFontString: function (t) { + return !t || n.isNullOrUndef(t.size) || n.isNullOrUndef(t.family) + ? null + : (t.style ? t.style + " " : "") + + (t.weight ? t.weight + " " : "") + + t.size + + "px " + + t.family; + }, + textSize: function (t, e, r) { + var n, + a = [].concat(e), + i = a.length, + o = t.font, + l = 0; + for (t.font = r.string, n = 0; n < i; ++n) + l = Math.max(t.measureText(a[n]).width, l); + return (t.font = o), {height: i * r.lineHeight, width: l}; + }, + parseFont: function (t) { + var e = r.default.defaults.global, + a = n.valueOrDefault(t.size, e.defaultFontSize), + o = { + family: n.valueOrDefault(t.family, e.defaultFontFamily), + lineHeight: n.options.toLineHeight(t.lineHeight, a), + size: a, + style: n.valueOrDefault(t.style, e.defaultFontStyle), + weight: n.valueOrDefault(t.weight, null), + string: "", + }; + return (o.string = i.toFontString(o)), o; + }, + bound: function (t, e, r) { + return Math.max(t, Math.min(e, r)); + }, + arrayDiff: function (t, e) { + var r, + n, + a, + i, + o = t.slice(), + l = []; + for (r = 0, a = e.length; r < a; ++r) + (i = e[r]), + (n = o.indexOf(i)) === -1 ? l.push([i, 1]) : o.splice(n, 1); + for (r = 0, a = o.length; r < a; ++r) l.push([o[r], -1]); + return l; + }, + rasterize: function (t) { + return Math.round(t * a) / a; + }, + }; + function o(t, e) { + var r = e.x, + n = e.y; + if (r === null) return {x: 0, y: -1}; + if (n === null) return {x: 1, y: 0}; + var a = t.x - r, + i = t.y - n, + o = Math.sqrt(a * a + i * i); + return {x: o ? a / o : 0, y: o ? i / o : -1}; + } + function l(t, e, r) { + var n = 0; + return ( + t < r.left ? (n |= 1) : t > r.right && (n |= 2), + e < r.top ? (n |= 8) : e > r.bottom && (n |= 4), + n + ); + } + function s(t, e) { + var r, + n, + a = e.anchor, + i = t; + return ( + e.clamp && + (i = (function (t, e) { + for ( + var r, + n, + a, + i = t.x0, + o = t.y0, + s = t.x1, + u = t.y1, + d = l(i, o, e), + f = l(s, u, e); + d | f && !(d & f); + + ) + 8 & (r = d || f) + ? ((n = i + ((s - i) * (e.top - o)) / (u - o)), (a = e.top)) + : 4 & r + ? ((n = i + ((s - i) * (e.bottom - o)) / (u - o)), + (a = e.bottom)) + : 2 & r + ? ((a = o + ((u - o) * (e.right - i)) / (s - i)), + (n = e.right)) + : 1 & r && + ((a = o + ((u - o) * (e.left - i)) / (s - i)), + (n = e.left)), + r === d + ? (d = l((i = n), (o = a), e)) + : (f = l((s = n), (u = a), e)); + return {x0: i, x1: s, y0: o, y1: u}; + })(i, e.area)), + a === "start" + ? ((r = i.x0), (n = i.y0)) + : a === "end" + ? ((r = i.x1), (n = i.y1)) + : ((r = (i.x0 + i.x1) / 2), (n = (i.y0 + i.y1) / 2)), + (function (t, e, r, n, a) { + switch (a) { + case "center": + r = n = 0; + break; + case "bottom": + (r = 0), (n = 1); + break; + case "right": + (r = 1), (n = 0); + break; + case "left": + (r = -1), (n = 0); + break; + case "top": + (r = 0), (n = -1); + break; + case "start": + (r = -r), (n = -n); + break; + case "end": + break; + default: + (a *= Math.PI / 180), (r = Math.cos(a)), (n = Math.sin(a)); + } + return {x: t, y: e, vx: r, vy: n}; + })(r, n, t.vx, t.vy, e.align) + ); + } + var u = function (t, e) { + var r = (t.startAngle + t.endAngle) / 2, + n = Math.cos(r), + a = Math.sin(r), + i = t.innerRadius, + o = t.outerRadius; + return s( + { + x0: t.x + n * i, + y0: t.y + a * i, + x1: t.x + n * o, + y1: t.y + a * o, + vx: n, + vy: a, + }, + e + ); + }, + d = function (t, e) { + var r = o(t, e.origin), + n = r.x * t.radius, + a = r.y * t.radius; + return s( + {x0: t.x - n, y0: t.y - a, x1: t.x + n, y1: t.y + a, vx: r.x, vy: r.y}, + e + ); + }, + f = function (t, e) { + var r = o(t, e.origin), + n = t.x, + a = t.y, + i = 0, + l = 0; + return ( + t.horizontal + ? ((n = Math.min(t.x, t.base)), (i = Math.abs(t.base - t.x))) + : ((a = Math.min(t.y, t.base)), (l = Math.abs(t.base - t.y))), + s({x0: n, y0: a + l, x1: n + i, y1: a, vx: r.x, vy: r.y}, e) + ); + }, + c = function (t, e) { + var r = o(t, e.origin); + return s({x0: t.x, y0: t.y, x1: t.x, y1: t.y, vx: r.x, vy: r.y}, e); + }, + h = r.default.helpers, + x = i.rasterize; + function y(t) { + var e = t._model.horizontal, + r = t._scale || (e && t._xScale) || t._yScale; + if (!r) return null; + if (void 0 !== r.xCenter && void 0 !== r.yCenter) + return {x: r.xCenter, y: r.yCenter}; + var n = r.getBasePixel(); + return e ? {x: n, y: null} : {x: null, y: n}; + } + function v(t, e, r) { + var n = t.shadowBlur, + a = r.stroked, + i = x(r.x), + o = x(r.y), + l = x(r.w); + a && t.strokeText(e, i, o, l), + r.filled && + (n && a && (t.shadowBlur = 0), + t.fillText(e, i, o, l), + n && a && (t.shadowBlur = n)); + } + var b = function (t, e, r, n) { + var a = this; + (a._config = t), + (a._index = n), + (a._model = null), + (a._rects = null), + (a._ctx = e), + (a._el = r); + }; + h.extend(b.prototype, { + _modelize: function (t, e, n, a) { + var o, + l = this, + s = l._index, + x = h.options.resolve, + v = i.parseFont(x([n.font, {}], a, s)), + b = x([n.color, r.default.defaults.global.defaultFontColor], a, s); + return { + align: x([n.align, "center"], a, s), + anchor: x([n.anchor, "center"], a, s), + area: a.chart.chartArea, + backgroundColor: x([n.backgroundColor, null], a, s), + borderColor: x([n.borderColor, null], a, s), + borderRadius: x([n.borderRadius, 0], a, s), + borderWidth: x([n.borderWidth, 0], a, s), + clamp: x([n.clamp, !1], a, s), + clip: x([n.clip, !1], a, s), + color: b, + display: t, + font: v, + lines: e, + offset: x([n.offset, 0], a, s), + opacity: x([n.opacity, 1], a, s), + origin: y(l._el), + padding: h.options.toPadding(x([n.padding, 0], a, s)), + positioner: + ((o = l._el), + o instanceof r.default.elements.Arc + ? u + : o instanceof r.default.elements.Point + ? d + : o instanceof r.default.elements.Rectangle + ? f + : c), + rotation: x([n.rotation, 0], a, s) * (Math.PI / 180), + size: i.textSize(l._ctx, e, v), + textAlign: x([n.textAlign, "start"], a, s), + textShadowBlur: x([n.textShadowBlur, 0], a, s), + textShadowColor: x([n.textShadowColor, b], a, s), + textStrokeColor: x([n.textStrokeColor, b], a, s), + textStrokeWidth: x([n.textStrokeWidth, 0], a, s), + }; + }, + update: function (t) { + var e, + r, + n, + a = this, + o = null, + l = null, + s = a._index, + u = a._config, + d = h.options.resolve([u.display, !0], t, s); + d && + ((e = t.dataset.data[s]), + (r = h.valueOrDefault(h.callback(u.formatter, [e, t]), e)), + (n = h.isNullOrUndef(r) ? [] : i.toTextLines(r)).length && + (l = (function (t) { + var e = t.borderWidth || 0, + r = t.padding, + n = t.size.height, + a = t.size.width, + i = -a / 2, + o = -n / 2; + return { + frame: { + x: i - r.left - e, + y: o - r.top - e, + w: a + r.width + 2 * e, + h: n + r.height + 2 * e, + }, + text: {x: i, y: o, w: a, h: n}, + }; + })((o = a._modelize(d, n, u, t))))), + (a._model = o), + (a._rects = l); + }, + geometry: function () { + return this._rects ? this._rects.frame : {}; + }, + rotation: function () { + return this._model ? this._model.rotation : 0; + }, + visible: function () { + return this._model && this._model.opacity; + }, + model: function () { + return this._model; + }, + draw: function (t, e) { + var r, + n = t.ctx, + a = this._model, + o = this._rects; + this.visible() && + (n.save(), + a.clip && + ((r = a.area), + n.beginPath(), + n.rect(r.left, r.top, r.right - r.left, r.bottom - r.top), + n.clip()), + (n.globalAlpha = i.bound(0, a.opacity, 1)), + n.translate(x(e.x), x(e.y)), + n.rotate(a.rotation), + (function (t, e, r) { + var n = r.backgroundColor, + a = r.borderColor, + i = r.borderWidth; + (n || (a && i)) && + (t.beginPath(), + h.canvas.roundedRect( + t, + x(e.x) + i / 2, + x(e.y) + i / 2, + x(e.w) - i, + x(e.h) - i, + r.borderRadius + ), + t.closePath(), + n && ((t.fillStyle = n), t.fill()), + a && + i && + ((t.strokeStyle = a), + (t.lineWidth = i), + (t.lineJoin = "miter"), + t.stroke())); + })(n, o.frame, a), + (function (t, e, r, n) { + var a, + i = n.textAlign, + o = n.color, + l = Boolean(o), + s = n.font, + u = e.length, + d = n.textStrokeColor, + f = n.textStrokeWidth, + c = d && f; + if (u && (l || c)) + for ( + r = (function (t, e, r) { + var n = r.lineHeight, + a = t.w, + i = t.x; + return ( + e === "center" + ? (i += a / 2) + : (e !== "end" && e !== "right") || (i += a), + {h: n, w: a, x: i, y: t.y + n / 2} + ); + })(r, i, s), + t.font = s.string, + t.textAlign = i, + t.textBaseline = "middle", + t.shadowBlur = n.textShadowBlur, + t.shadowColor = n.textShadowColor, + l && (t.fillStyle = o), + c && + ((t.lineJoin = "round"), + (t.lineWidth = f), + (t.strokeStyle = d)), + a = 0, + u = e.length; + a < u; + ++a + ) + v(t, e[a], { + stroked: c, + filled: l, + w: r.w, + x: r.x, + y: r.y + r.h * a, + }); + })(n, a.lines, o.text, a), + n.restore()); + }, + }); + var _ = r.default.helpers, + p = Number.MIN_SAFE_INTEGER || -9007199254740991, + g = Number.MAX_SAFE_INTEGER || 9007199254740991; + function m(t, e, r) { + var n = Math.cos(r), + a = Math.sin(r), + i = e.x, + o = e.y; + return { + x: i + n * (t.x - i) - a * (t.y - o), + y: o + a * (t.x - i) + n * (t.y - o), + }; + } + function w(t, e) { + var r, + n, + a, + i, + o, + l = g, + s = p, + u = e.origin; + for (r = 0; r < t.length; ++r) + (a = (n = t[r]).x - u.x), + (i = n.y - u.y), + (o = e.vx * a + e.vy * i), + (l = Math.min(l, o)), + (s = Math.max(s, o)); + return {min: l, max: s}; + } + function k(t, e) { + var r = e.x - t.x, + n = e.y - t.y, + a = Math.sqrt(r * r + n * n); + return {vx: (e.x - t.x) / a, vy: (e.y - t.y) / a, origin: t, ln: a}; + } + var M = function () { + (this._rotation = 0), (this._rect = {x: 0, y: 0, w: 0, h: 0}); + }; + function S(t, e, r) { + var n = e.positioner(t, e), + a = n.vx, + i = n.vy; + if (!a && !i) return {x: n.x, y: n.y}; + var o = r.w, + l = r.h, + s = e.rotation, + u = Math.abs((o / 2) * Math.cos(s)) + Math.abs((l / 2) * Math.sin(s)), + d = Math.abs((o / 2) * Math.sin(s)) + Math.abs((l / 2) * Math.cos(s)), + f = 1 / Math.max(Math.abs(a), Math.abs(i)); + return ( + (u *= a * f), + (d *= i * f), + (u += e.offset * a), + (d += e.offset * i), + {x: n.x + u, y: n.y + d} + ); + } + _.extend(M.prototype, { + center: function () { + var t = this._rect; + return {x: t.x + t.w / 2, y: t.y + t.h / 2}; + }, + update: function (t, e, r) { + (this._rotation = r), + (this._rect = {x: e.x + t.x, y: e.y + t.y, w: e.w, h: e.h}); + }, + contains: function (t) { + var e = this, + r = e._rect; + return !( + (t = m(t, e.center(), -e._rotation)).x < r.x - 1 || + t.y < r.y - 1 || + t.x > r.x + r.w + 2 || + t.y > r.y + r.h + 2 + ); + }, + intersects: function (t) { + var e, + r, + n, + a = this._points(), + i = t._points(), + o = [k(a[0], a[1]), k(a[0], a[3])]; + for ( + this._rotation !== t._rotation && o.push(k(i[0], i[1]), k(i[0], i[3])), + e = 0; + e < o.length; + ++e + ) + if ( + ((r = w(a, o[e])), (n = w(i, o[e])), r.max < n.min || n.max < r.min) + ) + return !1; + return !0; + }, + _points: function () { + var t = this, + e = t._rect, + r = t._rotation, + n = t.center(); + return [ + m({x: e.x, y: e.y}, n, r), + m({x: e.x + e.w, y: e.y}, n, r), + m({x: e.x + e.w, y: e.y + e.h}, n, r), + m({x: e.x, y: e.y + e.h}, n, r), + ]; + }, + }); + var $ = { + prepare: function (t) { + var e, + r, + n, + a, + i, + o = []; + for (e = 0, n = t.length; e < n; ++e) + for (r = 0, a = t[e].length; r < a; ++r) + (i = t[e][r]), + o.push(i), + (i.$layout = { + _box: new M(), + _hidable: !1, + _visible: !0, + _set: e, + _idx: r, + }); + return ( + o.sort(function (t, e) { + var r = t.$layout, + n = e.$layout; + return r._idx === n._idx ? n._set - r._set : n._idx - r._idx; + }), + this.update(o), + o + ); + }, + update: function (t) { + var e, + r, + n, + a, + i, + o = !1; + for (e = 0, r = t.length; e < r; ++e) + (a = (n = t[e]).model()), + ((i = n.$layout)._hidable = a && a.display === "auto"), + (i._visible = n.visible()), + (o |= i._hidable); + o && + (function (t) { + var e, r, n, a, i, o; + for (e = 0, r = t.length; e < r; ++e) + (a = (n = t[e]).$layout)._visible && + ((i = n.geometry()), + (o = S(n._el._model, n.model(), i)), + a._box.update(o, i, n.rotation())); + (function (t, e) { + var r, n, a, i; + for (r = t.length - 1; r >= 0; --r) + for ( + a = t[r].$layout, n = r - 1; + n >= 0 && a._visible; + --n + ) + (i = t[n].$layout)._visible && + a._box.intersects(i._box) && + e(a, i); + })(t, function (t, e) { + var r = t._hidable, + n = e._hidable; + (r && n) || n ? (e._visible = !1) : r && (t._visible = !1); + }); + })(t); + }, + lookup: function (t, e) { + var r, n; + for (r = t.length - 1; r >= 0; --r) + if ((n = t[r].$layout) && n._visible && n._box.contains(e)) + return t[r]; + return null; + }, + draw: function (t, e) { + var r, n, a, i, o, l; + for (r = 0, n = e.length; r < n; ++r) + (i = (a = e[r]).$layout)._visible && + ((o = a.geometry()), + (l = S(a._el._view, a.model(), o)), + i._box.update(l, o, a.rotation()), + a.draw(t, l)); + }, + }, + C = r.default.helpers, + z = { + align: "center", + anchor: "center", + backgroundColor: null, + borderColor: null, + borderRadius: 0, + borderWidth: 0, + clamp: !1, + clip: !1, + color: void 0, + display: !0, + font: { + family: void 0, + lineHeight: 1.2, + size: void 0, + style: void 0, + weight: null, + }, + formatter: function (t) { + if (C.isNullOrUndef(t)) return null; + var e, + r, + n, + a = t; + if (C.isObject(t)) + if (C.isNullOrUndef(t.label)) + if (C.isNullOrUndef(t.r)) + for ( + a = "", n = 0, r = (e = Object.keys(t)).length; + n < r; + ++n + ) + a += (n !== 0 ? ", " : "") + e[n] + ": " + t[e[n]]; + else a = t.r; + else a = t.label; + return String(a); + }, + labels: void 0, + listeners: {}, + offset: 4, + opacity: 1, + padding: {top: 4, right: 4, bottom: 4, left: 4}, + rotation: 0, + textAlign: "start", + textStrokeColor: void 0, + textStrokeWidth: 0, + textShadowBlur: 0, + textShadowColor: void 0, + }, + A = r.default.helpers, + O = "$default"; + function D(t, e, r) { + if (e) { + var n, + a = r.$context, + i = r.$groups; + e[i._set] && + (n = e[i._set][i._key]) && + !0 === A.callback(n, [a]) && + ((t.$datalabels._dirty = !0), r.update(a)); + } + } + function N(t, e) { + var r, + n, + a = t.$datalabels, + i = a._listeners; + if (i.enter || i.leave) { + if (e.type === "mousemove") n = $.lookup(a._labels, e); + else if (e.type !== "mouseout") return; + (r = a._hovered), + (a._hovered = n), + (function (t, e, r, n) { + var a, i; + (r || n) && + (r ? (n ? r !== n && (i = a = !0) : (i = !0)) : (a = !0), + i && D(t, e.leave, r), + a && D(t, e.enter, n)); + })(t, i, r, n); + } + } + return ( + (r.default.defaults.global.plugins.datalabels = z), + { + id: "datalabels", + beforeInit: function (t) { + t.$datalabels = {_actives: []}; + }, + beforeUpdate: function (t) { + var e = t.$datalabels; + (e._listened = !1), + (e._listeners = {}), + (e._datasets = []), + (e._labels = []); + }, + afterDatasetUpdate: function (t, e, r) { + var n, + a, + i, + o, + l, + s, + u, + d, + f = e.index, + c = t.$datalabels, + h = (c._datasets[f] = []), + x = t.isDatasetVisible(f), + y = t.data.datasets[f], + v = (function (t, e) { + var r, + n, + a, + i = t.datalabels, + o = []; + return !1 === i + ? null + : (!0 === i && (i = {}), + (e = A.merge({}, [e, i])), + (n = e.labels || {}), + (a = Object.keys(n)), + delete e.labels, + a.length + ? a.forEach(function (t) { + n[t] && + o.push(A.merge({}, [e, n[t], {_key: t}])); + }) + : o.push(e), + (r = o.reduce(function (t, e) { + return ( + A.each(e.listeners || {}, function (r, n) { + (t[n] = t[n] || {}), (t[n][e._key || O] = r); + }), + delete e.listeners, + t + ); + }, {})), + {labels: o, listeners: r}); + })(y, r), + _ = e.meta.data || [], + p = t.ctx; + for (p.save(), n = 0, i = _.length; n < i; ++n) + if ( + (((u = _[n]).$datalabels = []), + x && u && !u.hidden && !u._model.skip) + ) + for (a = 0, o = v.labels.length; a < o; ++a) + (s = (l = v.labels[a])._key), + ((d = new b(l, p, u, n)).$groups = { + _set: f, + _key: s || O, + }), + (d.$context = { + active: !1, + chart: t, + dataIndex: n, + dataset: y, + datasetIndex: f, + }), + d.update(d.$context), + u.$datalabels.push(d), + h.push(d); + p.restore(), + A.merge(c._listeners, v.listeners, { + merger: function (t, r, n) { + (r[t] = r[t] || {}), + (r[t][e.index] = n[t]), + (c._listened = !0); + }, + }); + }, + afterUpdate: function (t, e) { + t.$datalabels._labels = $.prepare(t.$datalabels._datasets, e); + }, + afterDatasetsDraw: function (t) { + $.draw(t, t.$datalabels._labels); + }, + beforeEvent: function (t, e) { + if (t.$datalabels._listened) + switch (e.type) { + case "mousemove": + case "mouseout": + N(t, e); + break; + case "click": + !(function (t, e) { + var r = t.$datalabels, + n = r._listeners.click, + a = n && $.lookup(r._labels, e); + a && D(t, n, a); + })(t, e); + } + }, + afterEvent: function (t) { + var e, + n, + a, + o, + l, + s, + u, + d = t.$datalabels, + f = d._actives, + c = (d._actives = t.lastActive || []), + h = i.arrayDiff(f, c); + for (e = 0, n = h.length; e < n; ++e) + if ((l = h[e])[1]) + for (a = 0, o = (u = l[0].$datalabels || []).length; a < o; ++a) + ((s = u[a]).$context.active = l[1] === 1), + s.update(s.$context); + (d._dirty || h.length) && + ($.update(d._labels), + (function (t) { + if (!t.animating) { + for ( + var e = r.default.animationService.animations, + n = 0, + a = e.length; + n < a; + ++n + ) + if (e[n].chart === t) return; + t.render({duration: 1, lazy: !0}); + } + })(t)), + delete d._dirty; + }, + } + ); +}); diff --git a/views/acc_operation_templates.xml b/views/acc_operation_templates.xml index d56dbf641c48bc6022b350442943bebbcdda8e1a..a77ae136fcaa2af61d95511dedb28fc15d0275d1 100644 --- a/views/acc_operation_templates.xml +++ b/views/acc_operation_templates.xml @@ -1,9 +1,16 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8" ?> <odoo> - <template id="assets_backend" name="operation assets" inherit_id="web.assets_backend"> + <template + id="assets_backend" + name="operation assets" + inherit_id="web.assets_backend" + > <xpath expr="." position="inside"> - <script type="text/javascript" src="/acc_cdc/static/src/js/operation_graph.js"></script> + <script + type="text/javascript" + src="/acc_cdc/static/src/js/operation_graph.js" + /> </xpath> </template> @@ -20,11 +27,56 @@ <div class="o_timesheet_plan_sale_timesheet"> <div class="o_timesheet_plan_sale_timesheet_dashboard"> <div class="container text-center mt32 mb32"> - <button t-att-context="{'first_day': data_values['date_day_start'], 'last_day': ''}" name="day" class="btn btn-secondary o_acc_button" title="Dernier jour" aria-label="Dernier jour" data-mode="day"><strong>Dernière journée</strong><br/><t t-esc="data_values['last_day']"/></button> - <button t-att-context="{'first_day': data_values['date_week_start'], 'last_day': data_values['date_week_end']}" name="week" class="btn btn-secondary o_acc_button" title="7 derniers jours" aria-label="7 derniers jours" data-mode="week"><strong>7 derniers jours</strong><br/><t t-esc="data_values['last_week']"/></button> - <button t-att-context="{'first_day': data_values['date_month_start'], 'last_day': data_values['date_month_end']}" name="month" class="btn btn-secondary o_acc_button" title="Dernier mois" aria-label="Dernier mois" data-mode="month"><strong>Dernier mois</strong><br/><t t-esc="data_values['last_month']"/></button> - <button t-att-context="{'first_day': data_values['date_semestre_start'], 'last_day': data_values['date_semestre_end']}" name="semestre" class="btn btn-secondary o_acc_button" title="6 derniers mois" aria-label="6 derniers mois" data-mode="semestre"><strong>6 derniers mois</strong><br/><t t-esc="data_values['last_semestre']"/></button> - <button t-att-context="{'first_day': data_values['date_year_start'], 'last_day': data_values['date_year_end']}" name="year" class="btn btn-secondary o_acc_button" title="12 derniers mois" aria-label="12 derniers mois" data-mode="year"><strong>12 derniers mois</strong><br/><t t-esc="data_values['last_year']"/></button> + <button + t-att-context="{'first_day': data_values['date_day_start'], 'last_day': ''}" + name="day" + class="btn btn-secondary o_acc_button" + title="Dernier jour" + aria-label="Dernier jour" + data-mode="day" + ><strong>Dernière journée</strong><br /><t + t-esc="data_values['last_day']" + /></button> + <button + t-att-context="{'first_day': data_values['date_week_start'], 'last_day': data_values['date_week_end']}" + name="week" + class="btn btn-secondary o_acc_button" + title="7 derniers jours" + aria-label="7 derniers jours" + data-mode="week" + ><strong>7 derniers jours</strong><br /><t + t-esc="data_values['last_week']" + /></button> + <button + t-att-context="{'first_day': data_values['date_month_start'], 'last_day': data_values['date_month_end']}" + name="month" + class="btn btn-secondary o_acc_button" + title="Dernier mois" + aria-label="Dernier mois" + data-mode="month" + ><strong>Dernier mois</strong><br /><t + t-esc="data_values['last_month']" + /></button> + <button + t-att-context="{'first_day': data_values['date_semestre_start'], 'last_day': data_values['date_semestre_end']}" + name="semestre" + class="btn btn-secondary o_acc_button" + title="6 derniers mois" + aria-label="6 derniers mois" + data-mode="semestre" + ><strong>6 derniers mois</strong><br /><t + t-esc="data_values['last_semestre']" + /></button> + <button + t-att-context="{'first_day': data_values['date_year_start'], 'last_day': data_values['date_year_end']}" + name="year" + class="btn btn-secondary o_acc_button" + title="12 derniers mois" + aria-label="12 derniers mois" + data-mode="year" + ><strong>12 derniers mois</strong><br /><t + t-esc="data_values['last_year']" + /></button> </div> <div class="text-center o_title mt32"> <h2>Vues Consommateurs</h2> @@ -33,13 +85,25 @@ <div class="container"> <div class="row mb32"> <div class="col-12 p-5"> - <canvas id="line_chart_conso" width="auto" height="200"></canvas> + <canvas + id="line_chart_conso" + width="auto" + height="200" + /> </div> <div class="col-md-6 col-12 p-5"> - <canvas id="donuts_chart_conso" width="auto" height="200"></canvas> + <canvas + id="donuts_chart_conso" + width="auto" + height="200" + /> </div> <div class="col-md-6 col-12 p-5"> - <canvas id="histo_chart_conso" width="auto" height="200"></canvas> + <canvas + id="histo_chart_conso" + width="auto" + height="200" + /> </div> </div> </div> @@ -53,13 +117,25 @@ <div class="container"> <div class="row mb32"> <div class="col-12 p-5"> - <canvas id="line_chart_prod" width="auto" height="200"></canvas> + <canvas + id="line_chart_prod" + width="auto" + height="200" + /> </div> <div class="col-md-6 col-12 p-5"> - <canvas id="donuts_chart_prod" width="auto" height="200"></canvas> + <canvas + id="donuts_chart_prod" + width="auto" + height="200" + /> </div> <div class="col-md-6 col-12 p-5"> - <canvas id="histo_chart_prod" width="auto" height="200"></canvas> + <canvas + id="histo_chart_prod" + width="auto" + height="200" + /> </div> </div> </div> diff --git a/views/acc_operation_views.xml b/views/acc_operation_views.xml index f5236d36b4ab34c823d897dd742ffdd6f99f0f34..5162354ffce9a543a44f1e9a2fd0e9037ad12c45 100644 --- a/views/acc_operation_views.xml +++ b/views/acc_operation_views.xml @@ -1,19 +1,20 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8" ?> <odoo> <data> <record id="cdc_acc_operation_form_view" model="ir.ui.view"> <field name="name">cdc.acc_operation_form_view.api.form</field> <field name="model">acc.operation</field> - <field name="inherit_id" ref="acc_enedis_api.acc_operation_form_view"/> + <field name="inherit_id" ref="acc_enedis_api.acc_operation_form_view" /> <field name="arch" type="xml"> <header position="inside"> <button - string="Voir les courbes" - type="object" - class="btn-primary" - name="action_view_courbes" - attrs="{'invisible':[('is_data_enedis', '!=', True)]}"/> + string="Voir les courbes" + type="object" + class="btn-primary" + name="action_view_courbes" + attrs="{'invisible':[('is_data_enedis', '!=', True)]}" + /> </header> </field> </record> @@ -25,4 +26,4 @@ </record> </data> -</odoo> \ No newline at end of file +</odoo> diff --git a/views/res_partner_views.xml b/views/res_partner_views.xml index 9a510bb1dedebdedb496b8c52845d590f524acde..02c40e2cd2fd6711a555c432f58b12ac4d48306b 100644 --- a/views/res_partner_views.xml +++ b/views/res_partner_views.xml @@ -1,23 +1,24 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8" ?> <odoo> <data> <record id="acc_place_form_view" model="ir.ui.view"> <field name="name">cdc.acc_place_form_view.api.form</field> <field name="model">acc.counter</field> - <field name="inherit_id" ref="acc_operation.acc_place_form_view"/> + <field name="inherit_id" ref="acc_operation.acc_place_form_view" /> <field name="arch" type="xml"> <xpath expr="//field[@name='acc_operation_id']" position="after"> - <button icon="fa-times" - class="text-danger" - string="Voir les courbes" - type="object" - name="action_view_courbes" - /> + <button + icon="fa-times" + class="text-danger" + string="Voir les courbes" + type="object" + name="action_view_courbes" + /> </xpath> </field> </record> </data> -</odoo> \ No newline at end of file +</odoo>