Skip to content

Instantly share code, notes, and snippets.

@davidjpfeiffer
Last active July 25, 2016 22:10
Show Gist options
  • Save davidjpfeiffer/78b04914e8d1978a70a8164b535bbfac to your computer and use it in GitHub Desktop.
Save davidjpfeiffer/78b04914e8d1978a70a8164b535bbfac to your computer and use it in GitHub Desktop.
This HTML file can be used with Chart JS to create a fully-functional example of the chart.
<!doctype html>
<html>
<head>
<title>Chart Example</title>
<script src="chart.js"></script>
</head>
<body>
<div style="width: 50%">
<canvas id="canvas" height="450" width="600"></canvas>
</div>
<script>
var getRandomDataArray = function () {
var dataArray = [];
for (var i = 0; i < 7; i++) dataArray.push(Math.round(Math.random() * 100));
return dataArray;
}
var chartData = [
{
value: 300,
color:"#F7464A",
highlight: "#FF5A5E",
label: "Red"
},
{
value: 50,
color: "#46BFBD",
highlight: "#5AD3D1",
label: "Green"
},
{
value: 100,
color: "#FDB45C",
highlight: "#FFC870",
label: "Yellow"
},
{
value: 40,
color: "#949FB1",
highlight: "#A8B3C5",
label: "Grey"
},
{
value: 120,
color: "#4D5360",
highlight: "#616774",
label: "Dark Grey"
}
];
window.onload = function(){
var chartOptions = { responsive : true };
var chart = document.getElementById("canvas").getContext("2d");
window.myBar = new Chart(chart).PolarArea(chartData, chartOptions);
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment