Plotr Prototype图表插件 项目简介
Plotr是一个基于PlotKit与MochiKit的轻量级Javascript制图库。Plotr依赖于prototype以及HTML Canvas。 Plotr 的使用相当简单,下面是Plotr的官方示例: <div><canvas id=<span class="string">"bars1"</span> height=<span class="string">"300"</span> width=<span class="string">"500"</span>></canvas></div><br> <script type=<span class="string">"text/javascript"</span>><br> // Define a dataset.<br> var dataset = {<br> <span class="string">'myFirstDataset'</span>: [[0, 1], [1, 1], [2, 1.414], [3, 1.73], [4, 2.56]],<br> <span class="string">'mySecondDataset'</span>: [[0, 0.3], [1, 2.67], [2, 1.34], [3, 1.73], [4, 1.9]],<br> <span class="string">'myThirdDataset'</span>: [[0, 0.46], [1, 1.45], [2, 2.5], [3, 1.2], [4, 2.4]],<br> <span class="string">'myFourthDataset'</span>: [[0, .86], [1, 0.83], [2, 3], [3, 1.73], [4, 0.76]],<br> };<br> // Define options.<br> var options = {<br> // Define a padding <span class="keywords">for</span> the canvas node<br> padding: {left: 30, right: 0, top: 10, bottom: 30},<br> // Background color to render.<br> backgroundColor: <span class="string">'#d8efb0'</span>,<br> // Use the predefined blue colorscheme.<br> colorScheme: <span class="string">'grey'</span>,<br> // Render a horizontal oriented barchart.<br> barOrientation: <span class="string">'vertical'</span>,<br> // Set the labels.<br> xTicks: [<br> {<span class="symbol">v:0</span>, label:<span class="string">'day 1'</span>},<br> {<span class="symbol">v:1</span>, label:<span class="string">'day 2'</span>},<br> {<span class="symbol">v:2</span>, label:<span class="string">'day 3'</span>},<br> {<span class="symbol">v:3</span>, label:<span class="string">'day 4'</span>}<br> ]<br> };<br> // Instantiate a new BarCart.<br> var vertical = new Plotr.BarChart<span class="brackets">(</span><span class="string">'bars1'</span>,options<span class="brackets">)</span>;<br> // Add a dataset to it.<br> vertical.addDataset<span class="brackets">(</span>dataset<span class="brackets">)</span>;<br> // Render it.<br> vertical.render<span class="brackets">(</span><span class="brackets">)</span>;<br> </script> 效果如下: