first version with new caleandar
This commit is contained in:
parent
06f4e64f2c
commit
1db3956d84
@ -1,33 +1,23 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="card row" v-if="dataLoaded">
|
<div class="card row" v-if="dataLoaded">
|
||||||
<GChart type="Calendar" :data="chartData" :options="chartOptions" :settings="{ packages: ['calendar'] }" />
|
<CalendarHeatmap :values="values" :end-date="endDate" :style="{'font-size': '12px'}" tooltip-unit="Wh" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
import { GChart } from 'vue-google-charts';
|
import { CalendarHeatmap } from 'vue3-calendar-heatmap'
|
||||||
import { authHeader, handleResponse } from '@/utils/authentication';
|
import { authHeader, handleResponse } from '@/utils/authentication';
|
||||||
var data_cal: any;
|
var data: Array<{ date: Date; count: number; }>;
|
||||||
|
|
||||||
export const options_cal = {
|
|
||||||
height: 480,
|
|
||||||
colorAxis: {
|
|
||||||
minValue: 0,
|
|
||||||
colors: ['#FFFFFF', '#0000FF']
|
|
||||||
},
|
|
||||||
calendar: {
|
|
||||||
cellSize: 24,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: {
|
components: {
|
||||||
GChart,
|
CalendarHeatmap,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
chartData: data_cal,
|
values: data,
|
||||||
chartOptions: options_cal,
|
endDate: new Date(),
|
||||||
dataLoaded: false,
|
dataLoaded: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -42,13 +32,11 @@ export default defineComponent({
|
|||||||
.then((response) => handleResponse(response, this.$emitter, this.$router))
|
.then((response) => handleResponse(response, this.$emitter, this.$router))
|
||||||
.then((energy) => {
|
.then((energy) => {
|
||||||
if (energy) {
|
if (energy) {
|
||||||
this.chartData = [[{ type: 'date', id: 'Date' }, { type: 'number', id: 'Energy' }]];
|
this.values = [];
|
||||||
var d: Date;
|
var d: Date;
|
||||||
var a: any;
|
|
||||||
energy.forEach((x: any[]) => {
|
energy.forEach((x: any[]) => {
|
||||||
d = new Date(x[0] + 2000, x[1] - 1, x[2], x[3])
|
d = new Date(x[0] + 2000, x[1] - 1, x[2], x[3])
|
||||||
a = [d, Math.round(x[4])]
|
this.values.push({ date: d, count: Math.round(x[4]) })
|
||||||
this.chartData.push(a)
|
|
||||||
})
|
})
|
||||||
this.dataLoaded = true;
|
this.dataLoaded = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Loading…
Reference in New Issue
Block a user