diff --git a/change/@fluentui-react-charts-5fa1937b-0155-4657-a858-48055caa5553.json b/change/@fluentui-react-charts-5fa1937b-0155-4657-a858-48055caa5553.json
new file mode 100644
index 00000000000000..4abab0453bbfeb
--- /dev/null
+++ b/change/@fluentui-react-charts-5fa1937b-0155-4657-a858-48055caa5553.json
@@ -0,0 +1,7 @@
+{
+ "type": "patch",
+ "comment": "feat: improve x-axis tick label layout with automatic wrapping, truncation, or multi-level rendering based on available space",
+ "packageName": "@fluentui/react-charts",
+ "email": "kumarkshitij@microsoft.com",
+ "dependentChangeType": "patch"
+}
diff --git a/packages/charts/react-charts/library/etc/react-charts.api.md b/packages/charts/react-charts/library/etc/react-charts.api.md
index d7324ac709eecc..702c809d5f2e2e 100644
--- a/packages/charts/react-charts/library/etc/react-charts.api.md
+++ b/packages/charts/react-charts/library/etc/react-charts.api.md
@@ -236,7 +236,9 @@ export interface CartesianChartProps {
useUTC?: string | boolean;
width?: number;
wrapXAxisLables?: boolean;
- xAxis?: AxisProps;
+ xAxis?: AxisProps & {
+ tickLayout?: 'default' | 'auto';
+ };
xAxisAnnotation?: string;
xAxisCategoryOrder?: AxisCategoryOrder;
xAxisTickCount?: number;
diff --git a/packages/charts/react-charts/library/src/components/AreaChart/AreaChart.tsx b/packages/charts/react-charts/library/src/components/AreaChart/AreaChart.tsx
index e4d993c8d6a1bb..d3c2af903088b0 100644
--- a/packages/charts/react-charts/library/src/components/AreaChart/AreaChart.tsx
+++ b/packages/charts/react-charts/library/src/components/AreaChart/AreaChart.tsx
@@ -1,10 +1,8 @@
'use client';
import * as React from 'react';
-import { useAreaChartStyles } from './useAreaChartStyles.styles';
import { max as d3Max, bisector } from 'd3-array';
import { pointer } from 'd3-selection';
-import { select as d3Select } from 'd3-selection';
import { tokens } from '@fluentui/react-theme';
import { area as d3Area, stack as d3Stack, curveMonotoneX as d3CurveBasis, line as d3Line } from 'd3-shape';
import {
@@ -25,7 +23,6 @@ import {
ChartTypes,
XAxisTypes,
getTypeOfAxis,
- tooltipOfAxislabels,
getNextColor,
getColorFromToken,
getSecureProps,
@@ -91,7 +88,6 @@ export const AreaChart: React.FunctionComponent = React.forwardR
const _verticalLineId: string = useId('verticalLine_');
const _circleId: string = useId('circle');
const _rectId: string = useId('rectangle');
- const _tooltipId: string = useId('AreaChartTooltipID');
//enableComputationOptimization is used for optimized code to group data points by x value
//from O(n^2) to O(n) using a map.
const _enableComputationOptimization: boolean = true;
@@ -149,8 +145,6 @@ export const AreaChart: React.FunctionComponent = React.forwardR
prevPropsRef.current = props;
}, [props]);
- const classes = useAreaChartStyles(props);
-
function _getMinMaxOfYAxis(points: LineChartPoints[], yAxisType: YAxisType, useSecondaryYScale: boolean) {
return findNumericMinMaxOfY(points, yAxisType, useSecondaryYScale);
}
@@ -846,29 +840,6 @@ export const AreaChart: React.FunctionComponent = React.forwardR
{...getSecureProps(pointLineOptions)}
/>,
);
- // Removing un wanted tooltip div from DOM, when prop not provided.
- if (!props.showXAxisLablesTooltip) {
- try {
- // eslint-disable-next-line @nx/workspace-no-restricted-globals
- document.getElementById(_tooltipId) && document.getElementById(_tooltipId)!.remove();
- // eslint-disable-next-line no-empty
- } catch (e) {}
- }
- // Used to display tooltip at x axis labels.
- if (!props.wrapXAxisLables && props.showXAxisLablesTooltip) {
- const xAxisElement = d3Select(xElement).call(xScale);
- try {
- // eslint-disable-next-line @nx/workspace-no-restricted-globals
- document.getElementById(_tooltipId) && document.getElementById(_tooltipId)!.remove();
- // eslint-disable-next-line no-empty
- } catch (e) {}
- const tooltipProps = {
- tooltipCls: classes.tooltip!,
- id: _tooltipId,
- axis: xAxisElement,
- };
- xAxisElement && tooltipOfAxislabels(tooltipProps);
- }
return graph;
}
diff --git a/packages/charts/react-charts/library/src/components/AreaChart/__snapshots__/AreaChart.test.tsx.snap b/packages/charts/react-charts/library/src/components/AreaChart/__snapshots__/AreaChart.test.tsx.snap
index e49435c950ecb5..fc4bcef1d3bc14 100644
--- a/packages/charts/react-charts/library/src/components/AreaChart/__snapshots__/AreaChart.test.tsx.snap
+++ b/packages/charts/react-charts/library/src/components/AreaChart/__snapshots__/AreaChart.test.tsx.snap
@@ -337,7 +337,7 @@ exports[`Area chart rendering Should render the Area Chart with negative y value
@@ -345,7 +345,7 @@ exports[`Area chart rendering Should render the Area Chart with negative y value
@@ -1203,7 +1203,7 @@ exports[`Area chart rendering Should render the Area Chart with tozeroy mode 1`]
@@ -2173,7 +2173,7 @@ exports[`Area chart rendering Should render the Area chart with secondary Y axis
-
@@ -4450,7 +4445,7 @@ Object {
@@ -5306,7 +5301,7 @@ Object {
-
@@ -6226,7 +6216,7 @@ Object {
@@ -7082,7 +7072,7 @@ Object {
-
@@ -8002,7 +7987,7 @@ Object {
@@ -8858,7 +8843,7 @@ Object {
@@ -9773,7 +9758,7 @@ Object {
@@ -10259,7 +10244,7 @@ Object {
@@ -10804,7 +10789,7 @@ Object {
@@ -11660,7 +11645,7 @@ Object {
@@ -12575,7 +12560,7 @@ Object {
@@ -13431,7 +13416,7 @@ Object {
@@ -14175,7 +14160,7 @@ Object {
@@ -14436,7 +14421,7 @@ Object {
@@ -14927,7 +14912,7 @@ Object {
@@ -15793,7 +15778,7 @@ Object {
@@ -16718,7 +16703,7 @@ Object {
@@ -17500,7 +17485,7 @@ Object {
@@ -18341,7 +18326,7 @@ Object {
@@ -19197,7 +19182,7 @@ Object {
-
@@ -19843,21 +19821,14 @@ Object {
/>
-
@@ -19876,21 +19847,14 @@ Object {
/>
-
@@ -19909,21 +19873,14 @@ Object {
/>
-
@@ -19942,21 +19899,14 @@ Object {
/>
-
@@ -19975,21 +19925,14 @@ Object {
/>
-
@@ -20008,21 +19951,14 @@ Object {
/>
-
@@ -20041,21 +19977,14 @@ Object {
/>
-
@@ -20074,21 +20003,14 @@ Object {
/>
-
@@ -20107,21 +20029,14 @@ Object {
/>
-
@@ -20244,7 +20159,7 @@ Object {
@@ -20252,7 +20167,7 @@ Object {
+
-
-
@@ -21898,15 +21742,14 @@ Object {
/>
@@ -21925,15 +21768,14 @@ Object {
/>
@@ -21952,15 +21794,14 @@ Object {
/>
@@ -21979,15 +21820,14 @@ Object {
/>
@@ -22006,15 +21846,14 @@ Object {
/>
@@ -22033,15 +21872,14 @@ Object {
/>
@@ -22060,15 +21898,14 @@ Object {
/>
@@ -22087,15 +21924,14 @@ Object {
/>
@@ -22114,15 +21950,14 @@ Object {
/>
@@ -22245,7 +22080,7 @@ Object {
@@ -22253,7 +22088,7 @@ Object {
+
+ 65
+