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

Sort + set 'categoryarray' #1689

Merged
merged 3 commits into from May 16, 2017

Conversation

Projects
None yet
3 participants
@etpinard
Copy link
Member

commented May 15, 2017

Plotly.newPlot('graph', [{
  mode: 'markers',
  x: ['A', 'B', 'C'],
  y: ['a', 'b', 'c'],
  marker: { size: [20, 30, 50] },
  transforms: [{
    type: 'sort',
    target: [2, 1, 0]
  }]
}])

currently gives:

image

where the categories are re-arranged after the sort transform - which is consistent with how we handle categories in filter transforms. See PR #1260 for more details.

But setting layout.xaxis.categoryarray: ['A', 'B', 'C] -- which implies that the category positions are fixed -- curently gives the same results as above.

With commit 7a2a2e1

Plotly.newPlot('graph', [{
  mode: 'markers',
  x: ['A', 'B', 'C'],
  y: ['a', 'b', 'c'],
  marker: { size: [20, 30, 50] },
  transforms: [{
    type: 'sort',
    target: [2, 1, 0]
  }]
}], {
  xaxis: {
    categoryarray: ['A', 'B', 'C']
  }
})

now gives:

image

where categoryarray is honored.

cc @n-riesco @alexcjohnson

@@ -2099,6 +2085,26 @@ plots.doCalcdata = function(gd, traces) {
}
};

plots.initCategories = function(axList) {

This comment has been minimized.

Copy link
@alexcjohnson

alexcjohnson May 15, 2017

Contributor

is there a reason to export this fn?

This comment has been minimized.

Copy link
@etpinard

etpinard May 15, 2017

Author Member

No.

This comment has been minimized.

Copy link
@alexcjohnson

alexcjohnson May 15, 2017

Contributor

Not a big deal, but I'd prefer not to since it goes into Plotly.Plots

This comment has been minimized.

Copy link
@etpinard

etpinard May 15, 2017

Author Member

Yeah, good call 👍

This comment has been minimized.

Copy link
@etpinard

etpinard May 15, 2017

Author Member

done in b8e5f52

// initialize the category list, if there is one, so we start over
// to be filled in later by ax.d2c
for(var i = 0; i < axList.length; i++) {
axList[i]._categories = axList[i]._initialCategories.slice();

This comment has been minimized.

Copy link
@rreusser

rreusser May 15, 2017

Contributor

Certainly would have been caught by now if this could ever be undefined, right? (I'm too cautious about checking for undefined unnecessarily)

This comment has been minimized.

Copy link
@etpinard

etpinard May 15, 2017

Author Member

Yeah. That _initialCategories thing is set in the defaults. Calling Plots.doCalcdata before supplyDefaults is like 🔫 yourself in the 👣 .

This comment has been minimized.

Copy link
@rreusser

rreusser May 15, 2017

Contributor

Haha the squirt gun. And then your socks are wet for the rest of the day.

@alexcjohnson

This comment has been minimized.

Copy link
Contributor

commented May 15, 2017

💃 very clean! But consider #1689 (comment) before merging.

@etpinard etpinard merged commit a86a5ac into master May 16, 2017

1 check passed

ci/circleci Your tests passed on CircleCI!
Details

@etpinard etpinard deleted the sort-with-categoryarray branch May 16, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.