ライブラリを読み込む

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="ja">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>Sample</title>
<link rel="stylesheet" href="css/main.css" type="text/css" media="all">
<script type="text/javascript" src="js/prototype.js" charset="shift_jis"></script>
<script type="text/javascript" src="js/excanvas.js" charset="shift_jis"></script>
<script type="text/javascript" src="js/plotr.js" charset="shift_jis"></script>
<script type="text/javascript"><!--
Event.observe(window, "load", function(){
var dataset = {
"Prototype": [[0, 25], [1, 42], [2, 44.5], [3, 47.5]],
"jQuery": [[0, 5], [1, 10], [2, 35], [3, 50.5]],
"MooTools": [[0, 10], [1, 15], [2, 12], [3, 19]]
};
var options = {
barOrientation: "horizontal",
padding: {left: 150, right: 0, top: 10, bottom: 10},
backgroundColor: "#dbdbdb",
colorScheme: "#003f00",
xTicks: [
{v:0, label:"2005"},
{v:1, label:"2006"},
{v:2, label:"2007"},
{v:3, label:"2008"}
]
};
var gBar = new Plotr.BarChart("graph1", options);
gBar.addDataset(dataset);
gBar.render();
options.colorScheme = "#000055";
var gPie = new Plotr.PieChart("graph2", options);
gPie.addDataset(dataset);
gPie.render();
}, false);
// --></script>
</head>
<body>
<h1>ライブラリを読み込む</h1>
<div><canvas id="graph1" height="300" width="600"></canvas></div>
<div><canvas id="graph2" height="300" width="600"></canvas></div>
</body>
</html>
サンプルを実行
[戻る]
prototype.jsパーフェクトリファレンス説明などは本書を参考にしてください。