# achromatic interpolation in \`d3@7\`?

**URL:** <https://talk.observablehq.com/t/achromatic-interpolation-in-d3-7/10952>\
**Category:** Help\
**Created:** [November 1, 2026, 12:14am UTC](https://talk.observablehq.com/t/achromatic-interpolation-in-d3-7/10952 "2026-11-01T00:14:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![akrawitz](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/akrawitz/32/4375_2.png) [@akrawitz](https://talk.observablehq.com/u/akrawitz)\
**Post date:** [November 1, 2026, 12:14am UTC](https://talk.observablehq.com/t/achromatic-interpolation-in-d3-7/10952/1 "2026-11-01T00:14:11Z")

</div>

What is the recommended way to fix achromatic interpolation with the current version of `d3`?

The approach described here in the `d3` docs no longer works with the current version of `d3` (the version available by implicit import in Observable):

[https://observablehq.com/@d3/achromatic-interpolation](https://observablehq.com/@d3/achromatic-interpolation)

You can confirm this for yourself by looking at this notebook:

[https://observablehq.com/d/d94fe55f41a9f5df](https://observablehq.com/d/d94fe55f41a9f5df)

If you uncomment the explicit `d3@6` import, you can confirm that this used to work in `d3@6` but doesn’t anymore in current `d3@7`.

---

<div class="post-metadata">

**Author:** ![mbostock](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mbostock/32/9_2.png) [@mbostock](https://talk.observablehq.com/u/mbostock)\
**Post date:** [November 2, 2026, 8:33pm UTC](https://talk.observablehq.com/t/achromatic-interpolation-in-d3-7/10952/2 "2026-11-02T20:33:02Z")

</div>

This is a bug with how jsDelivr bundles D3.

jsDelivr captures the version of a dependency when a module is bundled. This means that you can end up with multiple versions of a dependency. When this happens, the module might not behave correctly (for example if it uses `instanceof`).

Here d3-interpolate 3.0.1 is loading d3-color 3.0.1, but d3 7.9.0 is loading the more recent d3-color 3.1.0. And hence the d3.hcl instance you pass into d3.interpolateHcl is not detected correctly, and hence is converted to sRGB, such that the chroma (`c`) channel becomes NaN instead of 0.

You can fix this by loading D3 from esm.sh instead of jsDelivr:

```auto
import * as d3 from "https://esm.sh/d3";

```

This problem is not unique to D3; it affects many libraries, including React. I didn’t realize until now that this was already affecting D3, so thank you for the report. I’ve done more analysis in this notebook:

[https://observablehq.com/@observablehq/tracing-imports-on-js-delivr](https://observablehq.com/@observablehq/tracing-imports-on-js-delivr)

I have an open PR to switch Observable to use esm.sh to fix this behavior:

> <https://github.com/observablehq/notebook-kit/pull/208>

---

<div class="post-metadata">

**Author:** ![akrawitz](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/akrawitz/32/4375_2.png) [@akrawitz](https://talk.observablehq.com/u/akrawitz)\
**Post date:** [November 3, 2026, 1:40am UTC](https://talk.observablehq.com/t/achromatic-interpolation-in-d3-7/10952/3 "2026-11-03T01:40:31Z")

</div>

Wow. Thank you for looking at this, taking the time to explain what is going on, and sharing the code that you used! I vaguely knew that I could end up with conflicting versions of a package via _external_ dependencies (i.e. `a` imports `d3@7.9.0` while `b` imports `d3@7.8.0`), but it had not occurred to me that this might occur via a package’s own _internal_ imports. That’s a subtle and nasty bug (in jsDelivr!).

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/observablehq/original/2X/8/8515fb2ace542ad82412d6c45906339e74f2053f.png) [@system](https://talk.observablehq.com/u/system)\
**Post date:** [November 5, 2026, 1:41am UTC](https://talk.observablehq.com/t/achromatic-interpolation-in-d3-7/10952/4 "2026-11-05T01:41:09Z")

</div>

Closed on November 5, 2026, 1:41am UTC

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
