Search code examples
rrchartshtmlwidgetsnetworkd3

networkD3 conflict with rCharts


I have created a fairly large (multi-page) flexdashboard that includes different htmlwidgets (plotly, highcharts, leaflet, etc).

In order to avoid conflict between rCharts and other htmlwidgets, I included the javascript libraries mannually, excluding jQuery:

<link rel='stylesheet' href=C:/Users/stefanj/Documents/R/win-library/3.3/rCharts/libraries/nvd3/css/nv.d3.css>
  <link rel='stylesheet' href=C:/Users/stefanj/Documents/R/win-library/3.3/rCharts/libraries/nvd3/css/rNVD3.css>
  <script type='text/javascript' src=C:/Users/stefanj/Documents/R/win-library/3.3/rCharts/libraries/nvd3/js/d3.v3.min.js></script>
  <script type='text/javascript' src=C:/Users/stefanj/Documents/R/win-library/3.3/rCharts/libraries/nvd3/js/nv.d3.min-new.js></script>
  <script type='text/javascript' src=C:/Users/stefanj/Documents/R/win-library/3.3/rCharts/libraries/nvd3/js/fisheye.js></script> 

Also, I set the rChart chunk to:

```{r, echo=FALSE,results='asis', eval = TRUE, include_assets = FALSE}

However, when I plot a simpleNetwork, it does not render if the rCharts are included in the flexboard.

Any ideas?

P.S. not sure what else to include to make the question more reproducible.


Solution

  • networkD3 was updated to D3v4 in version 0.3 in. Feb. 2017, which is not compatible with v3 versions of D3, which is what rCharts appears to use. htmlwidgets, which is the underlying package that drives networkD3 and rCharts, only uses the most recent version of a dependency, so htmlwidgets that use conflicting versions of the same library can not both work. Check here for a starting point of discussion about this problem.

    You have a few possible options, though none of them are great...

    1. revert networkD3 to a version < 0.3 so that it also uses D3v3

    2. lobby for the rCharts developers to upgrade to D3v4

    3. lobby for the htmlwidgets` developers to come up with a robust way of dealing with conflicting JavaScript dependencies