【问题标题】:HighChart And R weird Column chart breaksHighChart 和 R 奇怪的柱形图中断
【发布时间】:2022-01-09 12:22:30
【问题描述】:

我正在尝试找出如何消除图表中的这些中断: enter image description here

下面是生成该图表的 R 代码。感谢您的帮助。

hchart(dfDouble %>% filter(Year == 2021), "column", hcaes(x = Day, y = FC), name = "Current FC", showInLegend = TRUE) %>%
  hc_add_series(dfDouble %>% filter(Year == 2020), "column", hcaes(x = Day, y = FC), name = "Prev FC", showInLegend = TRUE) %>%
  hc_title(text = "Revenue YTD")

【问题讨论】:

  • 提供一些数据以便获得good reproducible example 是最有帮助的。您可以使用dput(dfDouble) 执行此操作,然后将结果粘贴到您的问题中。

标签: r highcharts shiny


【解决方案1】:

是的,您可以设置borderWidth,这应该可以解决问题: https://api.highcharts.com/highcharts/plotOptions.column.borderWidth

R 中的代码:

library('highcharter')
highchart() %>%
  hc_chart(type = "column") %>% 
  hc_series(
    list(data=list(5, 4, 3, 5)),
    list(data=list(5, 4, 3, 5))
  ) %>% 
  hc_plotOptions(column = list(
    stacking = "normal",
    borderWidth = 0
    )
  ) 

【讨论】:

    【解决方案2】:

    plotOptions.column.borderWidth 设置为 0 应该有助于消除堆叠列段之间的中断。

    根据文档: 每列或每条的边框宽度。当有边框空间时默认为 1,但当列太密集以至于边框会覆盖下一列时默认为 0。

       plotOptions: {
        column: {
          stacking: 'normal',
          borderWidth: 0,
        },
      },
    

    现场演示: https://jsfiddle.net/BlackLabel/1kut32c8/

    API 参考: https://api.highcharts.com/highcharts/plotOptions.column.borderWidth

    【讨论】:

    • 非常感谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多