105 lines
9.9 KiB
HTML
105 lines
9.9 KiB
HTML
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Stock graphs</title><link rel="stylesheet" type="text/css" href="manual.css"><meta name="generator" content="DocBook XSL Stylesheets V1.76.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="ch15.html" title="Chapter 15. Different types of linear (cartesian) graph types"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Stock graphs</th></tr><tr><td width="20%" align="left"> </td><th width="60%" align="center">Chapter 15. Different types of linear (cartesian) graph types</th><td width="20%" align="right"> </td></tr></table><hr></div><div class="sect1" title="Stock graphs"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sec1.creating-stock-graphs"></a>Stock graphs</h2></div></div></div>
|
||
|
||
<p>Stock charts are used to display data values where one is interested in 4
|
||
different values for each data point. This could for example be used to display a
|
||
stocks open,close, min and max value during a specific day. Hence the name Stock
|
||
chart (or Stock plot).</p>
|
||
<p>Stock plots are created as an instance of <code class="code">class StockPlot</code> so the
|
||
module "<code class="filename">jpgraph_stock.php</code>" must first be included in the
|
||
script.</p>
|
||
<p><a class="xref" href="ch15s04.html#fig.stockex1" title="Figure 15.62. A stock graph (stockex1.php)">Figure 15.62. A stock graph <code class="uri"><a class="uri" href="example_src/stockex1.html" target="_top">(<code class="filename">stockex1.php</code>)</a></code> </a>illustrates a sample Stock chart plot</p>
|
||
<p>
|
||
</p><div class="figure"><a name="fig.stockex1"></a><p class="title"><b>Figure 15.62. A stock graph <code class="uri"><a class="uri" href="example_src/stockex1.html" target="_top">(<code class="filename">stockex1.php</code>)</a></code> </b></p><div class="figure-contents"> <span class="inlinemediaobject"><img src="images/stockex1.png" alt="A stock graph (stockex1.php)"></span> </div></div><p><br class="figure-break">
|
||
</p>
|
||
<p>For this type of plot the y-data array must be consist of a number of quadruples
|
||
of data where each quadruple consists of (open,close,min,max). The open and close
|
||
values determine the min max for the middle bar and the min,max determine the end
|
||
points of the "error-lines" at the top and bottom of each bar as shown in ??.</p>
|
||
<p>
|
||
</p><div class="informaltable">
|
||
<table border="0"><colgroup><col class="c1"><col class="c2"></colgroup><tbody><tr><td valign="top">
|
||
<div class="figure"><a name="fig.details-stock-chart"></a><p class="title"><b>Figure 15.63. Explaining stock graphs</b></p><div class="figure-contents">
|
||
|
||
<p>
|
||
<span class="inlinemediaobject"><img src="images/stock-detail-explanation.png" alt="Explaining stock graphs"></span>
|
||
</p>
|
||
</div></div><br class="figure-break">
|
||
</td><td valign="top">
|
||
<p>For this type of plot the y-data array must be consist of
|
||
a number of quadruples of data where each quadruple consists
|
||
of an even number of (open,close,min,max). </p>
|
||
<p>The open and close values determine the min max for the
|
||
middle bar and the min,max determine the end points of the
|
||
"error-lines" at the top and bottom of each bar as shown in
|
||
<a class="xref" href="ch15s04.html#fig.details-stock-chart" title="Figure 15.63. Explaining stock graphs">Figure 15.63. Explaining stock graphs</a>.</p>
|
||
<p>Note that the data follows the rules</p>
|
||
<p>
|
||
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
|
||
<p>min < max</p>
|
||
</li><li class="listitem">
|
||
<p>min < min( open, close )</p>
|
||
</li><li class="listitem">
|
||
<p>max > max( open, close )</p>
|
||
</li></ul></div><p>
|
||
</p>
|
||
</td></tr></tbody></table>
|
||
</div><p>
|
||
</p>
|
||
<p>To separate the two cases where "open > close" or "open < close " two different
|
||
colors are used. </p>
|
||
<p>These colors are specified with the method</p>
|
||
<p>
|
||
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
|
||
<p><code class="code">StockPlot::SetColor($aFrame, $aFill='white',
|
||
$aFrameNeg='darkred', $aFillNeg='darkred')</code></p>
|
||
<p><code class="code">$aFrame</code>, <code class="code">$aFill</code>, The frame and fill color
|
||
when open <= close</p>
|
||
<p><code class="code">$aFrameNeg</code>, <code class="code">$aFillNeg</code>, The frame and fill
|
||
color when open > close</p>
|
||
</li></ul></div><p>
|
||
</p>
|
||
<p><code class="code">StockPlot::SetColor()</code> method. By default a positive bar (close >
|
||
open) have a fill color of white and for the negative case where (close < open)
|
||
the bars have a red color.</p>
|
||
<p>The final possible variation of stock plots is the option to determine whether or
|
||
not the end point for the min,max lines should have the horizontal line marking the
|
||
end of the line or not. This can be adjusted with a call to method</p>
|
||
<p>
|
||
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
|
||
<p><code class="code">StockPlot::HideEndLines($aHide=true)</code></p>
|
||
</li></ul></div><p>
|
||
</p>
|
||
<div class="sect2" title="Stock plot variant: Boxplot"><div class="titlepage"><div><div><h3 class="title"><a name="id2561152"></a>Stock plot variant: Boxplot</h3></div></div></div>
|
||
|
||
<p>A minor variation of stock charts is the <code class="code">BoxPlot</code> plot type. this
|
||
is almost the same as <code class="code">StockPlot</code> but with the very small difference
|
||
that in addition to the open,close,min, max values it is also possible to
|
||
specify a fifth, median value . </p>
|
||
<p>A box plot is created as in instance of <code class="code">class BoxPlot</code> which is
|
||
defined in "<code class="filename">jpgraph_stock.php</code>"</p>
|
||
<p>The median lies between the open and close value and is illustrated as a
|
||
horizontal line within the bar. An example of this is shown in </p>
|
||
<p>
|
||
</p><div class="figure"><a name="fig.boxstockex1"></a><p class="title"><b>Figure 15.64. A typical boxplot <code class="uri"><a class="uri" href="example_src/boxstockex1.html" target="_top">(<code class="filename">boxstockex1.php</code>)</a></code> </b></p><div class="figure-contents"> <span class="inlinemediaobject"><img src="images/boxstockex1.png" alt="A typical boxplot (boxstockex1.php)"></span> </div></div><p><br class="figure-break">
|
||
</p>
|
||
<p>The color of the median line can be modified with a call to </p>
|
||
<p>
|
||
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
|
||
<p><code class="code">BoxPlot::SetMedianColor($aColor)</code></p>
|
||
</li></ul></div><p>
|
||
</p>
|
||
</div>
|
||
<div class="sect2" title="Image maps for Box and Stock charts"><div class="titlepage"><div><div><h3 class="title"><a name="id2561251"></a> Image maps for Box and Stock charts</h3></div></div></div>
|
||
|
||
<p>In the same way as for other plots it is possible to associate an image map
|
||
with these plots. The "hot" area for each plot is the mid "bar" section. In the
|
||
same way as other plot types the method </p>
|
||
<p>
|
||
</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
|
||
<p><code class="code">BoxPlot::SetCSIMTargets($aTargets,$aAlts='',$aWinTargets='')</code></p>
|
||
</li></ul></div><p>
|
||
</p>
|
||
<p>is used to set the URL:s for the hot areas</p>
|
||
</div>
|
||
</div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"> </td><td width="20%" align="center"><a accesskey="u" href="ch15.html">Up</a></td><td width="40%" align="right"> </td></tr><tr><td width="40%" align="left" valign="top"> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> </td></tr></table></div></body></html>
|