Skip to content
Snippets Groups Projects
Commit 873731fa authored by Wortman, Elliot (UG - Comp Sci & Elec Eng)'s avatar Wortman, Elliot (UG - Comp Sci & Elec Eng)
Browse files

Graph x-axis for past 7 days

parent e9974238
No related branches found
No related tags found
3 merge requests!5Replace Vue3 template site with NanoPatch UI & API,!4Modify passing x-axis-data as refering to function was causing errors in production build,!3Line Graphs + Design Overhaul
......@@ -11,6 +11,18 @@ export default {
MultiLineChart,
MultiAxisChart
},
methods: {
getPastSevenDays() {
const dates = [];
for (let i = 6; i >= 0; i--) {
const date = new Date();
date.setDate(date.getDate() - i);
const formattedDate = `${date.getDate().toString().padStart(2, '0')}/${(date.getMonth() + 1).toString().padStart(2, '0')}`;
dates.push(formattedDate);
}
return dates;
}
},
data() {
return {
npkData: {
......@@ -39,8 +51,8 @@ export default {
</div>
</div>
<div class="bottom-section">
<MultiLineChart :chart-data="npkData" />
<MultiAxisChart :chart-data="thmData" />
<MultiLineChart :chart-data="npkData" :x-axis-data=this.getPastSevenDays() />
<MultiAxisChart :chart-data="thmData" :x-axis-data=this.getPastSevenDays() />
</div>
</div>
</template>
......@@ -55,7 +67,6 @@ export default {
.top-section {
display: flex;
flex: 1;
/* position: relative; */
}
.logo-container {
......
......@@ -14,13 +14,17 @@ export default {
type: Object,
required: true
},
xAxisData: {
type: Array,
required: true
},
},
mounted() {
const ctx = this.$refs.multiLineChart.getContext('2d');
new Chart(ctx, {
type: 'line',
data: {
labels: ['Day 1', 'Day 2', 'Day 3', 'Day 4', 'Day 5', 'Day 6', 'Day 7'],
labels: this.xAxisData,
datasets: [
{
label: 'Temperature',
......
......@@ -14,13 +14,17 @@ export default {
type: Object,
required: true
},
xAxisData: {
type: Array,
required: true
},
},
mounted() {
const ctx = this.$refs.multiLineChart.getContext('2d');
new Chart(ctx, {
type: 'line',
data: {
labels: ['Day 1', 'Day 2', 'Day 3', 'Day 4', 'Day 5', 'Day 6', 'Day 7'],
labels: this.xAxisData,
datasets: [
{
label: 'Nitrogen',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment