-
-
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
Implement period ticklabelmode on cartesian date axes #4993
Changes from 12 commits
6de9589
4292f08
9f3e1db
0e124c2
35a9b91
93541eb
4f271d9
a5e6aae
79f6875
08c69d7
79385c2
66a98be
83f5cdd
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 |
---|---|---|
|
@@ -478,6 +478,20 @@ module.exports = { | |
'to the left/bottom of labels.' | ||
].join(' ') | ||
}, | ||
ticklabelmode: { | ||
valType: 'enumerated', | ||
values: ['instant', 'period'], | ||
dflt: 'instant', | ||
role: 'info', | ||
editType: 'ticks', | ||
description: [ | ||
'Determines where tick labels are drawn with respect to their', | ||
'corresponding ticks and grid lines.', | ||
'Only has an effect for axes of `type` *date*', | ||
'When set to *period*, tick labels are drawn in the middle of the period', | ||
'between ticks.' | ||
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. this is actually not quite the desired behaviour: if the ticks are spaced every 2 months and the labels are 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. Here's an example... https://codepen.io/nicolaskruchten/pen/ZEQRBWw?editors=0010 In "instant" mode we see 4 "month" labels spaced two months apart. In "period" mode we probably should see only 3 labels, but they should remain Jan/Mar/May, and they should be positioned on Jan 15, Mar 15, May 15 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. I'll add a clearer codepen in the original issue |
||
].join(' ') | ||
}, | ||
mirror: { | ||
valType: 'enumerated', | ||
values: [true, 'ticks', false, 'all', 'allticks'], | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
{ | ||
"data": [ | ||
{ | ||
"x": [ | ||
"1900-01-01", | ||
"2000-01-01", | ||
"2100-01-01" | ||
], | ||
"y": [1, 3, 2] | ||
}, | ||
{ | ||
"x": [ | ||
"2013-05-01", | ||
"2013-09-01", | ||
"2014-01-01" | ||
], | ||
"y": [1, 3, 2], | ||
"xaxis": "x2", | ||
"yaxis": "y2" | ||
}, | ||
{ | ||
"x": [ | ||
"2013-11-17", | ||
"2013-12-15", | ||
"2014-01-12" | ||
], | ||
"y": [1, 3, 2], | ||
"xaxis": "x3", | ||
"yaxis": "y3" | ||
}, | ||
{ | ||
"x": [ | ||
"2013-01-01", | ||
"2013-01-02", | ||
"2013-01-03" | ||
], | ||
"y": [1, 3, 2], | ||
"xaxis": "x4", | ||
"yaxis": "y4" | ||
}, | ||
{ | ||
"x": [ | ||
"2013-07-01 18:00", | ||
"2013-07-02 00:00", | ||
"2013-07-02 06:00" | ||
], | ||
"y": [1, 3, 2], | ||
"xaxis": "x5", | ||
"yaxis": "y5" | ||
}, | ||
{ | ||
"x": [ | ||
"2013-01-01 23:59", | ||
"2013-01-02 00:00", | ||
"2013-01-02 00:01" | ||
], | ||
"y": [1, 3, 2], | ||
"xaxis": "x6", | ||
"yaxis": "y6" | ||
}, | ||
{ | ||
"x": [ | ||
"2013-07-01 23:59:59", | ||
"2013-07-02 00:00:00", | ||
"2013-07-02 00:00:01" | ||
], | ||
"y": [1, 3, 2], | ||
"xaxis": "x7", | ||
"yaxis": "y7" | ||
} | ||
], | ||
"layout": { | ||
"showlegend": false, | ||
"width": 600, | ||
"height": 500, | ||
"yaxis": {"domain": [0, 0.04]}, | ||
"yaxis2": {"domain": [0.16, 0.2]}, | ||
"yaxis3": {"domain": [0.32, 0.36]}, | ||
"yaxis4": {"domain": [0.48, 0.52]}, | ||
"yaxis5": {"domain": [0.64, 0.68]}, | ||
"yaxis6": {"domain": [0.80, 0.84]}, | ||
"yaxis7": {"domain": [0.96, 1]}, | ||
"xaxis": {"ticklabelmode": "period"}, | ||
"xaxis2": {"ticklabelmode": "period", "anchor": "y2"}, | ||
"xaxis3": {"ticklabelmode": "period", "anchor": "y3"}, | ||
"xaxis4": {"ticklabelmode": "period", "anchor": "y4"}, | ||
"xaxis5": {"ticklabelmode": "period", "anchor": "y5"}, | ||
"xaxis6": {"ticklabelmode": "period", "anchor": "y6"}, | ||
"xaxis7": {"ticklabelmode": "period", "anchor": "y7"} | ||
} | ||
} |
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
tickVals.unshift({...})
is slightly more efficient here.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.
Good call.
I also fixed
reversed
range positioning and added few tests in 83f5cdd.