-
-
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
Add new formatting options by replacing d3.format
method with more recent d3-format
module
#5125
Conversation
Cool! Does this sidestep the challenges encountered in #5023 ? |
9c20e84
to
427e5e3
Compare
427e5e3
to
efaebd7
Compare
efaebd7
to
b59b1fb
Compare
b59b1fb
to
fb0e62e
Compare
fb0e62e
to
9f51808
Compare
9b69f1e
to
cd0d392
Compare
- centralize and wrap require d3 format in lib - adjust old and new formats
package.json
Outdated
@@ -66,7 +66,7 @@ | |||
] | |||
}, | |||
"dependencies": { | |||
"@plotly/d3": "3.7.0", | |||
"@plotly/d3": "git://github.com/plotly/d3.git#3fc195e30e85b008238783379d2aa067c737e636", |
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.
d3.format
method with more recent d3-format
module
Co-authored-by: Alex Johnson <johnson.alex.c@gmail.com>
src/lib/index.js
Outdated
@@ -1319,6 +1347,10 @@ lib.bigFont = function(size) { | |||
return Math.round(1.2 * size); | |||
}; | |||
|
|||
lib.beginCap = function(str) { | |||
return str.charAt(0).toUpperCase() + str.slice(1); |
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.
Lines 723 to 725 in bdb69fc
lib.titleCase = function(s) { | |
return s.charAt(0).toUpperCase() + s.substr(1); | |
}; |
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.
Done in 1efc41e
Lib.adjustFormat(formatStr) | ||
); | ||
} catch(e) { | ||
return Lib.noFormat; |
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 this catching invalid format strings? Do we want to lib.warn
when this happens, to help people fix it?
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.
Done in 878034b
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.
💃 after those couple of comments and merging/publishing plotly/d3#4
Nice job with lib.adjustFormat
!
An attempt to replace old d3 format functions with latest
d3-number
module as part of d3 bump cc: #424; while keep trimming the default option which was quite tricky.TODO:
d3.format
fromplotly/d3
fork and use it hereAlso to note:
d3.time
fromplotly/d3
fork and switched tod3-time
module in dc0d9cb cc: Bumping d3 #424@plotly/plotly_js
PR to help maintain previous behavior: https://github.com/plotly/plotly.js/pull/5820/files
Added new functionalities illustrated in
lib_number_format_test.js
785f128Also see extra options tested in #5842.