Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions client/src/lib/progress/progressChartConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import type { ChartConfiguration } from "chart.js"
import { DateTime } from "luxon";
import type { ExtendedPChartDataPoint, PChartTLabel, PChartTType } from '@/lib/progress/progressChartTypes'

const X_AXIS_MIN = new Date('2024-03-01').getTime()
const X_AXIS_MAX = new Date('2025-01-02').getTime()
const Y_AXIS_MIN = 0

const chartConfig: ChartConfiguration<PChartTType, ExtendedPChartDataPoint[], PChartTLabel> = {
type: 'line',
Expand All @@ -10,8 +13,10 @@ const chartConfig: ChartConfiguration<PChartTType, ExtendedPChartDataPoint[], PC
},
options: {
maintainAspectRatio: false,
responsive: true,
scales: {
x: {
position: 'top',
type: "time",
time: {
displayFormats: {
Expand All @@ -20,14 +25,15 @@ const chartConfig: ChartConfiguration<PChartTType, ExtendedPChartDataPoint[], PC
},
unit: 'month'
},
min: '2024-01-01',
max: '2025-01-02',
min: X_AXIS_MIN,
max: X_AXIS_MAX,
title: {
display: true,
text: "Day in year"
}
},
y: {
min: Y_AXIS_MIN,
title: {
display: true,
text: 'Mileage'
Expand All @@ -38,6 +44,9 @@ const chartConfig: ChartConfiguration<PChartTType, ExtendedPChartDataPoint[], PC
}
},
plugins: {
legend: {
position: 'top',
},
tooltip: {
boxPadding: 10,
callbacks: {
Expand Down Expand Up @@ -65,7 +74,11 @@ const chartConfig: ChartConfiguration<PChartTType, ExtendedPChartDataPoint[], PC
pan: {
enabled: true,

}
},
limits: {
x: { min: X_AXIS_MIN, max: X_AXIS_MAX },
y: { min: Y_AXIS_MIN, max: 'original' }
},
}
}
}
Expand Down
41 changes: 37 additions & 4 deletions client/src/views/ProgressChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
<button type="button" class="filterbuttons btn m-2" :class="bestClass" @click="toggleBest()">
Best</button>
</div>
<div class="d-flex flex-column flex-grow-1">
<canvas id="acquisitions" ref="canvasref"></canvas>
<div v-if="loading" class="myspinner" role="status" aria-label="Loading chart">
<b-spinner />
<!-- <div id="canvas-parent" class="d-flex flex-row flex-grow-1 mh-100 justify-content-center align-items-center w-100"> -->
<div id="canvas-parent">
<div id="canvas-wrapper">
<canvas id="acquisitions" ref="canvasref"></canvas>
<div v-if="loading" class="myspinner" role="status" aria-label="Loading chart">
<b-spinner />
</div>
</div>
</div>
</track-manager-nav-bar>
Expand Down Expand Up @@ -142,6 +145,36 @@ onMounted(() => {
</script>

<style scoped>
#canvas-parent {
display: flex;
flex-direction: column;
flex: 1;
align-items: center;
/* center the chart horizontally */
overflow: hidden;
/* needs an explicit height for children to reference 100% */
height: 100%;
}

#canvas-wrapper {
position: relative;
aspect-ratio: 3 / 4;
/* Drive sizing from height, not width */
height: 100%;
width: auto;
/* width follows from aspect-ratio + height */
max-width: 100%;
/* never overflow horizontally */
flex-shrink: 0;
}

#acquisitions {
position: absolute;
inset: 0;
width: 100% !important;
height: 100% !important;
}

.myspinner {
position: absolute;

Expand Down