improve radar-skip-points sample

- set title
- set same size canvas as other samples
- remove user select from canvas
- remove html legend
This commit is contained in:
Ville Hämäläinen 2016-02-28 09:22:14 +02:00
parent 428567d8cf
commit c7845d124d

View File

@ -5,23 +5,24 @@
<title>Radar Chart</title> <title>Radar Chart</title>
<script src="../dist/Chart.bundle.js"></script> <script src="../dist/Chart.bundle.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<style>
canvas {
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
}
</style>
</head> </head>
<body> <body>
<div style="width:50%"> <div style="width:75%">
<canvas id="canvas" height="450" width="450"></canvas> <canvas id="canvas"></canvas>
</div> </div>
<button id="randomizeData">Randomize Data</button> <button id="randomizeData">Randomize Data</button>
<button id="addDataset">Add Dataset</button> <button id="addDataset">Add Dataset</button>
<button id="removeDataset">Remove Dataset</button> <button id="removeDataset">Remove Dataset</button>
<button id="addData">Add Data</button> <button id="addData">Add Data</button>
<button id="removeData">Remove Data</button> <button id="removeData">Remove Data</button>
<div>
<h3>Legend</h3>
<div id="legendContainer">
</div>
</div>
<script> <script>
var randomScalingFactor = function() { var randomScalingFactor = function() {
return Math.round(Math.random() * 100); return Math.round(Math.random() * 100);
@ -62,6 +63,10 @@
}] }]
}, },
options: { options: {
title:{
display:true,
text:"Chart.js Radar Chart - Skip Points"
},
elements: { elements: {
line: { line: {
tension: 0.0, tension: 0.0,
@ -74,15 +79,8 @@
} }
}; };
function updateLegend() {
$legendContainer = $('#legendContainer');
$legendContainer.empty();
$legendContainer.append(window.myRadar.generateLegend());
}
window.onload = function() { window.onload = function() {
window.myRadar = new Chart(document.getElementById("canvas"), config); window.myRadar = new Chart(document.getElementById("canvas"), config);
updateLegend();
}; };
$('#randomizeData').click(function() { $('#randomizeData').click(function() {
@ -94,7 +92,6 @@
}); });
window.myRadar.update(); window.myRadar.update();
updateLegend();
}); });
$('#addDataset').click(function() { $('#addDataset').click(function() {
@ -114,7 +111,6 @@
config.data.datasets.push(newDataset); config.data.datasets.push(newDataset);
window.myRadar.update(); window.myRadar.update();
updateLegend();
}); });
$('#addData').click(function() { $('#addData').click(function() {
@ -126,14 +122,12 @@
}); });
window.myRadar.update(); window.myRadar.update();
updateLegend();
} }
}); });
$('#removeDataset').click(function() { $('#removeDataset').click(function() {
config.data.datasets.splice(0, 1); config.data.datasets.splice(0, 1);
window.myRadar.update(); window.myRadar.update();
updateLegend();
}); });
$('#removeData').click(function() { $('#removeData').click(function() {
@ -144,7 +138,6 @@
}); });
window.myRadar.update(); window.myRadar.update();
updateLegend();
}); });
</script> </script>
</body> </body>