LearnNewsExamplesConnect
Frontmatter
assigneesneo-opus-vega
createdAtNov 18, 2026, 9:42 PM
updatedAtNov 19, 2026, 2:54 AM
githubUrlhttps://github.com/neomjs/neo/issues/21400
authorneo-opus-vega
commentsCount0
parentIssue21367
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtNov 19, 2026, 2:54 AM

An amCharts chart's text ignores the page's Neo theme

neo-opus-vega
neo-opus-vega commented on Nov 18, 2026, 9:42 PM

Owner: Vega. Not curated for contributors: #21367 names Vega for this band's engine defects, and the Charts renewal waits on this fix before the Sun 22 Nov lock.

Context

On 18 Nov the slate read of the Charts group found the amCharts pie in examples/charts drawing no text: nine legend squares without names and no slice labels, while its tooltip carried the data (Lithuania: 30.5% (501.9)), at 1440 × 900 and 390 × 844 (defect-note a2375219). #21367 files each engine defect as a leaf before its card's renewal. This is the first leaf of Charts part 2.

The Problem

Measured on dev d4c33ec3bc in Chrome, examples/charts/index.html:

  • The chart's SVG holds 28 <text> nodes with their strings (Lithuania: 30.5%, Czech Republic: 18.3%, …). Each is 16 px, visible, opacity 1, and has a real box (getBBox 121 × 18).
  • Their computed fill is rgb(255, 255, 255), inherited from a <g fill="#ffffff"> that amCharts writes.
  • The body is neo-theme-light on rgb(250, 250, 250). Every label is white on near-white. The tooltip draws its own background, so it stays readable.

The cause is in the main-thread addon: Neo.main.addon.AmCharts#create calls am4core.useTheme(am4themes_dark) before every chart (src/main/addon/AmCharts.mjs:149), whatever theme the page or the component uses. Once registered, the dark theme stays in amCharts' global list (am4core.registry.themes), so every later chart in that window is created dark.

The consumers and their themes:

  • examples/charts: no themes in its neo-config.json, so the light theme comes first.
  • apps/covid, apps/sharedcovid: ["neo-theme-dark", "neo-theme-light"].
  • apps/colors: ["neo-theme-dark"].

The Architectural Reality

Design authority: "Maps a Neo theme onto one of {@link #editorThemes}." (Neo.component.wrapper.MonacoEditor#themeMap, src/component/wrapper/MonacoEditor.mjs:121). Neo.component.wrapper.Mermaid#themeMap and #resolveTheme have the same shape: a wrapper around a third-party renderer resolves its library's theme from the Neo theme through a themeMap config.

  • Neo.component.wrapper.AmChart (App worker) creates its chart through the addon in afterSetMounted. It passes {config, package, type, combineSeriesTooltip, data} and no theme.
  • Neo.component.Base#getTheme() (src/component/Base.mjs:1652) resolves the component's theme, else a neo-theme-* class up the parent chain, else the window's themes[0].
  • amCharts 4 applies themes when it creates an object, and am4core.unuseAllThemes() clears the global list. A chart therefore has to be created in its theme, and a theme change on a mounted chart means creating it again.

The Fix

  1. Neo.component.wrapper.AmChart:
    • a themeMap config: neo-theme-cyberpunk, neo-theme-dark and neo-theme-neo-dark → 'dark'; neo-theme-light and neo-theme-neo-light → null (amCharts' own light default);
    • a resolveTheme() reading themeMap[getTheme()];
    • create receives the resolved theme;
    • afterSetTheme creates a mounted chart again when the resolved theme changes.
  2. Neo.main.addon.AmCharts#create: clear the global theme list, apply only the requested theme ('dark' → am4themes_dark), then create.

Contract Ledger

Target Surface Source of Authority Proposed Behavior Fallback Docs Evidence
Neo.component.wrapper.AmChart#themeMap (new config) MonacoEditor#themeMap, Mermaid#themeMap maps a neo-theme-* name to an amCharts theme name, or null an unmapped theme resolves to null, amCharts' light default; a consumer extends the map the config's JSDoc AC-2
Neo.main.addon.AmCharts#create(data), new optional data.theme this ticket 'dark' creates this chart with am4themes_dark, and no theme carries over to the next chart absent or null → amCharts' default the method's JSDoc AC-3

Decision Record impact: none.

Acceptance Criteria

  • AC-1: examples/charts draws its legend names and slice labels readable: a dark fill under neo-theme-light and a light fill under neo-theme-dark, each with contrast ≥ 4.5:1 against the page background. Red on dev under the light theme.
  • AC-2: A unit arm resolves the chart theme for each shipped Neo theme, and for a chart that inherits its theme from a parent's neo-theme-* class.
  • AC-3: A unit arm creates two charts in a row with different themes through the addon (an am4core stub): each is created in its own theme, and the light one inherits nothing from the dark one.
  • AC-4: Setting theme on a mounted chart creates it again in the new theme (unit arm on the wrapper with the addon stubbed).

Out of Scope

  • An amCharts v5 port (Discussion #20309).
  • The COVID apps' theme button. It swaps the neo-theme-* class in its MainContainer's cls and never sets theme, so a mounted chart keeps the theme it was created in. That is today's behaviour, unchanged here; it gets a defect-note.
  • The Charts card itself (record, cover, layout): the next leaf of #21367.

Avoided Traps

  • A substring test on the theme name: neo-theme-cyberpunk is dark and its name does not say so (the reason MonacoEditor#themeMap is a map).
  • Recolouring text through CSS (svg text {fill: …}): amCharts writes fills as attributes on its groups, so a stylesheet would fight every chart's own colours, labels inside slices included.
  • Keeping useTheme without clearing the list: once one dark chart exists in a window, every chart created after it is dark too.

Related

Parent: #21367 · slate rows: #21142 · Charts part 1: #21322, PR #21328 · Discussion #20309 · defect-note a2375219.

Live latest-open + closed sweep: at 2026-11-18T20:43Z, read the latest 20 open, plus open and closed searches for "amCharts", "am4core", "chart text", "chart theme", "am4themes", "amCharts dark". The closed hits were unrelated, and nothing equivalent or excluded turned up. 81 open, red band; the owning epic is #21367, and this files under it. A2A in-flight sweep: the latest 30 messages in all read-states, newest 20:37:25Z, held no claim on amCharts or chart themes. MC sweep: "amCharts pie legend names and slice labels missing, white chart text on a light theme, tooltip shows the data", 6 results, no prior decision. Own-assignment sweep: 7 open, none overlapping (#21367 is the parent). Structure map: N/A, no Agent OS placement.

Origin Session ID: 82130fd4-f8a9-4794-9664-67fa9a133117 Retrieval Hint: "amCharts addon forces am4themes_dark: chart text white on light Neo themes; AmChart wrapper lacks the Monaco/Mermaid themeMap"

tobiu referenced in commit f8672a5 - "fix(charts): an amCharts chart draws its text in its Neo theme's colours (#21400) (#21401) on Nov 19, 2026, 2:54 AM
tobiu closed this issue on Nov 19, 2026, 2:54 AM