-
Notifications
You must be signed in to change notification settings - Fork 104
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
Pr/legend locale #71
Pr/legend locale #71
Conversation
src/legend.js
Outdated
thousands: ',', | ||
grouping: [3], | ||
currency: ['$', ''] | ||
}, |
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.
It looks like in the d3-format module it is published with the locale folder, so for this we can import something like d3-format/local/en-US.json
and use this as the default definition instead of remaking it here.
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.
I agree, this is not the most efficiant way to get the locale. But I'm facing two problems:
- I cannot access to the default locale, calling
d3.formatLocale()
without args throws an error - I cannot import the locales as simple as you said because of Publish locales as JSON data, not code. d3/d3-format#22 and External access to locale definitions? d3/d3-format#8
Should I import like this?
require('../node_modules/d3-format/locale/en-US.json')
I'm not fan
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.
I found an another way, a locale
is no more than an object with a format
and formatPrefix
methods, so I created a default one with the package methods.
Looks good, I just had one comment about the default format. Let me know when it's in the other two legend types and I'll take a look locally and update the docs. Thanks! |
This looks good to me, tested it out on the docs and it worked well. Did you have any other changes you wanted to make? |
I think we're good! It's on your hands now to build and update. |
@LaCroute exciting, congrats! It was great having your help to implement this feature. I'll move it in today and update the docs. Cheers! |
You can see the tests to understand how it works.
The basic idea:
locale
object in the legendlabelFormat
to use the locale's format. To do it I choose to use aspecifier
instead of theformat
functionlabelFormat
, by string or byd3.format
Let me know what to change. When it will be ok for you, I'll do the implementation for sizeLegend and symbolLegend too.