-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
add 'tickformatstops' #1965
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
Merged
Merged
add 'tickformatstops' #1965
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
1baa14a
add 'tickformatstops'
yauhen-kavaliou f958c3b
change tickformatstops definition and code review fixes
yauhen-kavaliou a155bd9
change valType
yauhen-kavaliou be11c03
remove axis attribute duplication
apalchys a13c29e
fix: add missed semicolon
apalchys 304d96b
add tests for tickformatstops
apalchys 0c9fb2b
add tickformatstop image for test
apalchys db526d9
Merge branch 'master' into tickformatstops
alexcjohnson 7f1fd41
editTypes for tickformatstops
alexcjohnson 86777f7
make sure the tickformatstops tests actually run as expected
alexcjohnson 531aea8
flatten tickformatstops tests
alexcjohnson 0b48a33
robustify tickformatstops supplydefaults
alexcjohnson 6420044
take the first matching tickformatstop
apalchys 92f7c13
replace Array.prototype.find with for loop and update tests
apalchys df72531
lint
alexcjohnson 7665b4c
updated tickformatstops baseline
alexcjohnson 0e6747f
merge tickformatstops_test into axes_test
alexcjohnson 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
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 |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
'use strict'; | ||
|
||
var Lib = require('../../lib'); | ||
|
||
var layoutAttributes = require('./layout_attributes'); | ||
|
||
/** | ||
* options: inherits font, outerTicks, noHover from axes.handleAxisDefaults | ||
|
@@ -40,6 +40,7 @@ module.exports = function handleTickLabelDefaults(containerIn, containerOut, coe | |
|
||
if(axType !== 'category') { | ||
var tickFormat = coerce('tickformat'); | ||
tickformatstopsDefaults(containerIn, containerOut); | ||
if(!tickFormat && axType !== 'date') { | ||
coerce('showexponent', showAttrDflt); | ||
coerce('exponentformat'); | ||
|
@@ -80,3 +81,26 @@ function getShowAttrDflt(containerIn) { | |
return containerIn[showAttrs[0]]; | ||
} | ||
} | ||
|
||
function tickformatstopsDefaults(tickformatIn, tickformatOut) { | ||
var valuesIn = tickformatIn.tickformatstops; | ||
var valuesOut = tickformatOut.tickformatstops = []; | ||
|
||
if(!Array.isArray(valuesIn)) return; | ||
|
||
var valueIn, valueOut; | ||
|
||
function coerce(attr, dflt) { | ||
return Lib.coerce(valueIn, valueOut, layoutAttributes.tickformatstops, attr, dflt); | ||
} | ||
|
||
for(var i = 0; i < valuesIn.length; i++) { | ||
valueIn = valuesIn[i]; | ||
valueOut = {}; | ||
|
||
coerce('dtickrange'); | ||
coerce('value'); | ||
|
||
valuesOut.push(valueOut); | ||
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. Nicely done. Thanks! 🎉 |
||
} | ||
} |
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
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.
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,46 @@ | ||
{ | ||
"data": [ | ||
{ | ||
"x": ["2005-01","2005-02","2005-03","2005-04","2005-05","2005-06","2005-07"], | ||
"y": [-20,10,-5,0,5,-10,20] | ||
} | ||
], | ||
"layout": { | ||
"xaxis": { | ||
"tickformatstops": [ | ||
{ | ||
"dtickrange": [null, 1000], | ||
"value": "%H:%M:%S.%L ms" | ||
}, | ||
{ | ||
"dtickrange": [1000, 60000], | ||
"value": "%H:%M:%S s" | ||
}, | ||
{ | ||
"dtickrange": [60000, 3600000], | ||
"value": "%H:%M m" | ||
}, | ||
{ | ||
"dtickrange": [3600000, 86400000], | ||
"value": "%H:%M h" | ||
}, | ||
{ | ||
"dtickrange": [86400000, 604800000], | ||
"value": "%e. %b d" | ||
}, | ||
{ | ||
"dtickrange": [604800000, "M1"], | ||
"value": "%e. %b w" | ||
}, | ||
{ | ||
"dtickrange": ["M1", "M12"], | ||
"value": "%b '%y M" | ||
}, | ||
{ | ||
"dtickrange": ["M12", null], | ||
"value": "%Y Y" | ||
} | ||
] | ||
} | ||
} | ||
} |
Oops, something went wrong.
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.
Is
axis.tickformat: ''
a valid format? More precisely, couldbe used to hide tick labels for some dtick range?
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,
tickformat: ''
gives our default formatting. I suppose we could imagine making our own "hide" tickformat (for date axes you can already hack this withtickformat: ' '
but that doesn't work for numbers) but it seems a bit of a kludgy way to handle a very esoteric edge case.