简体   繁体   English

nPLot x轴日期变量和rCharts中的默认堆叠条形图

[英]nPLot x-axis Date variable and default stacked Bar plot in rCharts

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). 我正在使用nPlot,我的X轴是Date变量,我希望它像我的数据'YYYY-MM-DD'中那样只是Date,垂直倾斜(90度)。 I want nPlot show the chart stacked by default. 我希望nPlot显示默认情况下堆叠的图表。 Please help me out. 请帮帮我。

在此处输入图片说明

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 并在server.R中

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


mainPanel(tabs)

}) })

in ui.R 在ui

uiOutput('mytabs')

Suppose that you stored your plot in the object n1 . 假设您将图存储在对象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. 这样做,即使这对您也有用,因为它将帮助遇到此问题的其他人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM