@@ -274,18 +274,25 @@ function getTextNode(index: number) {
274
274
275
275
function setTicks() {
276
276
ticksWithAttributes .value = ticks .value .map (
277
- (tick : string | number , index : number ) => {
278
- return {
279
- value: formatTick (tick ),
280
- group: mixins .getTickGroupAttributes (tick , index ),
281
- ghost: mixins .getTickGhostAttributes (getTextNode (index )),
282
- label: mixins .getTickLabelAttributes (),
283
- gridline: mixins .getGridLinesAttributes (),
284
- };
285
- }
277
+ (tick : string | number , index : number ) => ({
278
+ value: formatTick (tick ),
279
+ group: mixins .getTickGroupAttributes (tick , index ),
280
+ ghost: mixins .getTickGhostAttributes (getTextNode (index )),
281
+ label: mixins .getTickLabelAttributes (),
282
+ gridline: mixins .getGridLinesAttributes (),
283
+ })
286
284
);
287
285
}
288
286
287
+ function updateGridlines() {
288
+ if (ticksWithAttributes .value ) {
289
+ ticksWithAttributes .value .map ((tick ) => {
290
+ tick .gridline = mixins .getGridLinesAttributes ();
291
+ return tick ;
292
+ });
293
+ }
294
+ }
295
+
289
296
function init() {
290
297
if (! scale .value ) return ;
291
298
@@ -308,12 +315,17 @@ function init() {
308
315
// Setup watcher to get new mixins if scale changes (i.e. vertical to horizontal)
309
316
watch (scale , init , { flush: ' sync' , immediate: true });
310
317
311
- // Re-render after scale changes (new containerSize, new balebs , scale override, etc.)
318
+ // Re-render after scale changes (new containerSize, new values , scale override, etc.)
312
319
watch (scale , setTicks , { immediate: true });
313
320
// Re-render after `tickRefs` is defined (to grab text width)
314
321
watch (tickRefs , setTicks );
315
322
316
323
watch (axisSize , (size ) => emit (' lume__internal--axis-size' , size ));
317
324
325
+ // Re-calculate gridlines when container size changes
326
+ // This is needed for cases where the container width changes, so the Y gridlines need to update,
327
+ // but the Y scale doesn't change since the height is the same
328
+ watch (props .containerSize , updateGridlines );
329
+
318
330
onMounted (() => svgCheck (root .value ));
319
331
</script >
0 commit comments