2017-03-22 16 views
1

私はこのコードを$(document).readyから呼び出される関数に入れました。問題は、私のウェブでは軸が見えるが、バーは表示されないということだ。キャンバスでの描画の問題

var chart = new CanvasJS.Chart("chartContainer", { 
    axisY: { 
     title: "percent", 
     gridThickness: 0 
    }, 
    legend: { 
     visible: false, 
    }, 
    toolTip: { 
     enabled: false, 
    }, 
    animationEnabled: true, 
    data: [], 
}); 
var data = []; 
percentGraph.forEach(function(el, i) { 
    var objeto1 = { 
     type: "stackedBar100", 
     showInLegend: false, 
     name: el.code, 
     dataPoints: [] 
    } 
    el.percents.forEach(function(el2, j) { 
     if (i === j) { 
      var objeto2 = { 
       y: el2.percent, 
       label: el2.name, 
       color: colores[el2.code] 
      } 
     } else { 
      var objeto2 = { 
       y: el2.percent, 
       label: el2.name, 
       color: 'white' 
      } 
     } 
     objeto1.dataPoints.push(objeto2); 
    }); 
    data.push(objeto1); 
}); 
chart.options.data = data; 
chart.render(); 

console.log(chart.options.data)で、私はこの結果を持っている:私は、問題が何であるかを知っているドント

dataPoints: Array[4] 
0: Object 
color: "white" 
label: "Direccion " 
x: 0 
y: "10" 
__proto__: Object 
1: Object 
color: "white" 
label: "Talento" 
x: 1 
y: "60" 
__proto__: Object 
2: Object 
color: "white" 
label: "Ingenieria" 
x: 2 
y: "15" 
__proto__: Object 
3: Object 
color: "rgb(45,204,205)" 
label: "Ingenieria" 
x: 3 
y: "15" 
__proto__: Object 
length: 4 
__proto__: Array[0] 
name: "04" 
showInLegend: false 
type: "stackedBar100" 

これは各chart.options.dataオブジェクト

答えて

0

のデータstrcutureで申し訳ありませんが、私はその問題を発見しましたel2.percentは文字列であり、canvasjsには数字が必要です。

関連する問題