最近在做POWER BI报表时用户需要显示如下的显示卡:
![]()
我在网上搜寻答案,未能发现解决方案,后来我只好用R视图控件解决了该问题:
将动态字段放入到R控件的 Values中。
代码如下:
# dataset <- data.frame(AXISName)
# dataset <- unique(dataset)
# Paste or type your script code here:
# Paste or type your script code here:
library(ggplot2)
library(RColorBrewer)
library(reshape2) #提供melt()函数
library(plyr) #提供ddply()函数,join()函数
library(scales) #引入percent
#按渠道,排名排序
dd <- ""
columnTest <- isTRUE(nrow(dataset)>0)
if(columnTest) {
df <- dataset[order(dataset$AXISName),]
dd = df
ggplot()+
scale_x_continuous(limits = c(0,0.2), expand = c(0, 0)) +
scale_y_continuous(limits = c(0,1), expand = c(0, 0)) +
#自定义填充颜色
scale_fill_manual(values= c( c

在创建Power BI报表时,遇到用户需求要使标题垂直显示。在找不到现成解决方案的情况下,通过集成R视图控件实现了这一功能。具体做法是将动态字段放入R控件的Values中,利用ggplot2、reshape2等库进行数据处理和绘图,并通过annotate()函数设置角度为90度以垂直显示文本。最终实现的效果可供其他开发者参考。
最低0.47元/天 解锁文章
1279

被折叠的 条评论
为什么被折叠?



