Skip to content

Add new formatting options by replacing d3.format method with more recent d3-format module #5125

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 26 commits into from
Jul 17, 2021

Conversation

archmoj
Copy link
Contributor

@archmoj archmoj commented Sep 4, 2020

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:

  • test more cases to ensure old options still work
  • test new options
  • add fall back for the edge cases
  • drop d3.format from plotly/d3 fork and use it here

Also to note:

@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 785f128
Also see extra options tested in #5842.

@archmoj archmoj added bug something broken feature something new status: reviewable labels Sep 4, 2020
@nicolaskruchten
Copy link
Contributor

Cool! Does this sidestep the challenges encountered in #5023 ?

@archmoj
Copy link
Contributor Author

archmoj commented Sep 4, 2020

Cool! Does this sidestep the challenges encountered in #5023 ?

Positive. #5023 was not successful.

@archmoj archmoj force-pushed the new-d3-number-format branch 2 times, most recently from 9c20e84 to 427e5e3 Compare November 9, 2020 16:17
@archmoj archmoj force-pushed the new-d3-number-format branch from 427e5e3 to efaebd7 Compare December 3, 2020 14:51
@archmoj archmoj force-pushed the new-d3-number-format branch from efaebd7 to b59b1fb Compare January 5, 2021 17:22
@archmoj archmoj force-pushed the new-d3-number-format branch from b59b1fb to fb0e62e Compare May 22, 2021 17:57
@archmoj archmoj force-pushed the new-d3-number-format branch from fb0e62e to 9f51808 Compare June 26, 2021 16:05
@archmoj archmoj added this to the v2.3.0 milestone Jun 26, 2021
@archmoj archmoj force-pushed the new-d3-number-format branch 3 times, most recently from 9b69f1e to cd0d392 Compare July 7, 2021 18:38
package.json Outdated
@@ -66,7 +66,7 @@
]
},
"dependencies": {
"@plotly/d3": "3.7.0",
"@plotly/d3": "git://github.com/plotly/d3.git#3fc195e30e85b008238783379d2aa067c737e636",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@archmoj archmoj changed the title Upgrade d3 number formatting Add new formatting options by switching to d3-format module Jul 12, 2021
@archmoj archmoj changed the title Add new formatting options by switching to d3-format module Add new formatting options by replacing d3.format method with more recent d3-format module Jul 12, 2021
Co-authored-by: Alex Johnson <[email protected]>
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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plotly.js/src/lib/index.js

Lines 723 to 725 in bdb69fc

lib.titleCase = function(s) {
return s.charAt(0).toUpperCase() + s.substr(1);
};

Copy link
Contributor Author

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;
Copy link
Collaborator

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 878034b

Copy link
Collaborator

@alexcjohnson alexcjohnson left a 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken feature something new
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants