Immutable scales.

Open
#121 3 comments 19 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
15/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript

Research direction

Start by reading the scale mutation APIs and their use in d3-axis, then inspect how ordinal scales infer domains when used. The issue proposes making scale methods return new scales and requiring explicit ordinal domains; done means those changes work together and scale behavior remains deterministic, but the issue names no files or tests to begin from.

Written by the indexing model from the issue text.

Description

What if scales were immutable, and all methods that currently mutate scales instead returned new scales? It would eliminate the need for scale.copy, simplify the logic in d3-axis, and generally make scales easier to understand.

It would require a change to the implicit domain behavior of ordinal scales: these scales mutate on use! It’s not too onerous to require you to initialize the scale’s domain, however, and that is already a strongly recommended pattern for deterministic behavior and generating keys.

Dominant language
JavaScript
Stars
1.6k
Forks
288
Avg merge
6h 41m
Merged PRs (30d)
1

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from d3/d3-scale

All issues in d3/d3-scale

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.