Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use with ES6 (webpack/babel) #21

Open
ViggoV opened this issue Jul 17, 2017 · 4 comments
Open

Use with ES6 (webpack/babel) #21

ViggoV opened this issue Jul 17, 2017 · 4 comments
Assignees

Comments

@ViggoV
Copy link

ViggoV commented Jul 17, 2017

Hi there.

I can't seem to get this to work work in my simple webpack/babel setup, no matter what I do.
I've tried importing the following ways:

import 'd3-transform';
import d3Transform from 'd3-transform';
import * as d3Transform from 'd3-transform';
// and
var d3Transform = require('d3-transform');

But in all cases I get an Uncaught TypeError: [x] is not a function where [x] is whichever d3-transfom function I am trying to invoke. I have tried using both d3.transform() and d3Transform() but without any luck.

I'm sorry if I haven't provided enough detailed information, but at this point I am not quite sure where to begin.

Thanks on beforehand :)

@trinary trinary self-assigned this Jul 18, 2017
@trinary
Copy link
Owner

trinary commented Jul 18, 2017

I'll see if I can reproduce this, thanks for the heads up.

@moonthug
Copy link

moonthug commented Sep 20, 2017

You can use d3-transform like this:

import * as d3 from 'd3';
import { transform } from 'd3-transform';

let circles = svg.selectAll('circle')
  .attr('transform', transform()
    .translate(function(d) { return [20, d.size * 10] })
    .rotate(40)
    .scale(function(d) { return d.size + 2 }
  );

or as per the example styling

import * as d3 from 'd3';
import { transform } from 'd3-transform';

let circleTransform = transform()
    .translate(function(d) { return [20, d.size * 10] })
    .rotate(40)
    .scale(function(d) { return d.size + 2 });

let circles = svg.selectAll('circle')
  .attr('transform', circleTransform);

@trinary
Copy link
Owner

trinary commented Sep 20, 2017

Thanks for the help @moonthug, I dropped the ball on validating this. :)

@Munter
Copy link

Munter commented Nov 30, 2017

I'm trying import { transform } from 'd3-transform'; in my current webpack ksetup and all I get is undefined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants