8

我使用 highcharts 创建了一个基本的箱线图,当我将鼠标悬停在箱线图上时,它会显示最大值、最大四分位数、中位数、最小四分位数和最小值。我想以某种方式在每条线旁边的绘图本身中显示这些值。

我检查了 api,发现“dataLabel”会有所帮助,但箱线图不支持。有人可以启发我如何实现这一目标吗?

谢谢。

4

3 回答 3

2

添加另一个数据系列,这是一种“分散”类型,并使用标记将数据标签应用于该系列。诀窍是使用与背景颜色相同的填充颜色和 0 线宽,这样标记将不可见,只会显示标签。

{
        name: 'Outlier',
        color: 'white',
        type: 'scatter',
        data: [ // x, y positions where 0 is the first category
            {
                name: 'This is my label for the box',
                x:0,   //box index.  first one is 0.
                y:975 //it will be bigger than the maximum value of of the box
            }
        ],
        dataLabels : {
            align: 'left',
                enabled : true,
                formatter : function() {
                    return this.point.name;
                },
            y: 10,
            },
        marker: {
            fillColor: 'white',
            lineWidth: 0,
            lineColor: 'white'
        }
    }
于 2013-06-25T15:46:09.300 回答
2

不可能开箱即用,但正如 Steve Gu 所说,可以通过 scatter 实现。您甚至可以忽略格式化程序并一起禁用标记:

{
  series: [
    {
      type: 'scatter',
      tooltip: {
        enabled: false
      },
      dataLabels: {
        format: '{key}',
        enabled: true,
        y: 0,
      },
      data: [{ x: 0, y: 975, name: '975'}],
      marker: {
        enabled: false,
      }
    }
  ]
}

只需禁用标记并将格式设置为键。

于 2014-10-06T17:21:57.347 回答
0

不幸的是,不支持此选项,您只能使用渲染器在图表中添加自定义文本,但我知道它可能不是舒适的解决方案。http://api.highcharts.com/highcharts#Renderer.text()

显然,您可以在我们的用户语音系统http://highcharts.uservoice.com/中请求您的建议

于 2013-05-27T11:49:00.690 回答