Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] add jitter option for scatter plots #18432

Open
moshe-intel opened this issue Mar 28, 2023 · 5 comments · May be fixed by #19941
Open

[Feature] add jitter option for scatter plots #18432

moshe-intel opened this issue Mar 28, 2023 · 5 comments · May be fixed by #19941
Labels
en This issue is in English support

Comments

@moshe-intel
Copy link

What problem does this feature solve?

when we want to plot a scatter plot where one of axis types is category or we have only a singleAxis, and we want to clearly see the distribution of the points, especially on dense areas.

What does the proposed API look like?

having an option to add jitter parameter on a scatter series object.

@echarts-bot echarts-bot bot added en This issue is in English pending We are not sure about whether this is a bug/new feature. labels Mar 28, 2023
@helgasoft
Copy link

Jitter is data transformation that can be done before the plot.
Consider adding Math.random() * jitterWidth to data values. See also this.

@moshe-intel
Copy link
Author

Jitter is data transformation that can be done before the plot. Consider adding Math.random() * jitterWidth to data values. See also this.

i cant do that when i use a categorical variable in one of axes like this example:

option = {
  xAxis: { type: 'category' },
  yAxis: {},
  series: {
    data: [
      ['a', 8.04],
      ['a', 6.95],
      ['b', 7.58],
      ['b', 8.21],
      ['c', 8.33],
      ['c', 9.12]
    ],
    type: 'scatter'
  }
};

or using singleAxis like:

option = {
  singleAxis: {},
  series: {
    data: [[8.04], [6.95], [7.58], [8.21], [8.33], [9.12]],
    type: 'scatter',
    coordinateSystem: 'singleAxis'
  }
};

@helgasoft
Copy link

Workaround with two X-axes - Demo Code
image

@Ovilia Ovilia added support waiting-for: author and removed new-feature pending We are not sure about whether this is a bug/new feature. labels Apr 3, 2023
@moshe-intel
Copy link
Author

thank you @helgasoft .

if anyone have more ideas ill be grateful,

@revintec
Copy link

revintec commented Jul 18, 2023

maybe we could add a more universal way to do this? like

series: [{
  data: [], itemStyle: {
    x: (o)=>(Math.random()-0.5)*10, y: 7
  }
}]

the added itemStyle.x and itemStyle.y can either be a value or a callback of a value, defaults to 0
the values are used to adjust the relative position of the scattered symbol

this way no hidden redundant axis is needed, nor a redundant dataset and/or a encoding

@Ovilia Ovilia linked a pull request May 16, 2024 that will close this issue
8 tasks
@Ovilia Ovilia linked a pull request May 16, 2024 that will close this issue
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
en This issue is in English support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants