Home / Function/ ChartVisitors() — ui Function Reference

ChartVisitors() — ui Function Reference

Architecture documentation for the ChartVisitors() function in chart-visitors.tsx from the ui codebase.

Entity Profile

Dependency Diagram

graph TD
  e8f32f5d_9a6f_3087_8d22_5699426ebf37["ChartVisitors()"]
  7ddb33f5_8070_8324_043c_155333f37aab["chart-visitors.tsx"]
  e8f32f5d_9a6f_3087_8d22_5699426ebf37 -->|defined in| 7ddb33f5_8070_8324_043c_155333f37aab
  style e8f32f5d_9a6f_3087_8d22_5699426ebf37 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/v4/app/(examples)/dashboard-03/components/chart-visitors.tsx lines 70–189

export function ChartVisitors() {
  const id = "pie-interactive"
  const [activeMonth, setActiveMonth] = React.useState(desktopData[0].month)

  const activeIndex = React.useMemo(
    () => desktopData.findIndex((item) => item.month === activeMonth),
    [activeMonth]
  )
  const months = React.useMemo(() => desktopData.map((item) => item.month), [])

  return (
    <Card data-chart={id}>
      <ChartStyle id={id} config={chartConfig} />
      <CardHeader>
        <CardDescription>January - June 2024</CardDescription>
        <CardTitle className="text-2xl font-bold">1,234 visitors</CardTitle>
        <CardAction>
          <Select value={activeMonth} onValueChange={setActiveMonth}>
            <SelectTrigger
              className="ml-auto h-8 w-[120px]"
              aria-label="Select a value"
            >
              <SelectValue placeholder="Select month" />
            </SelectTrigger>
            <SelectContent align="end">
              {months.map((key) => {
                const config = chartConfig[key as keyof typeof chartConfig]

                if (!config) {
                  return null
                }

                const color = "color" in config ? config.color : undefined

                return (
                  <SelectItem key={key} value={key}>
                    <div className="flex items-center gap-2 text-xs">
                      <span
                        className="flex h-3 w-3 shrink-0 rounded-sm"
                        style={{
                          backgroundColor: color,
                        }}
                      />
                      {config?.label}
                    </div>
                  </SelectItem>
                )
              })}
            </SelectContent>
          </Select>
        </CardAction>
      </CardHeader>
      <CardContent className="flex flex-1 justify-center pb-0">
        <ChartContainer
          id={id}
          config={chartConfig}
          className="mx-auto aspect-square w-full max-w-[300px]"
        >
          <PieChart>
            <ChartTooltip
              cursor={false}
              content={<ChartTooltipContent hideLabel />}
            />
            <Pie
              data={desktopData}
              dataKey="desktop"
              nameKey="month"
              innerRadius={60}
              strokeWidth={5}
              activeIndex={activeIndex}
              activeShape={({
                outerRadius = 0,
                ...props
              }: PieSectorDataItem) => (
                <g>
                  <Sector {...props} outerRadius={outerRadius + 10} />
                  <Sector
                    {...props}
                    outerRadius={outerRadius + 25}
                    innerRadius={outerRadius + 12}
                  />

Subdomains

Frequently Asked Questions

What does ChartVisitors() do?
ChartVisitors() is a function in the ui codebase, defined in apps/v4/app/(examples)/dashboard-03/components/chart-visitors.tsx.
Where is ChartVisitors() defined?
ChartVisitors() is defined in apps/v4/app/(examples)/dashboard-03/components/chart-visitors.tsx at line 70.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free