Skip to content

fix(chart): make xticks count tick positions - #1440

Open
lovasoa wants to merge 2 commits into
mainfrom
fix/xticks-count
Open

fix(chart): make xticks count tick positions#1440
lovasoa wants to merge 2 commits into
mainfrom
fix/xticks-count

Conversation

@lovasoa

@lovasoa lovasoa commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • translate numeric xticks values from requested tick positions to ApexCharts intervals
  • assert the numeric chart fixture renders exactly the requested number of x-axis labels
  • update the chart documentation and unreleased changelog entry

Tests

  • npm run format
  • npm test
  • SQLPAGE_FIXTURE_BASE=http://127.0.0.1:18081 SQLPAGE_BINARY=/home/ophir/dev/SQLPage/target/debug/sqlpage npx playwright test fixtures/chart/test.ts --project=fixtures --reporter=line

@lovasoa
lovasoa requested a review from 81reap September 10, 2026 08:37
@lovasoa
lovasoa added this pull request to stack #1441 September 10, 2026 08:45
Base automatically changed from fix/numeric-chart-axis to main September 10, 2026 14:27
Comment thread sqlpage/apexcharts.js
lineCap: "round",
curve: "smooth",
},
xaxis: {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not define tickAmount as part of the initial builder?

Comment thread sqlpage/apexcharts.js
if (is_timeseries) return "datetime";
if (x_is_text(series)) return "category";
if (
typeof series[0]?.data?.[0]?.x === "number" &&

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] x_is_text is basically the same object being destructured

Comment thread sqlpage/apexcharts.js
*/
function xaxis_tick_amount(xticks, xaxis_type) {
if (!xticks) return;
return xaxis_type === "numeric" ? Math.max(1, xticks - 1) : xticks;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

numeric is only possible if is_horizontal is false (see line 70 before or 79 after)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -55,8 +70,22 @@ test("does not turn category-oriented charts into numeric axes", () => {
const numeric = [series("a", { x: 1, y: 1 })];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding a test for [series("a", { x: "a", y: 1 })] and checking assert.equal(value_axis_labels(3, axis), 3); instead of undefined may have caught the horizontal edge case

Comment thread sqlpage/apexcharts.js
// Numeric axes count intervals; category and time axes use tickAmount as a
// target for label density.
if (data.xticks) options.xaxis.tickAmount = data.xticks;
options.xaxis.tickAmount = xaxis_tick_amount(data.xticks, xaxis_type);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the docs say this is tick interval not the number of ticks

Number of Tick Intervals to show. Note: tickAmount doesn't affect datetime xaxis types. For numeric axes, use tickAmount: 'dataPoints' to match dataPoint counts.

https://apexcharts.com/docs/options/xaxis/

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.

Bug in the display of the chart component (x axis is not correctly aligned) reopened

2 participants