egroupware/phpgwapi/js/jquery/jqplot/examples/candlestickCanvasOverlay.html
2011-08-09 23:10:50 +00:00

221 lines
7.7 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<!--[if lt IE 9]><script language="javascript" type="text/javascript" src="../excanvas.js"></script><![endif]-->
<link rel="stylesheet" type="text/css" href="../jquery.jqplot.css" />
<link rel="stylesheet" type="text/css" href="examples.css" />
<!-- BEGIN: load jquery -->
<script language="javascript" type="text/javascript" src="../jquery.js"></script>
<!-- END: load jquery -->
<!-- BEGIN: load jqplot -->
<script language="javascript" type="text/javascript" src="../jquery.jqplot.js"></script>
<script language="javascript" type="text/javascript" src="../plugins/jqplot.dateAxisRenderer.js"></script>
<script language="javascript" type="text/javascript" src="../plugins/jqplot.categoryAxisRenderer.js"></script>
<script language="javascript" type="text/javascript" src="../plugins/jqplot.ohlcRenderer.js"></script>
<script language="javascript" type="text/javascript" src="../plugins/jqplot.canvasOverlay.js"></script>
<!-- END: load jqplot -->
<script language="javascript" type="text/javascript">
$(document).ready(function(){
var j = new $.jsDate();
var ohlc = [['07/06/09', 138.7, 139.68, 135.18, 135.4],
['06/29/09', 143.46, 144.66, 139.79, 140.02],
['06/22/09', 140.67, 143.56, 132.88, 142.44],
['06/15/09', 136.01, 139.5, 134.53, 139.48],
['06/08/09', 143.82, 144.56, 136.04, 136.97],
['06/01/09', 136.47, 146.4, 136, 144.67],
['05/26/09', 124.76, 135.9, 124.55, 135.81],
['05/18/09', 123.73, 129.31, 121.57, 122.5],
['05/11/09', 127.37, 130.96, 119.38, 122.42],
['05/04/09', 128.24, 133.5, 126.26, 129.19],
['04/27/09', 122.9, 127.95, 122.66, 127.24],
['04/20/09', 121.73, 127.2, 118.6, 123.9],
['04/13/09', 120.01, 124.25, 115.76, 123.42],
['04/06/09', 114.94, 120, 113.28, 119.57],
['03/30/09', 104.51, 116.13, 102.61, 115.99],
['03/23/09', 102.71, 109.98, 101.75, 106.85],
['03/16/09', 96.53, 103.48, 94.18, 101.59],
['03/09/09', 84.18, 97.2, 82.57, 95.93],
['03/02/09', 88.12, 92.77, 82.33, 85.3],
['02/23/09', 91.65, 92.92, 86.51, 89.31],
['02/17/09', 96.87, 97.04, 89, 91.2],
['02/09/09', 100, 103, 95.77, 99.16],
['02/02/09', 89.1, 100, 88.9, 99.72],
['01/26/09', 88.86, 95, 88.3, 90.13],
['01/20/09', 81.93, 90, 78.2, 88.36],
['01/12/09', 90.46, 90.99, 80.05, 82.33],
['01/05/09', 93.17, 97.17, 90.04, 90.58],
['12/29/08', 86.52, 91.04, 84.72, 90.75],
['12/22/08', 90.02, 90.03, 84.55, 85.81],
['12/15/08', 95.99, 96.48, 88.02, 90],
['12/08/08', 97.28, 103.6, 92.53, 98.27],
['12/01/08', 91.3, 96.23, 86.5, 94],
['11/24/08', 85.21, 95.25, 84.84, 92.67],
['11/17/08', 88.48, 91.58, 79.14, 82.58],
['11/10/08', 100.17, 100.4, 86.02, 90.24],
['11/03/08', 105.93, 111.79, 95.72, 98.24],
['10/27/08', 95.07, 112.19, 91.86, 107.59],
['10/20/08', 99.78, 101.25, 90.11, 96.38],
['10/13/08', 104.55, 116.4, 85.89, 97.4],
['10/06/08', 91.96, 101.5, 85, 96.8],
['09/29/08', 119.62, 119.68, 94.65, 97.07],
['09/22/08', 139.94, 140.25, 123, 128.24],
['09/15/08', 142.03, 147.69, 120.68, 140.91],
['09/08/08', 164.57, 164.89, 146, 148.94]
];
var ohlc = [['1/24/2011', 607.57, 612.49, 601.23, 611.08],
['1/21/2011', 639.58, 641.73, 611.36, 611.83],
['1/20/2011', 632.21, 634.08, 623.29, 626.77],
['1/19/2011', 642.12, 642.96, 629.66, 631.75],
['1/18/2011', 626.06, 641.99, 625.27, 639.63],
['1/14/2011', 617.4, 624.27, 617.08, 624.18],
['1/13/2011', 616.97, 619.67, 614.16, 616.69],
['1/12/2011', 619.35, 619.35, 614.77, 616.87],
['1/11/2011', 617.71, 618.8, 614.5, 616.01],
['1/10/2011', 614.8, 615.39, 608.56, 614.21],
['1/7/2011', 615.91, 618.25, 610.13, 616.44],
['1/6/2011', 610.68, 618.43, 610.05, 613.5],
['1/5/2011', 600.07, 610.33, 600.05, 609.07],
['1/4/2011', 605.62, 606.18, 600.12, 602.12],
['1/3/2011', 596.48, 605.59, 596.48, 604.35],
['12/31/2010', 596.74, 598.42, 592.03, 593.97],
['12/30/2010', 598, 601.33, 597.39, 598.86],
['12/29/2010', 602, 602.41, 598.92, 601],
['12/28/2010', 602.05, 603.87, 598.01, 598.92],
['12/27/2010', 602.74, 603.78, 599.5, 602.38],
['12/23/2010', 605.34, 606, 602.03, 604.23],
['12/22/2010', 604, 607, 603.28, 605.49],
['12/21/2010', 598.57, 604.72, 597.61, 603.07],
['12/20/2010', 594.65, 597.88, 588.66, 595.06],
['12/17/2010', 591, 592.56, 587.67, 590.8],
['12/16/2010', 592.85, 593.77, 588.07, 591.71],
['12/15/2010', 594.2, 596.45, 589.15, 590.3],
['12/14/2010', 597.09, 598.29, 592.48, 594.91],
['12/13/2010', 597.12, 603, 594.09, 594.62],
['12/10/2010', 593.14, 593.99, 590.29, 592.21],
['12/9/2010', 593.88, 595.58, 589, 591.5],
['12/8/2010', 591.97, 592.52, 583.69, 590.54],
['12/7/2010', 591.27, 593, 586, 587.14],
['12/6/2010', 580.57, 582, 576.61, 578.36],
['12/3/2010', 569.45, 576.48, 568, 573],
['12/2/2010', 568.66, 573.33, 565.35, 571.82],
['12/1/2010', 563, 571.57, 562.4, 564.35],
['11/30/2010', 574.32, 574.32, 553.31, 555.71],
['11/29/2010', 589.17, 589.8, 579.95, 582.11],
['11/26/2010', 590.46, 592.98, 587, 590],
['11/24/2010', 587.31, 596.6, 587.05, 594.97],
['11/23/2010', 587.01, 589.01, 578.2, 583.01],
['11/22/2010', 587.47, 593.44, 582.75, 591.22],
['11/19/2010', 597, 597.89, 590.34, 590.83],
['11/18/2010', 589, 599.98, 588.56, 596.56],
['11/17/2010', 585, 589.5, 581.37, 583.55],
['11/16/2010', 592.76, 597.89, 583.45, 583.72],
['11/15/2010', 603.08, 604, 594.05, 595.47],
['11/12/2010', 613.99, 616.9, 601.21, 603.29],
['11/11/2010', 619.7, 619.85, 614.21, 617.19],
['11/10/2010', 622.08, 623, 617.51, 622.88],
['11/9/2010', 630, 630.85, 620.51, 624.82],
['11/8/2010', 624.02, 629.49, 623.13, 626.77],
['11/5/2010', 623.18, 625.49, 621.11, 625.08],
['11/4/2010', 624.64, 629.92, 622.1, 624.27],
['11/3/2010', 617.5, 621.83, 613.5, 620.18],
['11/2/2010', 618.67, 620, 614.58, 615.6],
['11/1/2010', 615.73, 620.66, 611.21, 615],
['10/29/2010', 617.07, 619, 612.99, 613.7],
['10/28/2010', 620.05, 621, 613.3, 618.58]];
for (var i=0; i<ohlc.length; i++) {
//ohlc[i][0] = j.strftime('%Y-%m-%d');
j.add(-1, 'day');
}
plot1 = $.jqplot('chart1',[ohlc],{
title: 'Chart',
axesDefaults:{},
axes: {
xaxis: {
renderer:$.jqplot.DateAxisRenderer,
tickOptions:{formatString:'%b %e'},
},
yaxis: {
min: 560,
max: 650,
tickOptions:{formatString:'%.2f'}
}
},
series: [{renderer:$.jqplot.OHLCRenderer, rendererOptions:{candleStick:true}}]
});
});
function startit() {
counter = 0;
Interval = setInterval(runUpdate, 250);
}
function runUpdate() {
if (counter < 1000) {
var val = Math.random()*5 * (Math.random() - 0.5),
d = plot1.series[0].data,
dl = d.length,
curhi = d[dl - 1][2],
curlo = d[dl - 1][3],
curclose = d[dl - 1][4];
newval = curclose + val;
if (newval > curhi) { curhi = newval }
else if (newval < curlo) { curlo = newval }
d[dl - 1][2] = curhi;
d[dl - 1][3] = curlo;
d[dl - 1][4] = newval;
if (curhi > plot1.axes.yaxis.max) {
}
else if (curlo < plot1.axes.yaxis.min) {
}
else {
plot1.drawSeries({}, 0);
counter++;
}
val = d = dl = curhi = curlo = curclose = newval = null;
}
else {
val = d = dl = curhi = curlo = curclose = newval = null;
clearInterval(Interval);
}
}
function stopit() {
clearInterval(Interval);
}
</script>
</head>
<body>
<?php include "nav.inc"; ?>
<div id="chart1" style="margin:20px;height:400px; width:800px;"></div>
<button onclick="startit()">Start</button>
<button onclick="stopit()">Stop</button>
</body>
</html>