2016-09-22 4 views
1

動作するChart.jsでいくつかのグラフィックを作成しました。しかし、極グラフィックとレーダーは機能しません。私は次のエラーを取得:「キャッチされない例外TypeErrorを:ヌルの 『長さ』プロパティを読み取ることができません」エラー:「キャッチされていないTypeError:nullのプロパティ 'length'を読み取れません」Chart.js

を私はエラーが来ることができる場所を私は理解していないcharjs 2.3.0

を使用しています。

<div class="col-lg-6 col-md-6"> 
    <canvas class="box box-warning" id="myChart4" width="400" height="400"></canvas> 
</div> 

<div class="col-lg-6 col-md-6"> 
    <canvas class="box box-warning" id="myChart5" width="400" height="400"></canvas> 
</div> 

////////////////////////////////////////////// 
// Chart Polar 
////////////////////////////////////////////// 

var ctx = document.getElementById("myChart4"); 

new Chart(ctx, { 
    type: 'polarArea', 
    data: { 
     labels: [ 
      "Red", 
      "Blue", 
      "Yellow" 
     ], 
     datasets: [{ 
      data: [300, 50, 100], 
      backgroundColor: [ 
       "#FF6384", 
       "#36A2EB", 
       "#FFCE56" 
      ], 
      hoverBackgroundColor: [ 
       "#FF6384", 
       "#36A2EB", 
       "#FFCE56" 
      ] 
     }] 
    }, 
    options: { 
     cutoutPercentage: 50, 
     animation: { 
      animateScale: false 
     } 
    } 
}); 

////////////////////////////////////////////// 
// Radar 
////////////////////////////////////////////// 

var ctx = document.getElementById("myChart5"); 


var scatterChart = new Chart(ctx, { 
    type: 'radar', 
    data: data = { 

     labels: ["Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi", "Dimanche", ], 
     datasets: [{ 
      label: 'the first dataset', 
      backgroundColor: 'rgba(255, 99, 132, 0.2)', 
      borderColor: 'rgba(255,99,132,1)', 
      data: [10, 34, 50, 34, 56, 65, 43] 
     }, { 
      label: 'the second dataset', 

      backgroundColor: 'rgba(54, 162, 235, 0.2)', 
      borderColor: 'rgba(54, 162, 235, 1)', 

      data: [54, 72, 100, 36, 76, 23, 21] 
     }] 
    }, 
    options: { 
     scales: { 
      xAxes: [{ 
       type: 'linear', 
       position: 'bottom' 
      }] 
     } 
    } 
}); 
+0

のID「sexe」との任意の要素を持っていません、それはうまく動作します。エラーはありません。あなたはそれがChart.jsの問題だと確信していますか? https://jsfiddle.net/vwh2zsn9/ – Littlee

+0

私のコードは良いですし、他の場所に問題があります。私のコードでjsbinを作った:https://jsbin.com/wehalay/1/edit?html,js,output – DenisMasot

答えて

4

問題は、この行です:

var ctx = document.getElementById('sexe'); 

あなたのコードでChart.jsの同じバージョンを試した後のページ

関連する問題