最近在做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