c3js / c3

:bar_chart: A D3-based reusable chart library
http://c3js.org
MIT License
9.35k stars 1.39k forks source link

Support isomorphic js apps #1074

Open jbraithwaite opened 9 years ago

jbraithwaite commented 9 years ago

There is a lot of reliance on window existing, which is not the case on the server.

If I submit a pull request, is this something you'd merge?

aendra-rininsland commented 9 years ago

@jbraithwaite I'm interested. How would you do that? I've just started investigating isomorphic JS apps (Particularly via Meteor) but am a bit clueless about the ins and outs of them.

jbraithwaite commented 9 years ago

I don't plan on supporting rendering of the graphs on the server (at least not initially). I want to be able to require('c3') in my app without throwing errors.

I haven't tried Meteor but if you are willing to give React a whirl, you can download my react boilerplate and try requiring c3 in home.jsx to see where this library fails. Here are the steps.

$ git clone git@github.com:jbraithwaite/react-boilerplate.git
$ cd react-boilerplate/
$ npm install
$ npm install --save c3
$ vi app/routes/home.jsx

Add

var c3 = require('c3');

Back in terminal

$ gulp
aendra-rininsland commented 9 years ago

@jbraithwaite Apols for the delay getting back to you! I've totally made a Meteor app in the meantime and am now trying your React boilerplate. If C3's wanting the window object, that probably means it doesn't really work in NodeJS either, which it should.

Edit: Just noticed that console.log is even prefaced with window., such as here. That really shouldn't be the case, because NodeJS uses console.log but doesn't have window.

aendra-rininsland commented 9 years ago

@jbraithwaite In terms of your initial suggestion — a PR would be very much appreciated. I'm wanting to do some React stuff fairly soon, and being able to use C3 with it would be the bee's knees. :smile: :+1: :shipit:

jbraithwaite commented 9 years ago

Awesome, I'll get started on this.

ekmartin commented 8 years ago

This would be really cool! https://github.com/Olical/react-faux-dom makes it possible to render D3 charts with React server-side - would be awesome to be able to do the same using c3.

maZahaca commented 7 years ago

Do you have any update with this issue?