Skip to content

Commit 8269c3c

Browse files
committed
feat(annotations): add halo prop to text annotations
Allows disabling the paint-order stroke halo on text annotations via `halo: false`. Useful for white text overlaid on colored chart elements where the background-colored stroke makes text invisible.
1 parent 8c3fd6a commit 8269c3c

4 files changed

Lines changed: 6 additions & 1 deletion

File tree

packages/core/src/types/layout.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,8 @@ export interface ResolvedLabel {
505505
};
506506
/** Background color behind the label text. */
507507
background?: string;
508+
/** Whether to show the paint-order stroke halo. Default true. */
509+
halo?: boolean;
508510
}
509511

510512
// ---------------------------------------------------------------------------

packages/core/src/types/spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,8 @@ export interface TextAnnotation extends AnnotationBase {
563563
};
564564
/** Background color behind the text. Useful for readability over chart lines. */
565565
background?: string;
566+
/** Whether to show the paint-order stroke halo behind text. Default true. Set false for white text on colored backgrounds. */
567+
halo?: boolean;
566568
}
567569

568570
/**

packages/engine/src/annotations/resolve-text.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ export function resolveTextAnnotation(
121121
}
122122
: undefined,
123123
background: annotation.background,
124+
halo: annotation.halo,
124125
};
125126

126127
return {

packages/vanilla/src/renderers/annotations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ function renderAnnotation(
183183
rx: 2,
184184
});
185185
g.appendChild(bgRect);
186-
} else if (bgColor) {
186+
} else if (bgColor && annotation.label.halo !== false) {
187187
text.style.paintOrder = 'stroke';
188188
text.style.stroke = bgColor;
189189
text.style.strokeWidth = `${Math.round(fontSize * 0.3)}px`;

0 commit comments

Comments
 (0)