Skip to content

Commit 3aaa8a9

Browse files
Anush2303Anush
andauthored
feat(react-charts): add support for tickmode in declarative chart (microsoft#35121)
Co-authored-by: Anush <[email protected]>
1 parent d6d90ba commit 3aaa8a9

File tree

8 files changed

+600
-40
lines changed

8 files changed

+600
-40
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "add support for tickmode in declarative chart",
4+
"packageName": "@fluentui/react-charts",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

packages/charts/react-charts/library/etc/react-charts.api.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ export interface AreaChartStyles extends CartesianChartStyles {
7272
// @public
7373
export type AxisCategoryOrder = 'default' | 'data' | string[] | 'category ascending' | 'category descending' | 'total ascending' | 'total descending' | 'min ascending' | 'min descending' | 'max ascending' | 'max descending' | 'sum ascending' | 'sum descending' | 'mean ascending' | 'mean descending' | 'median ascending' | 'median descending';
7474

75+
// @public
76+
export type AxisProps = {
77+
tickStep?: number | string;
78+
tick0?: number | Date;
79+
};
80+
7581
// @public
7682
export type AxisScaleType = 'default' | 'log';
7783

@@ -179,6 +185,7 @@ export interface CartesianChartProps {
179185
useUTC?: string | boolean;
180186
width?: number;
181187
wrapXAxisLables?: boolean;
188+
xAxis?: AxisProps;
182189
xAxisAnnotation?: string;
183190
xAxisCategoryOrder?: AxisCategoryOrder;
184191
xAxisTickCount?: number;
@@ -187,10 +194,12 @@ export interface CartesianChartProps {
187194
xAxisTitle?: string;
188195
xMaxValue?: number;
189196
xScaleType?: AxisScaleType;
197+
yAxis?: AxisProps;
190198
yAxisAnnotation?: string;
191199
yAxisCategoryOrder?: AxisCategoryOrder;
192200
yAxisTickCount?: number;
193201
yAxisTickFormat?: any;
202+
yAxisTickValues?: number[] | Date[] | string[];
194203
yAxisTitle?: string;
195204
yMaxValue?: number;
196205
yMinValue?: number;

packages/charts/react-charts/library/src/components/CommonComponents/CartesianChart.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@ export const CartesianChart: React.FunctionComponent<ModifiedCartesianChartProps
270270
containerWidth: containerWidth,
271271
hideTickOverlap: props.rotateXAxisLables ? false : props.hideTickOverlap,
272272
calcMaxLabelWidth: _calcMaxLabelWidthWithTransform,
273+
tickStep: props.xAxis?.tickStep,
274+
tick0: props.xAxis?.tick0,
273275
};
274276

275277
/**
@@ -341,6 +343,9 @@ export const CartesianChart: React.FunctionComponent<ModifiedCartesianChartProps
341343
// and the parent chart(HBWA/Vertical etc..) for more details refer example
342344
// http://using-d3js.com/04_07_ordinal_scales.html
343345
yAxisPadding: props.yAxisPadding || 0,
346+
tickValues: props.yAxisTickValues,
347+
tickStep: props.yAxis?.tickStep,
348+
tick0: props.yAxis?.tick0,
344349
};
345350
/**
346351
* These scales used for 2 purposes.

packages/charts/react-charts/library/src/components/CommonComponents/CartesianChart.types.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
ScatterChartPoints,
1616
GanttChartDataPoint,
1717
AxisCategoryOrder,
18+
AxisProps,
1819
AxisScaleType,
1920
} from '../../types/index';
2021
import { TimeLocaleDefinition } from 'd3-time-format';
@@ -479,6 +480,24 @@ export interface CartesianChartProps {
479480
* @default 'default'
480481
*/
481482
secondaryYScaleType?: AxisScaleType;
483+
484+
/**
485+
* Explicit set of tick values for the y-axis.
486+
* If provided, these values override automatic tick generation.
487+
*/
488+
yAxisTickValues?: number[] | Date[] | string[];
489+
490+
/**
491+
* Configuration for the x-axis.
492+
* Use this to control `tickStep`, `tick0`, etc.
493+
*/
494+
xAxis?: AxisProps;
495+
496+
/**
497+
* Configuration for the y-axis.
498+
* Use this to control `tickStep`, `tick0`, etc.
499+
*/
500+
yAxis?: AxisProps;
482501
}
483502

484503
export interface YValueHover {

0 commit comments

Comments
 (0)