Created
July 12, 2014 01:43
-
-
Save larainema/b9a09b69b22cb890f084 to your computer and use it in GitHub Desktop.
use Chart.js to create line chart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Line Chart</title> | |
<script src="scripts/Chart.js"></script> | |
</head> | |
<body> | |
<div style="width:60%"> | |
<div> | |
<canvas id="canvas" height="450" width="600"></canvas> | |
</div> | |
</div> | |
<div> | |
RED: Ununpack<br> | |
BLUE:Adj2nest<br> | |
GREEN:Nomos<br> | |
YELLOW:Copyright<br> | |
LIGHT GREEN:Pkgagent | |
</div> | |
<script> | |
var randomScalingFactor = function(){ return Math.round(Math.random()*100)}; | |
var lineChartData = { | |
labels : ["2.0.0","2.1.0","2.2.0","2.3.0","2.4.0","2.5.0","lates",], | |
datasets : [ | |
{ | |
label: "Ununpack", | |
fillColor : "rgba(255,0,0,0.2)", | |
strokeColor : "rgba(255,0,0,1)", | |
pointColor : "rgba(255,0,0,1)", | |
pointStrokeColor : "#fff", | |
pointHighlightFill : "#fff", | |
pointHighlightStroke : "rgba(255,0,0,1)", | |
data : [75,78,75,75,75,71,71,] | |
}, | |
{ | |
label: "Adj2nest", | |
fillColor : "rgba(0,0,255,0.2)", | |
strokeColor : "rgba(0,0,255,1)", | |
pointColor : "rgba(0,0,255,1)", | |
pointStrokeColor : "#fff", | |
pointHighlightFill : "#fff", | |
pointHighlightStroke : "rgba(0,0,255,1)", | |
data : [165,150,154,154,154,154,154,] | |
}, | |
{ | |
label: "Nomos", | |
fillColor : "rgba(0,255,0,0.2)", | |
strokeColor : "rgba(0,255,0,1)", | |
pointColor : "rgba(0,255,0,1)", | |
pointStrokeColor : "#fff", | |
pointHighlightFill : "#fff", | |
pointHighlightStroke : "rgba(0,255,0,1)", | |
data : [12,12,9,9,9,8,8,] | |
}, | |
{ | |
label: "Copyright", | |
fillColor : "rgba(255,255,0,0.2)", | |
strokeColor : "rgba(255,255,0,1)", | |
pointColor : "rgba(255,255,0,1)", | |
pointStrokeColor : "#fff", | |
pointHighlightFill : "#fff", | |
pointHighlightStroke : "rgba(255,255,0,1)", | |
data : [138,173,197,172,153,138,197,] | |
}, | |
{ | |
label: "Pkgagent", | |
fillColor : "rgba(0,255,255,0.2)", | |
strokeColor : "rgba(0,255,255,1)", | |
pointColor : "rgba(0,255,255,1)", | |
pointStrokeColor : "#fff", | |
pointHighlightFill : "#fff", | |
pointHighlightStroke : "rgba(0,255,255,1)", | |
data : [20,20,20,20,20,20,10,] | |
} | |
] | |
} | |
window.onload = function(){ | |
var ctx = document.getElementById("canvas").getContext("2d"); | |
window.myLine = new Chart(ctx).Line(lineChartData, { | |
responsive: true | |
}); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment