Merge commit 'e5265a10d0b9d2f7df9aa53e1d482deb821ba4e7' into iipbs/wr/main_merge

This commit is contained in:
truthwing
2025-03-17 17:54:40 +09:00
3 changed files with 120 additions and 10 deletions
@@ -76,7 +76,24 @@ const CustomLegend = (props: any) => {
);
};
export default function Linechart(props: { chartConfig: ChartConfig; chartData: any[] | undefined; chartTitle:string}) {
type DataType = {label : string; val:number};
type ChartDataType = {
chartData1: DataType[];
chartData2: DataType[];
};
export default function Linechart(props: { chartConfig: ChartConfig; chartData: ChartDataType; chartTitle:string}) {
const mergedData = Object.values(props.chartData).reduce((acc, dataset) => {
dataset.forEach((entry, index) => {
if (!acc[index]) {
acc[index] = { label: entry.label }; // label 추가
}
const key = Object.keys(props.chartData).find(k => props.chartData[k] === dataset);
if (key) acc[index][key] = entry.val;
});
return acc;
}, [] as any[]);
return (
<Card className="h-full">
<CardContent className="h-full">
@@ -86,13 +103,15 @@ export default function Linechart(props: { chartConfig: ChartConfig; chartData:
</div>): null}
<div className="h-[calc(100%-42px)] flex justify-center">
<ChartContainer config={props.chartConfig} className="h-full w-full">
<LineChart data={props.chartData} className="h-full">
<CartesianGrid vertical={false} />
<LineChart data={mergedData} className="h-full">
<CartesianGrid vertical={false} />
<XAxis dataKey="label" fontSize="8px" fontWeight="bold"/>
<YAxis yAxisId="left" orientation="left" />
<Tooltip content={<CustomTooltip active={undefined} payload={undefined} label={undefined} />} />
<Legend content={CustomLegend}/>
<Line yAxisId="left" dataKey="val" type="linear" strokeWidth={2} dot={false} name="값"/>
{Object.keys(props.chartData).map((key, index) => (
<Line key={key} yAxisId="left" dataKey={key} type="linear" strokeWidth={2} dot={false} name={key} />
))}
</LineChart>
</ChartContainer>
</div>
@@ -1,7 +1,6 @@
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@common/components";
import UiPageNations from "./uiPageNations";
type UiTableProps = {
headName: React.ReactNode | undefined;
tableData: { [key: string]: string | number | boolean }[];
@@ -9,14 +8,15 @@ type UiTableProps = {
pageSize: number;
total: number;
children: React.ReactNode | undefined;
cellClick : (index:number)=>void | undefined;
}
type UiHeadProps = {
id: string;
title: string;
}
export function UiTable({ tableData, headlist, pageSize, total, children, headName }: UiTableProps) {
export function UiTable({ tableData, headlist, pageSize, total, children, headName, cellClick }: UiTableProps) {
const cur = 1;
return (
@@ -35,13 +35,11 @@ export function UiTable({ tableData, headlist, pageSize, total, children, headNa
{tableData?.map((el: { [key: string]: string | number | boolean }, index) => (
<TableRow key={index + "row"} >
{headlist.map((head) => (
<TableCell key={head.id + index}>{el[head.id]}</TableCell>
<TableCell onClick={()=>cellClick(index)} key={head.id + index}>{el[head.id]}</TableCell>
))}
</TableRow>
))}
</TableBody>
</Table>
{total <= 0 ? <></> : <UiPageNations total={total} cur={cur} pageSize={pageSize} />}
</>