【问题标题】:Highcharts Line Chart does not fit data into all of categoriesHighcharts折线图不适合所有类别的数据
【发布时间】:2017-09-05 01:10:04
【问题描述】:

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 Example

我正在努力实现的图像示例Image Link

【问题讨论】:

    标签: highcharts angular2-highcharts


    【解决方案1】:

    发生这种情况,因为在您的情况下,类别数组中定义的类别有更多点,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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-19
      • 2018-05-04
      • 2023-03-08
      • 1970-01-01
      相关资源
      最近更新 更多