TanStack Charts 是一个轻量级的 TypeScript 可视化语法,结合了 D3 的强大功能与图表库的易用性,适用于响应式、可访问且支持服务端渲染的应用图表,但当前仍处于私有早期验证阶段,不建议用于生产环境。

Stars

50

7 天增长

暂无数据

Fork 数

3

开放 Issue

1

开源协议

MIT

最近更新

2026-07-29

AI 仓库情报摘要
FR-AI / ANALYSIS

为什么值得关注

其独特的架构让 D3 在算法层面保持可见且可替换,同时提供一致的运行时和可摇树导入,支持在不替换数据模型的情况下创建自定义可视化。

适合谁使用

  • 需要 D3 级别灵活性的 React 开发者
  • 构建超越标准图表类型的定制化可视化的团队
  • 希望利用 D3 原生能力但减少样板代码的开发者
  • 评估服务端渲染或无障碍图表解决方案的工程师

典型使用场景

  • 使用原生 D3 比例尺构建响应式线图、柱状图、面积图和散点图
  • 通过场景协议实现自定义标记以创建独特可视化
  • 服务端渲染 SVG 图表并支持水合,实现快速首屏加载
  • 集成现有 D3 工作流的同时获得生命周期管理和无障碍功能

项目优势

  • 可摇树的入口点允许仅导入所需部分,减小打包体积
  • 框架无关的图表定义兼容 React、Octane、原生 DOM 和静态 SVG
  • 直接使用 D3 比例尺、曲线和布局,无需学习平行数学 API
  • 内置响应式布局、主题、交互、动画、无障碍和 SVG 服务端渲染等运行时特性

使用前须知

  • 目前为 0.0.0 版本,未在 npm 发布,不适用于生产
  • 需要熟悉 D3 比例尺和概念才能充分发挥库的能力
  • 文档和生态尚处于起步阶段,社区采用率较低

README 快速开始

TanStack Charts

D3's power. A chart library's ergonomics.

A tiny TypeScript visualization grammar for responsive, accessible, server-rendered application charts.

Quick look · Documentation · React example · Conformance catalog · Roadmap

[!IMPORTANT] TanStack Charts is currently a private 0.0.0 product proof. The packages are not published or ready for production use yet.

Most chart libraries are easy until the chart stops being standard. TanStack Charts gives you one typed grammar that can grow from a familiar line or bar chart into a product-specific visualization without replacing your data model or dropping down to a separate API.

  • Keep your data as it is. Marks consume arrays, objects, tuples, and iterables directly. Different layers can use different datum types.
  • Bring native D3 primitives. Use D3 scales, curves, transforms, and layout output instead of relearning a parallel math API.
  • Build from common to custom. Layer built-in marks or implement a custom mark against the same public scene protocol.
  • Get the application runtime too. Responsive layout, automatic guide margins, themes, interaction, animation, accessibility, SVG SSR, hydration, and export are part of the system.
  • Pay for what you import. Marks, renderers, interactions, and specialized D3 capabilities have independent, tree-shakeable entry points.

Quick look

import { max } from 'd3-array'
import { scaleBand, scaleLinear } from 'd3-scale'
import { barY, defineChart } from '@tanstack/charts'
import { Chart } from '@tanstack/react-charts'

const revenue = [
  { month: 'Jan', value: 42 },
  { month: 'Feb', value: 58 },
  { month: 'Mar', value: 76 },
  { month: 'Apr', value: 64 },
]

const revenueChart = defineChart({
  marks: [
    barY(revenue, {
      x: 'month',
      y: 'value',
    }),
  ],
  x: {
    scale: scaleBand()
      .domain(revenue.map((row) => row.month))
      .padding(0.2),
  },
  y: {
    scale: scaleLinear()
      .domain([0, max(revenue, (row) => row.value) ?? 0])
      .nice(),
    label: 'Revenue',
    grid: true,
  },
})

export function RevenueChart() {
  return (
    
  )
}

Marks consume the original rows, channels describe their visual encodings, and configured D3 scales own the domain and mapping. TanStack copies those scales, assigns their responsive pixel ranges, compiles a

项目描述

A tiny TypeScript visualization grammar for responsive, accessible, server-rendered charts—powered by granular D3 primitives.

相关仓库与替代方案

根据分类、Topic 和编程语言匹配的相似项目。

TanStack
精选
TanStack GitHub avatar

router

TanStack Router is a type-safe, data-driven React router with built-in caching, prefetching, and nested layouts, while TanStack Start extends it into a full-stack SSR framework.

Web 开发前端框架
14,861
talivia-group
精选
talivia-group GitHub avatar

talivia

Talivia is an open-source, self-hosted analytics platform that combines web analytics, session replay, and customer revenue tracking from multiple payment providers.

Web 开发数据与数据库
484
react
精选
react GitHub avatar

react

React is a JavaScript library for building user interfaces with declarative, component-based, and cross-platform design.

Web 开发前端框架
246,741