126126</template >
127127
128128<script setup lang="ts">
129+ import { computed } from ' vue'
129130import WBWidget from ' ../shared/WBWidget.vue'
130131import PgSourceGraph from ' ./PgSourceGraph.vue'
131132import PgUsageGraph from ' ./PgUsageGraph.vue'
@@ -154,7 +155,21 @@ import PgToolTips from './PgToolTips.vue'
154155
155156// state
156157const 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+ */
158173function 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+ */
166186function 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+ */
185209function 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+ */
190219function 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+ */
195228function 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 >
0 commit comments