feat(history): add electricity price chart
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref, watch } from 'vue';
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import useHistoryViewModel from '../viewmodels/HistoryViewModel';
|
||||
import moment from 'moment';
|
||||
import Chart from '../components/Chart.vue';
|
||||
|
||||
const model = useHistoryViewModel();
|
||||
|
||||
@@ -14,10 +15,19 @@ onMounted(() => {
|
||||
watch(date, (value) => {
|
||||
model.getHistoryData(moment(value).format('YYYY-MM-DD'));
|
||||
});
|
||||
|
||||
const chartData = computed(
|
||||
() =>
|
||||
model.historyData.value?.electricity
|
||||
.filter((e) => e.totalPriceTaxIncluded != null)
|
||||
.map((e) => ({
|
||||
label: moment(e.startDate).format('HH:mm'),
|
||||
value: e.totalPriceTaxIncluded,
|
||||
})) ?? [],
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<input type="date" v-model="date" />
|
||||
</div>
|
||||
<input type="date" v-model="date" />
|
||||
<Chart :data="chartData" />
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user