chartnew.js
Version:
Simple HTML5 Charts using the canvas element
155 lines (125 loc) • 4.25 kB
HTML
<!--[if lte IE 8]><SCRIPT src='source/excanvas.js'></script><![endif]--><SCRIPT src='../ChartNew.js'></script>
<SCRIPT src='../Add-ins/shapesInChart.js'></script>
<SCRIPT>
defCanvasWidth=1200;
defCanvasHeight=600;
var mydata1 = {
labels : ["January","February","March","April","May","June","July"],
datasets : [
{
fillColor : "rgba(220,220,220,0.5)",
strokeColor : "rgba(220,220,220,1)",
pointColor : "rgba(220,220,220,1)",
pointStrokeColor : "#fff",
data : [0.65,0.59,-0.90,0.81,0.56,0.55,0.40],
title : "pFirst data"
},
{
fillColor : "rgba(110,0,220,0.3)",
strokeColor : "rgba(110,0,220,1)",
pointColor : "rgba(110,0,220,1)",
pointStrokeColor : "#fff",
data : [-0.35,0.30,-0.54,0.18,0.7,,],
title : "pFirst data"
},
{
fillColor : "rgba(151,187,205,0.5)",
strokeColor : "rgba(151,187,205,1)",
pointColor : "rgba(151,187,205,1)",
pointStrokeColor : "#fff",
type : "Line",
data : [0.28,0.70,0.40,-0.19,-0.96,0.27,1.00],
title : "pSecond data"
}
]
}
var mydata2 = {
labels : [""],
datasets : [
{
data : [30],
fillColor : "#D97041",
title : "data1"
},
{
data : [90],
fillColor : "#C7604C",
title : "data2"
},
{
data : [24],
fillColor : "#21323D",
title : "data3"
},
{
data : [58],
fillColor : "#9D9B7F",
title : "data4"
},
{
data : [82],
fillColor : "#7D4F6D",
title : "data5"
},
{
data : [8],
fillColor : "#584A5E",
title : "data6"
}
]
};
var newopts = {
highLight : true,
highLightSet : { markerShape : "cross", pointStrokeColor : "red", pointDotRadius : 8, fillColor : "red", color : "red", expandOutRadius : 0.1, expandInRadius : -0.10,
addIns_shape : "RECTANGLE", addIns_fillColor : "rgba(210,220,230,0.5)" , addIns_strokeColor : "black"
},
endDrawScaleFunction : addIns_HighLight_endDraw,
datasetFill : true,
scaleLabel: "<%=value%>",
scaleFontSize : 16,
canvasBorders : true,
graphTitle : "Sample ChartNew.js",
graphTitleFontFamily : "'Arial'",
graphTitleFontSize : 24,
graphTitleFontStyle : "bold",
graphTitleFontColor : "#666",
inGraphDataShow : true,
footNote : "Footnote for the graph",
legend : true,
yAxisLabel : "Y Axis Label",
xAxisLabel : "X Axis Label",
yAxisUnit : "Y Unit",
annotateDisplay : false,
animation : false,
barBorderRadius : 5,
dynamicDisplay : false
}
</SCRIPT>
<html>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<head>
<title>Demo ChartNew.js</title>
</head>
<body>
<!/div>
<center>
<FONT SIZE=6><B>Demo of ChartNew.js !</B></FONT> <BR>
<script>
document.write("<canvas id=\"canvas_line\" height=\""+defCanvasHeight+"\" width=\""+defCanvasWidth+"\"></canvas>");
document.write("<canvas id=\"canvas_bar\" height=\""+defCanvasHeight+"\" width=\""+defCanvasWidth+"\"></canvas>");
document.write("<canvas id=\"canvas_stackedbar\" height=\""+defCanvasHeight+"\" width=\""+defCanvasWidth+"\"></canvas>");
document.write("<canvas id=\"canvas_horizontalbar\" height=\""+defCanvasHeight+"\" width=\""+defCanvasWidth+"\"></canvas>");
document.write("<canvas id=\"canvas_horizontalstackedbar\" height=\""+defCanvasHeight+"\" width=\""+defCanvasWidth+"\"></canvas>");
window.onload = function() {
if(1==1) {
var myLine = new Chart(document.getElementById("canvas_line").getContext("2d")).Line(mydata1,newopts);
var myLine = new Chart(document.getElementById("canvas_bar").getContext("2d")).Bar(mydata1,newopts);
var myLine = new Chart(document.getElementById("canvas_stackedbar").getContext("2d")).StackedBar(mydata1,newopts);
var myLine = new Chart(document.getElementById("canvas_horizontalbar").getContext("2d")).HorizontalBar(mydata1,newopts);
var myLine = new Chart(document.getElementById("canvas_horizontalstackedbar").getContext("2d")).HorizontalStackedBar(mydata1,newopts);
}
}
</script>
</body>
</html>