2017-09-29 39 views
0

我正試圖在條形圖的x軸上垂直顯示標籤,以便將所有標籤貼到圖表上。我在另一個問題中讀到,要做到這一點的方法是將最大和最小旋轉設置爲90.即使我在選項中設置了最小/最大旋轉,標籤仍然以某個角度顯示......任何想法我都是錯過/在這裏做錯了?Angular2圖表(chart.js)即使設置了選項,標籤也不垂直

我的選擇代碼:

options:any = { 
    scaleShowVerticalLines: false, 
    scaleShowValues: true, 
    scales: { 
     yAxis: [{ 
      ticks: { 
       beginAtZero: true 
      } 
     }], 
     xAxis: [{ 
      stacked: false,   
      scaleLabel: { 
       labelString: 'Date' 
      }, 
      ticks: { 
       stepSize: 1, 
       min: 0, 
       maxRotation: 90, 
       minRotation: 90, 
       autoSkip: false 
      } 
     }] 
    }, 
    responsive: true 
}; 

我的條形圖的屏幕截圖:

https://imgur.com/a/xW8Lb

+0

你可以試着去除'scaleShowVerticalLines'並看看它做了什麼嗎? –

+0

@QuentinLaillé沒有改變任何東西...... – user2094257

+0

你能提供圖表的圖片嗎? –

回答

0

我看不出有什麼毛病你的選擇,除了屬性名xAxisyAxis,這些是不正確的。正確的屬性名稱是xAxesyAxes

此外,您不應該設置scaleShowVerticalLinesscaleShowValues屬性。這些已被棄用。

options: any = { 
    scales: { 
     yAxes: [{ 
     ticks: { 
      beginAtZero: true 
     } 
     }], 
     xAxes: [{ 
     stacked: false, 
     scaleLabel: { 
      labelString: 'Date' 
     }, 
     ticks: { 
      stepSize: 1, 
      min: 0, 
      maxRotation: 90, 
      minRotation: 90, 
      autoSkip: false 
     } 
     }] 
    }, 
    responsive: true 
}; 
相關問題