@@ -60,6 +60,7 @@ type ChartReferenceLineProps = {
6060 label: string ;
6161};
6262
63+
6364type ChartXAxisProps = Omit <RechartsXAxisProps , ' tick' | ' label' | ' dataKey' | ' stroke' > & {
6465 /**
6566 * The label of the x-axis.
@@ -69,8 +70,58 @@ type ChartXAxisProps = Omit<RechartsXAxisProps, 'tick' | 'label' | 'dataKey' | '
6970 * The data key of the x-axis.
7071 */
7172 dataKey? : string ;
73+ /**
74+ * Optional secondary data key for multi-line X-axis labels.
75+ * When provided, the X-axis will display two lines of text:
76+ * - Primary label (from dataKey)
77+ * - Secondary label (from secondaryDataKey)
78+ * @example
79+ * // Data: [{ date: 'Jan', year: '2024' }, { date: 'Feb', year: '2024' }]
80+ * <ChartXAxis dataKey="date" secondaryDataKey="year" />
81+ * // Renders:
82+ * // Jan Feb
83+ * // 2024 2024
84+ */
85+ secondaryDataKey? : string ;
86+ /**
87+ * The interval of the x-axis.
88+ * @default : 0
89+ * @example
90+ * // Data: [{ date: 'Jan', year: '2024' }, { date: 'Feb', year: '2024' }]
91+ * <ChartXAxis dataKey="date" interval={1} />
92+ * // Renders:
93+ * // Jan
94+ * // Feb
95+ *
96+ * note: if you can't see all labels in case of large labels. try setting interval 0
97+ */
98+ interval? : number ;
99+ /**
100+ * Custom formatter function to transform tick values before display.
101+ * Useful for formatting timestamps, currencies, or other numeric values.
102+ *
103+ * @param value - The raw tick value from the data
104+ * @param index - The index of the tick
105+ * @returns The formatted string to display
106+ *
107+ * @example
108+ * // Format timestamp to readable date
109+ * <ChartXAxis
110+ * dataKey="timestamp"
111+ * tickFormatter={(value) => new Date(value).toLocaleDateString()}
112+ * />
113+ *
114+ * @example
115+ * // Format currency values
116+ * <ChartXAxis
117+ * dataKey="amount"
118+ * tickFormatter={(value) => `$${(value / 1000).toFixed(0)}K`}
119+ * />
120+ */
121+ tickFormatter? : (value : string , index : number ) => string ;
72122};
73123
124+
74125type ChartYAxisProps = Omit <RechartsYAxisProps , ' tick' | ' label' | ' dataKey' | ' stroke' > & {
75126 /**
76127 * The label of the y-axis.
0 commit comments