小编jeg*_*elu的帖子

如何在R highcharter包中设置dataLabel格式和轴标签角度

我正在尝试使用R highcharter包来创建条形图功能.代码如下.我请求帮助1 - 如何将dataLabels的格式更改为百分比?2 - 如何设置X轴标签显示角度.我想把它设置为45度

hcbar_categorycount_vertical <- function(data=x,var=y){
df <- data.frame(prop.table(table(data[var])))
names(df) <- c(var,'Proportion')
df$Proportion <- round(df$Proportion*100,2)
df <- df%>% arrange(-Proportion)
df[,1] <- as.character(df[,1])
df[,1] <- factor(df[,1], levels = df[,1])
df$Cumulative <- round(cumsum(df$Proportion),2)

highchart(debug = TRUE) %>%
hc_xAxis(categories=df[[1]]) %>%
hc_yAxis(labels = list(format = "{value}%"), max = 100) %>%
hc_add_series(name=var,data=df$Proportion,type = "column",dataLabels =       list(enabled = TRUE, format='{point.label}%'))
}
Run Code Online (Sandbox Code Playgroud)

我不确定dataLabel属性列表中"format"的语法应该是什么.上面的代码似乎不起作用.我已经提到了highcharter vignette和这个网站:http://jkunst.com/highcharter/highcharts-api.html#hc_xaxis-and-hc_yaxis

但找不到答案.我在这里先向您的帮助表示感谢.

r highcharts

4
推荐指数
2
解决办法
4848
查看次数

R DT表格顶部的水平滚动条

我的DT长而闪亮。默认情况下,我想在表格顶部显示水平滚动条。有没有办法做到这一点?我当前的DT定义如下所示:

DT::datatable(dt, rownames = FALSE,
                    filter = fbox,
                    style = "bootstrap",
                    options = list(
                      dom = dom,
                      scrollX = TRUE,
                      columnDefs = list(list(orderSequence = c('desc', 'asc'), targets = "_all")),
                      processing = FALSE,
                      pageLength = 500,
                      lengthMenu = list(c(500, 1000, 5000), c("500","1000","5000"))
                    ),
                    callback = DT::JS("$(window).unload(function() { table.state.clear(); })")
 ) %>% DT::formatStyle(., cn_cat,  color = "black", backgroundColor = "#dee6ea",fontWeight = "bold")
Run Code Online (Sandbox Code Playgroud)

提前致谢。

r shiny dt

4
推荐指数
1
解决办法
1219
查看次数

标签 统计

r ×2

dt ×1

highcharts ×1

shiny ×1