From 135c7c4efc0f0d1d4308a000bc1c7db70020cd7c Mon Sep 17 00:00:00 2001 From: mateuswetah Date: Sun, 28 Mar 2021 18:13:42 -0300 Subject: [PATCH] Continues modular implementation of charts. #483 --- .../admin/js/store/modules/report/index.js | 8 +- .../components/items-per-term-block.vue | 2 +- .../metadata-distribution-block.vue | 106 ++++++++++++ .../components/metadata-list-block.vue | 98 +++++++++++ .../components/metadata-types-block.vue | 4 +- .../components/terms-per-taxonomy-block.vue | 2 +- src/views/reports/js/reports-main.js | 4 + src/views/reports/pages/reports-list.vue | 155 +----------------- 8 files changed, 224 insertions(+), 155 deletions(-) create mode 100644 src/views/reports/components/metadata-distribution-block.vue create mode 100644 src/views/reports/components/metadata-list-block.vue diff --git a/src/views/admin/js/store/modules/report/index.js b/src/views/admin/js/store/modules/report/index.js index 08dd2240f..8dd12890b 100644 --- a/src/views/admin/js/store/modules/report/index.js +++ b/src/views/admin/js/store/modules/report/index.js @@ -45,12 +45,14 @@ const state = { xaxis: { type: 'category', tickPlacement: 'on', - categories: [] + categories: [], + tooltip: { enabled: true } }, yaxis: { title: { text: '' - } + }, + tooltip: { enabled: true } }, legend: { position: 'right', @@ -114,9 +116,11 @@ const state = { type: 'category', tickPlacement: 'on', categories: [], + tooltip: { enabled: true } }, yaxis: { tickPlacement: 'on', + tooltip: { enabled: true } }, tooltip: { y: { diff --git a/src/views/reports/components/items-per-term-block.vue b/src/views/reports/components/items-per-term-block.vue index 5b5fecf39..11b015426 100644 --- a/src/views/reports/components/items-per-term-block.vue +++ b/src/views/reports/components/items-per-term-block.vue @@ -197,7 +197,7 @@ export default { trim: true, hideOverlappingLabels: false }, - tooltip: true + tooltip: { enabled: true } }, yaxis: { title: { diff --git a/src/views/reports/components/metadata-distribution-block.vue b/src/views/reports/components/metadata-distribution-block.vue new file mode 100644 index 000000000..ebaa8a421 --- /dev/null +++ b/src/views/reports/components/metadata-distribution-block.vue @@ -0,0 +1,106 @@ + + + \ No newline at end of file diff --git a/src/views/reports/components/metadata-list-block.vue b/src/views/reports/components/metadata-list-block.vue new file mode 100644 index 000000000..dc7998688 --- /dev/null +++ b/src/views/reports/components/metadata-list-block.vue @@ -0,0 +1,98 @@ + + + \ No newline at end of file diff --git a/src/views/reports/components/metadata-types-block.vue b/src/views/reports/components/metadata-types-block.vue index 94953cd24..901239d23 100644 --- a/src/views/reports/components/metadata-types-block.vue +++ b/src/views/reports/components/metadata-types-block.vue @@ -1,7 +1,7 @@ @@ -151,13 +105,8 @@ export default { isFetchingMetadata: false, isFetchingMetadataList: false, isFetchingActivities: false, - collectionsListChartSeries: [], - collectionsListChartOptions: {}, metadataListChartSeries: [], metadataListChartOptions: {}, - metadataDistributionChartSeries: [], - metadataDistributionChartOptions: {}, - metadataDistributionChartHeight: 730, activitiesChartSeries: [], activitiesChartOptions: {} } @@ -173,7 +122,6 @@ export default { collectionsList: 'getCollectionsList', activities: 'getActivities', stackedBarChartOptions: 'getStackedBarChartOptions', - horizontalBarChartOptions: 'getHorizontalBarChartOptions', //heatMapChartOptions: 'getHeatMapChartOptions' }), metadataListArray() { @@ -233,62 +181,6 @@ export default { this.isFetchingMetadata = true; this.fetchMetadata({ collectionId: this.selectedCollection }) .then(() => { - - if (this.metadata.distribution) { - - // Building Metadata Distribution Bar chart - const orderedMetadataDistributions = Object.values(this.metadata.distribution).sort((a, b) => b.fill_percentage - a.fill_percentage ); - let metadataDistributionValues = []; - let metadataDistributionValuesInverted = []; - let metadataDistributionLabels = []; - const metadataCount = 100 + (this.metadata.totals.metadata.total * 36); - - orderedMetadataDistributions.forEach(metadataDistribution => { - metadataDistributionValues.push(parseFloat(metadataDistribution.fill_percentage)); - metadataDistributionValuesInverted.push(100.0000 - parseFloat(metadataDistribution.fill_percentage).toFixed(4)); - metadataDistributionLabels.push(metadataDistribution.name); - }) - - // Sets first metadatum as the selected one - if (orderedMetadataDistributions.length) - this.selectedMetadatum = orderedMetadataDistributions[0].id; - - this.metadataDistributionChartSeries = [ - { - name: this.$i18n.get('label_filled'), - data: metadataDistributionValues - }, - { - name: this.$i18n.get('label_not_filled'), - data: metadataDistributionValuesInverted - } - ]; - this.metadataDistributionChartOptions = { - ...this.horizontalBarChartOptions, - ...{ - chart: { - type: 'bar', - height: metadataCount, - stacked: true, - stackType: '100%', - toolbar: { - show: true - }, - zoom: { - type: 'y', - enabled: true, - autoScaleYaxis: true, - } - }, - title: { - text: this.$i18n.get('label_metadata_fill_distribution') - }, - labels: metadataDistributionLabels, - colors: ['#25a189', '#a23939'] - } - } - } - this.isFetchingMetadata = false; }) .catch(() => this.isFetchingMetadata = false); @@ -348,7 +240,7 @@ export default { trim: true, hideOverlappingLabels: false }, - tooltip: true + tooltip: { enabled: true } }, yaxis: { title: { @@ -365,42 +257,7 @@ export default { loadMetadataList() { this.isFetchingMetadataList = true; this.fetchMetadataList({ collectionId: this.collectionId, metadatumId: this.selectedMetadatum }) - .then(() => { - - // Building Metadata term usage chart - const orderedMetadata = Object.values(this.metadataList).sort((a, b) => b.total_items - a.total_items); - let metadataItemValues = []; - let metadataItemLabels = []; - - orderedMetadata.forEach(metadataItem => { - metadataItemValues.push(metadataItem.total_items); - metadataItemLabels.push(metadataItem.label); - }); - - this.metadataListChartSeries = [ - { - name: this.$i18n.get('label_items_with_this_metadum_value'), - data: metadataItemValues - } - ]; - - this.metadataListChartOptions = { - ...this.stackedBarChartOptions, - ...{ - title: {}, - xaxis: { - type: 'category', - tickPlacement: 'on', - categories: metadataItemLabels, - }, - yaxis: { - title: { - text: this.$i18n.get('label_number_of_items') - } - } - } - } - + .then(() => { this.isFetchingMetadataList = false; }) .catch(() => this.isFetchingMetadataList = false);