some cosmetic changes

This commit is contained in:
Ralf Bauer 2023-06-09 11:50:56 +02:00
parent 7c8b5bb05f
commit f5b5d7e170
3 changed files with 44 additions and 23 deletions

View File

@ -15,18 +15,29 @@ import type { DatabaseStatus } from "@/types/DatabaseStatus";
import { GChart } from 'vue-google-charts'; import { GChart } from 'vue-google-charts';
//import { DatetimeFormat } from 'vue-i18n'; //import { DatetimeFormat } from 'vue-i18n';
var data: any; var data_col: any;
export const type = 'ColumnChart'; export const type_col = 'ColumnChart';
export const options = { export const options_col = {
height: 300, height: 300,
chartArea: { top: 25, width: '85%', height: '80%' }, chartArea: {
top: 25,
width: '85%',
height: '80%'
},
bar: {
groupWidth: '100%'
},
legend: { legend: {
position: 'none' position: 'none'
}, },
hAxis: { hAxis: {
format: 'HH', format: 'HH',
minorGridlines: {
count: 0
}
}, },
vAxis: { vAxis: {
minValue: 0,
format: '# Wh' format: '# Wh'
} }
}; };
@ -40,9 +51,9 @@ export default defineComponent({
setup() { setup() {
return () => return () =>
h(GChart, { h(GChart, {
data, data: data_col,
options, options: options_col,
type type: type_col
}); });
}, },
beforeMount() { beforeMount() {
@ -60,11 +71,18 @@ export default defineComponent({
var old_energy = 0.0; var old_energy = 0.0;
start.setDate(end.getDate() - interval); start.setDate(end.getDate() - interval);
start.setHours(start.getHours() - 2); start.setHours(start.getHours() - 2);
data = [['Time', 'Energy']]; data_col = [[{
type: 'date',
id: 'Time'
},
{
type: 'number',
id: 'Energy'
}]]
energy.forEach((x: any[]) => { energy.forEach((x: any[]) => {
var d = new Date(x[0] + 2000, x[1] - 1, x[2], x[3]); var d = new Date(x[0] + 2000, x[1] - 1, x[2], x[3]);
if ((d >= start) && (d <= end) && (old_energy > 0.0)) { if ((d >= start) && (d <= end) && (old_energy > 0.0)) {
data.push([d, Math.round((x[4] - old_energy) * 1000)]) data_col.push([d, Math.round((x[4] - old_energy) * 1000)])
} }
old_energy = x[4] old_energy = x[4]
}) })

View File

@ -3,9 +3,11 @@
<div v-if="dataBase.valid_data"> <div v-if="dataBase.valid_data">
<div class="card-header"> <div class="card-header">
</div> </div>
<div>
<GoogleChart /> <GoogleChart />
</div> </div>
</div> </div>
</div>
</template> </template>
<script lang="ts"> <script lang="ts">
@ -13,15 +15,16 @@ import { defineComponent, type PropType, h } from 'vue';
import type { DatabaseStatus } from "@/types/DatabaseStatus"; import type { DatabaseStatus } from "@/types/DatabaseStatus";
import { GChart } from 'vue-google-charts'; import { GChart } from 'vue-google-charts';
var data: any; var data_cal: any;
export const type = 'Calendar'; export const type_cal = 'Calendar';
export const options = { export const options_cal = {
height: 250, height: 270,
colorAxis: { colorAxis: {
minValue: 0,
colors: ['#FFFFFF', '#0000FF'] colors: ['#FFFFFF', '#0000FF']
}, },
calendar: { calendar: {
cellSize: 20, cellSize: 24,
}, },
}; };
export default defineComponent({ export default defineComponent({
@ -34,9 +37,9 @@ export default defineComponent({
setup() { setup() {
return () => return () =>
h(GChart, { h(GChart, {
data, data: data_cal,
options, options: options_cal,
type, type: type_cal,
settings: { settings: {
packages: ['calendar'], packages: ['calendar'],
} }
@ -50,7 +53,7 @@ export default defineComponent({
}, },
methods: { methods: {
drawChart() { drawChart() {
data = [[{ data_cal = [[{
type: 'date', type: 'date',
id: 'Date' id: 'Date'
}, },
@ -70,7 +73,7 @@ export default defineComponent({
old_energy = x[4]; old_energy = x[4];
} else { } else {
if (x[2] != old_day) { if (x[2] != old_day) {
data.push(a) data_cal.push(a)
old_day = x[2] old_day = x[2]
old_energy = last_energy old_energy = last_energy
} }
@ -79,7 +82,7 @@ export default defineComponent({
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((last_energy - old_energy) * 1000)] a = [d, Math.round((last_energy - old_energy) * 1000)]
}) })
data.push(a) data_cal.push(a)
} }
} }
}); });

Binary file not shown.