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

Function Chart

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

Source from the content-addressed store, hash-verified

43}
44
45export function Chart({ data }: Props) {
46 const {
47 report: {
48 previous,
49 interval,
50 projectId,
51 startDate,
52 endDate,
53 range,
54 lineType,
55 series: reportSeries,
56 breakdowns,
57 visibleSeries: savedVisibleSeries,
58 },
59 isEditMode,
60 options: { hideXAxis, hideYAxis },
61 } = useReportChartContext();
62 const dispatch = useDispatch();
63 const trpc = useTRPC();
64 const references = useQuery(
65 trpc.reference.getChartReferences.queryOptions({
66 projectId,
67 startDate,
68 endDate,
69 range,
70 }),
71 );
72 const { series, setVisibleSeries } = useVisibleSeries(data, {
73 savedVisibleSeries,
74 onVisibleSeriesChange: isEditMode
75 ? (ids) => dispatch(changeVisibleSeries(ids))
76 : undefined,
77 });
78 const rechartData = useRechartDataModel(series);
79
80 let dotIndex = undefined;
81 if (range === 'today') {
82 // Find closest index based on times
83 dotIndex = rechartData.findIndex((item) => {
84 return isSameHour(item.date, new Date());
85 });
86 }
87
88 const lastSerieDataItem = last(series[0]?.data || [])?.date || new Date();
89 const useDashedLastLine = (() => {
90 if (range === 'today') {
91 return true;
92 }
93
94 if (interval === 'hour') {
95 return isSameHour(lastSerieDataItem, new Date());
96 }
97
98 if (interval === 'day') {
99 return isSameDay(lastSerieDataItem, new Date());
100 }
101
102 if (interval === 'month') {

Callers

nothing calls this directly

Calls 12

useReportChartContextFunction · 0.90
useVisibleSeriesFunction · 0.90
changeVisibleSeriesFunction · 0.90
useRechartDataModelFunction · 0.90
getChartColorFunction · 0.90
useYAxisPropsFunction · 0.90
useXAxisPropsFunction · 0.90
useDashedStrokeFunction · 0.90
cnFunction · 0.90
getStrokeDasharrayFunction · 0.85
mapMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected