GithubHelp home page GithubHelp logo

Comments (4)

milahu avatar milahu commented on April 25, 2024 2

When the modules d3-selection and d3-transition are separately loaded (as opposed to using a pre-bundled d3 package), the mix-in might not work as intended

thanks!

i had this error (svelte repl) with the unnecessary

import { scaleLinear } from 'd3-scale';
import { extent } from 'd3-array';
import { select } from 'd3-selection';
import { zoom, zoomIdentity } from 'd3-zoom';
import { axisTop, axisRight } from 'd3-axis';

import * as d3Transition from 'd3-transition';

const d3 = Object.freeze({
  scaleLinear, extent, zoom, zoomIdentity, select, axisTop, axisRight, ...d3Transition,
});

and its solved with the simple

import * as d3 from 'd3';

tree-shaking is done anyway ...

from d3-axis.

tomwanzek avatar tomwanzek commented on April 25, 2024

My first quick guess would be, that it has to do with the way the d3-transition module extends the d3-selection module. The d3-transition module extends the prototype of the selection to mix-in the transition and interrupt methods, so they can be called on selections generated by .select(...) or .selectAll(...).

When the modules d3-selection and d3-transition are separately loaded (as opposed to using a pre-bundled d3 package), the mix-in might not work as intended, because the relevant extension code in d3-transition extension of selection prototype is not executed on the object loaded from d3-selection.

from d3-axis.

mbostock avatar mbostock commented on April 25, 2024

@tomwanzek Parts of your description are accurate, but there’s not the problem here; there is no issue loading d3-selection and d3-transition separately as long as you load d3-transition after its dependencies (including d3-selection). I’m investigating.

from d3-axis.

mbostock avatar mbostock commented on April 25, 2024

The problem is that the README linked to an old version of d3-interpolate (0.5) which doesn’t export d3.interpolateTransformSvg, so the interpolator was undefined. This is fixed by updating to the correct version of d3-interpolate (0.8), which does:

<script src="https://d3js.org/d3-array.v0.7.min.js"></script>
<script src="https://d3js.org/d3-collection.v0.2.min.js"></script>
<script src="https://d3js.org/d3-color.v0.4.min.js"></script>
<script src="https://d3js.org/d3-format.v0.5.min.js"></script>
<script src="https://d3js.org/d3-interpolate.v0.8.min.js"></script>
<script src="https://d3js.org/d3-time.v0.2.min.js"></script>
<script src="https://d3js.org/d3-time-format.v0.3.min.js"></script>
<script src="https://d3js.org/d3-scale.v0.7.min.js"></script>
<script src="https://d3js.org/d3-selection.v0.7.min.js"></script>
<script src="https://d3js.org/d3-dispatch.v0.4.min.js"></script>
<script src="https://d3js.org/d3-ease.v0.7.min.js"></script>
<script src="https://d3js.org/d3-timer.v0.4.min.js"></script>
<script src="https://d3js.org/d3-transition.v0.2.min.js"></script>
<script src="https://d3js.org/d3-axis.v0.3.min.js"></script>

(Also note that d3-collection was out-of-date.)

Alternatively, and more simply, you can load the default build of D3 4.0:

<script src="https://d3js.org/d3.v4.0.0-alpha.44.min.js"></script>

Here’s a working example:

http://bl.ocks.org/mbostock/1d96d9fdecf1b214f1395f94e0ba8758

from d3-axis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.