0
votes

I've come to the realisation that all my attempts to set the width and height for my nvd3 chart (including adding my own css) are being sabotaged by some inline css:

<style>
.rChart {width: 800px; height: 400px}
</style>

What to do? I don't know where this is coming from or how to stop it from being output. Also, I can't think of any reasons why anybody would have set a fixed dimension for a plot in the first place...

UPDATE: I did not know there was a renderChart2() per comment below. I tried it as follows:

  output$testChart <- renderChart2({

    n1 <- nPlot(xxx~yyy, data = xyz, type = 'discreteBarChart')
    n1$xAxis(axisLabel = "Heading")
    #bug with nv.d3.js - without width, the ylabel is off the chart area and invisible?
    n1$yAxis(axisLabel = "label", width = 40)
    n1$set(title = "Title")
    n1$chart(width=1600, height=800, tooltipContent = "#! function(key, x, y, e){ 
  return 'x: ' + e.point.x+ '<br/>  y: ' + y 
} !#")
    n1$addParams(dom = 'testChart') #need this line, else it doesn't get rendered in dom!
    return(n1)

  })

And I got this in the html output (checked with firebug):

<div class="shiny-html-output rChart Nvd3 shiny-bound-output" id="testChart"><style>.rChart {width: 800px; height: 400px} </style>

<div class="rChart nvd3" id="testChart"></div>
<script type="text/javascript">
 $(document).ready(function(){
      drawtestChart()
    });
    function drawtestChart(){  
      var opts = {
 "dom": "testChart",
"width":    800,
"height":    400,
...(etc)...

Env:

> sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] markdown_0.7.4   knitr_1.8        rCharts_0.4.5    plyr_1.8.1       ggplot2_1.0.0   
[6] gplots_2.16.0    data.table_1.9.4 shiny_0.11      

And yes, I'm a bit out of my depth..

1
are you adding the raw css above directly into a shiny app?miles2know
No... this raw css is generated by some combination of r shiny and or r charts. It's not mine, I don't want it, and I don't know how to get rid of it or override it, lolrstruck
you should post your attempts to solve a problem in this forum. There are lot's of masterful folks on here that have been working on integrating the subjects in your title. Aside from that it seems to me that your a bit out of your depth, which is fine. Are you looking to develop a shiny app? Stating your goal is important and it is not at all clear.miles2know
I think this is better now. Take a look at these lines github.com/ramnathv/rCharts/blob/master/R/renderChart.R#L51-L60. Are you using the newest version? if so, do the 800px and 400px match the height and width you set for your chart?timelyportfolio

1 Answers

0
votes

Try changing:

n1$chart(width=1600, height=800, tooltipContent = "#! function(key, x, y, e)

to:

n1$set(width=1600, height=800, tooltipContent = "#! function(key, x, y, e)