<html>
<head>
<title></title>
</head>
<body>
<div style='width:50%'>
<canvas id="canvas" width="400" height="400"></canvas>
</div>
<script type="text/javascript" src='Chart.js'></script>
<script type="text/javascript">
//Get the context of the canvas element we want to select
window.onload = function() {
var ctx = document.getElementById("canvas").getContext("2d");
ctx.fillRect(10, 10, 20, 20);
window.myLine = new Chart(ctx).Line(lineChartData, {
responsive: true
});
};
//执行随机异步交互
var randomScalingFactor = function(){ return Math.round(Math.random()*100)};
var lineChartData = {
labels : ["January","February","March","April","May","June","July"],
datasets : [
{
label: "My First dataset",
fillColor : "rgba(220,220,220,0.2)",
strokeColor : "rgba(220,220,220,1)",
pointColor : "rgba(220,220,220,1)",
pointStrokeColor : "#fff",
pointHighlightFill : "#fff",
pointHighlightStroke : "rgba(220,220,220,1)",
data : [randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor()]
},
{
label: "My Second dataset",
fillColor : "rgba(151,187,205,0.2)",
strokeColor : "rgba(151,187,205,1)",
pointColor : "rgba(151,187,205,1)",
pointStrokeColor : "#fff",
pointHighlightFill : "#fff",
pointHighlightStroke : "rgba(151,187,205,1)",
data : [randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor()]
}
]
}
</script>
</body>
</html>