-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
cartesian 2dMap: implement sorting of categorical axes #3827
Merged
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
e1716c7
heatmap: reorder data based on categoryarray
antoinerg d8ef1d7
heatmap: :lock: down categoryorder and categoryarray with tests
antoinerg 9735683
heatmap: handle undefined axes in clean_2d_array
antoinerg 5798dd8
heatmap: properly sort categorical data when z data is a 1D array
antoinerg 56c6a4d
heatmap: do not sort categorical axes for contour
antoinerg f878387
heatmap: only sort categorical axes for trace type heatmap
antoinerg a34ca45
heatmap: fix - check trace exists before checking type
antoinerg 6b06516
heatmap: handle categorical axis sorting except for (contour)carpet
antoinerg 59edb57
heatmap calc: improve style, test contour and heatmap
antoinerg 22cfa82
:lock: down category ordering in histogram2d(contour) with tests
antoinerg 02e4089
:lock: down category ordering in heatmapgl with tests
antoinerg 5160948
test: tag @flaky test, :hocho: useless lines
antoinerg e966030
categorical heatmap: handle missing categories, 1D data and hover
antoinerg ae3ecf5
categorical contour: fix jasmine test
antoinerg e68c170
categorical 2dMap: fill missing category in input data with undefined
antoinerg ebf545f
categorial 2dMap: replace undefined with BADNUM
antoinerg 793c2a3
categorical 2dMap: update mock and baseline
antoinerg 4d4b0b7
categorical 2dmap: fix flaky tests
antoinerg f180c79
categorical 2dmap: do not use indexOf to find trace-level category ma…
antoinerg 0c41776
categorical cartesian: convert numbers to strings for _categories
antoinerg c7cd1f3
categorical 2dMap: remove hasOwnProperty() call
antoinerg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"data": [{ | ||
"type": "heatmap", | ||
"x": ["a", "a", "a", "b", "b", "b", "c", "c", "c"], | ||
"y": ["A", "B", "C", "A", "B", "C", "A", "B", "C"], | ||
"z": [0, 50, 100, 50, 0, 255, 100, 510, 1010] | ||
}], | ||
"layout": { | ||
"xaxis": { | ||
"categoryorder": "category descending" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"data": [{ | ||
"type": "heatmap", | ||
"x": ["Team A", "Team B", "Team C"], | ||
"xaxis": "x", | ||
"y": ["Game Three", "Game Two", "Game One"], | ||
"z": [ | ||
[0.1, 0.3, 0.5], | ||
[1, 0.8, 0.6], | ||
[0.6, 0.4, 0.2] | ||
], | ||
"yaxis": "y" | ||
}, { | ||
"type": "heatmap", | ||
"x": ["Team B", "Team C"], | ||
"xaxis": "x", | ||
"y": ["Game Three", "Game Two", "Game One"], | ||
"z": [ | ||
[0.3, 0.5], | ||
[0.8, 0.6], | ||
[0.4, 0.2] | ||
], | ||
"yaxis": "y2" | ||
}], | ||
"layout": { | ||
etpinard marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"xaxis": { | ||
"anchor": "y2", | ||
"domain": [0, 1], | ||
"type": "category", | ||
"range": [-0.5, 2.5], | ||
"autorange": true | ||
}, | ||
"yaxis": { | ||
"anchor": "free", | ||
"domain": [0.575, 1], | ||
"position": 0, | ||
"type": "category", | ||
"range": [-0.5, 2.5], | ||
"autorange": true | ||
}, | ||
"yaxis2": { | ||
"anchor": "x", | ||
"domain": [0, 0.425], | ||
"type": "category", | ||
"range": [-0.5, 2.5], | ||
"autorange": true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
adding
var axLetter = ax._id.charAt(0)
above probably wouldn't hurt.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.
Oh and can we use
ax._categoriesMap
instead of a (potentially) costlyindexOf
intoax._categories
?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.
One more thing, grepping for
xMap
andyMap
doesn't yield anything for me. Where do they come from?EDIT: Nevermind. I found them in
convert_column_xyz.js
.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.
Unfortunately, we cannot. For example, in the
heatmap_shared_categories
mock,_categoriesMap
links categoryTeam C
with index 2. That index is out of range for the second trace since it only has 2 columns. We really need to check whether each trace has data for a given category (and fill withBADNUM
) to fix #1117.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.
Ok, that's very unfortunate, because
can be very costly.
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.
What if instead you made
_(x|y)CategoryMap
lookup objects?That is, instead of:
we could have
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.
About your questions regarding
hasOwnProperty
:hasOwnProperty
is roughly 6 times faster thanindexOf
However, we now run it for every element so in the end, I'm not sure which is faster with real data.
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.
Sorry @antoinerg I got confused (again). Your logic looks right to me.
The way you have it setup right now, I think we can get rid of the
axMapping.hasOwnProperty(ax._categories[i])
and just have:where the
+ 1
takes care of theind === 0
case.This comment is non-blocking as I don't expect much of a performance gain from it 😏
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.
Awesome trick :) Done in c7cd1f3
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.
💃 💃