Skip to content

Commit

Permalink
Add query items
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeauchesne committed Mar 24, 2021
1 parent b1cd345 commit d4d0bbe
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/views/documents/utils/QueryItems.vue
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export default {
},
documentType() {
return this.$route.name.slice(0, -1);
return this.$route.name.split('-')[0].slice(0, -1);
},
associations() {
Expand Down
33 changes: 28 additions & 5 deletions src/views/portals/OutingsStatsView.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
<template>
<div class="section">
<h1>
<span>Outing statistics</span>
<html-header :title="$gettext('Outings statistics')" />
<h1 class="title is-3 header-section">
<span v-translate>Outing statistics</span>
<span v-if="!outings">{{ Math.round(loadingPercentage * 100) }}%</span>
</h1>
<div v-if="outings" class="columns">

<query-items class="filter-section" />

<div v-if="outings" class="columns result-section">
<div class="column">
<h2>By year</h2>
<h2 class="title is-4" v-translate>By year</h2>
<div ref="year_repartition"></div>
</div>
<div class="column">
<h2>By month</h2>
<h2 class="title is-4" v-translate>By month</h2>
<div ref="month_repartition"></div>
</div>
</div>
Expand All @@ -22,6 +26,7 @@ import { createHistogram } from './utils/outings-stats';
import c2c from '@/js/apis/c2c';
import d3 from '@/js/libs/d3';
import QueryItems from '@/views/documents/utils/QueryItems';
const getOutingYear = function (outing) {
return parseInt(outing.date_start.substring(0, 4), 10);
Expand All @@ -31,6 +36,10 @@ const getOutingMonth = function (outing) {
};
export default {
components: {
QueryItems,
},
data() {
return {
outings: null,
Expand Down Expand Up @@ -66,3 +75,17 @@ export default {
},
};
</script>

<style scoped lang="scss">
.filter-section {
padding-bottom: 0.5rem;
clear: both;
}
.result-section {
margin-top: 0.5rem;
border-top: 1px solid lightgrey;
padding-top: 0.5rem;
clear: both;
}
</style>
5 changes: 4 additions & 1 deletion src/views/portals/utils/outings-stats.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
export function createHistogram(d3, outings, htmlElement, aggregationFuntion) {
// clean
htmlElement.innerHTML = '';

// set the dimensions and margins of the graph
var margin = { top: 10, right: 30, bottom: 30, left: 40 },
width = 460 - margin.left - margin.right,
width = htmlElement.offsetWidth - margin.left - margin.right,
height = 400 - margin.top - margin.bottom;

// append the svg object to the body of the page
Expand Down

0 comments on commit d4d0bbe

Please sign in to comment.