2017-12-01 13 views
0

Chart.jsの折れ線グラフに「最後の試合で得点したゴールの時間」をプロットしたいと思います。chart.jsのデータを表すY軸だけを持つ方法

私はuserGoalTime配列を持っています。 [34, 80, 90] 私は相手のゴールタイムアレイを持っています。 [39, 42]

Y軸にはすべての分が含まれますが、X軸には何も付いていません。問題は、chart.jsがX軸上の何かを使って値を表現しなければならないと思うことです(それが意味をなさない場合)

Y軸だけを使ってチャート上の点をプロットする方法について、

未遂ソリューション:

let ctx = canvas.getContext('2d') 
    let lineChart = new Chart(ctx, { 
    type: 'line', 
    data: { 
     labels: ['0', '1'], // I DON'T WANT THE X AXES TO REPRESENT ANYTHING 
     datasets: [{ 
     label: 'For', 
     backgroundColor: '#85CE36', 
     fill: false, 
     showLine: showLine, // this is true 
     borderColor: '#85CE36', 
     data: userGoals // The array as described 
     }, { 
     label: 'Against', 
     backgroundColor: 'red', 
     fill: false, 
     showLine: showLine, // this is true 
     borderColor: 'red', 
     data: opponentGoals // The array as described 
     } 
     ] 
    }, 
    options: { 
     responsive: true, 
     title: { 
     display: true, 
     text: nameOfStat 
     }, 
     tooltips: { 
     mode: 'index', 
     intersect: false 
     }, 
     hover: { 
     mode: 'nearest', 
     intersect: true 
     }, 
     elements: { 
     point: { 
      pointStyle: style 
     } 
     }, 
     scales: { 
     xAxes: [{ 
      display: false // Not really what I am looking for... This just hides the X axes but that's it 
     }] 
     } 
    } 
    }) 

感謝。

答えて

0

この

new Chart(ctx, { 
    ... 
    options: 
    { 
     scales: 
     { 
      xAxes: [{ 
       display: false 
      }] 
     } 
    } 
}); 
に変更し、それを
関連する問題