MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / ChartContainer

Function ChartContainer

packages/react/src/components/chart.tsx:52–88  ·  view source on GitHub ↗
({
  id,
  className,
  children,
  config,
  initialDimension = INITIAL_DIMENSION,
  ...props
}: React.ComponentProps<"div"> & {
  config: ChartConfig;
  children: React.ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>["children"];
  initialDimension?: {
    width: number;
    height: number;
  };
})

Source from the content-addressed store, hash-verified

50}
51
52function ChartContainer({
53 id,
54 className,
55 children,
56 config,
57 initialDimension = INITIAL_DIMENSION,
58 ...props
59}: React.ComponentProps<"div"> & {
60 config: ChartConfig;
61 children: React.ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>["children"];
62 initialDimension?: {
63 width: number;
64 height: number;
65 };
66}) {
67 const uniqueId = React.useId();
68 const chartId = `chart-${id ?? uniqueId.replace(/:/g, "")}`;
69
70 return (
71 <ChartContext.Provider value={{ config }}>
72 <div
73 data-slot="chart"
74 data-chart={chartId}
75 className={cn(
76 "flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
77 className,
78 )}
79 {...props}
80 >
81 <ChartStyle id={chartId} config={config} />
82 <RechartsPrimitive.ResponsiveContainer initialDimension={initialDimension}>
83 {children}
84 </RechartsPrimitive.ResponsiveContainer>
85 </div>
86 </ChartContext.Provider>
87 );
88}
89
90const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
91 const colorConfig = Object.entries(config).filter(([, config]) => config.theme ?? config.color);

Callers

nothing calls this directly

Calls 2

cnFunction · 0.90
replaceMethod · 0.65

Tested by

no test coverage detected