d3rrc icon indicating copy to clipboard operation
d3rrc copied to clipboard

Could you provide even high level instructions on how to get this lib into a react project using webpack?

Open iDVB opened this issue 10 years ago • 4 comments

My project is using React and WebPack and I still have no idea how to get this to work.

In my jsx page I've tried..

var Charts = require('d3rrc');

and

var HBarChart = require('d3rrc').Charts.HBarChart;

and

var HBarChart = require('d3rrc').HBarChart;

I end up getting a ton of compile errors like this....

Module parse failed: /[MyDirRemoved]/node_modules/d3rrc/src/bar.jsx Line 179: Unexpected token <
You may need an appropriate loader to handle this file type.
|       'bar-chart': true
|     });
|     return <div className={classNames} />;
|   }
| });
 @ ./~/d3rrc/charts.js 3:13-37 4:13-37

iDVB avatar Sep 01 '15 20:09 iDVB

I also tried copying support.js and HBarChart.jsx into my own project and then requiring those....

var HBarChart = require('./../HBarChart/HBarChart.jsx');

It seems to compile fine but at runtime I get...

Uncaught TypeError: type.toUpperCase is not a function

seems to be coming from the autoGenerateWrapperClass()

iDVB avatar Sep 01 '15 21:09 iDVB

The first error is WebPack saying that it doesn't know how to deal with the JSX file. I haven't used WebPack before, and will be out of town for a few days, but when I get back I'll see if I can get it working with WebPack.

jdarling avatar Sep 03 '15 00:09 jdarling

Actually, wasn't that bad to get a working example. Check https://github.com/jdarling/d3rrc/tree/master/examples/webpack

Its commited but I didn't version since it doesn't impact the library.

To run it switch to the examples/webpack folder then:

../../node_modules/.bin/webpack-dev-server --progress --colors --port 8080

And open http://localhost:8080/

You will see the Donut chart example.

jdarling avatar Sep 03 '15 00:09 jdarling

Will add something to the documentation about how to do this.

jdarling avatar Sep 03 '15 00:09 jdarling