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

Function Chart

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

Source from the content-addressed store, hash-verified

52}
53
54export function Chart({ data }: Props) {
55 const {
56 isEditMode,
57 report: {
58 previous,
59 interval,
60 projectId,
61 startDate,
62 endDate,
63 range,
64 series: reportSeries,
65 breakdowns,
66 options: reportOptions,
67 visibleSeries: savedVisibleSeries,
68 },
69 options: { hideXAxis, hideYAxis },
70 } = useReportChartContext();
71 const dispatch = useDispatch();
72
73 const histogramOptions =
74 reportOptions?.type === 'histogram' ? reportOptions : undefined;
75 const isStacked = histogramOptions?.stacked ?? false;
76 const trpc = useTRPC();
77 const references = useQuery(
78 trpc.reference.getChartReferences.queryOptions({
79 projectId,
80 startDate,
81 endDate,
82 range,
83 }),
84 );
85 const { series, setVisibleSeries } = useVisibleSeries(data, {
86 savedVisibleSeries,
87 onVisibleSeriesChange: isEditMode
88 ? (ids) => dispatch(changeVisibleSeries(ids))
89 : undefined,
90 });
91 const rechartData = useRechartDataModel(series);
92 const yAxisProps = useYAxisProps({
93 hide: hideYAxis,
94 });
95 const xAxisProps = useXAxisProps({
96 hide: hideXAxis,
97 interval,
98 });
99
100 const getMenuItems = useCallback(
101 (e: any, clickedData: any): ChartClickMenuItem[] => {
102 const items: ChartClickMenuItem[] = [];
103
104 if (!clickedData?.date) {
105 return items;
106 }
107
108 // View Users - only show if we have projectId
109 if (projectId) {
110 items.push({
111 label: 'View Users',

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected