diff --git a/djaopsp/static/js/reporting-vue.js b/djaopsp/static/js/reporting-vue.js index 53167f33..558ff64b 100644 --- a/djaopsp/static/js/reporting-vue.js +++ b/djaopsp/static/js/reporting-vue.js @@ -425,7 +425,8 @@ Vue.component('engage-profiles', { Vue.component('djaopsp-compare-samples', { mixins: [ - practicesListMixin + practicesListMixin, + accountDetailMixin ], data: function() { return { @@ -441,6 +442,10 @@ Vue.component('djaopsp-compare-samples', { }, visualize: 'chart', //'table', percentToggle: true, + + // when clicking on Chart + selectedDatapoint: "", + selectedAccounts: [] } }, methods: { @@ -492,6 +497,29 @@ Vue.component('djaopsp-compare-samples', { var vm = this; vm.$refs.accountsTab.click(); }, + humanizePeriods: function(labels) { + var vm = this; + var results = []; + const dateFormat = new Intl.DateTimeFormat( + 'en-US', { + // day: '2-digit', + month: '2-digit', + year: 'numeric', + }); + for( let lblIdx = 0; lblIdx < labels.length; ++lblIdx ) { + const dtime = new Date(labels[lblIdx]); + results.push( + vm.periodType == 'yearly' ? dtime.getUTCFullYear() : ( + vm.periodType == 'monthly' ? dateFormat.format(dtime) : dtime)); + } + return results; + }, + onDatasetSelected: function() { + // This method is called when the component needs to show + // the list of accounts participating to a specific dataset. + var vm = this; + vm.populateAccounts(vm.selectedAccounts); + }, updateChart: function() { var vm = this; const entries = vm.getEntries(vm.displayMetric.path); @@ -626,6 +654,7 @@ Vue.component('djaopsp-compare-samples', { if( vm.compareChart ) { vm.compareChart.destroy(); } + labels = vm.humanizePeriods(labels); if( choices.length ) { vm.compareChart = new Chart( document.getElementById('summaryChart'), { diff --git a/djaopsp/templates/survey/matrix/compare.html b/djaopsp/templates/survey/matrix/compare.html index c037877c..ffbdd768 100644 --- a/djaopsp/templates/survey/matrix/compare.html +++ b/djaopsp/templates/survey/matrix/compare.html @@ -556,11 +556,13 @@
+ [[selectedDatapoint]] +
+{% trans %}Supplier ID{% endtrans %} | +{% trans %}Profile name{% endtrans %} | +
---|---|
+ [[index + 1 + (params.page ? (params.page - 1) * itemsPerPage : 0)]] + |
+
+ |
+