-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add half-year directive (%h) for formatting dates and improve descriptions to include extra date formatting options #5762
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
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e2508bc
add half-year format directive
archmoj efcbfaa
refactor - centralize axis format descriptions
archmoj defaf8e
add half-year directive to descriptions
archmoj 98a90ce
mention extra date formatting options in (x|y)hoverformat too
archmoj 73676ca
add dots after links to end the sentences
archmoj 4caa5d8
maintain string type
archmoj 7808217
rename file to axis_format_attributes
archmoj 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 hidden or 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 hidden or 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,47 @@ | ||
'use strict'; | ||
|
||
var docs = require('../../constants/docs'); | ||
var FORMAT_LINK = docs.FORMAT_LINK; | ||
var DATE_FORMAT_LINK = docs.DATE_FORMAT_LINK; | ||
|
||
function axisHoverFormat(x, noDates) { | ||
return { | ||
valType: 'string', | ||
dflt: '', | ||
editType: 'none', | ||
description: ( | ||
noDates ? descriptionOnlyNumbers : descriptionWithDates | ||
)('hover text', x) + [ | ||
'By default the values are formatted using ' + ( | ||
noDates ? | ||
'generic number format' : | ||
('`' + x + 'axis.hoverformat`') | ||
) + '.', | ||
].join(' ') | ||
}; | ||
} | ||
|
||
function descriptionOnlyNumbers(label, x) { | ||
return [ | ||
'Sets the ' + label + ' formatting rule' + (x ? 'for `' + x + '` ' : ''), | ||
'using d3 formatting mini-languages', | ||
'which are very similar to those in Python. For numbers, see: ' + FORMAT_LINK + '.' | ||
].join(' '); | ||
} | ||
|
||
function descriptionWithDates(label, x) { | ||
return descriptionOnlyNumbers(label, x) + [ | ||
' And for dates see: ' + DATE_FORMAT_LINK + '.', | ||
'We add two items to d3\'s date formatter:', | ||
'*%h* for half of the year as a decimal number as well as', | ||
'*%{n}f* for fractional seconds', | ||
'with n digits. For example, *2016-10-13 09:15:23.456* with tickformat', | ||
'*%H~%M~%S.%2f* would display *09~15~23.46*' | ||
].join(' '); | ||
} | ||
|
||
module.exports = { | ||
axisHoverFormat: axisHoverFormat, | ||
descriptionOnlyNumbers: descriptionOnlyNumbers, | ||
descriptionWithDates: descriptionWithDates | ||
}; | ||
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
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.
Nice idea to move this into cartesian and export the descriptions separately. I know it's a bit long, but can we put "attributes" in the file name? ie
axis_format_attributes.js
? Otherwise you'd be tempted to think this file contains actual text formatting functions.