Skip to content

Commit 6e485e5

Browse files
committed
Scatter chart: update labels of axis
1 parent a756999 commit 6e485e5

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

packages/charts/src/components/ScatterChart/ScatterChart.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ import {
1616
Tooltip,
1717
XAxis,
1818
YAxis,
19-
ZAxis
19+
ZAxis,
20+
Label
2021
} from 'recharts';
2122
import { useChartMargin } from '../../hooks/useChartMargin';
2223
import { useLongestYAxisLabel } from '../../hooks/useLongestYAxisLabel';
@@ -175,17 +176,17 @@ const ScatterChart: FC<ScatterChartProps> = forwardRef((props: ScatterChartProps
175176
<XAxis
176177
type={'number'}
177178
key={xMeasure?.[0]?.accessor}
178-
label={{ position: 'bottom', value: xMeasure?.[0]?.label }}
179179
dataKey={xMeasure?.[0]?.accessor}
180180
xAxisId={0}
181181
interval={xMeasure?.[0]?.interval ?? (isBigDataSet ? 'preserveStart' : 0)}
182182
tick={<XAxisTicks config={xMeasure?.[0]} />}
183183
padding={xAxisPadding}
184-
// height={xAxisHeights[0]}
184+
height={xAxisHeights[0]}
185+
label={xMeasure?.[0].label ? { value: xMeasure?.[0].label, dy: 15, position: 'insideRight' } : 0}
185186
/>
186187
)}
187188
<YAxis
188-
label={yMeasure?.[0]?.label ? { position: 'top', value: yMeasure?.[0]?.label } : false}
189+
label={yMeasure?.[0]?.label ? { value: yMeasure?.[0]?.label, angle: -90, position: 'insideLeft' } : false}
189190
type={'number'}
190191
name={yMeasure?.[0]?.accessor}
191192
axisLine={chartConfig.yAxisVisible}
@@ -195,8 +196,8 @@ const ScatterChart: FC<ScatterChartProps> = forwardRef((props: ScatterChartProps
195196
tickFormatter={yMeasure?.[0]?.formatter}
196197
interval={0}
197198
tick={<YAxisTicks config={yMeasure[0]} />}
198-
width={yAxisWidth}
199-
padding={yMeasure?.[0]?.label ? { top: 10 } : 0}
199+
width={yMeasure?.[0]?.label ? yAxisWidth + 10 : yAxisWidth}
200+
margin={yMeasure?.[0]?.label ? { left: 200 } : 0}
200201
/>
201202
<ZAxis
202203
name={zMeasure?.[0]?.accessor}

0 commit comments

Comments
 (0)