-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dbcadb4
commit 35578ce
Showing
25 changed files
with
318 additions
and
376 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,33 @@ | ||
import { ChartData } from '@/types/chat'; | ||
import { Chart } from '@berryv/g2-react'; | ||
import { Card, CardContent, Typography } from '@mui/joy'; | ||
import { useColorScheme } from '@mui/joy'; | ||
|
||
export default function BarChart({ chart }: { key: string; chart: ChartData }) { | ||
const { mode } = useColorScheme(); | ||
|
||
return ( | ||
<div className="flex-1 min-w-0"> | ||
<Card className="h-full" sx={{ background: 'transparent' }}> | ||
<CardContent className="h-full"> | ||
<Typography gutterBottom component="div"> | ||
{chart.chart_name} | ||
</Typography> | ||
<Typography gutterBottom level="body3"> | ||
{chart.chart_desc} | ||
</Typography> | ||
<div className="h-[300px]"> | ||
<Chart | ||
style={{ height: '100%' }} | ||
options={{ | ||
autoFit: true, | ||
type: 'interval', | ||
data: chart.values, | ||
encode: { x: 'name', y: 'value', color: 'type' }, | ||
axis: { | ||
x: { | ||
labelAutoRotate: false, | ||
}, | ||
<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="h-[300px]"> | ||
<Chart | ||
style={{ height: '100%' }} | ||
options={{ | ||
autoFit: true, | ||
theme: mode, | ||
type: 'interval', | ||
data: chart.values, | ||
encode: { x: 'name', y: 'value', color: 'type' }, | ||
axis: { | ||
x: { | ||
labelAutoRotate: false, | ||
}, | ||
}} | ||
/> | ||
</div> | ||
</CardContent> | ||
</Card> | ||
}, | ||
}} | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,56 @@ | ||
import { ChartData } from '@/types/chat'; | ||
import { Card, CardContent, Typography } from '@mui/joy'; | ||
import { useColorScheme } from '@mui/joy'; | ||
import { Chart } from '@berryv/g2-react'; | ||
|
||
export default function LineChart({ chart }: { chart: ChartData }) { | ||
const { mode } = useColorScheme(); | ||
|
||
return ( | ||
<div className="flex-1 min-w-0"> | ||
<Card className="h-full" sx={{ background: 'transparent' }}> | ||
<CardContent className="h-full"> | ||
<Typography gutterBottom component="div"> | ||
{chart.chart_name} | ||
</Typography> | ||
<Typography gutterBottom level="body3"> | ||
{chart.chart_desc} | ||
</Typography> | ||
<div className="h-[300px]"> | ||
<Chart | ||
style={{ height: '100%' }} | ||
options={{ | ||
autoFit: true, | ||
type: 'view', | ||
data: chart.values, | ||
children: [ | ||
{ | ||
type: 'line', | ||
encode: { | ||
x: 'name', | ||
y: 'value', | ||
color: 'type', | ||
shape: 'smooth', | ||
}, | ||
<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="h-[300px]"> | ||
<Chart | ||
style={{ height: '100%' }} | ||
options={{ | ||
autoFit: true, | ||
theme: mode, | ||
type: 'view', | ||
data: chart.values, | ||
children: [ | ||
{ | ||
type: 'line', | ||
encode: { | ||
x: 'name', | ||
y: 'value', | ||
color: 'type', | ||
shape: 'smooth', | ||
}, | ||
{ | ||
type: 'area', | ||
encode: { | ||
x: 'name', | ||
y: 'value', | ||
color: 'type', | ||
shape: 'smooth', | ||
}, | ||
legend: false, | ||
style: { | ||
fillOpacity: 0.15, | ||
}, | ||
}, | ||
{ | ||
type: 'area', | ||
encode: { | ||
x: 'name', | ||
y: 'value', | ||
color: 'type', | ||
shape: 'smooth', | ||
}, | ||
], | ||
axis: { | ||
x: { | ||
labelAutoRotate: false, | ||
legend: false, | ||
style: { | ||
fillOpacity: 0.15, | ||
}, | ||
}, | ||
}} | ||
/> | ||
</div> | ||
</CardContent> | ||
</Card> | ||
], | ||
axis: { | ||
x: { | ||
labelAutoRotate: false, | ||
}, | ||
}, | ||
}} | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,36 @@ | ||
import { ChartData } from '@/types/chat'; | ||
import { Card, CardContent, Typography, Table } from '@mui/joy'; | ||
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"> | ||
<Card className="h-full overflow-auto" sx={{ background: 'transparent' }}> | ||
<CardContent className="h-full"> | ||
<Typography gutterBottom component="div"> | ||
{chart.chart_name} | ||
</Typography> | ||
<Typography gutterBottom level="body3"> | ||
{chart.chart_desc} | ||
</Typography> | ||
<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> | ||
<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((value, i) => ( | ||
<tr key={i}> | ||
{Object.keys(data)?.map((k) => ( | ||
<td key={k}>{data?.[k]?.[i].value || ''}</td> | ||
))} | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{Object.values(data)?.[0]?.map((value, i) => ( | ||
<tr key={i}> | ||
{Object.keys(data)?.map((k) => ( | ||
<td key={k}>{data?.[k]?.[i].value || ''}</td> | ||
))} | ||
</tr> | ||
))} | ||
</tbody> | ||
</Table> | ||
</div> | ||
</CardContent> | ||
</Card> | ||
))} | ||
</tbody> | ||
</Table> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.