-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Axis category ordering - adds feature #189 #419
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 1 commit
94e0133
e36d163
df9ee94
eb499d4
c7fb84b
02ed858
53f12da
14908d0
b21ebb2
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 |
---|---|---|
|
@@ -465,6 +465,36 @@ module.exports = { | |
'Only has an effect if `anchor` is set to *free*.' | ||
].join(' ') | ||
}, | ||
categorymode: { | ||
valType: 'enumerated', | ||
values: [ | ||
'trace', 'category ascending', 'category descending', 'array' | ||
/*, 'value ascending', 'value descending'*/ // value ascending / descending to be implemented later | ||
], | ||
dflt: 'trace', | ||
role: 'info', | ||
description: [ | ||
'Specifies the ordering logic for the case of categorical variables.', | ||
'By default, plotly uses *trace*, which specifies the order that is present in the data supplied.', | ||
'Set `categorymode` to *category ascending* or *category descending* if order should be determined by', | ||
'the alphanumerical order of the category names.', | ||
/*'Set `categorymode` to *value ascending* or *value descending* if order should be determined by the', | ||
'numerical order of the values.',*/ // // value ascending / descending to be implemented later | ||
'Set `categorymode` to *array* to derive the ordering from the attribute `categorylist`. If a category', | ||
'is not found in the `categorylist` array, the sorting behavior for that attribute will be identical to', | ||
'the *trace* mode. The unspecified categories will follow the categories in `categorylist`.' | ||
].join(' ') | ||
}, | ||
categorylist: { | ||
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. other possibilities include: But I'd vote for the more verbose 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. +1 for 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. 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.
We don't want to confuse Other options:
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.
No. Only for axis 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. Got it. But eventually it would, right? And shouldn't need a different key? 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. That wasn't in the plans. Why would anyone want to reorder dates or numeric independent coordinates? 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. oh duh, woops my bad. 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. But my second point "We don't want to confuse categories with ticklabels" still stands :) |
||
valType: 'data_array', | ||
role: 'info', | ||
description: [ | ||
'Sets the order in which categories on this axis appear.', | ||
'Only has an effect if `categorymode` is set to *array*.', | ||
'Used with `categorymode`.' | ||
].join(' ') | ||
}, | ||
|
||
|
||
_deprecated: { | ||
autotick: { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,6 +68,35 @@ module.exports = { | |
description: 'Sets whether or not this axis is labeled' | ||
}, | ||
color: axesAttrs.color, | ||
categorymode: { | ||
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. Reuse the categorymode: axesAttrs.categorymode,
categorylist: axesAttrs.categorylist, 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. @etpinard good point! I'll await all PR responses and do them in one to not go wild with commits. |
||
valType: 'enumerated', | ||
values: [ | ||
'trace', 'category ascending', 'category descending', 'array' | ||
/*, 'value ascending', 'value descending'*/ // value ascending / descending to be implemented later | ||
], | ||
dflt: 'trace', | ||
role: 'info', | ||
description: [ | ||
'Specifies the ordering logic for the case of categorical variables.', | ||
'By default, plotly uses *trace*, which specifies the order that is present in the data supplied.', | ||
'Set `categorymode` to *category ascending* or *category descending* if order should be determined by', | ||
'the alphanumerical order of the category names.', | ||
/*'Set `categorymode` to *value ascending* or *value descending* if order should be determined by the', | ||
'numerical order of the values.',*/ // // value ascending / descending to be implemented later | ||
'Set `categorymode` to *array* to derive the ordering from the attribute `categorylist`. If a category', | ||
'is not found in the `categorylist` array, the sorting behavior for that attribute will be identical to', | ||
'the *trace* mode. The unspecified categories will follow the categories in `categorylist`.' | ||
].join(' ') | ||
}, | ||
categorylist: { | ||
valType: 'data_array', | ||
role: 'info', | ||
description: [ | ||
'Sets the order in which categories on this axis appear.', | ||
'Only has an effect if `categorymode` is set to *array*.', | ||
'Used with `categorymode`.' | ||
].join(' ') | ||
}, | ||
title: axesAttrs.title, | ||
titlefont: axesAttrs.titlefont, | ||
type: axesAttrs.type, | ||
|
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.
@cldougl @chriddyp does ⏫ look ok to you?
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.
👍 for me
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.
Maybe we should include truncated versions of those values as well e.g.
'cat asc'
,'cat des'
?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.
I'd suggest avoiding muti-word strings. Maybe just
ascending
anddescending
?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.
for me just
ascending
`descendingdoesn't have a clear relation to _alpha_numeric ordering. I definitely understand the aversion to multi-word strings, but I would vote for more description than
ascending\
descending`plus if
'value ascending'
\'value descending'
are going to be implemented eventuallyThere 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.
but I gotta say,
catergoryorder
doesn't sound bad at all.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.
You can add them as labels to the axes (currently described as
ticktext
) or use them as data (currently described asx
). Given that theaxis.type
iscategory
, one might think thatcategories
is how you would add data to that axis.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.
and maybe
categoryarray
instead ofcategorylist
@chriddyp we're already using the value
'array'
fortickmode
.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.
More like: categories are added automatically. Categories have no effect on
ticktext
.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.
Great point 👍
That's why I'm thinking that
categoryorder
might be the winner here.