diff --git a/change/@fluentui-react-charting-3e3805e8-7750-4654-8e75-736a660ed7b3.json b/change/@fluentui-react-charting-3e3805e8-7750-4654-8e75-736a660ed7b3.json new file mode 100644 index 0000000000000..ecd7b895cc826 --- /dev/null +++ b/change/@fluentui-react-charting-3e3805e8-7750-4654-8e75-736a660ed7b3.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "Add support for javascript date localization", + "packageName": "@fluentui/react-charting", + "email": "atishay.jain@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/packages/react-charting/TechnicalDetails.md b/packages/react-charting/TechnicalDetails.md index 21257e08d9ef2..2100767c26fd9 100644 --- a/packages/react-charting/TechnicalDetails.md +++ b/packages/react-charting/TechnicalDetails.md @@ -42,6 +42,10 @@ The charting components are built using following building blocks. | Tree Chart | -- | -- | -- | | Sparkline Chart | -- | -- | -- | + - Axis localization + The axes support javascript provided localization for numeric and date axis. + Specify the culture and dateLocalizeOptions for date axis to define target localization details. + - Event annotations (Available in line charts). - Data can be annotated using vertical lines representing the events of interest. See [line chart with events](https://fluentuipr.z22.web.core.windows.net/heads/master/react-charting/demo/index.html#/examples/linechart#Variants) for example. diff --git a/packages/react-charting/src/components/CommonComponents/CartesianChart.base.tsx b/packages/react-charting/src/components/CommonComponents/CartesianChart.base.tsx index 82967e916d66a..54b395289f658 100644 --- a/packages/react-charting/src/components/CommonComponents/CartesianChart.base.tsx +++ b/packages/react-charting/src/components/CommonComponents/CartesianChart.base.tsx @@ -134,7 +134,16 @@ export class CartesianChartBase extends React.Component { + return domainValue.toLocaleString(culture, options); + }); + } + tickParams.tickValues ? xAxis.tickValues(tickParams.tickValues) : ''; - tickParams.tickFormat ? xAxis.tickFormat(d3TimeFormat.timeFormat(tickParams.tickFormat)) : ''; + if (culture === undefined) { + tickParams.tickFormat ? xAxis.tickFormat(d3TimeFormat.timeFormat(tickParams.tickFormat)) : ''; + } if (xAxisElement) { d3Select(xAxisElement).call(xAxis).selectAll('text').attr('aria-hidden', 'true'); }