mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-07-28 22:37:31 +00:00
Co-authored-by: Fangyin Cheng <staneyffer@gmail.com> Co-authored-by: 谨欣 <echo.cmy@antgroup.com> Co-authored-by: 严志勇 <yanzhiyong@tiansuixiansheng.com> Co-authored-by: yanzhiyong <932374019@qq.com>
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import { ChartData } from '@/types/chat';
|
|
import { Table } from '@mui/joy';
|
|
import { groupBy } from 'lodash';
|
|
|
|
export default function TableChart({ chart }: { key: string; chart: ChartData }) {
|
|
const data = groupBy(chart.values, 'type');
|
|
|
|
return (
|
|
<div className='flex-1 min-w-0 p-4 bg-white dark:bg-theme-dark-container rounded'>
|
|
<div className='h-full'>
|
|
<div className='mb-2'>{chart.chart_name}</div>
|
|
<div className='opacity-80 text-sm mb-2'>{chart.chart_desc}</div>
|
|
<div className='flex-1'>
|
|
<Table aria-label='basic table' stripe='odd' hoverRow borderAxis='bothBetween'>
|
|
<thead>
|
|
<tr>
|
|
{Object.keys(data).map(key => (
|
|
<th key={key}>{key}</th>
|
|
))}
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{Object.values(data)?.[0]?.map((_, i) => (
|
|
<tr key={i}>{Object.keys(data)?.map(k => <td key={k}>{data?.[k]?.[i].value || ''}</td>)}</tr>
|
|
))}
|
|
</tbody>
|
|
</Table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|