BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/bklit-ui/chart-context

Chart Context

bklit-ui/chart-context
FreeComponent

Shared context and hooks for Bklit chart components

Install it

npx shadcn@latest add https://bklit.com/r/chart-context.json

Source

src/charts/chart-context.tsxbklit.com/r/chart-context.json · first 6 KB
1"use client";
2
3import type { scaleBand, scaleLinear, scaleTime } from "@visx/scale";
4
5type ScaleLinear<Output, _Input = number> = ReturnType<
6 typeof scaleLinear<Output>
7>;
8type ScaleTime<Output, _Input = Date | number> = ReturnType<
9 typeof scaleTime<Output>
10>;
11type ScaleBand<Domain extends { toString(): string }> = ReturnType<
12 typeof scaleBand<Domain>
13>;
14
15import type { Transition } from "motion/react";
16import {
17 createContext,
18 type Dispatch,
19 type ReactNode,
20 type RefObject,
21 type SetStateAction,
22 useContext,
23 useMemo,
24} from "react";
25import type { ChartPhase, ChartStatus } from "./chart-phase";
26import type { ReferenceAreaConfig } from "./reference-area-config";
27import type { ChartSelection } from "./use-chart-interaction";
28import { DEFAULT_Y_AXIS_ID } from "./y-axis-scales";
29import type { YDomain } from "./y-domain-utils";
30
31// CSS variable references for theming
32export const chartCssVars = {
33 background: "var(--chart-background)",
34 foreground: "var(--chart-foreground)",
35 foregroundMuted: "var(--chart-foreground-muted)",
36 label: "var(--chart-label)",
37 linePrimary: "var(--chart-line-primary)",
38 lineSecondary: "var(--chart-line-secondary)",
39 crosshair: "var(--chart-crosshair)",
40 grid: "var(--chart-grid)",
41 indicatorColor: "var(--chart-indicator-color)",
42 indicatorSecondaryColor: "var(--chart-indicator-secondary-color)",
43 markerBackground: "var(--chart-marker-background)",
44 markerBorder: "var(--chart-marker-border)",
45 markerForeground: "var(--chart-marker-foreground)",
46 badgeBackground: "var(--chart-marker-badge-background)",
47 badgeForeground: "var(--chart-marker-badge-foreground)",
48 segmentBackground: "var(--chart-segment-background)",
49 segmentLine: "var(--chart-segment-line)",
50 brushBorder: "var(--chart-brush-border)",
51 tooltipBackground: "var(--chart-tooltip-background)",
52};
53
54/** Default scatter series colors from the chart palette (`--chart-1` … `--chart-5`). */
55export const defaultScatterColors = [
56 "var(--chart-1)",
57 "var(--chart-2)",
58 "var(--chart-3)",
59 "var(--chart-4)",
60 "var(--chart-5)",
61] as const;
62
63export interface Margin {
64 top: number;
65 right: number;
66 bottom: number;
67 left: number;
68}
69
70export interface TooltipData {
71 /** The data point being hovered */
72 point: Record<string, unknown>;
73 /** Index in the data array */
74 index: number;
75 /** X position in pixels (relative to chart area) */
76 x: number;
77 /** Y positions for each line, keyed by dataKey */
78 yPositions: Record<string, number>;
79// … truncated

What it pulls in

npm packages

  • @visx/event@4.0.1-alpha.0
  • @visx/responsive@4.0.1-alpha.0
  • @visx/scale@4.0.1-alpha.0
  • d3-array
  • motion

Other registry items

  • @bklit/utils
  • @bklit/chart-utils

Files it writes

  • src/charts/chart-context.tsx
  • src/charts/reference-area-config.ts
  • src/charts/use-chart-interaction.ts
  • src/charts/y-axis-scales.ts
  • src/charts/y-axis-ticks.ts
  • src/charts/chart-phase.ts
  • src/charts/y-domain-utils.ts
  • src/charts/filter-data-by-x-domain.ts
  • src/charts/generate-chart-skeleton-data.ts
  • src/charts/use-animated-y-domains.ts
  • src/charts/use-chart-phase-orchestrator.ts
  • src/charts/line-loading-timing.ts

Facts

Registry
bklit-ui
Type
registry:component
Access
Free
Files written
12
Theme wiring
ships cssVars
Licence
MIT
First indexed
2026-08-04
Last confirmed
today

Go to the source

bklit.com bklit/bklit-ui on GitHub Raw registry item This item as JSON

More from bklit-ui

All 56 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Area Chartarea-chartbklit-uiComponentsFree4 deps · 14 files
Chart Backgroundbackgroundbklit-uiComponentsFree2 deps · 3 files
Bar Chartbar-chartbklit-uiComponentsFree4 deps · 13 files
Bar Depthbar-depthbklit-uiComponentsFree1 dep
Candlestick Chartcandlestick-chartbklit-uiComponentsFree4 deps · 4 files
Chart Animationchart-animationbklit-uiComponentsFree1 dep · 7 files
Chart Series Layerchart-seriesbklit-uiComponentsFree3 deps · 15 files
Chart Stat Flowchart-stat-flowbklit-uiComponentsFree2 deps
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex