0

在此处输入图像描述

  output$col3<-renderPlotly({
    fig <- plot_ly(type = "indicator",mode = "gauge+number",value=VTE_cal(),height = 265,
      gauge = list(axis = list(range = list(NULL,100),tickwidth = 1, tickcolor = "black"),
        bar = list(color = "darkblue"),bgcolor = "white",borderwidth = 2,bordercolor = "gray",
        steps = list(list(range = c(0,20), color = "red"),list(range = c(20,40), color = "pink"),list(range = c(40,60), color = "yellow"),list(range = c(60,80), color = "gold"),list(range = c(80,100), color = "teal")),
        threshold = list(line = list(color = "black", width = 4),thickness = 0.75,value = VTE_cal())))
    fig <- fig %>%layout(margin = list(l=30,r=50),paper_bgcolor = "lavender",font = list(color = "black", family = "Arial"))
           # annotations=list(showarrow=T,arrowhead=3,arrowsize=1,arrowwidth=4))
    fig
  })
4

1 回答 1

2

您可以使用number参数指定前缀或后缀value; 这是一个示例(带有适当的缩进!)

plot_ly(
    type = "indicator",
    mode = "gauge+number",
    value = 86,
    number = list(suffix = "%"),    # <- Specify `prefix` or `suffix`
    gauge = list(
        axis = list(
            range = list(NULL,100),
            tickwidth = 1, 
            tickcolor = "black"),
        bar = list(color = "darkblue"),
        bgcolor = "white", 
        borderwidth = 2,
        bordercolor = "gray",
        steps = list(
            list(range = c(0,20), color = "red"),
            list(range = c(20,40), color = "pink"),
            list(range = c(40,60), color = "yellow"),
            list(range = c(60,80), color = "gold"),
            list(range = c(80,100), color = "teal")),
        threshold = list(
            line = list(color = "black", width = 4),
            thickness = 0.75,
            value = 86))) %>%
    layout(
        margin = list(l = 30, r = 50),
        paper_bgcolor = "lavender",
        font = list(color = "black", family = "Arial"))

在此处输入图像描述

于 2021-06-22T07:01:19.470 回答