mirror of
https://github.com/chartjs/Chart.js.git
synced 2024-10-06 20:29:12 +02:00
12e2ace039
Conflicts: src/Chart.Core.js Fixed the sample files & chart type initialize methods so that this.data does not get set to undefined.
77 lines
1.7 KiB
HTML
77 lines
1.7 KiB
HTML
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<title>Polar Area Chart</title>
|
|
<script src="../Chart.js"></script>
|
|
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
|
|
</head>
|
|
<body>
|
|
<div id="canvas-holder" style="width:30%">
|
|
<canvas id="chart-area" width="300" height="300"/>
|
|
</div>
|
|
<button id="randomizeData">Randomize Data</button>
|
|
|
|
|
|
<script>
|
|
|
|
var randomScalingFactor = function(){ return Math.round(Math.random()*100)};
|
|
var randomColorFactor = function(){ return Math.round(Math.random()*255)};
|
|
|
|
var polarData = [
|
|
{
|
|
value: randomScalingFactor(),
|
|
color:"#F7464A",
|
|
highlight: "#FF5A5E",
|
|
label: "Red"
|
|
},
|
|
{
|
|
value: randomScalingFactor(),
|
|
color: "#46BFBD",
|
|
highlight: "#5AD3D1",
|
|
label: "Green"
|
|
},
|
|
{
|
|
value: randomScalingFactor(),
|
|
color: "#FDB45C",
|
|
highlight: "#FFC870",
|
|
label: "Yellow"
|
|
},
|
|
{
|
|
value: randomScalingFactor(),
|
|
color: "#949FB1",
|
|
highlight: "#A8B3C5",
|
|
label: "Grey"
|
|
},
|
|
{
|
|
value: randomScalingFactor(),
|
|
color: "#4D5360",
|
|
highlight: "#616774",
|
|
label: "Dark Grey"
|
|
}
|
|
|
|
];
|
|
|
|
window.onload = function(){
|
|
var ctx = document.getElementById("chart-area").getContext("2d");
|
|
window.myPolarArea = new Chart(ctx).PolarArea({
|
|
data: polarData,
|
|
options: {
|
|
responsive:true
|
|
}
|
|
});
|
|
};
|
|
|
|
$('#randomizeData').click(function(){
|
|
$.each(polarData, function(i, piece){
|
|
polarData[i].value = randomScalingFactor();
|
|
polarData[i].color = 'rgba(' + randomColorFactor() + ',' + randomColorFactor() + ',' + randomColorFactor() + ',.7)';
|
|
});
|
|
window.myPolarArea.update();
|
|
});
|
|
|
|
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|