2017-09-01 69 views
0

Highcharts似乎創建不在類別內的數字。有沒有辦法自動調整數據以適應類別。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

回答

0

它發生,因爲在你的情況下,你必須在規定的類別的詳細點類別數組和pointInterval等於1.例如,您可以將xAxis類型更改爲'datetime'並設置不同的pointInterval(例如6個月),但這取決於您h你安排你的數據。

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