2017-08-10 14 views
0

y軸に日数(2,4,6,8,10 ..)、x軸にorg1、org2、org3のbarchartを表示します。デフォルトでは、y軸に10,20,30と表示されます。それをどう変えるか教えてください。primeng barchartのy軸ラベルを変更するには?

** component.ts **

this.chartdata = { 
      labels: ['Org1', 'Org2', 'Org3', 'Org4', 'Org5', 'Org6', 'Org7'], 
      datasets: [ 
       { 
        label: '< 7 days', 
        backgroundColor: '#9CCC65', 
        borderColor: '#7CB342', 
        data: [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22] 
       }, 
       { 
        label: '< 14 days', 
        backgroundColor: '#f4eb3d', 
        borderColor: '#f4eb3d', 
        data: [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21] 
       }, 
       { 
        label: '> 21 days', 
        backgroundColor: '#ef220b', 
        borderColor: '#ef220b', 
        data: [1, 3, 5, 7, 9,12, 14, 16, 18, 20, 22] 
       } 

      ] 
     } 

** HTMLページ**

<p-chart type="bar" [data]="chartdata"></p-chart> 

**あなたがチャートを指定する必要が出力**

enter image description here

答えて

1

オプション:

<p-chart type="bar" [data]="chartdata" [options]="chartOptions"></p-chart> 

、その後、あなたは、y軸はオプションで刻み変更することができます。

public chartOptions = { 
    scales: { 
    yAxes: [{ 
     ticks: { 
     stepSize: 2, 
     beginAtZero: true 
     } 
    }] 
    } 
} 
+0

Thanks.Itが働いていました。 – Jan69

関連する問題