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

Function Chart

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

Source from the content-addressed store, hash-verified

12}
13
14export function Chart({ data }: Props) {
15 const {
16 report: { metric, unit },
17 } = useReportChartContext();
18 const { series } = useVisibleSeries(data, { limit: 99999 });
19 const [_, setFilter] = useEventQueryFilters();
20 const mapData = useMemo(
21 () =>
22 series.map((s) => ({
23 country: s.names[1]?.toLowerCase() ?? '',
24 value: s.metrics[metric] ?? 0,
25 })),
26 [series, metric],
27 );
28
29 return (
30 <AutoSizer disableHeight>
31 {({ width }) => (
32 <WorldMap
33 onClickFunction={(event) => {
34 if (event.countryCode) {
35 setFilter('country', event.countryCode);
36 }
37 }}
38 size={width}
39 data={mapData}
40 color={'var(--chart-0)'}
41 borderColor={'var(--foreground)'}
42 value-suffix={unit}
43 />
44 )}
45 </AutoSizer>
46 );
47}

Callers

nothing calls this directly

Calls 5

useReportChartContextFunction · 0.90
useVisibleSeriesFunction · 0.90
useEventQueryFiltersFunction · 0.90
setFilterFunction · 0.50
mapMethod · 0.45

Tested by

no test coverage detected