gka / d3-jetpack

🚀 Nifty convenience wrappers that speed up your daily work with d3.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

modular support

davidsmorais opened this issue · comments

Hey, anyway I can just import the function I need ? In this case wordwrap ?
I've tried importing directly from the path, justl ike I do with d3's modules, but it gives me an error.

import scaleBand from 'd3-scale/src/band';
import scaleLinear from 'd3-scale/src/linear';
import { wordwrap } from 'd3-jetpack/src/wordwrap';
import { tspans } from 'd3-jetpack/src/tspans';

axisGroup.selectAll(...).text(...).tspans is not a function: Uncaught type error

As a workaround, I did this function

 function applyTSpans(elem, ...args) {
  return tspans.call(elem, ...args);
}
//then at a label, do text('') and:

applyTSpans(labels, d => wordwrap(formatValue(d, format), 5), 12)

Wait, but why is tspans not a function? I, also, using the bundled version of d3 and jetpack can't use tspans as described in the docs.