Skip to content

Commit cf6d931

Browse files
authored
Colors Theme: Update Pricechart handling (#2756)
* update pricechart handling * improve layout of chargepoint config
1 parent 2ce24d7 commit cf6d931

8 files changed

Lines changed: 60 additions & 27 deletions

File tree

packages/modules/web_themes/colors/source/src/assets/js/themeConfig.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ export class Config {
4343
private _lowerPriceBound = 0
4444
private _upperPriceBound = 0
4545
private _showPmLabels = true
46-
isEtEnabled: boolean = false
47-
etPrice: number = 20.5
4846
showRightButton = true
4947
showLeftButton = true
5048
// graphMode = ''
@@ -407,6 +405,7 @@ export class GlobalData {
407405
cpDailyExported = 0
408406
evuId = 0
409407
etProvider = ''
408+
country = 'de'
410409
get pvBatteryPriority() {
411410
return this._pvBatteryPriority
412411
}

packages/modules/web_themes/colors/source/src/components/chargePointList/VehicleData.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,14 @@
120120
heading="Strompreis:"
121121
class="grid-col-4 grid-left"
122122
>
123-
<span :style="currentPriceStyle">{{ currentPrice }} ct </span>
123+
<span :style="currentPriceStyle">{{ etData.etCurrentPriceString }} </span>
124124
</InfoItem>
125125
<InfoItem v-if="cp.etActive" heading="max. Preis:" class="grid-col-4">
126126
<span type="button" @click="editPrice = !editPrice"
127127
>{{
128128
props.chargepoint.etActive
129129
? (Math.round(props.chargepoint.etMaxPrice * 10) / 10).toFixed(1) +
130-
' ct'
130+
priceUnit
131131
: '-'
132132
}}
133133
<i
@@ -175,6 +175,7 @@ import RangeInput from '../shared/RangeInput.vue'
175175
import PriceChart from '../priceChart/PriceChart.vue'
176176
import InfoItem from '@/components/shared/InfoItem.vue'
177177
import ChargingState from './ChargingState.vue'
178+
import { globalData } from '@/assets/js/model'
178179
179180
const props = defineProps<{
180181
chargepoint: ChargePoint
@@ -253,7 +254,9 @@ const modePillStyle = computed(() => {
253254
}
254255
}
255256
})
256-
257+
const priceUnit = computed(() => {
258+
return globalData.country === 'ch' ? ' Rp' : ' ct'
259+
})
257260
//methods
258261
function loadSoc() {
259262
updateServer('socUpdate', 1, props.chargepoint.connectedVehicle)

packages/modules/web_themes/colors/source/src/components/chargePointList/cpConfig/ConfigPv.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<template #inline-item>
1212
<SwitchInput v-model="useMinPv" />
1313
</template>
14-
<div class="subconfigstack grid-col-12">
14+
<div class="subconfigstack grid-col-12 mt-4">
1515
<div v-if="useMinPv" class="subconfig subgrid">
1616
<span class="subconfigtitle grid-col-1">Stärke:</span>
1717
<RangeInput
@@ -46,7 +46,7 @@
4646
<template #inline-item>
4747
<SwitchInput v-model="useMinSoc" class="grid-col-3" />
4848
</template>
49-
<div v-if="useMinSoc" class="subconfigstack">
49+
<div v-if="useMinSoc" class="subconfigstack mt-4">
5050
<div class="subconfig subgrid">
5151
<span class="subconfigtitle grid-col-1">SoC:</span>
5252
<RangeInput

packages/modules/web_themes/colors/source/src/components/powerGraph/processLiveGraphData.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,18 +125,18 @@ function extractValues(data: RawGraphDataItem): GraphDataItem {
125125

126126
values.charging = +data['charging-all']
127127
// charge points - we only show a maximum of 10 chargepoints in the graph
128-
/* for (let i = 0; i < 10; i++) {
128+
/* for (let i = 0; i < 10; i++) {
129129
const idx = 'cp' + i
130130
values[idx] = +(data[idx + '-power'] ?? 0)
131131
} */
132-
Object.keys(data)
133-
.filter(key => re_cp.test(key))
134-
.forEach((key) => {
135-
const found = key.match(re_cp)
136-
if (found && found[1]) {
137-
values['cp' + found[1]] = +(data[key] ?? 0)
138-
}
139-
})
132+
Object.keys(data)
133+
.filter((key) => re_cp.test(key))
134+
.forEach((key) => {
135+
const found = key.match(re_cp)
136+
if (found && found[1]) {
137+
values['cp' + found[1]] = +(data[key] ?? 0)
138+
}
139+
})
140140
values.selfUsage = values.pv - values.evuOut
141141
if (values.selfUsage < 0) {
142142
values.selfUsage = 0

packages/modules/web_themes/colors/source/src/components/priceChart/GlobalPriceChart.vue

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,11 @@ const xAxisGenerator = computed(() => {
127127
.ticks(plotdata.value.length)
128128
.tickSize(5)
129129
.tickSizeInner(-height)
130-
.tickFormat((d) => (d.getHours() % 6 == 0 ? timeFormat('%H:%M')(d) : ''))
130+
.tickFormat((d) =>
131+
d.getHours() % 6 == 0 && d.getMinutes() == 0
132+
? timeFormat('%H:%M')(d)
133+
: '',
134+
)
131135
})
132136
const yAxisGenerator = computed(() => {
133137
return (
@@ -156,7 +160,9 @@ const draw = computed(() => {
156160
bargroups
157161
.append('rect')
158162
.attr('class', 'bar')
159-
.attr('x', (d) => xScale.value(d[0]))
163+
.attr('x', (d) => {
164+
return xScale.value(d[0])
165+
})
160166
.attr('y', (d) => yScale.value(d[1]))
161167
.attr('width', barwidth.value)
162168
.attr('height', (d) => yScale.value(yDomain.value[0]) - yScale.value(d[1]))
@@ -172,7 +178,11 @@ const draw = computed(() => {
172178
.selectAll('.tick line')
173179
.attr('stroke', 'var(--color-bg)')
174180
.attr('stroke-width', (d) =>
175-
(d as Date).getHours() % 6 == 0 ? '2' : '0.5',
181+
(d as Date).getMinutes() == 0
182+
? (d as Date).getHours() % 6 == 0
183+
? '2'
184+
: '0.5'
185+
: '0',
176186
)
177187
xAxis.select('.domain').attr('stroke', 'var(--color-bg')
178188
// Y Axis

packages/modules/web_themes/colors/source/src/components/priceChart/PriceChart.vue

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
:show-subrange="true"
2424
:subrange-min="prices[0]"
2525
:subrange-max="prices[prices.length - 1]"
26-
unit="ct"
26+
:unit="globalData.country == 'ch' ? 'Rp' : 'ct'"
2727
/>
2828
</div>
2929
<div class="d-flex justify-content-between px-3 pb-2 pt-0 mt-0">
@@ -50,6 +50,7 @@
5050

5151
<script setup lang="ts">
5252
import { computed, onMounted, ref } from 'vue'
53+
import { globalData } from '@/assets/js/model'
5354
import { etData } from './model'
5455
import {
5556
extent,
@@ -106,7 +107,7 @@ const plotdata = computed(() => {
106107
})
107108
const barwidth = computed(() => {
108109
if (plotdata.value.length > 1) {
109-
return (width - margin.left - margin.right) / plotdata.value.length - 1
110+
return (width - margin.left - margin.right) / plotdata.value.length
110111
} else {
111112
return 0
112113
}
@@ -181,9 +182,14 @@ const zeroPath = computed(() => {
181182
182183
const xAxisGenerator = computed(() => {
183184
return axisBottom<Date>(xScale.value)
184-
.ticks(6)
185+
.ticks(plotdata.value.length)
185186
.tickSize(5)
186-
.tickFormat(timeFormat('%H:%M'))
187+
.tickSizeInner(-height)
188+
.tickFormat((d) =>
189+
d.getHours() % 6 == 0 && d.getMinutes() == 0
190+
? timeFormat('%H:%M')(d)
191+
: '',
192+
)
187193
})
188194
const yAxisGenerator = computed(() => {
189195
return axisLeft<number>(yScale.value)
@@ -221,8 +227,14 @@ const draw = computed(() => {
221227
.attr('color', 'var(--color-bg)')
222228
xAxis
223229
.selectAll('.tick line')
224-
.attr('stroke', 'var(--color-fg)')
225-
.attr('stroke-width', '0.5')
230+
.attr('stroke', 'var(--color-bg)')
231+
.attr('stroke-width', (d) =>
232+
(d as Date).getMinutes() == 0
233+
? (d as Date).getHours() % 6 == 0
234+
? '2'
235+
: '0.5'
236+
: '0',
237+
)
226238
xAxis.select('.domain').attr('stroke', 'var(--color-bg')
227239
// Y Axis
228240
const yAxis = svg.append('g').attr('class', 'axis').call(yAxisGenerator.value)

packages/modules/web_themes/colors/source/src/components/priceChart/model.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
import { reactive } from 'vue'
2-
// import { updateServer } from '@/assets/js/sendMessages'
2+
import { globalData } from '@/assets/js/model'
3+
34
class EtData {
45
active = false
56
etPriceList = new Map<Date, number>()
67
etProvider = ''
78
etMaxPrice = 0
9+
country = 'de'
810

911
get etCurrentPriceString() {
1012
const [p] = etData.etPriceList.values()
11-
return (Math.round(p * 10) / 10).toFixed(1) + ' ct'
13+
return (
14+
(Math.round(p * 10) / 10).toFixed(1) +
15+
(globalData.country === 'ch' ? ' Rp' : ' ct')
16+
)
1217
}
1318
}
1419

packages/modules/web_themes/colors/source/src/components/priceChart/processMessages.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { globalData } from '@/assets/js/model'
12
import { etData } from './model'
23

34
export function processEtProviderMessages(topic: string, message: string) {
@@ -9,6 +10,9 @@ export function processEtProviderMessages(topic: string, message: string) {
910
etData.active = true
1011
etData.etProvider = JSON.parse(message).name
1112
}
13+
if (data.configuration && data.configuration.country != null) {
14+
globalData.country = data.configuration.country
15+
}
1216
} else if (topic == 'openWB/optional/et/get/prices') {
1317
const plist = JSON.parse(message)
1418
etData.etPriceList = new Map<Date, number>()

0 commit comments

Comments
 (0)