Highcharts:在箱线图中显示标签(最小值,最大值,中位数等)

时间:2013-05-27 05:32:17

标签: javascript highcharts

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

我检查了api,发现“dataLabel”会有所帮助,但是boxplot不支持。有人可以告诉我如何实现这个目标吗?

感谢。

3 个答案:

答案 0 :(得分:1)

添加另一个数据系列,这是一种“ Scatter ”,并使用Marker将数据标签应用于此系列。诀窍是使用与背景颜色相同的填充颜色和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'
        }
    }

答案 1 :(得分:1)

不可能开箱即用,但正如史蒂夫古所提到的那样,分散可以实现。您甚至可以忽略格式化程序并完全禁用标记:

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

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

答案 2 :(得分:0)

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

很明显,您可以在我们的用户语音系统http://highcharts.uservoice.com/

中查询您的建议