使minPointLenght适用于堆叠柱形图中的所有块

时间:2019-10-23 10:38:30

标签: highcharts

我们使用minPointLength属性在堆叠的柱形图中显示值为0的点。问题是现在显示的点值为4(屏幕快照中从左数第三列)小于最小高度。在以下屏幕截图中,将鼠标悬停在值为4的非常小的块上,并以红色显示了具有0的块。

Chart with block smaller than minPointLength

我希望值大于0的块也大于值0或至少相同高度的块。

我们的总体目标是为所有块设置最小高度,以便可以显示所有框标签。

这里有个玩弄的小提琴:https://jsfiddle.net/ftmkxdbo/

这是图表的配置:

Highcharts.chart('container', {
  "chart": {
    "type": "column"
  },
  "title": {
    "text": ""
  },
  "credits": {
    "enabled": false
  },
  "xAxis": {
    "categories": ["10/17", "10/18", "10/19", "10/20"]
  },
  "yAxis": {
    "title": {
      "text": ""
    },
    "stackLabels": {
      "enabled": true,
      "style": {
        "color": "gray"
      }
    },
    "min": 0,
  },
  "legend": {
    "enabled": false
  },
  "plotOptions": {
    "column": {
      "stacking": "normal",
      "dataLabels": {
        "enabled": true,
        "style": {
          "fontSize": "10px",
          "fontWeight": "normal",
          "textShadow": "0px"
        },
      },
      "minPointLength": 5,
    }
  },
  "series": [{
    "name": "3",
    "data": [{
      "x": 0,
      "y": 3,
    }],
    "index": 0,
    "color": "rgba(120,185,40,0.8)"
  }, {
    "name": "12",
    "data": [{
      "x": 0,
      "y": 12,
    }],
    "index": 1,
    "color": "rgba(245,155,0,0.8)"
  }, {
    "name": "19",
    "data": [{
      "x": 0,
      "y": 19,
    }],
    "index": 2,
    "color": "rgba(120,185,40,0.8)"
  }, {
    "name": "13",
    "data": [{
      "x": 0,
      "y": 13,
    }],
    "index": 3,
    "color": "rgba(120,185,40,0.8)"
  }, {
    "name": "18",
    "data": [{
      "x": 1,
      "y": 18,
    }],
    "index": 0,
    "color": "rgba(120,185,40,0.8)"
  }, 
    // ...
  ]
});

1 个答案:

答案 0 :(得分:0)

这是一个非常有问题的问题。当前,这些列重叠,因为堆叠功能未考虑minPointLength选项。否则,该列的总值将不正确。

您可以在github上看到有关此问题的所有讨论:https://github.com/highcharts/highcharts/issues/1776