-
-
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
add 'tickformatstops' #1965
Changes from 2 commits
1baa14a
f958c3b
a155bd9
be11c03
a13c29e
304d96b
0c9fb2b
db526d9
7f1fd41
86777f7
531aea8
0b48a33
6420044
92f7c13
df72531
7665b4c
0e6747f
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 |
---|---|---|
|
@@ -448,6 +448,26 @@ module.exports = { | |
'*%H~%M~%S.%2f* would display *09~15~23.46*' | ||
].join(' ') | ||
}, | ||
tickformatstops: { | ||
_isLinkedToArray: 'tickformatstop', | ||
|
||
dtickrange: { | ||
valType: 'data_array', | ||
description: [ | ||
'range [*min*, *max*], where *min*, *max* - dtick values', | ||
'which describe some zoom level, it is possible to omit *min*', | ||
'or *max* value by passing *null*' | ||
].join(' ') | ||
}, | ||
value: { | ||
valType: 'string', | ||
dflt: '', | ||
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. Is tickformatstop: [{
dtickrange: [/* */],
value: ''
}] be used to hide tick labels for some dtick range? 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, |
||
role: 'style', | ||
description: [ | ||
'string - dtickformat for described zoom level, the same as *tickformat*' | ||
].join(' ') | ||
} | ||
}, | ||
hoverformat: { | ||
valType: 'string', | ||
dflt: '', | ||
|
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 || [], | ||
valuesOut = tickformatOut.tickformatstops = []; | ||
|
||
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! 🎉 |
||
} | ||
|
||
return valuesOut; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -265,6 +265,26 @@ module.exports = { | |
'*%H~%M~%S.%2f* would display *09~15~23.46*' | ||
].join(' ') | ||
}, | ||
tickformatstops: { | ||
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. Would you mind DRYing this up by adding var axesAttrs = require('../../plots/cartesian/layout_attributes')
// ....
tickformatstops: axesAtttrs.tickformatstops,
// ... 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. Fixed, thanks. |
||
_isLinkedToArray: 'tickformatstop', | ||
|
||
dtickrange: { | ||
valType: 'data_array', | ||
description: [ | ||
'range [*min*, *max*], where *min*, *max* - dtick values', | ||
'which describe some zoom level, it is possible to omit *min*', | ||
'or *max* value by passing *null*' | ||
].join(' ') | ||
}, | ||
value: { | ||
valType: 'string', | ||
dflt: '', | ||
role: 'style', | ||
description: [ | ||
'string - dtickformat for described zoom level, the same as *tickformat*' | ||
].join(' ') | ||
} | ||
}, | ||
categoryorder: { | ||
valType: 'enumerated', | ||
values: [ | ||
|
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.
info_array
please.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.
... just like
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.
fixed, thanks.