Skip to content

Commit f5c4e66

Browse files
authored
Fix powergraph headings and Axis (#2646)
* Fix powergraph headings and Axis * add documentation
1 parent 2b090bd commit f5c4e66

3 files changed

Lines changed: 48 additions & 24 deletions

File tree

packages/modules/web_themes/colors/source/src/components/powerGraph/PgXAxis.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,13 @@ const drawAxis1 = computed(() => {
132132
.attr('y', 12)
133133
.attr('fill', 'var(--color-axis)')
134134
.attr('font-size', fontsize)
135-
.text(graphData.graphMode == 'year' ? 'MW' : 'kW')
135+
.text(
136+
graphData.graphMode == 'year'
137+
? 'MWh'
138+
: graphData.graphMode == 'month'
139+
? 'kWh'
140+
: 'kW',
141+
)
136142
.attr('text-anchor', 'start')
137143
return 'PGXAxis.vue'
138144
})

packages/modules/web_themes/colors/source/src/components/powerGraph/PowerGraph.vue

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@
126126
</template>
127127

128128
<script setup lang="ts">
129+
import { computed } from 'vue'
129130
import WBWidget from '../shared/WBWidget.vue'
130131
import PgSourceGraph from './PgSourceGraph.vue'
131132
import PgUsageGraph from './PgUsageGraph.vue'
@@ -154,7 +155,21 @@ import PgToolTips from './PgToolTips.vue'
154155
155156
// state
156157
const stackOrderMax = 2
157-
const heading = 'Leistung / Ladestand '
158+
const heading = computed(() => {
159+
switch (graphData.graphMode) {
160+
case 'year':
161+
return 'Jahresübersicht'
162+
case 'month':
163+
return 'Monatsübersicht'
164+
default:
165+
return 'Leistung / Ladestand'
166+
}
167+
})
168+
/**
169+
* Changes the stack order for usage graph visualization
170+
* Cycles through available stack orders (0 to stackOrderMax)
171+
* Triggers usage graph reinitialization after change
172+
*/
158173
function changeStackOrder() {
159174
let newOrder = globalConfig.usageStackOrder + 1
160175
if (newOrder > stackOrderMax) {
@@ -163,6 +178,11 @@ function changeStackOrder() {
163178
globalConfig.usageStackOrder = newOrder
164179
setInitializeUsageGraph(true)
165180
}
181+
182+
/**
183+
* Configures zoom behavior for the power graph SVG
184+
* @param svg - D3 Selection of the SVG element to apply zoom to
185+
*/
166186
function setZoom(svg: Selection<Element, unknown, HTMLElement, unknown>) {
167187
const myextent: [[number, number], [number, number]] = [
168188
[0, margin.top],
@@ -181,17 +201,30 @@ function setZoom(svg: Selection<Element, unknown, HTMLElement, unknown>) {
181201
)
182202
}
183203
184-
// callback that is called when the user tries to pan/zoom in the window
204+
/**
205+
* Handles zoom events on the graph
206+
* Updates the transform value used for rendering
207+
* @param event - D3 zoom event containing transform information
208+
*/
185209
function zoomed(event: D3ZoomEvent<SVGGElement, unknown>) {
186210
mytransform.value = event.transform
187211
}
188212
189-
// prevent scrolling then apply the default filter
213+
/**
214+
* Filters zoom/pan events to control graph interaction
215+
* Prevents default scroll behavior and applies zoom constraints
216+
* @param event - Browser pointer or wheel event
217+
* @returns boolean indicating if the event should trigger zoom
218+
*/
190219
function filter(event: PointerEvent | WheelEvent) {
191220
event.preventDefault()
192221
return (!event.ctrlKey || event.type === 'wheel') && !event.button
193222
}
194223
224+
/**
225+
* Toggles the zoom state of the graph
226+
* Sets the current widget as active and toggles zoom mode
227+
*/
195228
function zoomGraph() {
196229
globalConfig.zoomedWidget = 1
197230
globalConfig.zoomGraph = !globalConfig.zoomGraph
@@ -207,22 +240,4 @@ onMounted(() => {
207240
.fa-magnifying-glass {
208241
color: var(--color-menu);
209242
}
210-
211-
.dateWbBadge {
212-
background-color: var(--color-menu);
213-
color: var(--color-bg);
214-
font-size: var(--font-medium);
215-
font-weight: normal;
216-
}
217-
218-
.waitsign {
219-
text-align: center;
220-
font-size: var(--font-medium);
221-
color: var(--color-fg);
222-
border: 1px solid var(--color-bg);
223-
padding: 2em;
224-
margin: 2em;
225-
margin-top: 4em;
226-
background-color: var(--color-bg);
227-
}
228243
</style>

packages/modules/web_themes/colors/source/src/components/powerMeter/PMArc.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@
3333
:transform="'translate(' + path.centroid(consumer) + ')'"
3434
>
3535
<PMPopup
36-
v-if="categoriesToShow.includes(consumer.data.type) && Math.abs(consumer.data.power) / summarizedPower > 0.05"
36+
v-if="
37+
categoriesToShow.includes(consumer.data.type) &&
38+
Math.abs(consumer.data.power) / summarizedPower > 0.05
39+
"
3740
:consumer="consumer.data"
3841
/>
3942
</g>
@@ -83,7 +86,7 @@ function strokeColor(d: PieArcDatum<PowerItem>, i: number): string {
8386
: 'null'
8487
: d.data.color
8588
}
86-
const summarizedPower = computed (() => {
89+
const summarizedPower = computed(() => {
8790
return props.plotdata.reduce((sum, item) => sum + Math.abs(item.power), 0)
8891
})
8992
</script>

0 commit comments

Comments
 (0)