Skip to content

fix: x-axis annotations missing on line/area/scatter charts (5.10.4 regression)#5201

Merged
junedchhipa merged 2 commits into
mainfrom
copilot/fix-line-chart-annotations-issue
Apr 5, 2026
Merged

fix: x-axis annotations missing on line/area/scatter charts (5.10.4 regression)#5201
junedchhipa merged 2 commits into
mainfrom
copilot/fix-line-chart-annotations-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 5, 2026

In 5.10.4, a type-safety change in getStringX() broke x-axis annotations on line, area, and scatter charts that use simple array series data — annotations were silently not rendered.

Root cause

Config.js automatically sets convertedCatToNumeric = true for line/area/scatter charts. This causes _generateExternalLabels to produce numeric categoryLabels (e.g. [1, 2, 3, 4, 5] via the default Math.floor formatter). The 5.10.4 change converted the search value to a string before the indexOf lookup:

// 5.10.4 — broken: searches for '2' in [1, 2, 3, 4, 5] → -1
x = w.labelData.categoryLabels.indexOf(String(x)) + 1

indexOf('2') returns -1 in a number array, so the annotation position resolves to index 0, the DOM lookup fails, and getStringX returns the raw annotation value (e.g. 2) as a pixel offset — placing the line at the far left edge or causing it to be clipped entirely.

Fix

Convert both sides to strings before comparing, which correctly handles all type combinations (number labels + number x, string labels + string x, cross-type):

// src/modules/annotations/Helpers.js
const strX = String(x)
x = w.labelData.categoryLabels.findIndex(
  (l) => String(l) === strX,
) + 1

Test

Added a regression test verifying that an xaxis annotation with a numeric x value renders on a line chart with simple array data.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • jsfiddle.net
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)
  • registry.npmmirror.com
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install --legacy-peer-deps (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install --prefer-offline conf�� get --global rgo/bin/git credential.helpegrep (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

…5198)

In 5.10.4, getStringX() changed from indexOf(x) to indexOf(String(x))
which breaks when categoryLabels contains numbers (e.g. line/area/scatter
charts with convertedCatToNumeric=true and auto-generated integer labels).

Fix by using findIndex with String() comparison on both sides, which correctly
handles all type combinations (number labels + number x, string labels +
string x, number labels + string x, string labels + number x).

Agent-Logs-Url: https://github.com/apexcharts/apexcharts.js/sessions/86796618-e73e-43c6-a6b4-237395ba6ad1

Co-authored-by: junedchhipa <17950663+junedchhipa@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix line chart x-axis annotations in version 5.10.4 fix: x-axis annotations missing on line/area/scatter charts (5.10.4 regression) Apr 5, 2026
Copilot AI requested a review from junedchhipa April 5, 2026 05:49
@junedchhipa junedchhipa marked this pull request as ready for review April 5, 2026 06:09
@junedchhipa junedchhipa merged commit 7dd405b into main Apr 5, 2026
5 of 11 checks passed
@junedchhipa junedchhipa deleted the copilot/fix-line-chart-annotations-issue branch April 5, 2026 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Line chart with x-axis annotations broken in 5.10.4

2 participants