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
  b01a5853_7a04_0011_7a8b_ab9fc567a8f0["chart.tsx"]
  1d141819_425e_b5fd_4c8e_32f7c6a42cf2["react"]
  b01a5853_7a04_0011_7a8b_ab9fc567a8f0 --> 1d141819_425e_b5fd_4c8e_32f7c6a42cf2
  da384753_eb23_55ed_e7a6_3bd0e172b999["recharts"]
  b01a5853_7a04_0011_7a8b_ab9fc567a8f0 --> da384753_eb23_55ed_e7a6_3bd0e172b999
  79081a1f_55a3_945a_fb8c_d53d6d3eab81["utils"]
  b01a5853_7a04_0011_7a8b_ab9fc567a8f0 --> 79081a1f_55a3_945a_fb8c_d53d6d3eab81
  style b01a5853_7a04_0011_7a8b_ab9fc567a8f0 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 "@/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
}

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

  return (
    <ChartContext.Provider value={{ config }}>
      <div
        data-chart={chartId}
        ref={ref}
        className={cn(
          "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-none [&_.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[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none",
          className
        )}
        {...props}
      >
        <ChartStyle id={chartId} config={config} />
// ... (310 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 deprecated/www/registry/default/ui/chart.tsx (domain: ComponentRegistry, subdomain: ChartRegistry, directory: deprecated/www/registry/default/ui).

Analyze Your Own Codebase

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

Try Supermodel Free