| Server IP : 104.21.80.248 / Your IP : 172.71.28.156 Web Server : Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/5.6.30 System : Windows NT WIN-ECQAAA40806 6.2 build 9200 (Windows Server 2012 Standard Edition) i586 User : SYSTEM ( 0) PHP Version : 5.6.30 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : E:/Inetpub/www/myschool/triamudom/check/RGraph/examples/ |
Upload File : |
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<!--
/**
* o------------------------------------------------------------------------------o
* | This file is part of the RGraph package - you can learn more at: |
* | |
* | http://www.rgraph.net |
* | |
* | This package is licensed under the RGraph license. For all kinds of business |
* | purposes there is a small one-time licensing fee to pay and for non |
* | commercial purposes it is free to use. You can read the full license here: |
* | |
* | http://www.rgraph.net/LICENSE.txt |
* o------------------------------------------------------------------------------o
*/
-->
<title>Scatter charts</title>
<meta name="keywords" content="rgraph html5 canvas example scatter chart" />
<meta name="description" content="Scatter charts example" />
<meta property="og:title" content="RGraph: HTML5 Javascript charts library" />
<meta property="og:description" content="A charts library based on the HTML5 canvas tag" />
<meta property="og:image" content="http://www.rgraph.net/images/logo.png"/>
<link rel="stylesheet" href="../css/website.css" type="text/css" media="screen" />
<link rel="icon" type="image/png" href="../images/favicon.png">
<!-- Place this tag in your head or just before your close body tag -->
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
<script src="../libraries/RGraph.common.core.js" ></script>
<script src="../libraries/RGraph.common.tooltips.js" ></script>
<script src="../libraries/RGraph.scatter.js" ></script>
<script src="../libraries/RGraph.common.key.js" ></script>
<!--[if lt IE 9]><script src="../excanvas/excanvas.original.js"></script><![endif]-->
<script>
var original_data = [
[0.5,[0,3,4,5,7, 'red', 'red'], 'black'],
[1.5,[2,3,5,6,9, 'red', 'red'], 'black'],
[2.5,[0,2,5.6,6.2,9, 'red', 'red'], 'black'],
[3.5,[2,4.8,6.1,6.5,9, 'red', 'red'], 'black'],
[4.5,[1.1,5.2,5.9,6.5,7.6, 'red', 'red'], 'black'],
[5.5,[0.8,3.9,7,7.5,7.99, 'red', 'red'], 'black'],
[6.5,[2,2.9,4,4.5,5.3, 'red', 'red'], 'black'],
[7.5,[2.5,3.0,4,4.9,5.5, 'red', 'red'], 'black'],
[8.5,[3,3.3,5,6.5,6.9, 'red', 'red'], 'black'],
[9.5,[1.1,3.3,6,6.5,6.9, 'red', 'red'], 'black'],
[10.5,[0.7,3.1,5,5.9,6.9, 'red', 'red'], 'black'],
[11.5,[0.3,2.5,3,4.5,4.9, 'red', 'red'], 'black'],
[12.5,[0.9,2.7,4.9,5.5,6.3, 'red', 'red'], 'black'],
[13.5,[0.7,3.0,3.8,4.2,4.9, 'red', 'red'], 'black'],
[14.5,[0.8,2.1,5.2,6.1,7.2, 'red', 'red'], 'black'],
[15.5,[0.9,2.2,3.8,5.5,6.2, 'red', 'red'], 'black'],
[16.5,[1.2,2.3,3.9,5.2,6, 'red', 'red'], 'black'],
[17.5,[0.8,2.2,4.1,5.2,5.9, 'red', 'red'], 'black'],
[18.5,[0.9,3.1,4.2,5.5,6.1, 'red', 'red'], 'black'],
[19.5,[0.9,2.9,4.9,5.5,6.2, 'red', 'red'], 'black'],
[20.5,[0.9,2.9,4.9,5.22,6.3, 'red', 'red'], 'black'],
[21.5,[1.7,2.9,5,5.4,6.3, 'red', 'red'], 'black'],
[22.5,[1.7,3.1,5.1,6.1,6.8, 'red', 'red'], 'black'],
[23.5,[1.9,2.5,4.3,5.5,6.6, 'red', 'red'], 'black'],
[24.5,[0.7,1.6,2.1,3.4,4.2, 'red', 'red'], 'black'],
[25.5,[0.8,1.5,2,3.6,4.2, 'red', 'red'], 'black'],
[26.5,[0.9,2,3,4.2,5.1, 'red', 'red'], 'black'],
[27.5,[0.6,2,2.7,3.6,5.5, 'red', 'red'], 'black'],
[28.5,[0.9,2,3,4.5,9, 'red', 'red'], 'black'],
[29.5,[1.1,3,4.5,5.1,10, 'red', 'red'], 'black'],
[30.5,[1.8,3,4.4,5.5,9, 'red', 'red'], 'black']
];
window.onload = function ()
{
var data = [
[10,15,'red'],[13,16,'red'],[12,11,'red'],[15,16,'red'],[20,19,'red'],[19,16,'red'],[13,15,'red'],[11,12,'red'],[13,16,'red'],[5,19,'red'],[16,15,'red'],[13,15,'red'],[14,14,'red'],[12,12,'red'],
[5,4,'green'],[6,14,'green'],[19,12,'green'],[3,5,'green'],[1,16,'green'],[13,5,'green'],[15,15,'green'],[13,5,'green'],[4,9,'green'],[16,6,'green'],[13,18,'green'],[18,12,'green'],[19,18,'green'],[13,16,'green'],[15,14,'green'],
[12,4,'blue'],[4,23,'blue'],[13,8,'blue'],[12,12,'blue'],[18,4,'blue'],[4,18,'blue'],[11,2,'blue'],[4,3,'blue'],[5,8,'blue'],[1,9,'blue'],[4,6,'blue'],[16,8,'blue'],[17,8,'blue'],[19,9,'blue'],[13,5,'blue'],[16,21,'blue'],
[12,4],[13,12],[11,16],[4,19],[4,3],[5,6],[1,9],[4,12],[6,12],[8,8],[16,6],[13,5],[15,13],[23,23,'red'], [1,1, 'gray'],
[1,4,'gray'], [2,3,'gray'], [1,6,'gray'], [2,3,'gray'], [2,5,'gray'], [3,7,'gray'], [1,4,'gray'], [2,7,'gray']
];
var scatter1 = new RGraph.Scatter('scatter1', data);
scatter1.Set('chart.ylabels.count', 10);
scatter1.Set('chart.background.grid.autofit.numhlines', 10);
scatter1.Set('chart.background.grid.autofit.numvlines', 28);
scatter1.Set('chart.labels', [['Week 1', 0], ['Week 2', 7], ['Week 3', 14], ['Week 4', 21]]);
scatter1.Set('chart.labels.specific.align', 'center');
scatter1.Set('chart.xmax', 28); // Necessary
scatter1.Set('chart.defaultcolor', 'black'); // Optional
scatter1.Set('chart.title', 'This months sales');
scatter1.Set('chart.gutter.left', 40);
scatter1.Set('chart.tickmarks', 'square');
scatter1.Set('chart.ticksize', 4);
scatter1.Set('chart.ymax', 30);
scatter1.Set('chart.units.pre', '$');
scatter1.Set('chart.line.colors', ['red','blue','black']);
scatter1.Set('chart.key', ['Bob','Fred','Gaz']);
scatter1.Draw();
ShowBoxplot();
}
/**
* This facilitates the selector changing
*/
function SelectorChange()
{
var selector = document.getElementById("chartSelector");
var canvas = document.getElementById("scatter2");
RGraph.Clear(canvas);
if (selector.value.toLowerCase() == 'high/low') {
ShowBoxplot();
} else {
ShowAverage();
}
}
/**
* This shows the box plot of stock prices
*/
function ShowBoxplot ()
{
var scatter = new RGraph.Scatter('scatter2', RGraph.array_clone(original_data));
scatter.Set('chart.title', 'High/low daily stock prices');
scatter.Set('chart.boxplot.width', 0.5);
scatter.Set('chart.boxplot.capped', false);
scatter.Set('chart.labels', ['Week 1', 'Week 2', 'Week 3', 'Week 4']);
scatter.Set('chart.xmax', 31);
scatter.Set('chart.ymax', 10);
scatter.Set('chart.scale.decimals', 1);
scatter.Set('chart.units.post', 'p');
scatter.Set('chart.gutter.left', 40);
scatter.Draw();
}
/**
* This shows the box plot of stock prices
*/
function ShowAverage ()
{
var data = RGraph.array_clone(original_data);
for (var i=0; i<data.length; ++i) {
data[i][1] = data[i][1][3];
}
var scatter = new RGraph.Scatter('scatter2', data);
scatter.Set('chart.title', 'Average daily stock prices');
scatter.Set('chart.labels', ['Week 1', 'Week 2', 'Week 3', 'Week 4']);
scatter.Set('chart.xmax', 31);
scatter.Set('chart.ymax', 10);
scatter.Set('chart.scale.decimals', 1);
scatter.Set('chart.units.post', 'p');
scatter.Set('chart.gutter.left', 40);
scatter.Set('chart.line', true);
scatter.Set('chart.line.colors', ['red']);
scatter.Set('chart.tickmarks', null);
scatter.Draw();
}
</script>
<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-54706-2']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<!-- Social networking buttons -->
<?php
$prefix = substr($_SERVER['SERVER_NAME'], 0, 3);
require("/rgraph.{$prefix}/social.html");
?>
<!-- Social networking buttons -->
<div id="breadcrumb">
<a href="../index.html">RGraph: HTML5 Javascript charts library</a>
>
<a href="./index.html">Examples</a>
>
Scatter charts
</div>
<h1>Scatter <span>charts</span></h1>
<script>
if (RGraph.isOld()) {
document.write('<div style="background-color: #fee; border: 2px dashed red; padding: 5px"><b>Important</b><br /><br /> Internet Explorer does not natively support the HTML5 canvas tag, so if you want to see the charts, you can either:<ul><li>Install <a href="http://code.google.com/chrome/chromeframe/">Google Chrome Frame</a></li><li>Use ExCanvas. This is provided in the RGraph Archive.</li><li>Use another browser entirely. Your choices are Firefox 3.5+, Chrome 2+, Safari 4+ or Opera 10.5+. </li></ul> <b>Note:</b> Internet Explorer 9 fully supports the canvas tag.</div>');
}
</script>
<p>
Scatter charts use two variables to plot points and makes it clear where there are congregations. The data points
make up the X and Y coordinates. The labels on the X axis are separate from the X units, allowing you to to have
lots of points, but only a few labels. The Scatter is a good chart to use if you want to show stock prices and
it also supports high/low charts - as shown below.
</p>
<div>
<ul>
<li><a href="../docs/scatter.html">Scatter charts API documentation</a></li>
</ul>
</div>
<div style="float: left">
<canvas id="scatter2" width="450" height="200">[No canvas support]</canvas><br />
Chart type:
<select id="chartSelector" onchange="SelectorChange()">
<option>High/low</option>
<option>Average</option>
</select>
</div>
<canvas id="scatter1" width="450" height="200">[No canvas support]</canvas>
</body>
</html>