【问题标题】:Highcharts - Plotbands on a column chartHighcharts - 柱状图上的图带
【发布时间】:2019-03-01 06:42:47
【问题描述】:

我想在 x 轴区域( a 到 c )之间显示 plotband。我尝试了以下方法,但仍然没有检测到 plotband。

https://jsfiddle.net/pavanskipo/nsoaveph/7/

以下是示例 TS 代码:

Highcharts.chart('container', {
  chart: {
    type: 'column'
  },
  xAxis: {
    plotBands: [{
      to: 'a',
      color: "#FFAAAA",
      from: 'c'
    }],
    categories: ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m"],
    crosshair: true
  },
  yAxis: {
    min: 0,
  },
  tooltip: {
    headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
    pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
      '<td style="padding:0"><b>{point.y:.1f} mm</b></td></tr>',
    footerFormat: '</table>',
    shared: true,
    useHTML: true
  },
  plotOptions: {
    column: {
      pointPadding: 0.2,
      borderWidth: 0
    }
  },
  series: [{
    "color": "#8085e9",
    "data": [null, 1, 1, 2, 2, 2, 2, 3, 1, 1, 1, 1, 1],
    "name": "Linux"
  }, {
    "color": "#f15c80",
    "data": [1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, null, null],
    "name": "Others"
  }]
});

【问题讨论】:

    标签: angular highcharts


    【解决方案1】:

    您需要将fromto 属性设置为数值:

    xAxis: {
        plotBands: [{
            to: 2.5,
            color: "#FFAAAA",
            from: -0.5
    
        }],
        ...
    },
    

    现场演示:https://jsfiddle.net/BlackLabel/gmj8eq0u/

    API 参考:https://api.highcharts.com/highcharts/xAxis.plotBands.from

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-04-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多