简体   繁体   中英

Gauge gradient echarts4r in R

I'm needing to create a gauge graph in r , but I can't make the "axisLine" function in gradient colors.

library(echarts4r)
gauge_x <- e_charts() %>%
e_gauge(800, 
      "Incerteza TC",
      startAngle = 180,
      endAngle = 0,
      min = 0,
      max = 1000,
      splitNumber = 5,
      radius = "185",
      itemStyle = list(color = "#000000"),
      #axisLine = list(lineStyle = list(color = list(type = "radial", x = "0.5", y = "0.5", r = "0.5",
                                                    #backgroundColor = radial_gradient))),
      axisTick = list(lineStyle = list(width = 2, color = "#000000")),
      splitLine = list(lineStyle = list(color = "#000000", type = "solid")),
      axisLabel = list(show = TRUE, color = "#000000", fontWeight = "bold", borderRadius = 5),
      pointer = list(show = TRUE, icon = "triangle", length = "80%"), itemStyle = list(color = "black"),
      detail = list(show = TRUE, color = "#000000"),
      title = list(show = TRUE, fontWeight = "bolder"))
print(gauge_x)



      

As I am seeing in the documentation , you can not specify gradient color or any pattern fill for axisLine color in the gauge chart. You can only specify an array of colors for segments. As per the documentation,

The axis line of gauge chart can be divided to several segments in different colors. The end position and color of each segment can be expressed by an array.

So you can only color the axisLine by specifying a list of vectors containing the percentages and corresponding colors in the following way :

library(echarts4r)
library(magrittr)


e_charts() %>%
    e_gauge(
        800,
        "Incerteza TC",
        startAngle = 180,
        endAngle = 0,
        min = 0,
        max = 1000,
        splitNumber = 5,
        radius = "185",
        itemStyle = list(color = "#000000"),
        axisLine = list(lineStyle = list(
            color = list(c(0.33, "red"), c(0.67, "blue"), c(1, "green"))
        )),
        axisTick = list(lineStyle = list(width = 2, color = "#000000")),
        splitLine = list(lineStyle = list(color = "#000000", type = "solid")),
        axisLabel = list(
            show = TRUE,
            color = "#000000",
            fontWeight = "bold",
            borderRadius = 5
        ),
        pointer = list(show = TRUE, icon = "triangle", length = "80%"),
        itemStyle = list(color = "black"),
        detail = list(show = TRUE, color = "#000000"),
        title = list(show = TRUE, fontWeight = "bolder")
    )

带有 axsiLine 彩色的 echarts 仪表图

Hope this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM