Highcharts x轴分组显示

原创
2018/08/10 17:00
阅读数 2K
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://blacklabel.github.io/grouped_categories/grouped-categories.js"></script>

<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>

样式一: 

Highcharts.chart('container', {
  chart: {
    type: 'column'
  },
  title: {
    text: ''
  },
  credits: {
    enabled: false
  },
  xAxis: {
    plotBands: [{
      id: 'first-category',
      color: '#A9CDD9',
      from: -0.5,
      to: 2.5
    }, {
      id: 'second-category',
      color: '#A9D9BB',
      from: 2.5,
      to: 6.5
    }],
    categories: [{
      name: 'First',
      categories: ['One', 'Two', 'Three']
    }, {
      name: 'Second',
      categories: ['Four', 'Five', 'Six', 'Seven']
    }],
    labels: {
      rotation: 0
    }
  },
  yAxis: {
    title: {
      text: ''
    }
  },
  series: [{
    data: [10, 10, 10, 10, 10, 10, 10]
  }]
});

样式二:

        columnChart.chartConfig.xAxis.plotBands = [
            {
                from:0,
                to:3,
                borderColor:$rootScope.deepxray_app.color.danger,
                borderWidth:1,
                label:{
                    text:"区域1",
                }
            },
            {
                from:3.1,
                to:7,
                borderColor:$rootScope.deepxray_app.color.success,
                borderWidth:1,
                label:{
                    text:"区域1",
                }
            }
        ]

 

plotBands API:https://api.hcharts.cn/highcharts#xAxis.plotBands.borderWidth

展开阅读全文
加载中

作者的其它热门文章

打赏
0
0 收藏
分享
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部