Skip to content

Commit

Permalink
fix: chart legend overlap on mobile (#1006)
Browse files Browse the repository at this point in the history
* fix: chart legend overlap on mobile

* style: prettier
  • Loading branch information
pocin authored Apr 14, 2024
1 parent f568c98 commit fced948
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions apps/dapp/src/components/Charts/BiAxialAreaChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@ import type { DataKey } from 'recharts/types/util/types';

import React from 'react';
import { useTheme } from 'styled-components';
import { ResponsiveContainer, AreaChart as RechartsChart, Area, XAxis, YAxis, Tooltip, Legend, CartesianGrid } from 'recharts';
import {
ResponsiveContainer,
AreaChart as RechartsChart,
Area,
XAxis,
YAxis,
Tooltip,
Legend,
CartesianGrid,
} from 'recharts';
import { formatNumberAbbreviated, formatNumberFixedDecimals } from 'utils/formatter';
import { useMediaQuery } from 'react-responsive';
import { queryPhone } from 'styles/breakpoints';
Expand Down Expand Up @@ -37,7 +46,7 @@ export default function BiAxialLineChart<T>(props: React.PropsWithChildren<LineC
return (
<ResponsiveContainer minHeight={200} minWidth={320} height={400}>
<RechartsChart data={chartData}>
<CartesianGrid horizontal={true} vertical={false} stroke={theme.palette.brandDarker}/>
<CartesianGrid horizontal={true} vertical={false} stroke={theme.palette.brandDarker} />
{lines.map((line) => (
<Area
key={line.series.toString()}
Expand Down Expand Up @@ -100,7 +109,14 @@ export default function BiAxialLineChart<T>(props: React.PropsWithChildren<LineC
return tooltipValuesFormatter(value, name);
}}
/>
{lines.length > 1 ? <Legend verticalAlign="top" height={20} formatter={legendFormatter} /> : null}
{lines.length > 1 ? (
<Legend
wrapperStyle={{ minHeight: '20px', height: 'auto', padding: '1rem' }}
verticalAlign="top"
height={20}
formatter={legendFormatter}
/>
) : null}
</RechartsChart>
</ResponsiveContainer>
);
Expand Down

0 comments on commit fced948

Please sign in to comment.