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 @@

{% trans %}left to ri {% include "app/reporting/_percentage_toggle.html" %}
+
@@ -585,6 +587,27 @@

{% trans %}left to ri

{# /datasets.length > 0 #} + + +
+

+ [[selectedDatapoint]] +

+ + + + + + + + + +
{% trans %}Supplier ID{% endtrans %}{% trans %}Profile name{% endtrans %}
+ [[index + 1 + (params.page ? (params.page - 1) * itemsPerPage : 0)]]
+
+ [[getAccountPrintableName(entry) || entry.slug]] +
+
{# /.col-md-9 #} {# /.row #} diff --git a/djaopsp/views/matrix.py b/djaopsp/views/matrix.py index 0bdae684..0cff8d62 100644 --- a/djaopsp/views/matrix.py +++ b/djaopsp/views/matrix.py @@ -37,6 +37,7 @@ def get_context_data(self, **kwargs): update_context_urls(context, { 'api_version': site_url("/api"), 'api_account_candidates': site_url("/api/accounts/profiles"), + 'api_accounts': site_url("/api/profile"), 'api_plans': site_url("/api/profile/%(profile)s/plans" % { 'profile': self.account}), 'api_subscriptions': site_url(