0

Highcharts 似乎创建了不在类别内的数字。有没有办法自动调整数据以适应类别。

this.options = {
            chart: {
            type: 'line'
    },
    title: {
        text: 'Line Test Chart'
    },
    subtitle: {
        text: ''
    },
    xAxis: {
        categories: [2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017],
        crosshair: true
    },
    yAxis: {
      stackLabels: { enabled: true}
    },
    tooltip: {
             headerFormat: '<b>{point.x}</b><br/>',
             pointFormat: '{series.name}: {point.y}'
            },
    plotOptions: {
        column: {
          stacking: 'normal',
           grouping: false,
          dataLabels: {enabled: true},
            pointPadding: 0.2,
            borderWidth: 0
        }
    },
    series: [{
        name: 'Construction--Spending Non-Residential',
        data: [100, 99, 98, 99, 99, 100, 99, 97, 98, 99, 100, 99, 97, 99, 98, 99]
            },{
        name: 'Construction--Spending Residential',
        data: [100, 98, 99, 97, 96, 98, 100, 97, 98, 96, 98, 97, 98, 100, 98, 97]
            }]
        };
    }
    options: Object;

请参阅: Plunker 示例

我想要实现的图像示例图像链接

4

1 回答 1

0

发生这种情况,因为在您的情况下,您有更多的点,类别数组中定义的类别pointInterval等于 1。例如,您可以将 xAxis 类型更改为“日期时间”并设置不同的pointInterval(例如 6 个月),但这取决于您如何安排您的数据。

API 参考: http: //api.highcharts.com/highcharts/xAxis.type
http://api.highcharts.com/highcharts/plotOptions.series.pointStart
http://api.highcharts.com/highcharts/plotOptions.series
.pointInterval

示例:
https ://plnkr.co/edit/KBDyCQsEPXNc3GUtUukr?p=preview

于 2017-09-04T17:10:04.157 回答