Adjustments to activities heatmap.

This commit is contained in:
mateuswetah 2021-03-12 13:45:46 -03:00
parent 17cb67ee10
commit ce49fce25f
3 changed files with 37 additions and 36 deletions

View File

@ -142,6 +142,7 @@ const state = {
dataLabels: { dataLabels: {
enabled: false enabled: false
}, },
colors: [ '#298596' ],
title: { title: {
text: '' text: ''
}, },

View File

@ -143,7 +143,7 @@
style="min-height=740px" style="min-height=740px"
class="skeleton postbox" /> class="skeleton postbox" />
</div> </div>
<div <!-- <div
v-if="metadataList != undefined" v-if="metadataList != undefined"
class="column is-full"> class="column is-full">
<select <select
@ -169,7 +169,7 @@
v-else v-else
style="min-height=380px" style="min-height=380px"
class="skeleton postbox" /> class="skeleton postbox" />
</div> </div> -->
<div <div
v-if="activities != undefined" v-if="activities != undefined"
class="column is-full"> class="column is-full">
@ -316,8 +316,8 @@ export default {
let metadataTypeLabels = []; let metadataTypeLabels = [];
for (const metadataType in this.metadata.totals.metadata_per_type) { for (const metadataType in this.metadata.totals.metadata_per_type) {
metadataTypeValues.push(this.metadata.totals.metadata_per_type[metadataType].count); metadataTypeValues.push(this.metadata.totals.metadata_per_type[metadataType].count ? this.metadata.totals.metadata_per_type[metadataType].count : 0);
metadataTypeLabels.push(this.metadata.totals.metadata_per_type[metadataType].name); metadataTypeLabels.push(this.metadata.totals.metadata_per_type[metadataType].name ? this.metadata.totals.metadata_per_type[metadataType].name : '');
} }
this.metadataTypeChartSeries = metadataTypeValues; this.metadataTypeChartSeries = metadataTypeValues;
@ -613,7 +613,7 @@ export default {
(val,index) => { (val,index) => {
return { return {
name: (index + 1), name: (index + 1),
data: new Array(53).fill({x: '', y: 0}) data: new Array(53).fill({ x: '', y: 0 })
} }
} }
); );
@ -629,55 +629,54 @@ export default {
for (let line = 0; line < 7; line++) { for (let line = 0; line < 7; line++) {
// If there are no more days with activities, get outta here // If there are no more days with activities, get outta here
if (dayWithActivityIndex >= daysWithActivities.length) if (dayWithActivityIndex < daysWithActivities.length - 1) {
break;
// We should only begin inserting days from firstDayOfTheWeekWithActivity
if (column == 0 && line < firstDayOfTheWeekWithActivity - 1) {
continue;
// We should only begin inserting days from firstDayOfTheWeekWithActivity // On the first day, we don't need to calculate distances, just set the value and save the date
if (column == 0 && line < firstDayOfTheWeekWithActivity - 1) { } else if (column == 0 && line == firstDayOfTheWeekWithActivity - 1) {
continue;
// On the first day, we don't need to calculate distances, just set the value and save the date
} else if (column == 0 && line == firstDayOfTheWeekWithActivity - 1) {
everyDayOfTheYear[line].data[column] = {
x: '',
y: parseInt(daysWithActivities[dayWithActivityIndex].total)
};
const lastDayWithActivity = new Date(daysWithActivities[dayWithActivityIndex].year, daysWithActivities[dayWithActivityIndex].month - 1, daysWithActivities[dayWithActivityIndex].day);
dayWithActivityIndex++;
const nextDayWithActivity = new Date(daysWithActivities[dayWithActivityIndex].year, daysWithActivities[dayWithActivityIndex].month - 1, daysWithActivities[dayWithActivityIndex].day);
daysToSkip = Math.floor( (nextDayWithActivity - lastDayWithActivity) / (1000 * 60 * 60 * 24) );
} else {
daysToSkip--;
// If we don't have more days to skip, time to update values
if ( daysToSkip <= 0) {
everyDayOfTheYear[line].data[column] = { everyDayOfTheYear[line].data[column] = {
x: '', x: '',
y: parseInt(daysWithActivities[dayWithActivityIndex].total) y: parseInt(daysWithActivities[dayWithActivityIndex].total)
}; };
const lastDayWithActivity = new Date(daysWithActivities[dayWithActivityIndex].year, daysWithActivities[dayWithActivityIndex].month - 1, daysWithActivities[dayWithActivityIndex].day); const lastDayWithActivity = new Date(daysWithActivities[dayWithActivityIndex].date);
dayWithActivityIndex++; dayWithActivityIndex++;
const nextDayWithActivity = new Date(daysWithActivities[dayWithActivityIndex].year, daysWithActivities[dayWithActivityIndex].month - 1, daysWithActivities[dayWithActivityIndex].day); const nextDayWithActivity = new Date(daysWithActivities[dayWithActivityIndex].date);
daysToSkip = Math.floor( (nextDayWithActivity - lastDayWithActivity) / (1000 * 60 * 60 * 24) ); daysToSkip = Math.floor( (nextDayWithActivity - lastDayWithActivity) / (1000 * 60 * 60 * 24) );
console.log(daysToSkip, nextDayWithActivity, lastDayWithActivity); } else {
daysToSkip--;
// If we don't have more days to skip, time to update values
if ( daysToSkip <= 0) {
everyDayOfTheYear[line].data[column] = {
x: '',
y: parseInt(daysWithActivities[dayWithActivityIndex].total)
};
const lastDayWithActivity = new Date(daysWithActivities[dayWithActivityIndex].date);
dayWithActivityIndex++;
const nextDayWithActivity = new Date(daysWithActivities[dayWithActivityIndex].date);
daysToSkip = Math.floor( (nextDayWithActivity - lastDayWithActivity) / (1000 * 60 * 60 * 24) );
console.log(lastDayWithActivity);
}
} }
} }
} }
} }
this.activitiesChartSeries = everyDayOfTheYear;
this.activitiesChartSeries = everyDayOfTheYear();
this.activitiesChartOptions = { this.activitiesChartOptions = {
...this.heatMapChartOptions, ...this.heatMapChartOptions,
title: { title: {
text: this.$i18n.get('label_activities_last_year') text: this.$i18n.get('label_activities_last_year')
}, },
} };
} else { } else {
this.activitiesChartSeries = []; this.activitiesChartSeries = [];
this.activitiesChartOptions = { this.activitiesChartOptions = {

View File

@ -510,7 +510,8 @@ return apply_filters( 'tainacan-admin-i18n', [
'label_select_a_taxonomy' => __( 'Select a taxonomy', 'tainacan' ), 'label_select_a_taxonomy' => __( 'Select a taxonomy', 'tainacan' ),
'label_items_with_this_metadum_value' => __( 'Items with this metadatum value', 'tainacan' ), 'label_items_with_this_metadum_value' => __( 'Items with this metadatum value', 'tainacan' ),
'label_amount_of_items_per_metadatum_value' => __( 'Amount of items per metadatum value', 'tainacan' ), 'label_amount_of_items_per_metadatum_value' => __( 'Amount of items per metadatum value', 'tainacan' ),
'label_activities_last_year' => __( 'Activities last year', 'tainacan' ),
// Instructions. More complex sentences to guide user and placeholders // Instructions. More complex sentences to guide user and placeholders
'instruction_delete_selected_collections' => __( 'Delete selected collections', 'tainacan' ), 'instruction_delete_selected_collections' => __( 'Delete selected collections', 'tainacan' ),
'instruction_delete_selected_items' => __( 'Delete selected items', 'tainacan' ), 'instruction_delete_selected_items' => __( 'Delete selected items', 'tainacan' ),