Home / File/ chart.tsx — ui Source File

chart.tsx — ui Source File

Architecture documentation for chart.tsx, a tsx file in the ui codebase. 3 imports, 0 dependents.

File tsx ComponentRegistry ChartRegistry 3 imports 6 functions

Entity Profile

Dependency Diagram

graph LR
  bca50faa_8d6b_703f_dfd2_c4cbfa71c486["chart.tsx"]
  1d141819_425e_b5fd_4c8e_32f7c6a42cf2["react"]
  bca50faa_8d6b_703f_dfd2_c4cbfa71c486 --> 1d141819_425e_b5fd_4c8e_32f7c6a42cf2
  da384753_eb23_55ed_e7a6_3bd0e172b999["recharts"]
  bca50faa_8d6b_703f_dfd2_c4cbfa71c486 --> da384753_eb23_55ed_e7a6_3bd0e172b999
  ef4051f4_aeb7_8d0c_a726_0ba96ad80cf6["utils"]
  bca50faa_8d6b_703f_dfd2_c4cbfa71c486 --> ef4051f4_aeb7_8d0c_a726_0ba96ad80cf6
  style bca50faa_8d6b_703f_dfd2_c4cbfa71c486 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"use client"

import * as React from "react"
import * as RechartsPrimitive from "recharts"

import { cn } from "@/registry/bases/radix/lib/utils"

// Format: { THEME_NAME: CSS_SELECTOR }
const THEMES = { light: "", dark: ".dark" } as const

export type ChartConfig = {
  [k in string]: {
    label?: React.ReactNode
    icon?: React.ComponentType
  } & (
    | { color?: string; theme?: never }
    | { color?: never; theme: Record<keyof typeof THEMES, string> }
  )
}

type ChartContextProps = {
  config: ChartConfig
}

const ChartContext = React.createContext<ChartContextProps | null>(null)

function useChart() {
  const context = React.useContext(ChartContext)

  if (!context) {
    throw new Error("useChart must be used within a <ChartContainer />")
  }

  return context
}

function ChartContainer({
  id,
  className,
  children,
  config,
  ...props
}: React.ComponentProps<"div"> & {
  config: ChartConfig
  children: React.ComponentProps<
    typeof RechartsPrimitive.ResponsiveContainer
  >["children"]
}) {
  const uniqueId = React.useId()
  const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`

  return (
    <ChartContext.Provider value={{ config }}>
      <div
        data-slot="chart"
        data-chart={chartId}
        className={cn(
          "cn-chart [&_.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-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 flex aspect-video justify-center text-xs [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
          className
        )}
// ... (294 more lines)

Subdomains

Dependencies

  • react
  • recharts
  • utils

Frequently Asked Questions

What does chart.tsx do?
chart.tsx is a source file in the ui codebase, written in tsx. It belongs to the ComponentRegistry domain, ChartRegistry subdomain.
What functions are defined in chart.tsx?
chart.tsx defines 6 function(s): ChartContainer, ChartLegendContent, ChartStyle, ChartTooltipContent, getPayloadConfigFromPayload, useChart.
What does chart.tsx depend on?
chart.tsx imports 3 module(s): react, recharts, utils.
Where is chart.tsx in the architecture?
chart.tsx is located at apps/v4/registry/bases/radix/ui/chart.tsx (domain: ComponentRegistry, subdomain: ChartRegistry, directory: apps/v4/registry/bases/radix/ui).

Analyze Your Own Codebase

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

Try Supermodel Free