Open jcheng5 opened 8 years ago
Yep, it will be messy.
Hmm. Yeah, this will be messy. Let us talk to figure out what we can potentially do.
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.
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?
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 codeCode follows the structure below:
class Chart {
constructor(opts) {
// stuff
}
setColor() {
// more stuff
}
setData() {
// even more stuff
}
}
@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.
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.
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.