【问题标题】:Highcharts : Display the labels (min, max, median etc.) in boxplotHighcharts:在箱线图中显示标签(最小值、最大值、中值等)
【发布时间】:2013-05-27 05:32:16
【问题描述】:

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

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

谢谢。

【问题讨论】:

    标签: javascript highcharts


    【解决方案1】:

    不可能开箱即用,但正如 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,
          }
        }
      ]
    }
    

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

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        【解决方案3】:

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

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

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2017-07-23
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2019-04-02
          • 1970-01-01
          相关资源
          最近更新 更多