title: sankey diagram with rCharts into shiny application. Color issue
body: <p>I am using rCharts to create a Sankey plot</p>
  
  <pre><code>library(networkD3)
  library(rCharts)
  source1 = c('Proizvodnja okroglega lesa', 'Uvoz okroglega lesa', 'Poraba okroglega lesa', 'Poraba okroglega lesa',
              'Zage','Zage','Zage', 'Zagan les','Uvoz zaganega lesa','Zagan les','Stanje','Stanje')
  target1=c('Poraba okroglega lesa','Poraba okroglega lesa', 'Izvoz okroglega lesa', 'Zage', 'Celuloza in plosce',
            'Energetska raba','Zagan les', 'Lesni ostanki','Stanje','Stanje',
            'Poraba zaganega lesa v Sloveniji', 'Izvoz zaganega lesa')
  value1 = c(2.765, 0.152, 1.372, 1.545, 0.340, 0.205, 1,0.350, 0.814, 0.650, 0.521, 0.943)
  
  links=data.frame(source1, target1, value1)
  colnames(links) &lt;- c("source", "target", "value")
  
  links$source &lt;- sapply(links$source, FUN = function(x) {return(as.character(nodes[x+1]))}) #x+1 since js starts at 0
  links$target &lt;- sapply(links$target, FUN = function(x) {return(nodes[x+1])}) #x+1 since js starts at 0
  sankeyPlot &lt;- rCharts$new()
  sankeyPlot$setLib('http://timelyportfolio.github.io/rCharts_d3_sankey')
  sankeyPlot$set(
    data = links,
    nodeWidth = 30,
    nodePadding = 80,
    layout = 100,
    width = 900,
    height = 500,
    units = "TWh",
    NodeGroup = links$group,
    title = "Sankey Diagram",
    fontSize = 1, 
    opacity = 0.9
  )
  
  sankeyPlot$setTemplate(
    afterScript = "
    &lt;script&gt;
    var cscale = d3.scale.category20b();
  
    // to be specific in case you have more than one chart
    d3.selectAll('#{{ chartId }} svg path.link')
    .style('stroke', function(d){
    //here we will use the source color
    //if you want target then sub target for source
    //or if you want something other than gray
    //supply a constant
    //or use a categorical scale or gradient
    //return d.source.color;
    return cscale(d.source.name);
    })
    //note no changes were made to opacity
    //to do uncomment below but will affect mouseover
    //so will need to define mouseover and mouseout
    //happy to show how to do this also
    // .style('stroke-opacity', .7)
    d3.selectAll('#{{ chartId }} svg .node rect')
    .style('fill', function(d){
    return cscale(d.name)
    })
    .style('stroke', 'none')
    &lt;/script&gt;
    ")
  sankeyPlot
  </code></pre>
  
  <p>Now, I would like to use the same plot to create a shiny application. This code should do the trick: </p>
  
  <pre><code>require(shiny)
  runApp(list(
    ui = pageWithSidebar(
      headerPanel('Test'),
      sidebarPanel(  'Test'  ),
      mainPanel(
        chartOutput("Plot", 'C:/Users/JernejJ/Documents/R/win-library/3.2/rCharts/widgets/d3_sankey')  
      )
    ),
    server = function(input, output, session){
  
      source1 = c('Proizvodnja okroglega lesa', 'Uvoz okroglega lesa', 'Poraba okroglega lesa', 'Poraba okroglega lesa',
                  'Zage','Zage','Zage', 'Zagan les','Uvoz zaganega lesa','Zagan les','Stanje','Stanje')
      target1=c('Poraba okroglega lesa','Poraba okroglega lesa', 'Izvoz okroglega lesa', 'Zage', 'Celuloza in plosce',
                'Energetska raba','Zagan les', 'Lesni ostanki','Stanje','Stanje',
                'Poraba zaganega lesa v Sloveniji', 'Izvoz zaganega lesa')
      value1 = c(2.765, 0.152, 1.372, 1.545, 0.340, 0.205, 1,0.350, 0.814, 0.650, 0.521, 0.943)
      group = c(1,1,1,1,1,1,1,1,1,1,1,1)
  
      links=data.frame(source1, target1, value1, group)
      colnames(links) &lt;- c("source", "target", "value", 'group')
      output$Plot &lt;-  renderChart2({
        sankeyPlot2 &lt;- rCharts$new()
        sankeyPlot2$setLib('C:/Users/JernejJ/Documents/R/win-library/3.2/rCharts/widgets/d3_sankey')
        sankeyPlot2$set(
          data = links,
          nodeWidth = 50,
          nodePadding = 80,
          layout = 100,
          width = 960,
          height = 500,
          units = "TWh",
          title = "Sankey Diagram"
        )
        sankeyPlot2$setTemplate(
          afterScript = "
    &lt;script&gt;
    var cscale = d3.scale.category20b();
  
    // to be specific in case you have more than one chart
    d3.selectAll('#{{ chartId }} svg path.link')
    .style('stroke', function(d){
    //here we will use the source color
    //if you want target then sub target for source
    //or if you want something other than gray
    //supply a constant
    //or use a categorical scale or gradient
    //return d.source.color;
    return cscale(d.source.name);
    })
    //note no changes were made to opacity
    //to do uncomment below but will affect mouseover
    //so will need to define mouseover and mouseout
    //happy to show how to do this also
    // .style('stroke-opacity', .7)
    d3.selectAll('#{{ chartId }} svg .node rect')
    .style('fill', function(d){
    return cscale(d.name)
    })
    .style('stroke', 'none')
    &lt;/script&gt;
    ")
        sankeyPlot2
      })
    }
  ))
  </code></pre>
  
  <p>Everything is OK, but colors defined in after script do not change. Where is the problem? </p>
  
  <p>Bellow is PrtScr of my current sankey application. Why do I get this strange letters d..ž? </p>
  
  <p><a href="https://i.stack.imgur.com/hTxfk.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hTxfk.jpg" alt="enter image description here"></a></p>