Skip to content

fix(scatter): apply jitter on both category axes when both configured (Fixes #21728) - #21729

Open
waterWang wants to merge 1 commit into
apache:masterfrom
waterWang:fix/scatter-jitter-category-21728
Open

fix(scatter): apply jitter on both category axes when both configured (Fixes #21728)#21729
waterWang wants to merge 1 commit into
apache:masterfrom
waterWang:fix/scatter-jitter-category-21728

Conversation

@waterWang

Copy link
Copy Markdown

Fixes #21728

Problem

The jitterLayout stage only checked the base axis (returned by getBaseAxis()) for jitter configuration. When both axes were category (ordinal) with jitter configured, only the base axis direction was jittered. The other axis jitter configuration was completely ignored.

For example, with:

xAxis: { type: 'category', data: ['a'], jitter: 300 },
yAxis: { type: 'category', data: ['xx'], jitter: 300 },

Only the x-axis jitter was applied, and the y-axis scatter points had no random offset.

Changes

In jitterLayout.ts:

  1. After checking the base axis for jitter, also check the other axis (e.g. yAxis when baseAxis is xAxis) using coordSys.getOtherAxis()
  2. If the other axis is ordinal and has jitter > 0, apply jitter along that axis direction too
  3. The early-return guard now checks both axes: if (!hasJitter && !hasOtherJitter) return;

This enables jittering on both axis directions when both axes are category with jitter configured, matching the behavior of JMP-style scatter plots where points spread in both x and y directions.

Test

Scatter plot with both category axes, each with jitter: 300, should now show random offset in both x and y directions.

@echarts-bot

echarts-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown

Thanks for your contribution!
The community will review it ASAP. In the meanwhile, please checkout the coding standard and Wiki about How to make a pull request.

Please DO NOT commit the files in dist, i18n, and ssr/client/dist folders in a non-release pull request. These folders are for release use only.

To reviewers: If this PR is going to be described in the changelog in the future release, please make sure this PR has one of the following labels: PR: doc ready, PR: awaiting doc, PR: doc unchanged

This message is shown because the PR description doesn't contain the document related template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] jitter not working in Y Axis Config

1 participant