fix(chart): make xticks count tick positions - #1440
Conversation
51f4f0a to
c7fe07b
Compare
c7fe07b to
488a51f
Compare
488a51f to
ed9ccf2
Compare
| lineCap: "round", | ||
| curve: "smooth", | ||
| }, | ||
| xaxis: { |
There was a problem hiding this comment.
why not define tickAmount as part of the initial builder?
| if (is_timeseries) return "datetime"; | ||
| if (x_is_text(series)) return "category"; | ||
| if ( | ||
| typeof series[0]?.data?.[0]?.x === "number" && |
There was a problem hiding this comment.
[nit] x_is_text is basically the same object being destructured
| */ | ||
| function xaxis_tick_amount(xticks, xaxis_type) { | ||
| if (!xticks) return; | ||
| return xaxis_type === "numeric" ? Math.max(1, xticks - 1) : xticks; |
There was a problem hiding this comment.
numeric is only possible if is_horizontal is false (see line 70 before or 79 after)
There was a problem hiding this comment.
| @@ -55,8 +70,22 @@ test("does not turn category-oriented charts into numeric axes", () => { | |||
| const numeric = [series("a", { x: 1, y: 1 })]; | |||
There was a problem hiding this comment.
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
| // 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); |
There was a problem hiding this comment.
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.
Summary
xticksvalues from requested tick positions to ApexCharts intervalsTests
npm run formatnpm testSQLPAGE_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