Show properly x labels with rCharts and dimplejs

怎甘沉沦 提交于 2019-12-12 11:51:14

问题


Hi I drew a graph with rCharts using the dimple javascript library, but I have some trouble with x labels which don't appear properly, I tried to use setBounds and setMargins without any success. Any help is welcome! Thx

# my data (I put all because with less data there's no problem : x labels appears horizontally)
structure(list(date = c("2014-01-01", "2014-01-02", "2014-01-03", 
"2014-01-04", "2014-01-05", "2014-01-06", "2014-01-07", "2014-01-08", 
"2014-01-09", "2014-01-10", "2014-01-11", "2014-01-12", "2014-01-13", 
"2014-01-14", "2014-01-15", "2014-01-16", "2014-01-17", "2014-01-18", 
"2014-01-19", "2014-01-20", "2014-01-21", "2014-01-22", "2014-01-23", 
"2014-01-24", "2014-01-25", "2014-01-26", "2014-01-27", "2014-01-28", 
"2014-01-29", "2014-01-30"), value = c(198L, 391L, 353L, 176L, 
143L, 544L, 497L, 553L, 572L, 492L, 165L, 179L, 452L, 687L, 578L, 
561L, 529L, 182L, 191L, 494L, 515L, 592L, 576L, 598L, 203L, 199L, 
577L, 586L, 588L, 345L), date2 = c("mer. 01", "jeu. 02", "ven. 03", 
"sam. 04", "dim. 05", "lun. 06", "mar. 07", "mer. 08", "jeu. 09", 
"ven. 10", "sam. 11", "dim. 12", "lun. 13", "mar. 14", "mer. 15", 
"jeu. 16", "ven. 17", "sam. 18", "dim. 19", "lun. 20", "mar. 21", 
"mer. 22", "jeu. 23", "ven. 24", "sam. 25", "dim. 26", "lun. 27", 
"mar. 28", "mer. 29", "jeu. 30")), .Names = c("date", "value", 
"date2"), row.names = c(NA, -30L), class = "data.frame")

# the graph
library(rCharts)
d1 <- dPlot(
  value ~ date2,
  data = x, 
  type = 'line'
)
d1$xAxis(orderRule="date")
d1

回答1:


Solved !

d1 <- dPlot(
  value ~ date2,
  data = x, 
  type = 'line',
  # Add bounds here
  bounds = list(x=70,y=10,height=320,width=500)
)
d1$xAxis(orderRule="date")
d1


来源:https://stackoverflow.com/questions/22045397/show-properly-x-labels-with-rcharts-and-dimplejs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!