我正在创建一个闪亮的 R 仪表板,并创建了两个图表:
output$plotDefPriorBar <- renderPlotly({
ggplotly(
ggplot(data = dataDefPrior_barchart(), aes(x = TaskDate, y = DefectCount, fill = TaskPriority)) + theme(axis.ticks.x=element_blank(),axis.text.x=element_text(angle=90,hjust=1,size = rel(0.7)) ) +
geom_bar(stat = "identity") +
xlab("Date") + ylab("Total defects")
) })
output$plotDefPrior <- renderPlotly({
plot_ly(dataInteractivePlotDefPrior(),
values = counts,
labels = task_priority,
marker = list(colors = brewer.pal(12, "Set3")),
type = 'pie',
showlegend = TRUE) })
在哪里
dataDefPrior <- reactive({
data() %>%
select(-c(DefectType, TaskResolution)) %>%
dcast(EpicName ~ TaskPriority) %>%
arrange(EpicName) %>%
janitor::adorn_totals(which = c("row", "col")) %>%
arrange(desc(Total)) })
dataDefPrior_barchart <- reactive({
data() %>%
select(TaskCreateDate,TaskPriority) %>%
mutate(CreateDate = as.Date(TaskCreateDate)) %>%
mutate(TaskDate = format(as.Date(CreateDate),"%Y-%m"))%>%
select(-c(TaskCreateDate,CreateDate)) %>%
group_by(TaskDate,TaskPriority) %>%
summarize(DefectCount = n()) %>%
arrange(TaskDate) })
图表上的相同值(即不会修复)具有不同的颜色。 在此处输入图像描述
如何解决?图表上的颜色应保持一致。