MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / Chart

Function Chart

apps/start/src/components/report-chart/retention/chart.tsx:24–110  ·  view source on GitHub ↗
({ data }: Props)

Source from the content-addressed store, hash-verified

22}
23
24export function Chart({ data }: Props) {
25 const {
26 report: { interval },
27 isEditMode,
28 options: { hideXAxis, hideYAxis },
29 } = useReportChartContext();
30
31 const xAxisProps = useXAxisProps({ interval, hide: hideXAxis });
32 const yAxisProps = useYAxisProps({
33 hide: hideYAxis,
34 tickFormatter: (value) => `${value}%`,
35 });
36 const averageRow = data[0];
37 const averageRetentionRate =
38 average(averageRow?.percentages || [], true) * 100;
39 const rechartData = averageRow?.percentages.map((item, index) => ({
40 days: index,
41 percentage: item * 100,
42 value: averageRow.values?.[index],
43 sum: averageRow.sum,
44 }));
45
46 return (
47 <>
48 <div className={cn('h-full w-full', isEditMode && 'card p-4')}>
49 <ResponsiveContainer>
50 <ComposedChart data={rechartData}>
51 <CartesianGrid
52 strokeDasharray="3 3"
53 horizontal={true}
54 vertical={true}
55 className="stroke-border"
56 />
57 <YAxis {...yAxisProps} dataKey="retentionRate" domain={[0, 100]} />
58 <XAxis
59 {...xAxisProps}
60 dataKey="days"
61 allowDuplicatedCategory
62 scale="linear"
63 tickFormatter={(value) => value.toString()}
64 tickCount={31}
65 interval={0}
66 />
67 <Tooltip content={<RetentionTooltip />} />
68 <defs>
69 <linearGradient id={'color'} x1="0" y1="0" x2="0" y2="1">
70 <stop
71 offset="0%"
72 stopColor={getChartColor(0)}
73 stopOpacity={0.8}
74 />
75 <stop
76 offset="100%"
77 stopColor={getChartColor(0)}
78 stopOpacity={0.1}
79 />
80 </linearGradient>
81 </defs>

Callers

nothing calls this directly

Calls 9

useReportChartContextFunction · 0.90
useXAxisPropsFunction · 0.90
useYAxisPropsFunction · 0.90
averageFunction · 0.90
cnFunction · 0.90
getChartColorFunction · 0.90
roundFunction · 0.90
mapMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected