円グラフの描画でchart.jsを使用しています。
coffeeスクリプトで書いています。
rgbの色を[i]の配列ごとに違う色にし、コードにある(1)と(2)の値を同じにして
出力したいのですが、どのように、変更を加えればよろしいでしょうか?
よろしくお願いいたします。
window.draw_graph = -> ctx = document.getElementById("myChart").getContext('2d') colorNum = gon.data1.length bgColors = new Array(colorNum) bdColors = new Array(colorNum) for i in [0...colorNum] bgColors[i] = 'rgba(75, 192, 192, 0.2)' ←この色をi毎に変えたい(1) bdColors[i] = 'rgba(75, 192, 192, 1)' ←この色をi毎に変えたい(2) myPieChart = new Chart(ctx, { type: 'pie', data: { datasets: [{ data: gon.data1, backgroundColor: bgColors, borderColor: bdColors, }] labels: gon.data2, }, options: {} })
回答1件
あなたの回答
tips
プレビュー