Control axes: NVD3 chart in rCharts

I use the rCharts nPlot() function to display grouped or grouped histograms, data like contingency table data. "MultiBarChart" is displayed in a brilliant application. Below is a snippet of code that I use in my brilliant application.

  graphData <- reactive({ as.data.frame(table(eval(inputVar1()),eval(inputVar2()))) }) output$myChart <- renderChart({ p1 <- nPlot(Freq ~ Var1, group="Var2", data=graphData(), type="multiBarChart") p1$addParams(dom='myChart') return(p1) }) 

In my dataset, one categorical variable has 16 levels. When this variable is displayed along the x axis of "multiBarChart", not all labels are displayed. Is there a way in nPlot to change the font size of axis labels? I think something like cex.axis=0.5 or cex.lab=0.5 or something like that.

Alternatively, is there a parameter like las= that would allow me to rotate the axis label 90 degrees and possibly have a cleaner graph where all labels of categorical variables are displayed along the x axis of the graph.

Any advice a group can provide is greatly appreciated !!

+7
r shiny rcharts
source share
1 answer

The answer to your question can be found here . The main idea is to set the reduceXTicks option to FALSE, as well as sway the labels.

 n1 <- nPlot(value ~ region, data = dat, group = 'variable', type = 'multiBarChart') n1$chart(reduceXTicks = FALSE) n1$xAxis(staggerLabels = TRUE) 

If the labels are large, you can control the size of the text using CSS. At this point, you will have to manually paste this into your HTML, but in a future version of rCharts I will simplify adding arbitrary HTML / CSS / JS to your diagram directly from the R console.

 <style> svg text {font-size: 9px;} </style> 
+11
source share

All Articles