-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
12 changed files
with
786 additions
and
77 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
35 changes: 35 additions & 0 deletions
35
src/modules/AieraChat/Messages/MessageFactory/Block/Chart/Area/index.tsx
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React from 'react'; | ||
import { Area, AreaChart, CartesianGrid, Legend, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts'; | ||
import { COLORS, ChartBlock, ChartMetaBase, ChartSeries, ChartType } from '..'; | ||
|
||
export interface AreaChartMeta extends ChartMetaBase { | ||
chartType: ChartType.area; | ||
series: ChartSeries[]; | ||
stackedSeries?: boolean; | ||
} | ||
|
||
export function AreaChartBlock({ data, meta }: ChartBlock) { | ||
const { series, stackedSeries, xAxis, yAxis } = meta as AreaChartMeta; | ||
return ( | ||
<ResponsiveContainer width="100%" height={400}> | ||
<AreaChart data={data}> | ||
<CartesianGrid strokeDasharray="3 3" /> | ||
<XAxis dataKey="name" label={xAxis ? { value: xAxis, position: 'bottom' } : undefined} /> | ||
<YAxis label={yAxis ? { value: yAxis, angle: -90, position: 'left' } : undefined} /> | ||
<Tooltip /> | ||
<Legend /> | ||
{series.map((s, index) => ( | ||
<Area | ||
key={s.key} | ||
type="monotone" | ||
dataKey={s.key} | ||
name={s.label} | ||
stackId={stackedSeries ? 'stack' : undefined} | ||
fill={s.color || COLORS[index % COLORS.length]} | ||
stroke={s.color || COLORS[index % COLORS.length]} | ||
/> | ||
))} | ||
</AreaChart> | ||
</ResponsiveContainer> | ||
); | ||
} |
33 changes: 33 additions & 0 deletions
33
src/modules/AieraChat/Messages/MessageFactory/Block/Chart/Bar/index.tsx
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React from 'react'; | ||
import { Bar, BarChart, CartesianGrid, Legend, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts'; | ||
import { COLORS, ChartBlock, ChartMetaBase, ChartSeries, ChartType } from '..'; | ||
|
||
export interface BarChartMeta extends ChartMetaBase { | ||
chartType: ChartType.bar; | ||
series: ChartSeries[]; | ||
stackedBars?: boolean; | ||
} | ||
|
||
export function BarChartBlock({ data, meta }: ChartBlock) { | ||
const { series, stackedBars, xAxis, yAxis } = meta as BarChartMeta; | ||
return ( | ||
<ResponsiveContainer width="100%" height={400}> | ||
<BarChart data={data}> | ||
<CartesianGrid strokeDasharray="3 3" /> | ||
<XAxis dataKey="name" label={xAxis ? { value: xAxis, position: 'bottom' } : undefined} /> | ||
<YAxis label={yAxis ? { value: yAxis, angle: -90, position: 'left' } : undefined} /> | ||
<Tooltip /> | ||
<Legend /> | ||
{series.map((s, index) => ( | ||
<Bar | ||
key={s.key} | ||
dataKey={s.key} | ||
name={s.label} | ||
stackId={stackedBars ? 'stack' : undefined} | ||
fill={s.color || COLORS[index % COLORS.length]} | ||
/> | ||
))} | ||
</BarChart> | ||
</ResponsiveContainer> | ||
); | ||
} |
32 changes: 32 additions & 0 deletions
32
src/modules/AieraChat/Messages/MessageFactory/Block/Chart/Line/index.tsx
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from 'react'; | ||
import { CartesianGrid, Legend, Line, LineChart, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts'; | ||
import { ChartMetaBase, ChartType, ChartSeries, ChartBlock, COLORS } from '..'; | ||
|
||
export interface LineChartMeta extends ChartMetaBase { | ||
chartType: ChartType.line; | ||
series: ChartSeries[]; | ||
} | ||
|
||
export function LineChartBlock({ data, meta }: ChartBlock) { | ||
const { series, xAxis, yAxis } = meta as LineChartMeta; | ||
return ( | ||
<ResponsiveContainer width="100%" height={400}> | ||
<LineChart data={data}> | ||
<CartesianGrid strokeDasharray="3 3" /> | ||
<XAxis dataKey="name" label={xAxis ? { value: xAxis, position: 'bottom' } : undefined} /> | ||
<YAxis label={yAxis ? { value: yAxis, angle: -90, position: 'left' } : undefined} /> | ||
<Tooltip /> | ||
<Legend /> | ||
{series.map((s, index) => ( | ||
<Line | ||
key={s.key} | ||
type="monotone" | ||
dataKey={s.key} | ||
name={s.label} | ||
stroke={s.color || COLORS[index % COLORS.length]} | ||
/> | ||
))} | ||
</LineChart> | ||
</ResponsiveContainer> | ||
); | ||
} |
27 changes: 27 additions & 0 deletions
27
src/modules/AieraChat/Messages/MessageFactory/Block/Chart/Pie/index.tsx
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from 'react'; | ||
import { Cell, Legend, Pie, PieChart, ResponsiveContainer, Tooltip } from 'recharts'; | ||
import { COLORS, ChartBlock, ChartMetaBase, ChartType } from '..'; | ||
|
||
export interface PieChartMeta extends ChartMetaBase { | ||
chartType: ChartType.pie; | ||
valueKey: string; // Which field to use for values | ||
nameKey: string; // Which field to use for segment names | ||
colors?: string[]; // Optional array of colors for segments | ||
} | ||
|
||
export function PieChartBlock({ data, meta }: ChartBlock) { | ||
const { valueKey, nameKey, colors = COLORS, title } = meta as PieChartMeta; | ||
return ( | ||
<ResponsiveContainer width="100%" height={400}> | ||
<PieChart> | ||
<Pie data={data} dataKey={valueKey} nameKey={nameKey} cx="50%" cy="50%" label> | ||
{data.map((_, index) => ( | ||
<Cell key={`cell-${index}`} fill={colors[index % colors.length]} /> | ||
))} | ||
</Pie> | ||
<Tooltip /> | ||
<Legend /> | ||
</PieChart> | ||
</ResponsiveContainer> | ||
); | ||
} |
28 changes: 28 additions & 0 deletions
28
src/modules/AieraChat/Messages/MessageFactory/Block/Chart/Scatter/index.tsx
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from 'react'; | ||
import { CartesianGrid, Legend, ResponsiveContainer, Scatter, ScatterChart, Tooltip, XAxis, YAxis } from 'recharts'; | ||
import { ChartMetaBase, ChartType, ChartBlock, COLORS } from '..'; | ||
|
||
export interface ScatterChartMeta extends ChartMetaBase { | ||
chartType: ChartType.scatter; | ||
xKey: string; // Field for X coordinates | ||
yKey: string; // Field for Y coordinates | ||
sizeKey?: string; // Optional field for point sizes | ||
nameKey: string; // Field for point labels | ||
colors?: string[]; // Optional array of colors | ||
} | ||
|
||
export function ScatterChartBlock({ data, meta }: ChartBlock) { | ||
const { xKey, yKey, sizeKey, nameKey, colors = COLORS, xAxis, yAxis } = meta as ScatterChartMeta; | ||
return ( | ||
<ResponsiveContainer width="100%" height={400}> | ||
<ScatterChart> | ||
<CartesianGrid strokeDasharray="3 3" /> | ||
<XAxis dataKey={xKey} name={xAxis} /> | ||
<YAxis dataKey={yKey} name={yAxis} /> | ||
<Tooltip cursor={{ strokeDasharray: '3 3' }} /> | ||
<Legend /> | ||
<Scatter name={nameKey} data={data} fill={colors[0]} /> | ||
</ScatterChart> | ||
</ResponsiveContainer> | ||
); | ||
} |
23 changes: 23 additions & 0 deletions
23
src/modules/AieraChat/Messages/MessageFactory/Block/Chart/Tree/index.tsx
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from 'react'; | ||
import { Cell, ResponsiveContainer, Treemap } from 'recharts'; | ||
import { COLORS, ChartBlock, ChartMetaBase, ChartType } from '..'; | ||
|
||
export interface TreeMapMeta extends ChartMetaBase { | ||
chartType: ChartType.treemap; | ||
valueKey: string; // Field for box sizes | ||
nameKey: string; // Field for box labels | ||
colors?: string[]; // Optional array of colors | ||
} | ||
|
||
export function TreeMapBlock({ data, meta }: ChartBlock) { | ||
const { valueKey, nameKey, colors = COLORS } = meta as TreeMapMeta; | ||
return ( | ||
<ResponsiveContainer width="100%" height={400}> | ||
<Treemap data={data} dataKey={valueKey} nameKey={nameKey} aspectRatio={4 / 3}> | ||
{data.map((_, index) => ( | ||
<Cell key={`cell-${index}`} fill={colors[index % colors.length]} /> | ||
))} | ||
</Treemap> | ||
</ResponsiveContainer> | ||
); | ||
} |
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