Skip to content

Commit

Permalink
[@mantine/charts] Fix unexpected padding on the right side of the cha…
Browse files Browse the repository at this point in the history
…rt in BarChart, AreaChart and LineChart components (#6467)
  • Loading branch information
rtivital committed Jun 28, 2024
1 parent c7e52e4 commit 0c5e3bb
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
11 changes: 6 additions & 5 deletions packages/@mantine/charts/src/AreaChart/AreaChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ export const AreaChart = factory<AreaChartFactory>((_props, ref) => {
});

const sharedYAxisProps = {
hide: !withYAxis,
axisLine: false,
...(orientation === 'vertical'
? { dataKey, type: 'category' as const }
Expand Down Expand Up @@ -402,10 +401,11 @@ export const AreaChart = factory<AreaChartFactory>((_props, ref) => {
yAxisId="left"
orientation="left"
tick={{ transform: 'translate(-10, 0)', fontSize: 12, fill: 'currentColor' }}
hide={!withYAxis}
{...sharedYAxisProps}
{...yAxisProps}
>
{rightYAxisLabel && (
{yAxisLabel && (
<Label
position="insideLeft"
angle={-90}
Expand All @@ -414,7 +414,7 @@ export const AreaChart = factory<AreaChartFactory>((_props, ref) => {
offset={-5}
{...getStyles('axisLabel')}
>
{rightYAxisLabel}
{yAxisLabel}
</Label>
)}
{yAxisProps?.children}
Expand All @@ -424,10 +424,11 @@ export const AreaChart = factory<AreaChartFactory>((_props, ref) => {
yAxisId="right"
orientation="right"
tick={{ transform: 'translate(10, 0)', fontSize: 12, fill: 'currentColor' }}
hide={!withRightYAxis}
{...sharedYAxisProps}
{...rightYAxisProps}
>
{yAxisLabel && (
{rightYAxisLabel && (
<Label
position="insideRight"
angle={90}
Expand All @@ -436,7 +437,7 @@ export const AreaChart = factory<AreaChartFactory>((_props, ref) => {
offset={-5}
{...getStyles('axisLabel')}
>
{yAxisLabel}
{rightYAxisLabel}
</Label>
)}
{yAxisProps?.children}
Expand Down
2 changes: 1 addition & 1 deletion packages/@mantine/charts/src/BarChart/BarChart.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const waterfallData = [

export function Usage() {
return (
<div style={{ padding: 40 }}>
<div style={{ background: 'silver' }}>
<BarChart
h={300}
data={simpleData}
Expand Down
11 changes: 6 additions & 5 deletions packages/@mantine/charts/src/BarChart/BarChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ export const BarChart = factory<BarChartFactory>((_props, ref) => {
});

const sharedYAxisProps = {
hide: !withYAxis,
axisLine: false,
...(orientation === 'vertical'
? { dataKey, type: 'category' as const }
Expand Down Expand Up @@ -352,10 +351,11 @@ export const BarChart = factory<BarChartFactory>((_props, ref) => {
yAxisId="left"
orientation="left"
tick={{ transform: 'translate(-10, 0)', fontSize: 12, fill: 'currentColor' }}
hide={!withYAxis}
{...sharedYAxisProps}
{...yAxisProps}
>
{rightYAxisLabel && (
{yAxisLabel && (
<Label
position="insideLeft"
angle={-90}
Expand All @@ -364,7 +364,7 @@ export const BarChart = factory<BarChartFactory>((_props, ref) => {
offset={-5}
{...getStyles('axisLabel')}
>
{rightYAxisLabel}
{yAxisLabel}
</Label>
)}
{yAxisProps?.children}
Expand All @@ -374,10 +374,11 @@ export const BarChart = factory<BarChartFactory>((_props, ref) => {
yAxisId="right"
orientation="right"
tick={{ transform: 'translate(10, 0)', fontSize: 12, fill: 'currentColor' }}
hide={!withRightYAxis}
{...sharedYAxisProps}
{...rightYAxisProps}
>
{yAxisLabel && (
{rightYAxisLabel && (
<Label
position="insideRight"
angle={90}
Expand All @@ -386,7 +387,7 @@ export const BarChart = factory<BarChartFactory>((_props, ref) => {
offset={-5}
{...getStyles('axisLabel')}
>
{yAxisLabel}
{rightYAxisLabel}
</Label>
)}
{yAxisProps?.children}
Expand Down
11 changes: 6 additions & 5 deletions packages/@mantine/charts/src/LineChart/LineChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ export const LineChart = factory<LineChartFactory>((_props, ref) => {
});

const sharedYAxisProps = {
hide: !withYAxis,
axisLine: false,
...(orientation === 'vertical'
? { dataKey, type: 'category' as const }
Expand Down Expand Up @@ -383,10 +382,11 @@ export const LineChart = factory<LineChartFactory>((_props, ref) => {
yAxisId="left"
orientation="left"
tick={{ transform: 'translate(-10, 0)', fontSize: 12, fill: 'currentColor' }}
hide={!withYAxis}
{...sharedYAxisProps}
{...yAxisProps}
>
{rightYAxisLabel && (
{yAxisLabel && (
<Label
position="insideLeft"
angle={-90}
Expand All @@ -395,7 +395,7 @@ export const LineChart = factory<LineChartFactory>((_props, ref) => {
offset={-5}
{...getStyles('axisLabel')}
>
{rightYAxisLabel}
{yAxisLabel}
</Label>
)}
{yAxisProps?.children}
Expand All @@ -405,10 +405,11 @@ export const LineChart = factory<LineChartFactory>((_props, ref) => {
yAxisId="right"
orientation="right"
tick={{ transform: 'translate(10, 0)', fontSize: 12, fill: 'currentColor' }}
hide={!withRightYAxis}
{...sharedYAxisProps}
{...rightYAxisProps}
>
{yAxisLabel && (
{rightYAxisLabel && (
<Label
position="insideRight"
angle={90}
Expand All @@ -417,7 +418,7 @@ export const LineChart = factory<LineChartFactory>((_props, ref) => {
offset={-5}
{...getStyles('axisLabel')}
>
{yAxisLabel}
{rightYAxisLabel}
</Label>
)}
{yAxisProps?.children}
Expand Down

0 comments on commit 0c5e3bb

Please sign in to comment.