Skip to content
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

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.

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
src/lib/index.js Outdated Show resolved Hide resolved
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);
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