Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2k
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
Uh oh!
There was an error while loading. Please reload this page.
add 'tickformatstops' #1965
Changes from all commits
1baa14af958c3ba155bd9be11c03a13c29e304d96b0c9fb2bdb526d97f1fd4186777f7531aea80b48a33642004492f7c13df725317665b4c0e6747fFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| 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); | ||
Contributor 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! 🎉 | ||
| } | ||
| } | ||
| 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" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.
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.