2017-09-15 136 views
0

我想用一條線創建一個小圖。 當我第一次創建時,我沒有看到起點和終點之間的巨大差異。所以我試着將最小值設定爲最小值。而作爲我的yAxes最大值的最大價值。Chart.js的最大值和最小值的問題[折線圖]

這裏是我的代碼:

var generateNormalChart = function (dataForNormalGraph, randomColors, theLongNameOfTheCoin,currency,exchange,minVal,maxVal,stepsize) { 
    var ctx = document.getElementById('normalChartGraph' + theLongNameOfTheCoin + currency + exchange).getContext('2d'); 
    var normalChart = new Chart(ctx, { 
    type: 'line', 
    data: { 
     datasets: [{ 
      fill: false, 
      borderColor: randomColors, 
      data: dataForNormalGraph, 
      pointRadius: 1, 
      borderWidth: 2 
     }] 
    }, 
    options: { 
     legend: { 
      display: false 
     }, 
     scales: { 
      xAxes: [{ 
       display: false 

      }], 
      yAxes:[{ 
       display: false, 
       ticks: { 
        max: maxVal, 
        min: minVal 
        // stepSize: stepsize 
       } 
      }] 
     } 
    } 
}); 

};

數據的一個例子,我用:

這是MAXVAL:0.0000505

這是MINVAL:0.00005483

這是dataForNormalGraph:

0:0.00005162 
1:0.00005124 
2:0.0000505 
3:0.00005056 
4:0.00005089 
5:0.0000509 
6:0.00005102 
7:0.00005067 
8:0.00005087 
9:0.00005156 
10:0.00005173 
11:0.00005191 
12:0.00005363 
13:0.00005276 
14:0.00005309 
15:0.00005297 
16:0.00005231 
17:0.00005243 
18:0.00005252 
19:0.00005271 
20:0.00005326 
21:0.00005408 
22:0.00005483 
23:0.00005376 
24:0.00005365 

就像你所看到的我評論了步驟值。 我甚至與嘗試過通過計算((the max and min val)/25)之間的區別,那就是:1.7320000000000004e-7

我也不想看到的標籤和軸的價值,因爲它需要太多的空間。

我有2名照片的喜歡,你可以看到他忽略了最大值和最小值VAL:

A photo with the values on the yAxes

我想要什麼,但然後用正確的最大值和最小值

what I want but then with the right max and min values

回答

0

我忘了給yAxes值沒有產生一個好的圖表。 我需要做的唯一的事情是,增添

  labels: nameOfTheCoins, 

所以yAxes有一個值

相關問題