Question

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')
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top