@fundar/data-chart-telling

中文文档
1.20.0发布于 2026/11/12MITTypeScriptES Module构建来源已验证近 30 天下载 4510

Declarative charts, maps and small multiples for Svelte, built on svelteplot.

原始使用文档
文档目录6 节
  1. Introduction
  2. Install
  3. Stepping through time
  4. Documentation
  5. For LLMs and coding agents
  6. License
data-chart-telling-logo

npm GitHub release (latest by date) GitHub License CI Storybook CodeQL

Introduction

Svelte 5 plots for data storytelling, built on svelteplot. A plot is one graph - axes and marks - that carries its own title, legend, tooltip, facets and timeline, so a finished, readable figure is one component with a handful of props.

It aims for a sweet spot between the flexibility of d3, the declarative spirit of the grammar of graphics (data mapped to channels, scales and marks) and the convenience of a classic plotting library, where each plot kind is a first-class component.

<script lang="ts">
    import { LinePlot } from '@fundar/data-chart-telling';
    import { REGION_VALUES } from './datasets';
</script>

<!-- One line per region, with a title, the automatic legend, end-of-line values and a tooltip. -->
<LinePlot
    width={720}
    height={400}
    title="Monthly inflation by region (%)"
    data={REGION_VALUES}
    x="date"
    y="value"
    color="region"
    tooltip
    scales={{ x: { label: false } }}
    styles={{ values: { show: true } }}
/>

A line plot with a title, a legend, end-of-line value labels and a tooltip

Every Svelte snippet in this README is a runnable file in examples/, and the data comes from examples/datasets/.

Every plot kind shares one vocabulary: the same channels (x, y, color, grouping, opacity, symbol, r), the same scales, styles, segments, markers, transforms, tooltip, legend, timeline and facet props, and one global theme.

Install

pnpm add @fundar/data-chart-telling svelte svelteplot
# only for GeoPlot fed with TopoJSON
pnpm add topojson-client

The package ships Svelte components, so the app needs the Svelte compiler (@sveltejs/vite-plugin-svelte or SvelteKit). Types ship with it.

Stepping through time

timeline slices the rows by a field and steps through them. It draws as a player by default: play and pause, the current step and a slider, in the figure's chrome.

<script lang="ts">
    import { BarPlot } from '@fundar/data-chart-telling';
    import { REGION_VALUES } from './datasets';
</script>

<!--
    `timeline` slices the rows by `accessor`. A timeline is a player by default:
    play/pause, the current step and a slider in the chrome. `progress` sets where
    it starts. `type: 'rule'` draws a guide beside the plot with no controls
    instead (see TimelineRule). To build your own widget, read
    `useFigure().timeline` (seek, play, pause, next, ...).
-->
<BarPlot
    width={720}
    height={400}
    data={REGION_VALUES}
    x="region"
    y="value"
    scales={{ y: { domain: [0, 30] } }}
    timeline={{ accessor: 'date', progress: 0.25, player: { autoplay: false, loop: true } }}
/>

A bar plot with a player bar

type: 'rule' draws a rule beside the plot instead, a line with the steps written along it. The page drives it through progress (0 to 1), from a slider, scroll position or anything else.

<script lang="ts">
    import { LinePlot } from '@fundar/data-chart-telling';
    import { REGION_VALUES } from './datasets';

    // A rule has no controls of its own: the page moves it through `progress` (0 to 1).
    // One step per year; a line plot shows every row up to the current step.
    let progress = $state(0.5);
</script>

<input type="range" min="0" max="1" step="0.001" bind:value={progress} />
<LinePlot
    width={720}
    height={400}
    data={REGION_VALUES}
    x="date"
    y="value"
    color="region"
    timeline={{ accessor: (row) => row.date.getUTCFullYear(), type: 'rule', progress }}
/>

A line plot revealed up to the current step, with a timeline rule

See Timeline for both in detail.

Documentation

Start with the concepts; the rest is organised by what you want a plot to do.

TopicWhat it covers
Getting startedInstalling, a first plot, sizing a plot to its container, loading data
ConceptsPlots and figures, rows and series, channels, the props every plot shares
PlotsEvery plot kind: what it draws and what it needs
ScalesAxes (x, y) and channel scales (color, grouping, opacity, symbol, r, length)
Styles and segmentsValue labels in brief, frames, gap filling, and styling ranges of the data
Value labelsA plot's values on its shapes, and a marker's labels: layouts and their options
MarkersExtra marks on a plot: annotations, regions, hover highlights, custom components
Transforms and statisticsStacking, binning, smoothing, regression and the other data transforms
Tooltip and hoverFloating tooltips, in-plot highlights, syncing hover across plots
LegendThe automatic legend, toggling series, custom sections
TimelineStepping through the data by time, with a player bar (default) or a rule
ChromeTitle, subtitle, caption, header, footer, dividers and their order
FacetsSmall multiples: grids, carousels, pages
ComposerSeveral plots in one figure, with shared hover, legend and timeline
Reading plot stateusePlot and useFigure, to build custom UI around a plot
MapsGeoPlot: data, projections, choropleths, camera and map markers
ThemingThe global configuration, themes, locale and CSS variables
ArchitectureHow a plot is assembled, for contributors
DevelopmentBuilding, testing, Storybook and publishing

Working examples live in examples/; the online Storybook (or pnpm storybook locally) shows every option live.

For LLMs and coding agents

llms.txt is the index and llms-full.txt is a single-file guide with the rules that matter most. Both ship inside the npm package, next to the runnable examples/.

License

MIT. Keep the copyright notice and license text in copies of the code.

版本与发布记录

@fundar/data-chart-telling 共发布 87 个版本,首次发布于 2026/06/26;过去 12 个月发布了 87 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.20.0latest2026/11/123 天前
1.19.02026/11/114 天前
1.18.02026/11/106 天前
1.17.02026/11/079 天前
1.16.02026/11/0511 天前
1.15.02026/11/0511 天前

关于 @fundar/data-chart-telling 的常见问题

@fundar/data-chart-telling 是什么?

Declarative charts, maps and small multiples for Svelte, built on svelteplot.

如何安装 @fundar/data-chart-telling?

在项目目录运行 npm install @fundar/data-chart-telling,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:svelte(^5.0.0)、svelteplot(^0.14.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@fundar/data-chart-telling 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@fundar/data-chart-telling 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@fundar/data-chart-telling 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.19。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@fundar/data-chart-telling 可以商用吗?

@fundar/data-chart-telling 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@fundar/data-chart-telling 的下载量有多少?

根据 npm 官方下载统计,@fundar/data-chart-telling 在 2026/10/16 – 2026/11/14 这 30 天内被下载 4,510 次,日均约 150 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@fundar/data-chart-telling 还在维护吗?

最新版本 1.20.0 发布于 2026/11/12(3 天前);至今共发布 87 个版本,其中过去 12 个月发布了 87 个;首次发布于 2026/06/26。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。