R级梯度echarts4r

发布于 2025-02-12 13:52:03 字数 1007 浏览 1 评论 0原文

我需要在r中创建量规图,但是我无法在渐变颜色中制作“轴线”功能。

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)



      

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)



      

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

等往事风中吹 2025-02-19 13:52:03

正如我在文档,,您不能指定梯度颜色或axisline颜色的任何图案填充。您只能为细分指定各种颜色。根据文档,

仪表图的轴线可以分为不同颜色的几个段。每个段的末端位置和颜色可以通过数组表示。

因此,您只能通过以下方式指定包含百分比和相应颜色的向量列表来为axisline上色:

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")
    )

“

希望这会有所帮助!

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")
    )

echarts gauge chart with axsiLine colored

Hope this helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文