|
|
@ -76,6 +76,16 @@ |
|
|
<script src="{% static 'chart.min.js' %}"></script> |
|
|
<script src="{% static 'chart.min.js' %}"></script> |
|
|
<script> |
|
|
<script> |
|
|
var ctx = document.getElementById("myChart").getContext('2d'); |
|
|
var ctx = document.getElementById("myChart").getContext('2d'); |
|
|
|
|
|
baseColor = Math.round(Math.random()*255) + "," + Math.round(Math.random()*255) + "," + Math.round(Math.random()*255); |
|
|
|
|
|
console.log(baseColor) |
|
|
|
|
|
$.get("http://www.thecolorapi.com/scheme?rgb=" + baseColor + "&mode=analogic&count={{products | length}}", function( data ) { |
|
|
|
|
|
colors = data.colors |
|
|
|
|
|
console.log(colors) |
|
|
|
|
|
var bgColor = [] |
|
|
|
|
|
for(var i = 0; i < colors.length; i++){ |
|
|
|
|
|
color = colors[i] |
|
|
|
|
|
bgColor.push("rgb(" + color.rgb.r + "," + color.rgb.g + "," + color.rgb.b + ")") |
|
|
|
|
|
} |
|
|
var myChart = new Chart(ctx, { |
|
|
var myChart = new Chart(ctx, { |
|
|
type: 'pie', |
|
|
type: 'pie', |
|
|
data: { |
|
|
data: { |
|
|
@ -83,11 +93,7 @@ |
|
|
datasets: [{ |
|
|
datasets: [{ |
|
|
label: '# of Votes', |
|
|
label: '# of Votes', |
|
|
data: [{% for q in quantities %}{{q}}, {% endfor %}], |
|
|
data: [{% for q in quantities %}{{q}}, {% endfor %}], |
|
|
backgroundColor: [ |
|
|
backgroundColor: bgColor |
|
|
{% for q in products %} |
|
|
|
|
|
'rgb({% random_filter 0 255 %}, {% random_filter 0 255 %}, {% random_filter 0 255 %})', |
|
|
|
|
|
{% endfor %} |
|
|
|
|
|
], |
|
|
|
|
|
}] |
|
|
}] |
|
|
}, |
|
|
}, |
|
|
options: { |
|
|
options: { |
|
|
@ -100,6 +106,7 @@ |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
}, "json" ); |
|
|
</script> |
|
|
</script> |
|
|
</section> |
|
|
</section> |
|
|
</section> |
|
|
</section> |
|
|
|