-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Sort + set 'categoryarray' #1689
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1973,8 +1973,6 @@ plots.doCalcdata = function(gd, traces) { | |
|
||
var trace, _module, i, j; | ||
|
||
var hasCategoryAxis = false; | ||
|
||
// XXX: Is this correct? Needs a closer look so that *some* traces can be recomputed without | ||
// *all* needing doCalcdata: | ||
var calcdata = new Array(fullData.length); | ||
|
@@ -1996,20 +1994,6 @@ plots.doCalcdata = function(gd, traces) { | |
fullLayout._piecolormap = {}; | ||
fullLayout._piedefaultcolorcount = 0; | ||
|
||
// initialize the category list, if there is one, so we start over | ||
// to be filled in later by ax.d2c | ||
for(i = 0; i < axList.length; i++) { | ||
axList[i]._categories = axList[i]._initialCategories.slice(); | ||
|
||
// Build the lookup map for initialized categories | ||
axList[i]._categoriesMap = {}; | ||
for(j = 0; j < axList[i]._categories.length; j++) { | ||
axList[i]._categoriesMap[axList[i]._categories[j]] = j; | ||
} | ||
|
||
if(axList[i].type === 'category') hasCategoryAxis = true; | ||
} | ||
|
||
// If traces were specified and this trace was not included, | ||
// then transfer it over from the old calcdata: | ||
for(i = 0; i < fullData.length; i++) { | ||
|
@@ -2019,6 +2003,8 @@ plots.doCalcdata = function(gd, traces) { | |
} | ||
} | ||
|
||
var hasCategoryAxis = plots.initCategories(axList); | ||
|
||
var hasCalcTransform = false; | ||
|
||
// transform loop | ||
|
@@ -2051,9 +2037,9 @@ plots.doCalcdata = function(gd, traces) { | |
axList[i]._min = []; | ||
axList[i]._max = []; | ||
axList[i]._categories = []; | ||
// Reset the look up map | ||
axList[i]._categoriesMap = {}; | ||
} | ||
plots.initCategories(axList); | ||
} | ||
|
||
// 'regular' loop | ||
|
@@ -2099,6 +2085,26 @@ plots.doCalcdata = function(gd, traces) { | |
} | ||
}; | ||
|
||
plots.initCategories = function(axList) { | ||
var hasCategoryAxis = false; | ||
|
||
// 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(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Certainly would have been caught by now if this could ever be undefined, right? (I'm too cautious about checking for undefined unnecessarily) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah. That There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Haha the squirt gun. And then your socks are wet for the rest of the day. |
||
|
||
// Build the lookup map for initialized categories | ||
axList[i]._categoriesMap = {}; | ||
for(var j = 0; j < axList[i]._categories.length; j++) { | ||
axList[i]._categoriesMap[axList[i]._categories[j]] = j; | ||
} | ||
|
||
if(axList[i].type === 'category') hasCategoryAxis = true; | ||
} | ||
|
||
return hasCategoryAxis; | ||
}; | ||
|
||
plots.rehover = function(gd) { | ||
if(gd._fullLayout._rehover) { | ||
gd._fullLayout._rehover(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a reason to export this fn?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a big deal, but I'd prefer not to since it goes into
Plotly.Plots
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, good call 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in b8e5f52