ramnathv / htmlwidgets

HTML Widgets for R
http://htmlwidgets.org
Other
792 stars 205 forks source link

d3 v4 #211

Open jcheng5 opened 8 years ago

jcheng5 commented 8 years ago

I just found out the just released d3 v4.0 isn't backward compatible with older versions of d3. I don't know how we can compose widgets that use both on the same page.

timelyportfolio commented 8 years ago

Yep, it will be messy.

ramnathv commented 8 years ago

Hmm. Yeah, this will be messy. Let us talk to figure out what we can potentially do.

ramnathv commented 8 years ago

So, I just realized that people developing on d3 v4.0 are more likely to use ES6 and build custom bundles of the d3 modules and their application code. If not, we can encourage them to do so. This way, the bundle will be standalone and will not pollute the namespace and hence these widgets can co-exist with d3 v3.0.

I have a widget built using d3 v4.0 that is close to completion and I can use that to test this.

mortonanalytics commented 6 years ago

I'm writing a reusable charting htmlwidget using d3.js v4 and ES6 standards.

class throws an error in the RStudio HTML viewer: SyntaxError: Use of reserved word 'class'. Should class be supported or do I need to refactor to ES5 constructors? Or is this an RStudio issue?

System details

setting value
version R version 3.4.3 (2017-11-30) system x86_64, mingw32
ui RStudio (1.1.383)
language (EN)
collate English_United States.1252
tz America/Denver
date 2018-01-25

htmlwidget JS code

Code follows the structure below:

class Chart {
    constructor(opts) {
        // stuff
    }
    setColor() {
        // more stuff
    }
    setData() {
        // even more stuff
    }
}
timelyportfolio commented 6 years ago

@mortonanalytics, this is a RStudio Viewer issue. I would recommend using babel to transpile. If you want to stay within R, then reactR has a babel_transform() function. Hope this helps.

jcheng5 commented 6 years ago

RStudio 1.2 should resolve this (the underlying browser engine will switch from an old WebKit fork to something Chromium based) but it's quite a few months away from being ready for release, much less the predominant version.