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

X Axis (type: category) sorting gets lost when traces have different X values #254

Closed
arikfr opened this issue Feb 12, 2016 · 3 comments
Closed

Comments

@arikfr
Copy link

arikfr commented Feb 12, 2016

Here's an example: http://codepen.io/anon/pen/vLbXQX

The traces are:

var trace1 = {
  x: [1, 7, 8, 10, 15, 16, 17], 
  y: [10, 15, 13, 17, 5,6,7], 
  type: 'bar'
};
var trace2 = {
  x: [ 1, 4, 5, 7], 
  y: [16, 11,2, 9], 
  type: 'bar'
};

Resulting plot is:
image

Notice how the values for 4 & 5 are at the end of the X axis.

It doesn't happen all the time, for example if we switch the order of trace1 and trace2, it gets drawn properly:

image

Is it me holding it wrong or an actual issue?

@etpinard
Copy link
Contributor

@arikfr thanks for the very detailed report 🍻

What you described is actually the desired behaviour in the current specs. plotly.js does not sort categories. Categories are listed in the order where they are supplied in the data.

So, the categories in the first trace come first then the categories in the second trace either get paired up with the categories already present or are appended at the end of the category list.

We are planning on adding more control to categorical axes. See #189 for more details. So I'll mark this issue as a duplicate.

@etpinard
Copy link
Contributor

duplicate of #189

@arikfr
Copy link
Author

arikfr commented Feb 12, 2016

@etpinard thanks for the quick reply. I will follow #189 and apply some workaround on our side until then.

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

No branches or pull requests

2 participants