diff --git a/change/@fluentui-react-charting-7de74a81-afc6-44d4-bf74-78e6f91d3c5a.json b/change/@fluentui-react-charting-7de74a81-afc6-44d4-bf74-78e6f91d3c5a.json
new file mode 100644
index 00000000000000..3a6b5971010f40
--- /dev/null
+++ b/change/@fluentui-react-charting-7de74a81-afc6-44d4-bf74-78e6f91d3c5a.json
@@ -0,0 +1,7 @@
+{
+ "type": "patch",
+ "comment": "Add support for custom locale for date axis",
+ "packageName": "@fluentui/react-charting",
+ "email": "atishay.jain@microsoft.com",
+ "dependentChangeType": "patch"
+}
diff --git a/packages/react-charting/README.md b/packages/react-charting/README.md
index a9a36e3d15253f..79cad1a43d4ada 100644
--- a/packages/react-charting/README.md
+++ b/packages/react-charting/README.md
@@ -28,10 +28,6 @@ To import charting components:
import { ComponentName } from '@fluentui/react-charting/lib/ComponentName';
```
-**Technical Guide**
-
-Technical information about chart components is available at [Technical details](./TechnicalDetails.md)
-
**Contributing**
Refer the main fluentui [wiki](https://github.com/microsoft/fluentui/wiki) for detailed instructions on setup and contributing to the package.
@@ -56,3 +52,87 @@ You could also create issues under the [charting](https://github.com/microsoft/f
**Coding Guidelines**
Refer fluent [Coding guidelines](https://github.com/microsoft/fluentui/wiki/Coding-Style)
+
+# Technical details
+
+**Overview**
+
+This document describes different chart components in detail.
+
+This can be used as a guide to use the charts and contribute new functionalities or improvements to the library.
+
+**Components**
+
+The charting components are built using following building blocks.
+
+- Cartesian Charts.
+
+ - Charts built using cartesian coordinate system (two axes - x axis perpendicular to y axis) are called cartesian charts. Majority of the chart in the library are cartesian charts. Some charts like horizontal chart, donut chart, sankey and tree charts are non cartesian charts.
+
+- Legends.
+
+ - A legend contains a list of the variables appearing in the chart and an example of their appearance. This information allows the data from each variable to be identified in the chart.
+
+- Hover Callouts.
+
+ - Whenever the mouse is hovered over a datapoint, a callout is shown representing the details of data for that point. For a stacked chart, the hover callout can represent the data for all the points for the same X coordinate.
+
+- Axes.
+
+ - Our charts currently support cartesian axes. Different charts support different type of axes - numerical axis, date or time series axis, string or categorical axis. Detals about supported axes can be found in readme for each chart.
+
+ - Axes support for different charts
+
+ | Chart | Numeric Axis | Date Axis | String Axis |
+ | -------------------------- | ------------ | --------- | ----------- |
+ | Line Chart | Yes | Yes | No |
+ | Area Chart | Yes | Yes | No |
+ | Vertical Bar Chart | Yes | No | Yes |
+ | Vertical Stacked Bar Chart | Yes | No | Yes |
+ | Grouped Vertical Bar Chart | No | No | Yes |
+ | Heatmap Chart | Yes | Yes | Yes |
+ | Horizontal Bar Chart | -- | -- | -- |
+ | Donut Chart | -- | -- | -- |
+ | Sankey Chart | -- | -- | -- |
+ | Tree Chart | -- | -- | -- |
+ | Sparkline Chart | -- | -- | -- |
+
+ - Axis localization
+ The axes support 2 ways of localization.
+ 1. Javascript provided inbuilt localization for numeric and date axis. Specify the culture and dateLocalizeOptions for date axis to define target localization. Refer the [javascript localization guide](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString) for usage.
+ 2. Custom locale definition: The consumer of the library can specify a custom locale definition as supported by d3 (like [this](https://github.com/d3/d3-time-format/blob/main/locale/en-US.json)). The date axis will use the date range and the multiformat specified in the definition to determine the correct format to show in the ticks. For example - If the date range is in days then the axis will show hourly ticks. If the date range spans across months then the axis will show months in tick labels and so on.
+ Specify the custom locale definition in the timeFormatLocale prop.
+ Refer to the Custom Locale Date Axis example in line chart for sample usage.
+
+- 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.
+
+- Typography.
+
+ - Our font classes represent the type ramp for the fluent design language. Each base class sets a default size, weight, and color.
+
+- Colors
+
+ - The charts are designed using the accessible color palette defined for the fluent design system.
+
+- Themes
+
+ - The library supports light and dark mode out of box. In addition, consumers can define their own themese as detailed [here](https://github.com/microsoft/fluentui/wiki/Theming)
+
+- Accessibility.
+
+ - Our charts have elaborate accessibility support. The charts are WCAG 2.1 MAS C compliant for accessibility.
+ Consumers can define their own aria labels for each point by setting the `xAxisCalloutAccessibilityData` and `callOutAccessibilityData` properties.
+
+- RTL Support
+
+ - The charts support RTL languages wherever applicable.
+
+- Component Styling
+
+ - [This article](https://github.com/microsoft/fluentui/wiki/Component-Styling) talks about the styling approach followed within charting library.
+
+- Details about ticks.
+ - Tick values are applicable only for date axis. Doesn't work for string or numeric axis.
+ Tickcount works for numeric and date axis. Doesn't work for string (scaleBand) axis.
diff --git a/packages/react-charting/TechnicalDetails.md b/packages/react-charting/TechnicalDetails.md
deleted file mode 100644
index 2100767c26fd97..00000000000000
--- a/packages/react-charting/TechnicalDetails.md
+++ /dev/null
@@ -1,80 +0,0 @@
-# Technical details
-
-**Overview**
-
-This document describes different charts and their components in detail.
-
-This can be used as a guide to use the charts and contribute new functionalities or improvements to the library.
-
-**Components**
-
-The charting components are built using following building blocks.
-
-- Cartesian Charts.
-
- - Charts built using cartesian coordinate system (two axes - x axis perpendicular to y axis) are called cartesian charts. Majority of the chart in the library are cartesian charts. Some charts like horizontal chart, donut chart, sankey and tree charts are non cartesian charts.
-
-- Legends.
-
- - A legend contains a list of the variables appearing in the chart and an example of their appearance. This information allows the data from each variable to be identified in the chart.
-
-- Hover Callouts.
-
- - Whenever the mouse is hovered over a datapoint, a callout is shown representing the details of data for that point. For a stacked chart, the hover callout can represent the data for all the points for the same X coordinate.
-
-- Axes.
-
- - Our charts currently support cartesian axes. Different charts support different type of axes - numerical axis, date or time series axis, string or categorical axis. Detals about supported axes can be found in readme for each chart.
-
- - Axes support for different charts
-
- | Chart | Numeric Axis | Date Axis | String Axis |
- | -------------------------- | ------------ | --------- | ----------- |
- | Line Chart | Yes | Yes | No |
- | Area Chart | Yes | Yes | No |
- | Vertical Bar Chart | Yes | No | Yes |
- | Vertical Stacked Bar Chart | Yes | No | Yes |
- | Grouped Vertical Bar Chart | No | No | Yes |
- | Heatmap Chart | Yes | Yes | Yes |
- | Horizontal Bar Chart | -- | -- | -- |
- | Donut Chart | -- | -- | -- |
- | Sankey Chart | -- | -- | -- |
- | 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.
-
-- Typography.
-
- - Our font classes represent the type ramp for the fluent design language. Each base class sets a default size, weight, and color.
-
-- Colors
-
- - The charts are designed using the accessible color palette defined for the fluent design system.
-
-- Themes
-
- - The library supports light and dark mode out of box. In addition, consumers can define their own themese as detailed [here](https://github.com/microsoft/fluentui/wiki/Theming)
-
-- Accessibility.
-
- - Our charts have elaborate accessibility support. The charts are WCAG 2.1 MAS C compliant for accessibility.
- Consumers can define their own aria labels for each point by setting the `xAxisCalloutAccessibilityData` and `callOutAccessibilityData` properties.
-
-- RTL Support
-
- - The charts support RTL languages wherever applicable.
-
-- Component Styling
-
- - [This article](https://github.com/microsoft/fluentui/wiki/Component-Styling) talks about the styling approach followed within charting library.
-
-- Details about ticks.
- - Tick values are applicable only for date axis. Doesn't work for string or numeric axis.
- Tickcount works for numeric and date axis. Doesn't work for string (scaleBand) axis.
diff --git a/packages/react-charting/package.json b/packages/react-charting/package.json
index 659b4c90b2f05b..e83f64133c3d37 100644
--- a/packages/react-charting/package.json
+++ b/packages/react-charting/package.json
@@ -45,6 +45,7 @@
"@types/d3-selection": "1.4.1",
"@types/d3-shape": "^1.2.3",
"@types/d3-time-format": "^2.1.0",
+ "@types/d3-time": "^1.1.0",
"@fluentui/set-version": "^8.2.2",
"d3-array": "1.2.1",
"d3-axis": "1.0.8",
@@ -55,6 +56,7 @@
"d3-selection": "1.3.0",
"d3-shape": "^1.2.0",
"d3-time-format": "^2.1.3",
+ "d3-time": "^1.1.0",
"tslib": "^2.1.0"
},
"peerDependencies": {
diff --git a/packages/react-charting/src/components/CommonComponents/CartesianChart.base.tsx b/packages/react-charting/src/components/CommonComponents/CartesianChart.base.tsx
index 54b395289f6585..c94bb9f4ec61e2 100644
--- a/packages/react-charting/src/components/CommonComponents/CartesianChart.base.tsx
+++ b/packages/react-charting/src/components/CommonComponents/CartesianChart.base.tsx
@@ -143,6 +143,7 @@ export class CartesianChartBase extends React.ComponentcallOutAccessibilityData to configure x axis and y axis accessibility messages
respectively.
+ The axes support 2 ways of localization.
+ 1. Javascript provided inbuilt localization for numeric and date axis. Specify the culture and
+ dateLocalizeOptions for date axis to define target localization. Refer the
+
+ Javascript localization guide
+
+ for usage.
+ 2. Custom locale definition: The consumer of the library can specify a custom locale definition as
+ supported by d3 like this.
+ The date axis will use the date range and the multiformat specified in the definition to determine the
+ correct labels to show in the ticks. For example - If the date range is in days then the axis will show
+ hourly ticks. If the date range spans across months then the axis will show months in tick labels and so
+ on. Specify the custom locale definition in the timeFormatLocale prop. Refer to the Custom
+ Locale Date Axis example in line chart for sample usage.
+
For string y axis use: yAxisStringFormatter
+ The axes support 2 ways of localization.
+ 1. Javascript provided inbuilt localization for numeric and date axis. Specify the culture and
+ dateLocalizeOptions for date axis to define target localization. Refer the
+
+ Javascript localization guide
+
+ for usage.
+ 2. Custom locale definition: The consumer of the library can specify a custom locale definition as
+ supported by d3 like this.
+ The date axis will use the date range and the multiformat specified in the definition to determine the
+ correct labels to show in the ticks. For example - If the date range is in days then the axis will show
+ hourly ticks. If the date range spans across months then the axis will show months in tick labels and so
+ on. Specify the custom locale definition in the timeFormatLocale prop. Refer to the Custom
+ Locale Date Axis example in line chart for sample usage.
+
callOutAccessibilityData to configure x axis and y axis accessibility messages
respectively.
+
+ The axes support 2 ways of localization.
+ 1. Javascript provided inbuilt localization for numeric and date axis. Specify the culture and
+ dateLocalizeOptions for date axis to define target localization. Refer the
+
+ Javascript localization guide
+
+ for usage.
+ 2. Custom locale definition: The consumer of the library can specify a custom locale definition as
+ supported by d3 like this.
+ The date axis will use the date range and the multiformat specified in the definition to determine the
+ correct labels to show in the ticks. For example - If the date range is in days then the axis will show
+ hourly ticks. If the date range spans across months then the axis will show months in tick labels and so
+ on. Specify the custom locale definition in the timeFormatLocale prop. Refer to the Custom
+ Locale Date Axis example in line chart for sample usage.
+