Open nstuyvesant opened 11 months ago
removing the valueFormatters would be a breaking change. what if we introduce a new central formatter that'd currently override all your specific formatters if you use it... and we can drop the valueFormatters in a major version release down the road?
I was thinking if a valueFormatter is provided, then it dictates the output; otherwise, it uses the global locale settings. This would avoid a breaking change. Thoughts?
yeah that could be it too, and potentially adding console logs to warn user of the fact that those would be removed in a the next major version
One use case for continuing to support valueFormatters (in additional to a chart-wide locale) would be if you want to add some kind of additional information like a badge to go with the value like in a tooltip.
User Story
As a developer, I want to apply international locales to ticks (both axes), tooltips, and the tabular data representation displayed by the toolbar. Currently, I have to write formatter functions for ticks.formatter, tooltip.valueFormatter and/or supply a
date-fns
localeObject for timeScaleOptions. The latter approach is limited to dates and relies on a bloated package which increases the bundle size of@carbon/charts
. I also want@carbon/charts
to adjust the display to my browser's navigator.language property unless the language is hard-coded by me.Problems: I cannot change the format of numbers and dates in the Toolbar / Tabular representation or labels for Group, the title of the Tabular representation modal or exports. Also, I have to explicitly override multiple ticks and the tooltip values rather than doing it globally.
Technical Specs
For every chart type, I want a top-level property to options called
locale
. This property should have this interface:Defaults for optional properties would be as follows:
Example of setting options for a chart the old way...
Example of the same thing with the new
locale
property...Justification
date-fns
but it only applies to TimeScaleOptions which only affects one axis's ticks. Also, many considerdate-fns
to be the equivalent of using a bazooka to swat a fly.What priority level would this issue be in your opinion?
P1 because it would close 7 issues.