MCPcopy Index your code
hub / github.com/ChartGPU/ChartGPU / addAxisLabelsToOverlay

Function addAxisLabelsToOverlay

src/utils/axisLabelStyling.ts:49–81  ·  view source on GitHub ↗
(
  overlay: TextOverlay,
  xLabels: readonly AxisLabel[],
  yLabels: readonly AxisLabel[],
  theme: AxisLabelThemeConfig
)

Source from the content-addressed store, hash-verified

47 * Adds axis labels to a text overlay with consistent styling.
48 */
49export function addAxisLabelsToOverlay(
50 overlay: TextOverlay,
51 xLabels: readonly AxisLabel[],
52 yLabels: readonly AxisLabel[],
53 theme: AxisLabelThemeConfig
54): void {
55 // Clear existing labels
56 overlay.clear();
57
58 const axisNameFontSize = getAxisTitleFontSize(theme.fontSize);
59
60 // Add X-axis labels
61 for (const label of xLabels) {
62 const span = overlay.addLabel(label.text, label.x, label.y, {
63 fontSize: label.isTitle ? axisNameFontSize : theme.fontSize,
64 color: theme.textColor,
65 anchor: label.anchor ?? 'middle',
66 rotation: label.rotation,
67 });
68 styleAxisLabelSpan(span, label, theme);
69 }
70
71 // Add Y-axis labels
72 for (const label of yLabels) {
73 const span = overlay.addLabel(label.text, label.x, label.y, {
74 fontSize: label.isTitle ? axisNameFontSize : theme.fontSize,
75 color: theme.textColor,
76 anchor: label.anchor ?? 'end',
77 rotation: label.rotation,
78 });
79 styleAxisLabelSpan(span, label, theme);
80 }
81}

Callers 1

Calls 4

getAxisTitleFontSizeFunction · 0.85
styleAxisLabelSpanFunction · 0.85
addLabelMethod · 0.80
clearMethod · 0.65

Tested by

no test coverage detected