2

I am using nPlot, my X-axis is Date variable, I want this to just Date as in my data 'YYYY-MM-DD', tilted vertically (90 degrees). I want nPlot show the chart stacked by default. Please help me out.

enter image description here

output$testChart = renderChart({
testChart = nPlot(Count~Date, data = df, group = 'Category', 
      type = 'multiBarChart')
testChart$chart(reduceXTicks = F)
testChart$xAxis(staggerLabels = T)
testChart$chart(stacked = T)
testChart$xAxis(tickFormat = "#! d3.time.format('%Y-%m-%d') !#")
return(testChart)
})

and in server.R

output$mytabs = renderUI({
  tabs = tabsetPanel(
         tabPanel('Tab1', h5("Tab1"), 
                  fluidRow(showOutput("testChart"))
                  )
         )


mainPanel(tabs)

})

in ui.R

uiOutput('mytabs')
BigDataScientist
  • 1,045
  • 5
  • 17
  • 37

1 Answers1

3

Suppose that you stored your plot in the object n1. Here is how you can customize it do what you seek.

n1$chart(stacked = TRUE)
n1$xAxis(
  tickFormat = "#! d3.time.format('%Y-%m-%d') !#",
  rotateLabels = 90
)
n1

I have no way to verify that this works. So I would suggest that you post your data and the code that you used to generate this plot. Doing so, even this works for you, would be useful as it would help others who come across this question.

Ramnath
  • 54,439
  • 16
  • 125
  • 152
  • It is not rendering in Shiny, giving LIB not found or unused argument "nvd3". Can I also title X-axis labels by 90 degrees. – BigDataScientist Jan 31 '14 at 21:30
  • Unless you post your code on what you tried, there is no way for any of us to provide you with a solution. – Ramnath Jan 31 '14 at 21:39
  • I have updated with my code. Can you also let me know how to tilt labels on x-axis. – BigDataScientist Jan 31 '14 at 21:50
  • `showOutput` takes two arguments. You need to pass the name of the library, `nvd3` as the second argument to `showOutput`. – Ramnath Jan 31 '14 at 21:54
  • Thanks!, that works. I have two more additional questions, can we specify width and height and tilt x-labels? The plot is not fully seen in the browser, only first half is visible. – BigDataScientist Jan 31 '14 at 21:57
  • Please post a fully reproducible example with the data needed to replicate the problem. You have posted code, but not the data. You will find useful pointers on how to create a reproducible example [here](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – Ramnath Jan 31 '14 at 22:02
  • I am sorry, I understood fluidRow() is creating shopping issues. Will post my code. Can you point me to any example which show how to use nPlot and other rHightcharts together in one tab using shiny, without overlapping and chopping off. – BigDataScientist Jan 31 '14 at 22:05
  • Please post a separate question. SO questions are intended to address a specific issue at hand. – Ramnath Jan 31 '14 at 23:53