【问题标题】:Highcharts: are multiple legends possible?Highcharts:可能有多个传说吗?
【发布时间】:2013-04-27 17:24:05
【问题描述】:

我是 Highcharts 的新手,到目前为止它看起来很棒。但是,我需要在图例中将我的六个系列分成三列。这可以通过限制图例宽度和使用legendIndex 来实现。在 Coffeescript 中配置这个的 sn-p:

  legend:
    # 3 items side-by-side with some margins
    itemWidth: Math.floor(config.width / 3.8)
  series: [
      # top left
      legendIndex: 1
      ...
    ,
      # bottom left
      legendIndex: 4
      ...
    ...  # 4 more series; other columns in indices 2,5 and 3,6
    ]

问题是,我还需要为每个组设置一个单独的标题。所以像这样(ascii 艺术):

Title A               Title B                 Title C
[ ] Item A1           [ ] Item B1             [ ] Item C1
[ ] Item A2           [ ] Item B2             [ ] Item C2

请注意,我也需要导出功能,因此据我所知,HTML 定位是不可能的。我怎样才能让我的图例看起来像这样?

【问题讨论】:

  • 事实证明我绝对需要多个图例——有标题的组是不够的。
  • 您是否尝试过使用 labelFormatter 和 insdie 函数计算何时应添加“标题”? api.highcharts.com/highcharts#legend.labelFormatter
  • @SebastianBochan 感谢您的意见!我想到了这一点,但如果我用useHTML 定位标题,导出就会变得混乱。
  • 非正常导出的图表不使用 html / css 样式。
  • 这个问题和stackoverflow.com/questions/17833248/…类似,但是那里的答案也是“不可能的”

标签: highcharts legend


【解决方案1】:

您可以使用 Highcharts 渲染器在图表上放置自定义文本

http://api.highcharts.com/highcharts#Renderer

你不能制作多个图例,但你可以用一个图例做很多事情,让它看起来像多个图例。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-05-18
    • 2018-02-22
    • 1970-01-01
    • 1970-01-01
    • 2013-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多