Home / Function/ ChartTooltipAdvanced() — ui Function Reference

ChartTooltipAdvanced() — ui Function Reference

Architecture documentation for the ChartTooltipAdvanced() function in chart-tooltip-advanced.tsx from the ui codebase.

Entity Profile

Dependency Diagram

graph TD
  d87ad9d8_02f5_f55c_5aea_700e84eb9f9f["ChartTooltipAdvanced()"]
  d8952899_3ac7_2bdc_597c_b1a7e74ef468["chart-tooltip-advanced.tsx"]
  d87ad9d8_02f5_f55c_5aea_700e84eb9f9f -->|defined in| d8952899_3ac7_2bdc_597c_b1a7e74ef468
  style d87ad9d8_02f5_f55c_5aea_700e84eb9f9f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/v4/registry/new-york-v4/charts/chart-tooltip-advanced.tsx lines 41–123

export function ChartTooltipAdvanced() {
  return (
    <Card>
      <CardHeader>
        <CardTitle>Tooltip - Advanced</CardTitle>
        <CardDescription>
          Tooltip with custom formatter and total.
        </CardDescription>
      </CardHeader>
      <CardContent>
        <ChartContainer config={chartConfig}>
          <BarChart accessibilityLayer data={chartData}>
            <XAxis
              dataKey="date"
              tickLine={false}
              tickMargin={10}
              axisLine={false}
              tickFormatter={(value) => {
                return new Date(value).toLocaleDateString("en-US", {
                  weekday: "short",
                })
              }}
            />
            <Bar
              dataKey="running"
              stackId="a"
              fill="var(--color-running)"
              radius={[0, 0, 4, 4]}
            />
            <Bar
              dataKey="swimming"
              stackId="a"
              fill="var(--color-swimming)"
              radius={[4, 4, 0, 0]}
            />
            <ChartTooltip
              content={
                <ChartTooltipContent
                  hideLabel
                  className="w-[180px]"
                  formatter={(value, name, item, index) => (
                    <>
                      <div
                        className="h-2.5 w-2.5 shrink-0 rounded-[2px] bg-(--color-bg)"
                        style={
                          {
                            "--color-bg": `var(--color-${name})`,
                          } as React.CSSProperties
                        }
                      />
                      {chartConfig[name as keyof typeof chartConfig]?.label ||
                        name}
                      <div className="text-foreground ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums">
                        {value}
                        <span className="text-muted-foreground font-normal">
                          kcal
                        </span>
                      </div>
                      {/* Add this after the last item */}
                      {index === 1 && (
                        <div className="text-foreground mt-1.5 flex basis-full items-center border-t pt-1.5 text-xs font-medium">
                          Total
                          <div className="text-foreground ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums">
                            {item.payload.running + item.payload.swimming}
                            <span className="text-muted-foreground font-normal">
                              kcal
                            </span>
                          </div>
                        </div>
                      )}
                    </>
                  )}
                />
              }
              cursor={false}
              defaultIndex={1}
            />
          </BarChart>
        </ChartContainer>
      </CardContent>
    </Card>

Subdomains

Frequently Asked Questions

What does ChartTooltipAdvanced() do?
ChartTooltipAdvanced() is a function in the ui codebase, defined in apps/v4/registry/new-york-v4/charts/chart-tooltip-advanced.tsx.
Where is ChartTooltipAdvanced() defined?
ChartTooltipAdvanced() is defined in apps/v4/registry/new-york-v4/charts/chart-tooltip-advanced.tsx at line 41.

Analyze Your Own Codebase

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

Try Supermodel Free