refactor(PaymentsOverviewChart): enhance chart responsiveness and layout
- Updated the PaymentsOverviewChart component to improve responsiveness by enabling redraw on parent and window resize. - Adjusted chart options for better label handling and grid padding. - Modified the container div to ensure full width and height for the chart display.
This commit is contained in:
@@ -24,12 +24,13 @@ export function PaymentsOverviewChart({ data }: PropsType) {
|
|||||||
},
|
},
|
||||||
colors: ["#5750F1", "#0ABEF9"],
|
colors: ["#5750F1", "#0ABEF9"],
|
||||||
chart: {
|
chart: {
|
||||||
height: 310,
|
|
||||||
type: "area",
|
type: "area",
|
||||||
toolbar: {
|
toolbar: {
|
||||||
show: false,
|
show: false,
|
||||||
},
|
},
|
||||||
fontFamily: "inherit",
|
fontFamily: "inherit",
|
||||||
|
redrawOnParentResize: true,
|
||||||
|
redrawOnWindowResize: true,
|
||||||
},
|
},
|
||||||
fill: {
|
fill: {
|
||||||
gradient: {
|
gradient: {
|
||||||
@@ -61,6 +62,9 @@ export function PaymentsOverviewChart({ data }: PropsType) {
|
|||||||
},
|
},
|
||||||
grid: {
|
grid: {
|
||||||
strokeDashArray: 5,
|
strokeDashArray: 5,
|
||||||
|
padding: {
|
||||||
|
right: 8,
|
||||||
|
},
|
||||||
yaxis: {
|
yaxis: {
|
||||||
lines: {
|
lines: {
|
||||||
show: true,
|
show: true,
|
||||||
@@ -82,11 +86,18 @@ export function PaymentsOverviewChart({ data }: PropsType) {
|
|||||||
axisTicks: {
|
axisTicks: {
|
||||||
show: false,
|
show: false,
|
||||||
},
|
},
|
||||||
|
labels: {
|
||||||
|
rotate: -45,
|
||||||
|
rotateAlways: false,
|
||||||
|
hideOverlappingLabels: true,
|
||||||
|
...(isMobile && { maxHeight: 60 }),
|
||||||
|
},
|
||||||
|
tickAmount: isMobile ? 4 : undefined,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="-ml-4 -mr-5 h-[310px]">
|
<div className="h-[310px] w-full overflow-hidden sm:-ml-4 sm:-mr-5">
|
||||||
<Chart
|
<Chart
|
||||||
options={options}
|
options={options}
|
||||||
series={[
|
series={[
|
||||||
@@ -100,7 +111,8 @@ export function PaymentsOverviewChart({ data }: PropsType) {
|
|||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
type="area"
|
type="area"
|
||||||
height={310}
|
width="100%"
|
||||||
|
height="100%"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user