Skip to content
Source
Sign inSign up
TanStack/charts

[Size] Time scale: no d3-free option, so time axes pull in about 10 KB gzip of d3 #206

Closedtoomingos(GitHub profile, opens in a new tab) opened this issue 1 comment

@tanstack/charts/scales/band, linear, ordinal and point are small and need no d3 (package.json:184-187). There is no time scale, so a time-series chart uses d3-scale scaleUtc. That brings d3-time, d3-time-format, d3-format, d3-color and d3-interpolate: about 28 KB min, 10 KB gzip (esbuild 0.28, minify, tree-shake).

For comparison, moving two of our charts from d3-scale scaleLinear to scales/linear saved about 7 KB gzip each.

Proposal

A scales/time (UTC) with the same contract as scales/linear: domain, range, copy, ticks, tickFormat, invert.

Checked against 57774e14a1a86081eddb3a23523724a40da05640 (v1.1.0).

  1. toomingos(GitHub profile, opens in a new tab) changed the title

  2. Thanks for the proposal, @toomingos. The opt-in UTC scale shipped in 1.3.0. You can import scaleUtc from @tanstack/charts/scales/time or @tanstack/charts-scales/time. It supports two-endpoint UTC date domains and has no D3 runtime dependency. Both packages are verified on npm. See #257 for the implementation and checks.

  3. tannerlinsley closed this

Sign in to join this conversation.