r39789 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r39788‎ | r39789 | r39790 >
Date:21:52, 21 August 2008
Author:aaron
Status:old (Comments)
Tags:
Comment:
* Add svg graph library and support it in RatingHistory
* Add HTML table fallback for graphs
* Tweak png graph points
* Tweak CSS and bump style version
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/flaggedrevs.css (modified) (history)
  • /trunk/extensions/FlaggedRevs/specialpages/RatingHistory_body.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/svggraph (added) (history)
  • /trunk/extensions/FlaggedRevs/svggraph/LICENSE.LGPL (added) (history)
  • /trunk/extensions/FlaggedRevs/svggraph/svgGraph.html (added) (history)
  • /trunk/extensions/FlaggedRevs/svggraph/svgGraph.php (added) (history)
  • /trunk/extensions/FlaggedRevs/svggraph/svgGraph1.php (added) (history)
  • /trunk/extensions/FlaggedRevs/svggraph/svgGraph2.php (added) (history)
  • /trunk/extensions/FlaggedRevs/svggraph/test01.php (added) (history)
  • /trunk/extensions/FlaggedRevs/svggraph/test02.php (added) (history)
  • /trunk/extensions/FlaggedRevs/svggraph/test03.php (added) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -248,13 +248,14 @@
249249 # How long before stats page is updated?
250250 $wgFlaggedRevsStatsAge = 2 * 3600; // 2 hours
251251
 252+$wgSvgGraphDir = dirname(__FILE__) . '/svggraph';
252253 $wgPHPlotDir = dirname(__FILE__) . '/phplot-5.0.5';
253254
254255 # End of configuration variables.
255256 #########
256257
257258 # Bump this number every time you change flaggedrevs.css/flaggedrevs.js
258 -$wgFlaggedRevStyleVersion = 38;
 259+$wgFlaggedRevStyleVersion = 39;
259260
260261 $wgExtensionFunctions[] = 'efLoadFlaggedRevs';
261262
Index: trunk/extensions/FlaggedRevs/flaggedrevs.css
@@ -309,3 +309,11 @@
310310 .fr-comment-box {
311311 margin-top: .25em;
312312 }
 313+
 314+.fr-rating-dave {
 315+ background-color: lightblue;
 316+}
 317+
 318+.fr-rating-rave {
 319+ background-color: lightgreen;
 320+}
Index: trunk/extensions/FlaggedRevs/svggraph/svgGraph.html
@@ -0,0 +1,1233 @@
 2+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
 3+<!--NewPage-->
 4+<HTML>
 5+<HEAD>
 6+<!-- Generated by javadoc on Wed Jun 05 09:53:38 NZST 2002 -->
 7+<TITLE>
 8+Documentation: Class svgGraph
 9+</TITLE>
 10+<style>
 11+/* Define colors, fonts and other style attributes here to override the defaults */
 12+
 13+/* Page background color */
 14+body { background-color: #FFFFFF }
 15+
 16+/* Table colors */
 17+.TableHeadingColor { background: #CCCCFF } /* Dark mauve */
 18+.TableSubHeadingColor { background: #EEEEFF } /* Light mauve */
 19+.TableRowColor { background: #FFFFFF } /* White */
 20+
 21+/* Font used in left-hand frame lists */
 22+.FrameTitleFont { font-size: normal; font-family: normal }
 23+.FrameHeadingFont { font-size: normal; font-family: normal }
 24+.FrameItemFont { font-size: normal; font-family: normal }
 25+
 26+/* Example of smaller, sans-serif font in frames */
 27+/* .FrameItemFont { font-size: 10pt; font-family: Helvetica, Arial, sans-serif } */
 28+
 29+/* Navigation bar fonts and colors */
 30+.NavBarCell1 { background-color:#EEEEFF;}/* Light mauve */
 31+.NavBarCell1Rev { background-color:#00008B;}/* Dark Blue */
 32+.NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;}
 33+.NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;}
 34+
 35+.NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;}
 36+.NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;}
 37+</style>
 38+</HEAD>
 39+<BODY BGCOLOR="white">
 40+
 41+<!-- ========== START OF NAVBAR ========== -->
 42+<A NAME="navbar_top"><!-- --></A>
 43+<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0">
 44+<TR>
 45+<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
 46+<A NAME="navbar_top_firstrow"><!-- --></A>
 47+<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">
 48+ <TR ALIGN="center" VALIGN="top">
 49+ <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
 50+ </TR>
 51+</TABLE>
 52+</TD>
 53+<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
 54+</EM>
 55+</TD>
 56+</TR>
 57+
 58+<TR>
 59+<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
 60+&nbsp;PREV CLASS&nbsp;
 61+&nbsp;NEXT CLASS</FONT></TD>
 62+<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
 63+ <A HREF="index.html" TARGET="_top"><B>FRAMES</B></A> &nbsp;
 64+&nbsp;<A HREF="svgGraph.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD>
 65+</TR>
 66+<TR>
 67+<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
 68+ SUMMARY: &nbsp;INNER&nbsp;|&nbsp;<A HREF="#field_summary">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
 69+<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
 70+DETAIL: &nbsp;<A HREF="#field_detail">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
 71+</TR>
 72+</TABLE>
 73+<!-- =========== END OF NAVBAR =========== -->
 74+
 75+<HR>
 76+<!-- ======== START OF CLASS DATA ======== -->
 77+<H2>
 78+Class svgGraph</H2>
 79+<PRE>
 80+<B>svgGraph</B>
 81+</PRE>
 82+<HR>
 83+<DL>
 84+<DT>public class <B>svgGraph</B></DL>
 85+
 86+<P>
 87+Takes an array or multiple arrays of data and outputs a graph in SVG format.
 88+ The SVG language allows for a high degree of control of the output,
 89+ thus this class is intended to be extended.
 90+<P>
 91+<DL>
 92+<DT><B>Version: </B><DD>1.0alpha</DD>
 93+<DT><B>Author: </B><DD>Herman Veluwenkamp</DD>
 94+</DL>
 95+<HR>
 96+
 97+<P>
 98+<!-- ======== INNER CLASS SUMMARY ======== -->
 99+
 100+
 101+<!-- =========== FIELD SUMMARY =========== -->
 102+
 103+<A NAME="field_summary"><!-- --></A>
 104+<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
 105+<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
 106+<TD COLSPAN=2><FONT SIZE="+2">
 107+<B>Field Summary</B></FONT></TD>
 108+</TR>
 109+<TR BGCOLOR="white" CLASS="TableRowColor">
 110+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 111+<CODE>&nbsp;string</CODE></FONT></TD>
 112+<TD><CODE><B><A HREF="svgGraph.html#$dataX">$dataX</A></B></CODE>
 113+
 114+<BR>
 115+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Array of data holding values for X axis</TD>
 116+</TR>
 117+<TR BGCOLOR="white" CLASS="TableRowColor">
 118+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 119+<CODE>&nbsp;string</CODE></FONT></TD>
 120+<TD><CODE><B><A HREF="svgGraph.html#$dataY">$dataY</A></B></CODE>
 121+
 122+<BR>
 123+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Two dimensional array holding values for Y axis.</TD>
 124+</TR>
 125+<TR BGCOLOR="white" CLASS="TableRowColor">
 126+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 127+<CODE>&nbsp;integer</CODE></FONT></TD>
 128+<TD><CODE><B><A HREF="svgGraph.html#$decimalPlacesY">$decimalPlacesY</A></B></CODE>
 129+
 130+<BR>
 131+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Number of decimal places to show for Y axis tags.</TD>
 132+</TR>
 133+<TR BGCOLOR="white" CLASS="TableRowColor">
 134+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 135+<CODE>&nbsp;string</CODE></FONT></TD>
 136+<TD><CODE><B><A HREF="svgGraph.html#$error">$error</A></B></CODE>
 137+
 138+<BR>
 139+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Contains error messages.</TD>
 140+</TR>
 141+<TR BGCOLOR="white" CLASS="TableRowColor">
 142+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 143+<CODE>&nbsp;string</CODE></FONT></TD>
 144+<TD><CODE><B><A HREF="svgGraph.html#$extraSVG">$extraSVG</A></B></CODE>
 145+
 146+<BR>
 147+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Extra SVG to add to graph.</TD>
 148+</TR>
 149+<TR BGCOLOR="white" CLASS="TableRowColor">
 150+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 151+<CODE>&nbsp;integer</CODE></FONT></TD>
 152+<TD><CODE><B><A HREF="svgGraph.html#$graphicHeight">$graphicHeight</A></B></CODE>
 153+
 154+<BR>
 155+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Total height of svg graphic.</TD>
 156+</TR>
 157+<TR BGCOLOR="white" CLASS="TableRowColor">
 158+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 159+<CODE>&nbsp;integer</CODE></FONT></TD>
 160+<TD><CODE><B><A HREF="svgGraph.html#$graphicWidth">$graphicWidth</A></B></CODE>
 161+
 162+<BR>
 163+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Total width of svg graphic.</TD>
 164+</TR>
 165+<TR BGCOLOR="white" CLASS="TableRowColor">
 166+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 167+<CODE>&nbsp;integer</CODE></FONT></TD>
 168+<TD><CODE><B><A HREF="svgGraph.html#$innerPaddingX">$innerPaddingX</A></B></CODE>
 169+
 170+<BR>
 171+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Padding between bottom border of plot area and text (tags).</TD>
 172+</TR>
 173+<TR BGCOLOR="white" CLASS="TableRowColor">
 174+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 175+<CODE>&nbsp;integer</CODE></FONT></TD>
 176+<TD><CODE><B><A HREF="svgGraph.html#$innerPaddingY">$innerPaddingY</A></B></CODE>
 177+
 178+<BR>
 179+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Padding between left border of plot area and text (tags).</TD>
 180+</TR>
 181+<TR BGCOLOR="white" CLASS="TableRowColor">
 182+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 183+<CODE>&nbsp;string</CODE></FONT></TD>
 184+<TD><CODE><B><A HREF="svgGraph.html#$labelX">$labelX</A></B></CODE>
 185+
 186+<BR>
 187+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Label for X axis.</TD>
 188+</TR>
 189+<TR BGCOLOR="white" CLASS="TableRowColor">
 190+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 191+<CODE>&nbsp;string</CODE></FONT></TD>
 192+<TD><CODE><B><A HREF="svgGraph.html#$labelY">$labelY</A></B></CODE>
 193+
 194+<BR>
 195+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Label for Y axis.</TD>
 196+</TR>
 197+<TR BGCOLOR="white" CLASS="TableRowColor">
 198+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 199+<CODE>&nbsp;integer</CODE></FONT></TD>
 200+<TD><CODE><B><A HREF="svgGraph.html#$maxY">$maxY</A></B></CODE>
 201+
 202+<BR>
 203+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Maximum value for Y axis values.</TD>
 204+</TR>
 205+<TR BGCOLOR="white" CLASS="TableRowColor">
 206+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 207+<CODE>&nbsp;integer</CODE></FONT></TD>
 208+<TD><CODE><B><A HREF="svgGraph.html#$minY">$minY</A></B></CODE>
 209+
 210+<BR>
 211+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Minimum value for Y axis values.</TD>
 212+</TR>
 213+<TR BGCOLOR="white" CLASS="TableRowColor">
 214+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 215+<CODE>&nbsp;integer</CODE></FONT></TD>
 216+<TD><CODE><B><A HREF="svgGraph.html#$numGridlinesX">$numGridlinesX</A></B></CODE>
 217+
 218+<BR>
 219+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Number of grid lines corresponding to X axis.</TD>
 220+</TR>
 221+<TR BGCOLOR="white" CLASS="TableRowColor">
 222+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 223+<CODE>&nbsp;integer</CODE></FONT></TD>
 224+<TD><CODE><B><A HREF="svgGraph.html#$numGridlinesY">$numGridlinesY</A></B></CODE>
 225+
 226+<BR>
 227+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Number of grid lines corresponding to Y axis.</TD>
 228+</TR>
 229+<TR BGCOLOR="white" CLASS="TableRowColor">
 230+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 231+<CODE>&nbsp;integer</CODE></FONT></TD>
 232+<TD><CODE><B><A HREF="svgGraph.html#$offsetGridlinesX">$offsetGridlinesX</A></B></CODE>
 233+
 234+<BR>
 235+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Offset of first X axis gridline from lower-left of plot area as a
 236+ fraction of normal gridline spacing.</TD>
 237+</TR>
 238+<TR BGCOLOR="white" CLASS="TableRowColor">
 239+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 240+<CODE>&nbsp;integer</CODE></FONT></TD>
 241+<TD><CODE><B><A HREF="svgGraph.html#$offsetGridlinesY">$offsetGridlinesY</A></B></CODE>
 242+
 243+<BR>
 244+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Offset of first Y axis gridline from lower-left of plot area as a
 245+ fraction of normal gridline spacing.</TD>
 246+</TR>
 247+<TR BGCOLOR="white" CLASS="TableRowColor">
 248+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 249+<CODE>&nbsp;integer</CODE></FONT></TD>
 250+<TD><CODE><B><A HREF="svgGraph.html#$outerPadding">$outerPadding</A></B></CODE>
 251+
 252+<BR>
 253+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Padding between outer border of graphic area and text (title and labels).</TD>
 254+</TR>
 255+<TR BGCOLOR="white" CLASS="TableRowColor">
 256+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 257+<CODE>&nbsp;integer</CODE></FONT></TD>
 258+<TD><CODE><B><A HREF="svgGraph.html#$plotHeight">$plotHeight</A></B></CODE>
 259+
 260+<BR>
 261+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Height of plot area.</TD>
 262+</TR>
 263+<TR BGCOLOR="white" CLASS="TableRowColor">
 264+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 265+<CODE>&nbsp;integer</CODE></FONT></TD>
 266+<TD><CODE><B><A HREF="svgGraph.html#$plotOffsetX">$plotOffsetX</A></B></CODE>
 267+
 268+<BR>
 269+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Offset of plot area from left of graphic area.</TD>
 270+</TR>
 271+<TR BGCOLOR="white" CLASS="TableRowColor">
 272+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 273+<CODE>&nbsp;integer</CODE></FONT></TD>
 274+<TD><CODE><B><A HREF="svgGraph.html#$plotOffsetY">$plotOffsetY</A></B></CODE>
 275+
 276+<BR>
 277+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Offset of plot area from top of graphic area.</TD>
 278+</TR>
 279+<TR BGCOLOR="white" CLASS="TableRowColor">
 280+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 281+<CODE>&nbsp;integer</CODE></FONT></TD>
 282+<TD><CODE><B><A HREF="svgGraph.html#$plotWidth">$plotWidth</A></B></CODE>
 283+
 284+<BR>
 285+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Width of plot area.</TD>
 286+</TR>
 287+<TR BGCOLOR="white" CLASS="TableRowColor">
 288+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 289+<CODE>&nbsp;integer</CODE></FONT></TD>
 290+<TD><CODE><B><A HREF="svgGraph.html#$resolutionY">$resolutionY</A></B></CODE>
 291+
 292+<BR>
 293+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Resolution for Y axis tags.</TD>
 294+</TR>
 295+<TR BGCOLOR="white" CLASS="TableRowColor">
 296+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 297+<CODE>&nbsp;integer</CODE></FONT></TD>
 298+<TD><CODE><B><A HREF="svgGraph.html#$rotTagsX">$rotTagsX</A></B></CODE>
 299+
 300+<BR>
 301+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;X axis tags rotation.</TD>
 302+</TR>
 303+<TR BGCOLOR="white" CLASS="TableRowColor">
 304+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 305+<CODE>&nbsp;integer</CODE></FONT></TD>
 306+<TD><CODE><B><A HREF="svgGraph.html#$rotTagsY">$rotTagsY</A></B></CODE>
 307+
 308+<BR>
 309+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Y axis tags rotation.</TD>
 310+</TR>
 311+<TR BGCOLOR="white" CLASS="TableRowColor">
 312+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 313+<CODE>&nbsp;string</CODE></FONT></TD>
 314+<TD><CODE><B><A HREF="svgGraph.html#$styleBarDefault">$styleBarDefault</A></B></CODE>
 315+
 316+<BR>
 317+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Default presentation attributes for bar plots.</TD>
 318+</TR>
 319+<TR BGCOLOR="white" CLASS="TableRowColor">
 320+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 321+<CODE>&nbsp;string</CODE></FONT></TD>
 322+<TD><CODE><B><A HREF="svgGraph.html#$styleBox">$styleBox</A></B></CODE>
 323+
 324+<BR>
 325+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Presentation attributes for box around plot area.</TD>
 326+</TR>
 327+<TR BGCOLOR="white" CLASS="TableRowColor">
 328+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 329+<CODE>&nbsp;string</CODE></FONT></TD>
 330+<TD><CODE><B><A HREF="svgGraph.html#$styleBoxDefault">$styleBoxDefault</A></B></CODE>
 331+
 332+<BR>
 333+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Default presentation attributes for box around plot area.</TD>
 334+</TR>
 335+<TR BGCOLOR="white" CLASS="TableRowColor">
 336+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 337+<CODE>&nbsp;string</CODE></FONT></TD>
 338+<TD><CODE><B><A HREF="svgGraph.html#$styleGridX">$styleGridX</A></B></CODE>
 339+
 340+<BR>
 341+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Presentation attributes for grid corresponding to X axis.</TD>
 342+</TR>
 343+<TR BGCOLOR="white" CLASS="TableRowColor">
 344+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 345+<CODE>&nbsp;string</CODE></FONT></TD>
 346+<TD><CODE><B><A HREF="svgGraph.html#$styleGridXDefault">$styleGridXDefault</A></B></CODE>
 347+
 348+<BR>
 349+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Default presentation attributes for grid corresponding to X axis.</TD>
 350+</TR>
 351+<TR BGCOLOR="white" CLASS="TableRowColor">
 352+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 353+<CODE>&nbsp;string</CODE></FONT></TD>
 354+<TD><CODE><B><A HREF="svgGraph.html#$styleGridY">$styleGridY</A></B></CODE>
 355+
 356+<BR>
 357+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Presentation attributes for grid corresponding to Y axis.</TD>
 358+</TR>
 359+<TR BGCOLOR="white" CLASS="TableRowColor">
 360+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 361+<CODE>&nbsp;string</CODE></FONT></TD>
 362+<TD><CODE><B><A HREF="svgGraph.html#$styleGridYDefault">$styleGridYDefault</A></B></CODE>
 363+
 364+<BR>
 365+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Default presentation attributes for grid corresponding to X axis.</TD>
 366+</TR>
 367+<TR BGCOLOR="white" CLASS="TableRowColor">
 368+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 369+<CODE>&nbsp;string</CODE></FONT></TD>
 370+<TD><CODE><B><A HREF="svgGraph.html#$styleLabelX">$styleLabelX</A></B></CODE>
 371+
 372+<BR>
 373+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Presentation attributes for label.</TD>
 374+</TR>
 375+<TR BGCOLOR="white" CLASS="TableRowColor">
 376+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 377+<CODE>&nbsp;string</CODE></FONT></TD>
 378+<TD><CODE><B><A HREF="svgGraph.html#$styleLabelXDefault">$styleLabelXDefault</A></B></CODE>
 379+
 380+<BR>
 381+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Default presentation attributes for label.</TD>
 382+</TR>
 383+<TR BGCOLOR="white" CLASS="TableRowColor">
 384+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 385+<CODE>&nbsp;string</CODE></FONT></TD>
 386+<TD><CODE><B><A HREF="svgGraph.html#$styleLabelY">$styleLabelY</A></B></CODE>
 387+
 388+<BR>
 389+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Presentation attributes for label.</TD>
 390+</TR>
 391+<TR BGCOLOR="white" CLASS="TableRowColor">
 392+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 393+<CODE>&nbsp;string</CODE></FONT></TD>
 394+<TD><CODE><B><A HREF="svgGraph.html#$styleLabelYDefault">$styleLabelYDefault</A></B></CODE>
 395+
 396+<BR>
 397+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Default presentation attributes for label.</TD>
 398+</TR>
 399+<TR BGCOLOR="white" CLASS="TableRowColor">
 400+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 401+<CODE>&nbsp;string</CODE></FONT></TD>
 402+<TD><CODE><B><A HREF="svgGraph.html#$styleLineDefault">$styleLineDefault</A></B></CODE>
 403+
 404+<BR>
 405+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Default presentation attributes for line plots.</TD>
 406+</TR>
 407+<TR BGCOLOR="white" CLASS="TableRowColor">
 408+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 409+<CODE>&nbsp;string</CODE></FONT></TD>
 410+<TD><CODE><B><A HREF="svgGraph.html#$stylePolylineDefault">$stylePolylineDefault</A></B></CODE>
 411+
 412+<BR>
 413+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Default presentation attributes for polyline plots (inside group tag).</TD>
 414+</TR>
 415+<TR BGCOLOR="white" CLASS="TableRowColor">
 416+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 417+<CODE>&nbsp;string</CODE></FONT></TD>
 418+<TD><CODE><B><A HREF="svgGraph.html#$styleTagsX">$styleTagsX</A></B></CODE>
 419+
 420+<BR>
 421+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Presentation attributes for X axis tags.</TD>
 422+</TR>
 423+<TR BGCOLOR="white" CLASS="TableRowColor">
 424+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 425+<CODE>&nbsp;string</CODE></FONT></TD>
 426+<TD><CODE><B><A HREF="svgGraph.html#$styleTagsXDefault">$styleTagsXDefault</A></B></CODE>
 427+
 428+<BR>
 429+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Default presentation attributes for X axis tags.</TD>
 430+</TR>
 431+<TR BGCOLOR="white" CLASS="TableRowColor">
 432+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 433+<CODE>&nbsp;string</CODE></FONT></TD>
 434+<TD><CODE><B><A HREF="svgGraph.html#$styleTagsY">$styleTagsY</A></B></CODE>
 435+
 436+<BR>
 437+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Presentation attributes for Y axis tags.</TD>
 438+</TR>
 439+<TR BGCOLOR="white" CLASS="TableRowColor">
 440+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 441+<CODE>&nbsp;string</CODE></FONT></TD>
 442+<TD><CODE><B><A HREF="svgGraph.html#$styleTagsYDefault">$styleTagsYDefault</A></B></CODE>
 443+
 444+<BR>
 445+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Default presentation attributes for Y axis tags.</TD>
 446+</TR>
 447+<TR BGCOLOR="white" CLASS="TableRowColor">
 448+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 449+<CODE>&nbsp;string</CODE></FONT></TD>
 450+<TD><CODE><B><A HREF="svgGraph.html#$styleTitle">$styleTitle</A></B></CODE>
 451+
 452+<BR>
 453+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Presentation attributes for title.</TD>
 454+</TR>
 455+<TR BGCOLOR="white" CLASS="TableRowColor">
 456+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 457+<CODE>&nbsp;string</CODE></FONT></TD>
 458+<TD><CODE><B><A HREF="svgGraph.html#$styleTitleDefault">$styleTitleDefault</A></B></CODE>
 459+
 460+<BR>
 461+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Default presentation attributes for title.</TD>
 462+</TR>
 463+<TR BGCOLOR="white" CLASS="TableRowColor">
 464+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 465+<CODE>&nbsp;string</CODE></FONT></TD>
 466+<TD><CODE><B><A HREF="svgGraph.html#$svg">$svg</A></B></CODE>
 467+
 468+<BR>
 469+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SVG XML result.</TD>
 470+</TR>
 471+<TR BGCOLOR="white" CLASS="TableRowColor">
 472+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 473+<CODE>&nbsp;string</CODE></FONT></TD>
 474+<TD><CODE><B><A HREF="svgGraph.html#$title">$title</A></B></CODE>
 475+
 476+<BR>
 477+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Title for Graph.</TD>
 478+</TR>
 479+</TABLE>
 480+&nbsp;
 481+<!-- ======== CONSTRUCTOR SUMMARY ======== -->
 482+
 483+<A NAME="constructor_summary"><!-- --></A>
 484+<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
 485+<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
 486+<TD COLSPAN=2><FONT SIZE="+2">
 487+<B>Constructor Summary</B></FONT></TD>
 488+</TR>
 489+<TR BGCOLOR="white" CLASS="TableRowColor">
 490+<TD><CODE><B><A HREF="svgGraph.html#svgGraph()">svgGraph</A></B>()</CODE>
 491+
 492+<BR>
 493+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Define static variables used in the class.</TD>
 494+</TR>
 495+</TABLE>
 496+&nbsp;
 497+<!-- ========== METHOD SUMMARY =========== -->
 498+
 499+<A NAME="method_summary"><!-- --></A>
 500+<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
 501+<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
 502+<TD COLSPAN=2><FONT SIZE="+2">
 503+<B>Method Summary</B></FONT></TD>
 504+</TR>
 505+<TR BGCOLOR="white" CLASS="TableRowColor">
 506+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 507+<CODE>private &nbsp;array</CODE></FONT></TD>
 508+<TD><CODE><B><A HREF="svgGraph.html#_findRange(var, var, var, var)">_findRange</A></B>(var&nbsp;$data,
 509+ var&nbsp;$min,
 510+ var&nbsp;$max,
 511+ var&nbsp;$resolution)</CODE>
 512+
 513+<BR>
 514+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Find the maximum and minimum values for a set of data.<br>
 515+ The $resolution variable is used for rounding maximum and minimum values.<br>
 516+ If maximum value is 8645 then<br>
 517+ If $resolution is 0, then maximum value becomes 9000.<br>
 518+ If $resolution is 1, then maximum value becomes 8700.<br>
 519+ If $resolution is 2, then maximum value becomes 8650.<br>
 520+ If $resolution is 3, then maximum value becomes 8645.<br></TD>
 521+</TR>
 522+<TR BGCOLOR="white" CLASS="TableRowColor">
 523+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 524+<CODE>&nbsp;boolean</CODE></FONT></TD>
 525+<TD><CODE><B><A HREF="svgGraph.html#bar(var)">bar</A></B>(var&nbsp;$whichDataSet)</CODE>
 526+
 527+<BR>
 528+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Draw a bar for each data point from the data set selected.</TD>
 529+</TR>
 530+<TR BGCOLOR="white" CLASS="TableRowColor">
 531+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 532+<CODE>&nbsp;void</CODE></FONT></TD>
 533+<TD><CODE><B><A HREF="svgGraph.html#drawBox()">drawBox</A></B>()</CODE>
 534+
 535+<BR>
 536+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Draws the box around the plotting area.</TD>
 537+</TR>
 538+<TR BGCOLOR="white" CLASS="TableRowColor">
 539+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 540+<CODE>&nbsp;void</CODE></FONT></TD>
 541+<TD><CODE><B><A HREF="svgGraph.html#drawGraph()">drawGraph</A></B>()</CODE>
 542+
 543+<BR>
 544+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Calls functions to draw title, labels, tags, grid lines, and box of graph.</TD>
 545+</TR>
 546+<TR BGCOLOR="white" CLASS="TableRowColor">
 547+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 548+<CODE>&nbsp;void</CODE></FONT></TD>
 549+<TD><CODE><B><A HREF="svgGraph.html#drawGridX()">drawGridX</A></B>()</CODE>
 550+
 551+<BR>
 552+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Draws the grid lines from top to bottom in the plotting area.</TD>
 553+</TR>
 554+<TR BGCOLOR="white" CLASS="TableRowColor">
 555+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 556+<CODE>&nbsp;void</CODE></FONT></TD>
 557+<TD><CODE><B><A HREF="svgGraph.html#drawGridY()">drawGridY</A></B>()</CODE>
 558+
 559+<BR>
 560+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Draws the grid lines from right to left in the plotting area.</TD>
 561+</TR>
 562+<TR BGCOLOR="white" CLASS="TableRowColor">
 563+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 564+<CODE>&nbsp;void</CODE></FONT></TD>
 565+<TD><CODE><B><A HREF="svgGraph.html#drawOuterText()">drawOuterText</A></B>()</CODE>
 566+
 567+<BR>
 568+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Draw the title and axis labels around the outside of the graphic area.</TD>
 569+</TR>
 570+<TR BGCOLOR="white" CLASS="TableRowColor">
 571+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 572+<CODE>&nbsp;void</CODE></FONT></TD>
 573+<TD><CODE><B><A HREF="svgGraph.html#drawTagsX()">drawTagsX</A></B>()</CODE>
 574+
 575+<BR>
 576+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Draws the axis tag text outside the plotting area on the x axis.</TD>
 577+</TR>
 578+<TR BGCOLOR="white" CLASS="TableRowColor">
 579+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 580+<CODE>&nbsp;void</CODE></FONT></TD>
 581+<TD><CODE><B><A HREF="svgGraph.html#drawTagsY()">drawTagsY</A></B>()</CODE>
 582+
 583+<BR>
 584+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Draws the axis tag text outside the plotting area on the y axis.</TD>
 585+</TR>
 586+<TR BGCOLOR="white" CLASS="TableRowColor">
 587+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 588+<CODE>&nbsp;void</CODE></FONT></TD>
 589+<TD><CODE><B><A HREF="svgGraph.html#generateSVG()">generateSVG</A></B>()</CODE>
 590+
 591+<BR>
 592+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Generate SVG for entire graph.</TD>
 593+</TR>
 594+<TR BGCOLOR="white" CLASS="TableRowColor">
 595+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 596+<CODE>&nbsp;boolean</CODE></FONT></TD>
 597+<TD><CODE><B><A HREF="svgGraph.html#init()">init</A></B>()</CODE>
 598+
 599+<BR>
 600+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Initialises the variables used for drawing points, lines, grid, and ticks in the plotting area.</TD>
 601+</TR>
 602+<TR BGCOLOR="white" CLASS="TableRowColor">
 603+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 604+<CODE>&nbsp;void</CODE></FONT></TD>
 605+<TD><CODE><B><A HREF="svgGraph.html#line(var)">line</A></B>(var&nbsp;$whichDataSet)</CODE>
 606+
 607+<BR>
 608+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Draw line from one point to the next stopping at each.</TD>
 609+</TR>
 610+<TR BGCOLOR="white" CLASS="TableRowColor">
 611+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 612+<CODE>&nbsp;void</CODE></FONT></TD>
 613+<TD><CODE><B><A HREF="svgGraph.html#outputSVG()">outputSVG</A></B>()</CODE>
 614+
 615+<BR>
 616+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Output SVG as XML text including appropriate HTTP header information.</TD>
 617+</TR>
 618+<TR BGCOLOR="white" CLASS="TableRowColor">
 619+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 620+<CODE>&nbsp;boolean</CODE></FONT></TD>
 621+<TD><CODE><B><A HREF="svgGraph.html#polyLine(var)">polyLine</A></B>(var&nbsp;$whichDataSet)</CODE>
 622+
 623+<BR>
 624+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Draw a line from one point to the next continuously without stopping to draw markers.</TD>
 625+</TR>
 626+</TABLE>
 627+&nbsp;
 628+<P>
 629+
 630+<!-- ============ FIELD DETAIL =========== -->
 631+
 632+<A NAME="field_detail"><!-- --></A>
 633+<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
 634+<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
 635+<TD COLSPAN=1><FONT SIZE="+2">
 636+<B>Field Detail</B></FONT></TD>
 637+</TR>
 638+</TABLE>
 639+
 640+<A NAME="$dataX"><!-- --></A><H3>
 641+$dataX</H3>
 642+<PRE>
 643+public string <B>$dataX</B></PRE>
 644+<DL>
 645+<DD>Array of data holding values for X axis</DL>
 646+<HR>
 647+
 648+<A NAME="$dataY"><!-- --></A><H3>
 649+$dataY</H3>
 650+<PRE>
 651+public string <B>$dataY</B></PRE>
 652+<DL>
 653+<DD>Two dimensional array holding values for Y axis. The key for each array must be unique.</DL>
 654+<HR>
 655+
 656+<A NAME="$decimalPlacesY"><!-- --></A><H3>
 657+$decimalPlacesY</H3>
 658+<PRE>
 659+public integer <B>$decimalPlacesY</B></PRE>
 660+<DL>
 661+<DD>Number of decimal places to show for Y axis tags.</DL>
 662+<HR>
 663+
 664+<A NAME="$error"><!-- --></A><H3>
 665+$error</H3>
 666+<PRE>
 667+public string <B>$error</B></PRE>
 668+<DL>
 669+<DD>Contains error messages.</DL>
 670+<HR>
 671+
 672+<A NAME="$extraSVG"><!-- --></A><H3>
 673+$extraSVG</H3>
 674+<PRE>
 675+public string <B>$extraSVG</B></PRE>
 676+<DL>
 677+<DD>Extra SVG to add to graph. e.g. Filters, Defs, Title.
 678+ Note: Title is useful to add if image is viewed out of context.
 679+ <dt><code>$svg</code><dd>
 680+ String holding SVG text.
 681+ </dl></DL>
 682+<HR>
 683+
 684+<A NAME="$graphicHeight"><!-- --></A><H3>
 685+$graphicHeight</H3>
 686+<PRE>
 687+public integer <B>$graphicHeight</B></PRE>
 688+<DL>
 689+<DD>Total height of svg graphic.</DL>
 690+<HR>
 691+
 692+<A NAME="$graphicWidth"><!-- --></A><H3>
 693+$graphicWidth</H3>
 694+<PRE>
 695+public integer <B>$graphicWidth</B></PRE>
 696+<DL>
 697+<DD>Total width of svg graphic.</DL>
 698+<HR>
 699+
 700+<A NAME="$innerPaddingX"><!-- --></A><H3>
 701+$innerPaddingX</H3>
 702+<PRE>
 703+public integer <B>$innerPaddingX</B></PRE>
 704+<DL>
 705+<DD>Padding between bottom border of plot area and text (tags).</DL>
 706+<HR>
 707+
 708+<A NAME="$innerPaddingY"><!-- --></A><H3>
 709+$innerPaddingY</H3>
 710+<PRE>
 711+public integer <B>$innerPaddingY</B></PRE>
 712+<DL>
 713+<DD>Padding between left border of plot area and text (tags).</DL>
 714+<HR>
 715+
 716+<A NAME="$labelX"><!-- --></A><H3>
 717+$labelX</H3>
 718+<PRE>
 719+public string <B>$labelX</B></PRE>
 720+<DL>
 721+<DD>Label for X axis.</DL>
 722+<HR>
 723+
 724+<A NAME="$labelY"><!-- --></A><H3>
 725+$labelY</H3>
 726+<PRE>
 727+public string <B>$labelY</B></PRE>
 728+<DL>
 729+<DD>Label for Y axis.</DL>
 730+<HR>
 731+
 732+<A NAME="$maxY"><!-- --></A><H3>
 733+$maxY</H3>
 734+<PRE>
 735+public integer <B>$maxY</B></PRE>
 736+<DL>
 737+<DD>Maximum value for Y axis values. If a higher value is found in data then
 738+ this value is not used.</DL>
 739+<HR>
 740+
 741+<A NAME="$minY"><!-- --></A><H3>
 742+$minY</H3>
 743+<PRE>
 744+public integer <B>$minY</B></PRE>
 745+<DL>
 746+<DD>Minimum value for Y axis values. If a lower value is found in data then
 747+ this value is not used.</DL>
 748+<HR>
 749+
 750+<A NAME="$numGridlinesX"><!-- --></A><H3>
 751+$numGridlinesX</H3>
 752+<PRE>
 753+public integer <B>$numGridlinesX</B></PRE>
 754+<DL>
 755+<DD>Number of grid lines corresponding to X axis.</DL>
 756+<HR>
 757+
 758+<A NAME="$numGridlinesY"><!-- --></A><H3>
 759+$numGridlinesY</H3>
 760+<PRE>
 761+public integer <B>$numGridlinesY</B></PRE>
 762+<DL>
 763+<DD>Number of grid lines corresponding to Y axis.</DL>
 764+<HR>
 765+
 766+<A NAME="$offsetGridlinesX"><!-- --></A><H3>
 767+$offsetGridlinesX</H3>
 768+<PRE>
 769+public integer <B>$offsetGridlinesX</B></PRE>
 770+<DL>
 771+<DD>Offset of first X axis gridline from lower-left of plot area as a
 772+ fraction of normal gridline spacing.</DL>
 773+<HR>
 774+
 775+<A NAME="$offsetGridlinesY"><!-- --></A><H3>
 776+$offsetGridlinesY</H3>
 777+<PRE>
 778+public integer <B>$offsetGridlinesY</B></PRE>
 779+<DL>
 780+<DD>Offset of first Y axis gridline from lower-left of plot area as a
 781+ fraction of normal gridline spacing.</DL>
 782+<HR>
 783+
 784+<A NAME="$outerPadding"><!-- --></A><H3>
 785+$outerPadding</H3>
 786+<PRE>
 787+public integer <B>$outerPadding</B></PRE>
 788+<DL>
 789+<DD>Padding between outer border of graphic area and text (title and labels).</DL>
 790+<HR>
 791+
 792+<A NAME="$plotHeight"><!-- --></A><H3>
 793+$plotHeight</H3>
 794+<PRE>
 795+public integer <B>$plotHeight</B></PRE>
 796+<DL>
 797+<DD>Height of plot area.</DL>
 798+<HR>
 799+
 800+<A NAME="$plotOffsetX"><!-- --></A><H3>
 801+$plotOffsetX</H3>
 802+<PRE>
 803+public integer <B>$plotOffsetX</B></PRE>
 804+<DL>
 805+<DD>Offset of plot area from left of graphic area.</DL>
 806+<HR>
 807+
 808+<A NAME="$plotOffsetY"><!-- --></A><H3>
 809+$plotOffsetY</H3>
 810+<PRE>
 811+public integer <B>$plotOffsetY</B></PRE>
 812+<DL>
 813+<DD>Offset of plot area from top of graphic area.</DL>
 814+<HR>
 815+
 816+<A NAME="$plotWidth"><!-- --></A><H3>
 817+$plotWidth</H3>
 818+<PRE>
 819+public integer <B>$plotWidth</B></PRE>
 820+<DL>
 821+<DD>Width of plot area.</DL>
 822+<HR>
 823+
 824+<A NAME="$resolutionY"><!-- --></A><H3>
 825+$resolutionY</H3>
 826+<PRE>
 827+public integer <B>$resolutionY</B></PRE>
 828+<DL>
 829+<DD>Resolution for Y axis tags. See notes for method <code>_findRange</code>.</DL>
 830+<HR>
 831+
 832+<A NAME="$rotTagsX"><!-- --></A><H3>
 833+$rotTagsX</H3>
 834+<PRE>
 835+public integer <B>$rotTagsX</B></PRE>
 836+<DL>
 837+<DD>X axis tags rotation. Negative/Anticlockwise.
 838+ Increase innerPaddingX to prevent overlap with plot area.</DL>
 839+<HR>
 840+
 841+<A NAME="$rotTagsY"><!-- --></A><H3>
 842+$rotTagsY</H3>
 843+<PRE>
 844+public integer <B>$rotTagsY</B></PRE>
 845+<DL>
 846+<DD>Y axis tags rotation. Negative/Anticlockwise.
 847+ Increase innerPaddingY to prevent overlap with plot area.</DL>
 848+<HR>
 849+
 850+<A NAME="$styleBarDefault"><!-- --></A><H3>
 851+$styleBarDefault</H3>
 852+<PRE>
 853+public string <B>$styleBarDefault</B></PRE>
 854+<DL>
 855+<DD>Default presentation attributes for bar plots.</DL>
 856+<HR>
 857+
 858+<A NAME="$styleBox"><!-- --></A><H3>
 859+$styleBox</H3>
 860+<PRE>
 861+public string <B>$styleBox</B></PRE>
 862+<DL>
 863+<DD>Presentation attributes for box around plot area.</DL>
 864+<HR>
 865+
 866+<A NAME="$styleBoxDefault"><!-- --></A><H3>
 867+$styleBoxDefault</H3>
 868+<PRE>
 869+public string <B>$styleBoxDefault</B></PRE>
 870+<DL>
 871+<DD>Default presentation attributes for box around plot area.</DL>
 872+<HR>
 873+
 874+<A NAME="$styleGridX"><!-- --></A><H3>
 875+$styleGridX</H3>
 876+<PRE>
 877+public string <B>$styleGridX</B></PRE>
 878+<DL>
 879+<DD>Presentation attributes for grid corresponding to X axis.</DL>
 880+<HR>
 881+
 882+<A NAME="$styleGridXDefault"><!-- --></A><H3>
 883+$styleGridXDefault</H3>
 884+<PRE>
 885+public string <B>$styleGridXDefault</B></PRE>
 886+<DL>
 887+<DD>Default presentation attributes for grid corresponding to X axis.</DL>
 888+<HR>
 889+
 890+<A NAME="$styleGridY"><!-- --></A><H3>
 891+$styleGridY</H3>
 892+<PRE>
 893+public string <B>$styleGridY</B></PRE>
 894+<DL>
 895+<DD>Presentation attributes for grid corresponding to Y axis.</DL>
 896+<HR>
 897+
 898+<A NAME="$styleGridYDefault"><!-- --></A><H3>
 899+$styleGridYDefault</H3>
 900+<PRE>
 901+public string <B>$styleGridYDefault</B></PRE>
 902+<DL>
 903+<DD>Default presentation attributes for grid corresponding to X axis.</DL>
 904+<HR>
 905+
 906+<A NAME="$styleLabelX"><!-- --></A><H3>
 907+$styleLabelX</H3>
 908+<PRE>
 909+public string <B>$styleLabelX</B></PRE>
 910+<DL>
 911+<DD>Presentation attributes for label.</DL>
 912+<HR>
 913+
 914+<A NAME="$styleLabelXDefault"><!-- --></A><H3>
 915+$styleLabelXDefault</H3>
 916+<PRE>
 917+public string <B>$styleLabelXDefault</B></PRE>
 918+<DL>
 919+<DD>Default presentation attributes for label.</DL>
 920+<HR>
 921+
 922+<A NAME="$styleLabelY"><!-- --></A><H3>
 923+$styleLabelY</H3>
 924+<PRE>
 925+public string <B>$styleLabelY</B></PRE>
 926+<DL>
 927+<DD>Presentation attributes for label.</DL>
 928+<HR>
 929+
 930+<A NAME="$styleLabelYDefault"><!-- --></A><H3>
 931+$styleLabelYDefault</H3>
 932+<PRE>
 933+public string <B>$styleLabelYDefault</B></PRE>
 934+<DL>
 935+<DD>Default presentation attributes for label.</DL>
 936+<HR>
 937+
 938+<A NAME="$styleLineDefault"><!-- --></A><H3>
 939+$styleLineDefault</H3>
 940+<PRE>
 941+public string <B>$styleLineDefault</B></PRE>
 942+<DL>
 943+<DD>Default presentation attributes for line plots.</DL>
 944+<HR>
 945+
 946+<A NAME="$stylePolylineDefault"><!-- --></A><H3>
 947+$stylePolylineDefault</H3>
 948+<PRE>
 949+public string <B>$stylePolylineDefault</B></PRE>
 950+<DL>
 951+<DD>Default presentation attributes for polyline plots (inside group tag).</DL>
 952+<HR>
 953+
 954+<A NAME="$styleTagsX"><!-- --></A><H3>
 955+$styleTagsX</H3>
 956+<PRE>
 957+public string <B>$styleTagsX</B></PRE>
 958+<DL>
 959+<DD>Presentation attributes for X axis tags.</DL>
 960+<HR>
 961+
 962+<A NAME="$styleTagsXDefault"><!-- --></A><H3>
 963+$styleTagsXDefault</H3>
 964+<PRE>
 965+public string <B>$styleTagsXDefault</B></PRE>
 966+<DL>
 967+<DD>Default presentation attributes for X axis tags.</DL>
 968+<HR>
 969+
 970+<A NAME="$styleTagsY"><!-- --></A><H3>
 971+$styleTagsY</H3>
 972+<PRE>
 973+public string <B>$styleTagsY</B></PRE>
 974+<DL>
 975+<DD>Presentation attributes for Y axis tags.</DL>
 976+<HR>
 977+
 978+<A NAME="$styleTagsYDefault"><!-- --></A><H3>
 979+$styleTagsYDefault</H3>
 980+<PRE>
 981+public string <B>$styleTagsYDefault</B></PRE>
 982+<DL>
 983+<DD>Default presentation attributes for Y axis tags.</DL>
 984+<HR>
 985+
 986+<A NAME="$styleTitle"><!-- --></A><H3>
 987+$styleTitle</H3>
 988+<PRE>
 989+public string <B>$styleTitle</B></PRE>
 990+<DL>
 991+<DD>Presentation attributes for title.</DL>
 992+<HR>
 993+
 994+<A NAME="$styleTitleDefault"><!-- --></A><H3>
 995+$styleTitleDefault</H3>
 996+<PRE>
 997+public string <B>$styleTitleDefault</B></PRE>
 998+<DL>
 999+<DD>Default presentation attributes for title.</DL>
 1000+<HR>
 1001+
 1002+<A NAME="$svg"><!-- --></A><H3>
 1003+$svg</H3>
 1004+<PRE>
 1005+public string <B>$svg</B></PRE>
 1006+<DL>
 1007+<DD>SVG XML result.</DL>
 1008+<HR>
 1009+
 1010+<A NAME="$title"><!-- --></A><H3>
 1011+$title</H3>
 1012+<PRE>
 1013+public string <B>$title</B></PRE>
 1014+<DL>
 1015+<DD>Title for Graph.</DL>
 1016+
 1017+<!-- ========= CONSTRUCTOR DETAIL ======== -->
 1018+
 1019+<A NAME="constructor_detail"><!-- --></A>
 1020+<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
 1021+<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
 1022+<TD COLSPAN=1><FONT SIZE="+2">
 1023+<B>Constructor Detail</B></FONT></TD>
 1024+</TR>
 1025+</TABLE>
 1026+
 1027+<A NAME="svgGraph()"><!-- --></A><H3>
 1028+svgGraph</H3>
 1029+<PRE>
 1030+public <B>svgGraph</B>()</PRE>
 1031+<DL>
 1032+<DD>Define static variables used in the class.</DL>
 1033+
 1034+<!-- ============ METHOD DETAIL ========== -->
 1035+
 1036+<A NAME="method_detail"><!-- --></A>
 1037+<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
 1038+<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
 1039+<TD COLSPAN=1><FONT SIZE="+2">
 1040+<B>Method Detail</B></FONT></TD>
 1041+</TR>
 1042+</TABLE>
 1043+
 1044+<A NAME="_findRange(var, var, var, var)"><!-- --></A><H3>
 1045+_findRange</H3>
 1046+<PRE>
 1047+private array <B>_findRange</B>(var&nbsp;$data,
 1048+ var&nbsp;$min,
 1049+ var&nbsp;$max,
 1050+ var&nbsp;$resolution)</PRE>
 1051+<DL>
 1052+<DD>Find the maximum and minimum values for a set of data.<br>
 1053+ The $resolution variable is used for rounding maximum and minimum values.<br>
 1054+ If maximum value is 8645 then<br>
 1055+ If $resolution is 0, then maximum value becomes 9000.<br>
 1056+ If $resolution is 1, then maximum value becomes 8700.<br>
 1057+ If $resolution is 2, then maximum value becomes 8650.<br>
 1058+ If $resolution is 3, then maximum value becomes 8645.<br><DD><DL>
 1059+<DT><B>Parameters:</B><DD><CODE>$data</CODE> - Data to find the range for<DD><CODE>$min</CODE> - Minimum value to start at. If a lower number is found then this value is not used.<DD><CODE>$max</CODE> - Maximum value to start at. If a larger number is found then this value is not used.<DD><CODE>$resolution</CODE> - Resolution for range.</DL>
 1060+</DD>
 1061+</DL>
 1062+<HR>
 1063+
 1064+<A NAME="bar(var)"><!-- --></A><H3>
 1065+bar</H3>
 1066+<PRE>
 1067+public boolean <B>bar</B>(var&nbsp;$whichDataSet)</PRE>
 1068+<DL>
 1069+<DD>Draw a bar for each data point from the data set selected.<DD><DL>
 1070+<DT><B>Parameters:</B><DD><CODE>$whichDataSet</CODE> - Which set of data to draw. This is the index of the data array to be used.
 1071+ <br><br>
 1072+ The format parameter array for the selected dataset can have three members:<br>
 1073+ 'style' - Style for bar,<br>
 1074+ 'barWidth' - Width of bar as fraction of distance between gridlines.
 1075+ Values greater than 1 will result in bars overlapping.<br>
 1076+ 'barOffset' - Offset of the bar as fraction of bar width. By default it is centered on the gridline.<DT><B>Returns:</B><DD>BOOLEAN FALSE if style, barWidth, or barOffset parameters are missing.</DL>
 1077+</DD>
 1078+</DL>
 1079+<HR>
 1080+
 1081+<A NAME="drawBox()"><!-- --></A><H3>
 1082+drawBox</H3>
 1083+<PRE>
 1084+public void <B>drawBox</B>()</PRE>
 1085+<DL>
 1086+<DD>Draws the box around the plotting area.</DL>
 1087+<HR>
 1088+
 1089+<A NAME="drawGraph()"><!-- --></A><H3>
 1090+drawGraph</H3>
 1091+<PRE>
 1092+public void <B>drawGraph</B>()</PRE>
 1093+<DL>
 1094+<DD>Calls functions to draw title, labels, tags, grid lines, and box of graph.</DL>
 1095+<HR>
 1096+
 1097+<A NAME="drawGridX()"><!-- --></A><H3>
 1098+drawGridX</H3>
 1099+<PRE>
 1100+public void <B>drawGridX</B>()</PRE>
 1101+<DL>
 1102+<DD>Draws the grid lines from top to bottom in the plotting area.</DL>
 1103+<HR>
 1104+
 1105+<A NAME="drawGridY()"><!-- --></A><H3>
 1106+drawGridY</H3>
 1107+<PRE>
 1108+public void <B>drawGridY</B>()</PRE>
 1109+<DL>
 1110+<DD>Draws the grid lines from right to left in the plotting area.</DL>
 1111+<HR>
 1112+
 1113+<A NAME="drawOuterText()"><!-- --></A><H3>
 1114+drawOuterText</H3>
 1115+<PRE>
 1116+public void <B>drawOuterText</B>()</PRE>
 1117+<DL>
 1118+<DD>Draw the title and axis labels around the outside of the graphic area.</DL>
 1119+<HR>
 1120+
 1121+<A NAME="drawTagsX()"><!-- --></A><H3>
 1122+drawTagsX</H3>
 1123+<PRE>
 1124+public void <B>drawTagsX</B>()</PRE>
 1125+<DL>
 1126+<DD>Draws the axis tag text outside the plotting area on the x axis.</DL>
 1127+<HR>
 1128+
 1129+<A NAME="drawTagsY()"><!-- --></A><H3>
 1130+drawTagsY</H3>
 1131+<PRE>
 1132+public void <B>drawTagsY</B>()</PRE>
 1133+<DL>
 1134+<DD>Draws the axis tag text outside the plotting area on the y axis.</DL>
 1135+<HR>
 1136+
 1137+<A NAME="generateSVG()"><!-- --></A><H3>
 1138+generateSVG</H3>
 1139+<PRE>
 1140+public void <B>generateSVG</B>()</PRE>
 1141+<DL>
 1142+<DD>Generate SVG for entire graph.</DL>
 1143+<HR>
 1144+
 1145+<A NAME="init()"><!-- --></A><H3>
 1146+init</H3>
 1147+<PRE>
 1148+public boolean <B>init</B>()</PRE>
 1149+<DL>
 1150+<DD>Initialises the variables used for drawing points, lines, grid, and ticks in the plotting area.<DD><DL>
 1151+<DT><B>Returns:</B><DD>Boolean - FALSE if an error was encountered while processing data.</DL>
 1152+</DD>
 1153+</DL>
 1154+<HR>
 1155+
 1156+<A NAME="line(var)"><!-- --></A><H3>
 1157+line</H3>
 1158+<PRE>
 1159+public void <B>line</B>(var&nbsp;$whichDataSet)</PRE>
 1160+<DL>
 1161+<DD>Draw line from one point to the next stopping at each.
 1162+ This method is used for drawing lines with markers at each plot point.
 1163+ <br><br>
 1164+ The format parameter array for the selected dataset can have two members:<br>
 1165+ 'style' - Style for line,<br>
 1166+ 'attributes' - Attributes to place inside line tag.<DD><DL>
 1167+<DT><B>Parameters:</B><DD><CODE>$whichDataSet</CODE> - Which set of data to draw. This is the index of the data array to be used.</DL>
 1168+</DD>
 1169+</DL>
 1170+<HR>
 1171+
 1172+<A NAME="outputSVG()"><!-- --></A><H3>
 1173+outputSVG</H3>
 1174+<PRE>
 1175+public void <B>outputSVG</B>()</PRE>
 1176+<DL>
 1177+<DD>Output SVG as XML text including appropriate HTTP header information.</DL>
 1178+<HR>
 1179+
 1180+<A NAME="polyLine(var)"><!-- --></A><H3>
 1181+polyLine</H3>
 1182+<PRE>
 1183+public boolean <B>polyLine</B>(var&nbsp;$whichDataSet)</PRE>
 1184+<DL>
 1185+<DD>Draw a line from one point to the next continuously without stopping to draw markers.
 1186+ This method is used for drawing lines with markers on the end, for example, an arrow indicating trend.
 1187+ <br><br>
 1188+ The format parameter array for the selected dataset can have two members:<br>
 1189+ 'style' - Style for line,<br>
 1190+ 'attributes' - Attributes to place inside polyline tag.<DD><DL>
 1191+<DT><B>Parameters:</B><DD><CODE>$whichDataSet</CODE> - Which set of data to draw. This is the index of the data array to be used.<DT><B>Returns:</B><DD>BOOLEAN FALSE if no style is defined for the data set selected.</DL>
 1192+</DD>
 1193+</DL>
 1194+<!-- ========= END OF CLASS DATA ========= -->
 1195+<HR>
 1196+
 1197+<!-- ========== START OF NAVBAR ========== -->
 1198+<A NAME="navbar_bottom"><!-- --></A>
 1199+<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0">
 1200+<TR>
 1201+<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
 1202+<A NAME="navbar_bottom_firstrow"><!-- --></A>
 1203+<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">
 1204+ <TR ALIGN="center" VALIGN="top">
 1205+ <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
 1206+ </TR>
 1207+</TABLE>
 1208+</TD>
 1209+<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
 1210+</EM>
 1211+</TD>
 1212+</TR>
 1213+
 1214+<TR>
 1215+<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
 1216+&nbsp;PREV CLASS&nbsp;
 1217+&nbsp;NEXT CLASS</FONT></TD>
 1218+<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
 1219+ <A HREF="index.html" TARGET="_top"><B>FRAMES</B></A> &nbsp;
 1220+&nbsp;<A HREF="svgGraph.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD>
 1221+</TR>
 1222+<TR>
 1223+<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
 1224+ SUMMARY: &nbsp;INNER&nbsp;|&nbsp;<A HREF="#field_summary">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
 1225+<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
 1226+DETAIL: &nbsp;<A HREF="#field_detail">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
 1227+</TR>
 1228+</TABLE>
 1229+<!-- =========== END OF NAVBAR =========== -->
 1230+
 1231+<HR>
 1232+
 1233+</BODY>
 1234+</HTML>
Index: trunk/extensions/FlaggedRevs/svggraph/test01.php
@@ -0,0 +1,58 @@
 2+<?php
 3+error_reporting(0);
 4+
 5+include 'svgGraph.php';
 6+include 'svgGraph1.php';
 7+
 8+$graph = new svgGraph1;
 9+$graph->graphicWidth = 400;
 10+$graph->graphicHeight = 300;
 11+$graph->plotWidth = 300;
 12+$graph->plotHeight = 200;
 13+$graph->plotOffsetX = 70;
 14+$graph->plotOffsetY = 50;
 15+$graph->numGridlinesY = 6;
 16+$graph->numTicksY = 6;
 17+
 18+$graph->innerPaddingX = 4;
 19+$graph->innerPaddingY = 4;
 20+$graph->outerPadding = 10;
 21+
 22+$graph->offsetGridlinesX = 0;
 23+
 24+$graph->decimalPlacesY = 2;
 25+
 26+$graph->title = 'Sample Line Graph';
 27+$graph->styleTitle = 'font-family: sans-serif; font-size: 12pt;';
 28+
 29+$graph->labelX = 'Day of the Week';
 30+$graph->styleLabelX = 'font-family: sans-serif; font-size: 10pt;';
 31+$graph->labelY = 'Some Parameters';
 32+$graph->styleLabelY = 'font-family: sans-serif; font-size: 10pt;';
 33+
 34+$graph->dataX = array('Fri', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri');
 35+$graph->dataY['alpha'] = array(8.610, 7.940, 3.670, 3.670, 6.940, 8.650);
 36+$graph->dataY['beta'] = array(1.456, 3.001, 5.145, 2.050, 1.998, 1.678);
 37+$graph->dataY['gamma'] = array(4.896, 4.500, 4.190, 3.050, 2.888, 3.678);
 38+
 39+$graph->styleTagsX = 'font-family: monospace; font-size: 8pt;';
 40+$graph->styleTagsY = 'font-family: monospace; font-size: 8pt;';
 41+
 42+$graph->format['alpha'] = array(
 43+ 'style' => 'stroke:#F00; stroke-width:4;');
 44+
 45+$graph->format['beta'] = array(
 46+ 'style' => 'stroke:#0F0; stroke-width:4;');
 47+
 48+$graph->format['gamma'] = array(
 49+ 'style' => 'stroke:#00F; stroke-width:4;');
 50+
 51+
 52+$graph->init() or die($graph->error);
 53+$graph->drawGraph();
 54+$graph->line('gamma') or die($graph->error);
 55+$graph->line('beta') or die($graph->error);
 56+$graph->line('alpha') or die($graph->error);
 57+
 58+$graph->outputSVG();
 59+?>
\ No newline at end of file
Property changes on: trunk/extensions/FlaggedRevs/svggraph/test01.php
___________________________________________________________________
Added: svn:eol-style
160 + native
Index: trunk/extensions/FlaggedRevs/svggraph/svgGraph.php
@@ -0,0 +1,760 @@
 2+<?php
 3+/**
 4+* This library is free software; you can redistribute it and/or
 5+* modify it under the terms of the GNU Lesser General Public
 6+* License as published by the Free Software Foundation; either
 7+* version 2.1 of the License, or (at your option) any later version.
 8+*
 9+* This library is distributed in the hope that it will be useful,
 10+* but WITHOUT ANY WARRANTY; without even the implied warranty of
 11+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 12+* Lesser General Public License for more details.
 13+*
 14+* You should have received a copy of the GNU Lesser General Public
 15+* License along with this library; if not, write to the Free Software
 16+* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 17+*
 18+* Copy of GNU Lesser General Public License at: http://www.gnu.org/copyleft/lesser.txt
 19+* Contact author at: hveluwenkamp@myrealbox.com
 20+*
 21+*/
 22+
 23+/**
 24+* Takes an array or multiple arrays of data and outputs a graph in SVG format.
 25+* The SVG language allows for a high degree of control of the output,
 26+* thus this class is intended to be extended.
 27+*
 28+* @author Herman Veluwenkamp
 29+* @version 1.2alpha
 30+*/
 31+class svgGraph {
 32+
 33+ /**
 34+ * Total width of svg graphic.
 35+ * @type integer
 36+ * @public
 37+ */
 38+ var $graphicWidth = 0;
 39+
 40+ /**
 41+ * Total height of svg graphic.
 42+ * @type integer
 43+ * @public
 44+ */
 45+ var $graphicHeight = 0;
 46+
 47+ /**
 48+ * Width of plot area.
 49+ * @type integer
 50+ * @public
 51+ */
 52+ var $plotWidth = 0;
 53+
 54+ /**
 55+ * Height of plot area.
 56+ * @type integer
 57+ * @public
 58+ */
 59+ var $plotHeight = 0;
 60+
 61+ /**
 62+ * Offset of plot area from left of graphic area.
 63+ * @type integer
 64+ * @public
 65+ */
 66+ var $plotOffsetX = 0;
 67+
 68+ /**
 69+ * Offset of plot area from top of graphic area.
 70+ * @type integer
 71+ * @public
 72+ */
 73+ var $plotOffsetY = 0;
 74+
 75+ /**
 76+ * Padding between outer border of graphic area and text (title and labels).
 77+ * @type integer
 78+ * @public
 79+ */
 80+ var $outerPadding = 0;
 81+
 82+ /**
 83+ * Padding between bottom border of plot area and text (tags).
 84+ * @type integer
 85+ * @public
 86+ */
 87+ var $innerPaddingX = 0;
 88+
 89+ /**
 90+ * Padding between left border of plot area and text (tags).
 91+ * @type integer
 92+ * @public
 93+ */
 94+ var $innerPaddingY = 0;
 95+
 96+ /**
 97+ * Array of data holding values for X axis
 98+ * @type string
 99+ * @public
 100+ */
 101+ var $dataX = array();
 102+
 103+ /**
 104+ * Two dimensional array holding values for Y axis. The key for each array must be unique.
 105+ * @type string
 106+ * @public
 107+ */
 108+ var $dataY = array();
 109+
 110+ /**
 111+ * Title for Graph.
 112+ * @type string
 113+ * @public
 114+ */
 115+ var $title = '';
 116+
 117+ /**
 118+ * Presentation attributes for title.
 119+ * @type string
 120+ * @public
 121+ */
 122+ var $styleTitle = '';
 123+
 124+ /**
 125+ * Default presentation attributes for title.
 126+ * @type string
 127+ * @public
 128+ */
 129+ var $styleTitleDefault = '';
 130+
 131+ /**
 132+ * Label for X axis.
 133+ * @type string
 134+ * @public
 135+ */
 136+ var $labelX = '';
 137+
 138+ /**
 139+ * Presentation attributes for label.
 140+ * @type string
 141+ * @public
 142+ */
 143+ var $styleLabelX = '';
 144+
 145+ /**
 146+ * Default presentation attributes for label.
 147+ * @type string
 148+ * @public
 149+ */
 150+ var $styleLabelXDefault = '';
 151+
 152+ /**
 153+ * Label for Y axis.
 154+ * @type string
 155+ * @public
 156+ */
 157+ var $labelY = '';
 158+
 159+ /**
 160+ * Presentation attributes for label.
 161+ * @type string
 162+ * @public
 163+ */
 164+ var $styleLabelY = '';
 165+
 166+ /**
 167+ * Default presentation attributes for label.
 168+ * @type string
 169+ * @public
 170+ */
 171+ var $styleLabelYDefault = '';
 172+
 173+ /**
 174+ * Offset of first X axis gridline from lower-left of plot area as a
 175+ * fraction of normal gridline spacing.
 176+ * @type integer
 177+ * @public
 178+ */
 179+ var $offsetGridlinesX = 0;
 180+
 181+ /**
 182+ * Offset of first Y axis gridline from lower-left of plot area as a
 183+ * fraction of normal gridline spacing.
 184+ * @type integer
 185+ * @public
 186+ */
 187+ var $offsetGridlinesY = 0;
 188+
 189+ /**
 190+ * Minimum value for Y axis values. If a lower value is found in data then
 191+ * this value is not used.
 192+ * @type integer
 193+ * @public
 194+ */
 195+ var $minY = 0;
 196+
 197+ /**
 198+ * Maximum value for Y axis values. If a higher value is found in data then
 199+ * this value is not used.
 200+ * @type integer
 201+ * @public
 202+ */
 203+ var $maxY = 0;
 204+
 205+ /**
 206+ * Resolution for Y axis tags. See notes for method <code>_findRange</code>.
 207+ * @type integer
 208+ * @public
 209+ */
 210+ var $resolutionY = 0;
 211+
 212+ /**
 213+ * Number of decimal places to show for Y axis tags.
 214+ * @type integer
 215+ * @public
 216+ */
 217+ var $decimalPlacesY = 0;
 218+
 219+ /**
 220+ * Number of grid lines corresponding to X axis.
 221+ * @type integer
 222+ * @public
 223+ */
 224+ var $numGridlinesX = 0;
 225+
 226+ /**
 227+ * Number of grid lines corresponding to Y axis.
 228+ * @type integer
 229+ * @public
 230+ */
 231+ var $numGridlinesY = 0;
 232+
 233+ /**
 234+ * Presentation attributes for grid corresponding to X axis.
 235+ * @type string
 236+ * @public
 237+ */
 238+ var $styleGridX = '';
 239+
 240+ /**
 241+ * Default presentation attributes for grid corresponding to X axis.
 242+ * @type string
 243+ * @public
 244+ */
 245+ var $styleGridXDefault = '';
 246+
 247+ /**
 248+ * Presentation attributes for grid corresponding to Y axis.
 249+ * @type string
 250+ * @public
 251+ */
 252+ var $styleGridY = '';
 253+
 254+ /**
 255+ * Default presentation attributes for grid corresponding to X axis.
 256+ * @type string
 257+ * @public
 258+ */
 259+ var $styleGridYDefault = '';
 260+
 261+ /**
 262+ * Presentation attributes for box around plot area.
 263+ * @type string
 264+ * @public
 265+ */
 266+ var $styleBox = '';
 267+
 268+ /**
 269+ * Default presentation attributes for box around plot area.
 270+ * @type string
 271+ * @public
 272+ */
 273+ var $styleBoxDefault = '';
 274+
 275+ /**
 276+ * Presentation attributes for X axis tags.
 277+ * @type string
 278+ * @public
 279+ */
 280+ var $styleTagsX = '';
 281+
 282+ /**
 283+ * Default presentation attributes for X axis tags.
 284+ * @type string
 285+ * @public
 286+ */
 287+ var $styleTagsXDefault = '';
 288+
 289+ /**
 290+ * X axis tags rotation. Negative/Anticlockwise.
 291+ * Increase innerPaddingX to prevent overlap with plot area.
 292+ * @type integer
 293+ * @public
 294+ */
 295+ var $rotTagsX = 0;
 296+
 297+ /**
 298+ * Presentation attributes for Y axis tags.
 299+ * @type string
 300+ * @public
 301+ */
 302+ var $styleTagsY = '';
 303+
 304+ /**
 305+ * Default presentation attributes for Y axis tags.
 306+ * @type string
 307+ * @public
 308+ */
 309+ var $styleTagsYDefault = '';
 310+
 311+ /**
 312+ * Y axis tags rotation. Negative/Anticlockwise.
 313+ * Increase innerPaddingY to prevent overlap with plot area.
 314+ * @type integer
 315+ * @public
 316+ */
 317+ var $rotTagsY = 0;
 318+
 319+ /**
 320+ * Default presentation attributes for line plots.
 321+ * @type string
 322+ * @public
 323+ */
 324+ var $styleLineDefault = '';
 325+
 326+ /**
 327+ * Default presentation attributes for bar plots.
 328+ * @type string
 329+ * @public
 330+ */
 331+ var $styleBarDefault = '';
 332+
 333+ /**
 334+ * Default presentation attributes for polyline plots (inside group tag).
 335+ * @type string
 336+ * @public
 337+ */
 338+ var $stylePolylineDefault = '';
 339+
 340+ /**
 341+ * Extra SVG to add to graph. e.g. Filters, Defs, Title.
 342+ * Note: Title is useful to add if image is viewed out of context.
 343+ * <dt><code>$svg</code><dd>
 344+ * String holding SVG text.
 345+ * </dl>
 346+ * @type string
 347+ * @public
 348+ */
 349+ var $extraSVG = '';
 350+
 351+ /**
 352+ * SVG XML result.
 353+ * @type string
 354+ * @public
 355+ */
 356+ var $svg = '';
 357+
 358+ /**
 359+ * Contains error messages.
 360+ * @type string
 361+ * @public
 362+ */
 363+ var $error = '';
 364+
 365+
 366+ /**
 367+ * Define static variables used in the class.
 368+ * @returns void
 369+ */
 370+ function svgGraph() {
 371+ if( !defined("DECIMAL_POINT") )
 372+ define("DECIMAL_POINT", ".");
 373+ if( !defined("THOUSANDS_SEPERATOR") )
 374+ define("THOUSANDS_SEPERATOR", ",");
 375+ }
 376+
 377+ /**
 378+ * Initialises the variables used for drawing points, lines, grid, and ticks in the plotting area.
 379+ * @return Boolean - FALSE if an error was encountered while processing data.
 380+ * @returns boolean
 381+ */
 382+ function init() {
 383+ $this->svg = ''; // complete SVG of graph
 384+ $this->svgText = ''; // SVG for outer text labels and title
 385+ $this->svgPlot = ''; // SVG for plot including tag text
 386+ $this->numGridlinesX = sizeof($this->dataX);
 387+ if ($this->numGridlinesX == 0) {
 388+ $this->error = 'No data to plot. Check data.';
 389+ return FALSE;
 390+ }
 391+ if ($this->numGridlinesY == 0) {
 392+ $this->error = 'No range for Y values. Check number of Y ticks.';
 393+ return FALSE;
 394+ }
 395+ $width = $this->plotWidth - 1;
 396+ $height = $this->plotHeight - 1;
 397+
 398+ // find range of all y values
 399+ $allDataY = array();
 400+ foreach ($this->dataY as $i => $dataY) $allDataY = array_merge($allDataY, $dataY);
 401+ $this->allDataY = $allDataY;
 402+ $data = $this->_findRange($allDataY, $this->minY, $this->maxY, $this->resolutionY);
 403+ $this->dataMinY = $data['min'];
 404+ $this->dataMaxY = $data['max'];
 405+ if (($this->dataMaxY - $this->dataMinY) == 0) {
 406+ $this->error = 'No range to plot. Check data.';
 407+ return FALSE; // data error
 408+ }
 409+ // find spacing for ticks and grid lines
 410+ $this->deltaTicksX = $width / ($this->numGridlinesX - 1 + (2 * $this->offsetGridlinesX));
 411+ $this->deltaTicksY = $height / ($this->numGridlinesY - 1 + (2 * $this->offsetGridlinesY));
 412+ $this->factorY = $height / ($this->dataMaxY - $this->dataMinY);
 413+
 414+ // format text for tags on Y axis
 415+ //$deltaTagsY = $this->dataMaxY / ($this->numGridlinesY - 1 + (2 * $this->offsetGridlinesY));
 416+ $deltaTagsY = ($this->dataMaxY - $this->dataMinY) / ($this->numGridlinesY - 1 + (2 * $this->offsetGridlinesY));
 417+ //$factorTagsY = $this->dataMaxY / ($this->dataMaxY - $this->dataMinY);
 418+ for ($i=0; $i<$this->numGridlinesY; $i++) {
 419+ $text = $this->dataMinY + $deltaTagsY * ($i + $this->offsetGridlinesY);
 420+ $this->tagsY[$i] = number_format($text, $this->decimalPlacesY, DECIMAL_POINT, THOUSANDS_SEPERATOR);
 421+ }
 422+ $this->tagsY = array_reverse($this->tagsY);
 423+ if (empty($this->tagsY)) {
 424+ $this->error = 'No Y axis data.';
 425+ return FALSE;
 426+ }
 427+ return TRUE;
 428+ }
 429+
 430+ /**
 431+ * Calls functions to draw title, labels, tags, grid lines, and box of graph.
 432+ * @returns void
 433+ */
 434+ function drawGraph() {
 435+ $this->drawOuterText();
 436+ $this->drawGridX();
 437+ $this->drawGridY();
 438+ $this->drawBox();
 439+ $this->drawTagsX();
 440+ $this->drawTagsY();
 441+ }
 442+
 443+ /**
 444+ * Draw the title and axis labels around the outside of the graphic area.
 445+ * @returns void
 446+ */
 447+ function drawOuterText() {
 448+ $outerPadding = $this->outerPadding;
 449+
 450+ // draw title
 451+ if (!empty($this->title)) { // check if there is something to draw
 452+ $offset = $this->graphicWidth / 2;
 453+ $transform = "transform='translate(0, $outerPadding)'";
 454+ $this->svgText .= "<text text-anchor='middle' $transform x='$offset' y='1em' ";
 455+ $this->svgText .= "style='{$this->styleTitleDefault}{$this->styleTitle}'>";
 456+ $this->svgText .= "{$this->title}</text>\n";
 457+ }
 458+
 459+ //draw label Y
 460+ if (!empty($this->labelY)) { // check if there is something to draw
 461+ $offset = $this->plotOffsetY + ($this->plotHeight / 2);
 462+ $transform = "transform='translate($outerPadding, 0) rotate(-90 0 $offset)'";
 463+ $this->svgText .= "<text text-anchor='middle' $transform x='0' y='$offset' dy='1em' ";
 464+ $this->svgText .= "style='{$this->styleLabelYDefault}{$this->styleLabelY}'>";
 465+ $this->svgText .= "{$this->labelY}</text>\n";
 466+ }
 467+
 468+ //draw label X
 469+ if (!empty($this->labelX)) { // check if there is something to draw
 470+ $offset = $this->plotOffsetX + ($this->plotWidth / 2);
 471+ $transform = "transform='translate(0, -$outerPadding)'";
 472+ $this->svgText .= "<text text-anchor='middle' $transform x='$offset' y='{$this->graphicHeight}' ";
 473+ $this->svgText .= "style='{$this->styleLabelXDefault}{$this->styleLabelX}'>";
 474+ $this->svgText .= "{$this->labelX}</text>\n";
 475+ }
 476+ }
 477+
 478+ /**
 479+ * Draws the grid lines from top to bottom in the plotting area.
 480+ * @returns void
 481+ */
 482+ function drawGridX() {
 483+ $this->svgPlot .= "<g style='{$this->styleGridXDefault}{$this->styleGridX}'>\n";
 484+ $top = 0;
 485+ $bottom = $this->plotHeight - 1;
 486+ foreach ($this->dataX as $i => $x) {
 487+ $u = $this->deltaTicksX * ($i + $this->offsetGridlinesX);
 488+ $this->svgPlot .= "<line x1='$u' y1='$top' x2='$u' y2='$bottom'/>\n";
 489+ }
 490+ $this->svgPlot .= "</g>\n";
 491+ }
 492+
 493+ /**
 494+ * Draws the grid lines from right to left in the plotting area.
 495+ * @returns void
 496+ */
 497+ function drawGridY() {
 498+ $this->svgPlot .= "<g style='{$this->styleGridYDefault}{$this->styleGridX}'>\n";
 499+ $left = 0;
 500+ $right = $this->plotWidth - 1;
 501+ for ($i = 0; $i < $this->numGridlinesY; $i++) {
 502+ $v = $this->deltaTicksY * ($i + $this->offsetGridlinesY);
 503+ $this->svgPlot .= "<line x1='$left' y1='$v' x2='$right' y2='$v'/>\n";
 504+ }
 505+ $this->svgPlot .= "</g>\n";
 506+ }
 507+
 508+ /**
 509+ * Draws the box around the plotting area.
 510+ * @returns void
 511+ */
 512+ function drawBox() {
 513+ $width = $this->plotWidth - 1;
 514+ $height = $this->plotHeight - 1;
 515+ $this->svgPlot .= "<g style='{$this->styleBoxDefault}{$this->styleBox}'>\n";
 516+ $this->svgPlot .= "<line x1='0' y1='0' x2='$width' y2='0'/>\n";
 517+ $this->svgPlot .= "<line x1='0' y1='$height' x2='$width' y2='$height'/>\n";
 518+ $this->svgPlot .= "<line x1='$width' y1='0' x2='$width' y2='$height'/>\n";
 519+ $this->svgPlot .= "<line x1='0' y1='0' x2='0' y2='$height'/>\n";
 520+ $this->svgPlot .= "</g>\n";
 521+ }
 522+
 523+ /**
 524+ * Draws the axis tag text outside the plotting area on the x axis.
 525+ * @returns void
 526+ */
 527+ function drawTagsX() {
 528+ $this->svgPlot .= "<g style='{$this->styleTagsXDefault}{$this->styleTagsX}'>\n";
 529+ $bottom = $this->plotHeight - 1;
 530+ $innerPadding = $this->innerPaddingX;
 531+
 532+ foreach ($this->dataX as $i => $text) {
 533+ $u = $this->deltaTicksX * ($i + $this->offsetGridlinesX);
 534+
 535+ if ($this->rotTagsX == 0) {
 536+ $transform = "transform='translate(0, $innerPadding)'";
 537+ $this->svgPlot .= "<text text-anchor='middle' $transform dy='1em' x='$u' y='$bottom'>$text</text>\n";
 538+ } else if($this->rotTagsX > 0) {
 539+ $transform = "transform='translate(0, $innerPadding) rotate({$this->rotTagsX} $u $bottom)'";
 540+ $this->svgPlot .= "<text text-anchor='start' $transform x='$u' y='$bottom'>$text</text>\n";
 541+ } else {
 542+ $transform = "transform='translate(0, $innerPadding) rotate({$this->rotTagsX} $u $bottom)'";
 543+ $this->svgPlot .= "<text text-anchor='end' $transform x='$u' y='$bottom'>$text</text>\n";
 544+ }
 545+ }
 546+ $this->svgPlot .= "</g>\n";
 547+ }
 548+
 549+ /**
 550+ * Draws the axis tag text outside the plotting area on the y axis.
 551+ * @returns void
 552+ */
 553+ function drawTagsY() {
 554+ if (empty($this->tagsY)) return; // no data to plot. error should be picked up by init method.
 555+ $this->svgPlot .= "<g style='{$this->styleTagsYDefault}{$this->styleTagsY}'>\n";
 556+ $innerPadding = $this->innerPaddingY;
 557+ foreach ($this->tagsY as $i => $text) {
 558+ $v = $this->deltaTicksY * ($i + $this->offsetGridlinesY);
 559+ if ($this->rotTagsY == 0) {
 560+ $transform = "transform='translate(-$innerPadding, 0)'";
 561+ $this->svgPlot .= "<text text-anchor='end' $transform x='0' dy='0.5em' y='$v'>$text</text>\n";
 562+ } else {
 563+ $transform = "transform='translate(-$innerPadding, 0) rotate({$this->rotTagsY} 0 $v)'";
 564+ $this->svgPlot .= "<text text-anchor='end' $transform x='0' dy='0.5em' y='$v'>$text</text>\n";
 565+ }
 566+ }
 567+ $this->svgPlot .= "</g>\n";
 568+ }
 569+
 570+ /**
 571+ * Draw a line from one point to the next continuously without stopping to draw markers.
 572+ * This method is used for drawing lines with markers on the end, for example, an arrow indicating trend.
 573+ * <br><br>
 574+ * The format parameter array for the selected dataset can have two members:<br>
 575+ * 'style' - Style for line,<br>
 576+ * 'attributes' - Attributes to place inside polyline tag.
 577+ * @param $whichDataSet Which set of data to draw. This is the index of the data array to be used.
 578+ * @return BOOLEAN FALSE if no style is defined for the data set selected.
 579+ * @returns boolean
 580+ */
 581+ function polyLine($whichDataSet) {
 582+ if (empty($this->format[$whichDataSet]['style'])) {
 583+ $this->error = 'No style defined for data plot.';
 584+ return FALSE; // data error
 585+ }
 586+ $attributes = empty($this->format[$whichDataSet]['attributes']) ?
 587+ '' : $this->format[$whichDataSet]['attributes'];
 588+
 589+ $this->svgPlot .= "<g style='{$this->stylePolylineDefault}{$this->format[$whichDataSet]['style']}'>\n";
 590+ $this->svgPlot .= "<polyline $attributes ";
 591+ $u = 0;
 592+ $v = 0;
 593+ foreach ($this->dataX as $i => $x) {
 594+ $y = $this->dataY[$whichDataSet][$i];
 595+ $u = $this->deltaTicksX * ($i + $this->offsetGridlinesX);
 596+ $v = $this->factorY * ($y - $this->dataMinY);
 597+ $v = $this->plotHeight - $v;
 598+ if ($i==0) $this->svgPlot .= "points='$u,$v";
 599+ else $this->svgPlot .= " $u,$v ";
 600+ $oldU = $u;
 601+ $oldV = $v;
 602+ }
 603+ $this->svgPlot .= "'/>\n</g>\n";
 604+ return TRUE;
 605+ }
 606+
 607+ /**
 608+ * Draw line from one point to the next stopping at each.
 609+ * This method is used for drawing lines with markers at each plot point.
 610+ * <br><br>
 611+ * The format parameter array for the selected dataset can have two members:<br>
 612+ * 'style' - Style for line,<br>
 613+ * 'attributes' - Attributes to place inside line tag.
 614+ * @param $whichDataSet Which set of data to draw. This is the index of the data array to be used.
 615+ * @returns void
 616+ */
 617+ function line($whichDataSet) {
 618+ if (empty($this->format[$whichDataSet]['style'])) {
 619+ $this->error = 'No style defined for data plot. Check parameters.';
 620+ return FALSE; // data error
 621+ }
 622+
 623+ $attributes = empty($this->format[$whichDataSet]['attributes']) ?
 624+ '' : $this->format[$whichDataSet]['attributes'];
 625+ $this->svgPlot .= "<g style='{$this->styleLineDefault}{$this->format[$whichDataSet]['style']}'>\n";
 626+ $u = 0;
 627+ $v = 0;
 628+ foreach ($this->dataX as $i => $x) {
 629+ $y = $this->dataY[$whichDataSet][$i];
 630+ $u = $this->deltaTicksX * ($i + $this->offsetGridlinesX);
 631+ $v = $this->factorY * ($y - $this->dataMinY);
 632+ $v = $this->plotHeight - $v;
 633+ if ($i==0) {
 634+ $oldU = $u;
 635+ $oldV = $v;
 636+ }
 637+ $this->svgPlot .= "<line $attributes x1='$oldU' y1='$oldV' x2='$u' y2='$v'/>\n";
 638+ $oldU = $u;
 639+ $oldV = $v;
 640+ }
 641+ $this->svgPlot .= "</g>\n";
 642+ return TRUE;
 643+ }
 644+
 645+ /**
 646+ * Draw a bar for each data point from the data set selected.
 647+ * @param $whichDataSet Which set of data to draw. This is the index of the data array to be used.
 648+ * <br><br>
 649+ * The format parameter array for the selected dataset can have three members:<br>
 650+ * 'style' - Style for bar,<br>
 651+ * 'barWidth' - Width of bar as fraction of distance between gridlines.
 652+ * Values greater than 1 will result in bars overlapping.<br>
 653+ * 'barOffset' - Offset of the bar as fraction of bar width. By default it is centered on the gridline.
 654+ * @return BOOLEAN FALSE if style, barWidth, or barOffset parameters are missing.
 655+ * @returns boolean
 656+ */
 657+ function bar($whichDataSet) {
 658+ if (!isset($this->format[$whichDataSet]['style']) ||
 659+ !isset($this->format[$whichDataSet]['barWidth']) ||
 660+ !isset($this->format[$whichDataSet]['barOffset'] )) {
 661+ $this->error = 'Style parameters missing for bar plot.';
 662+ return FALSE; // data error
 663+ }
 664+ $this->svgPlot .= "<g style='{$this->styleBarDefault}{$this->format[$whichDataSet]['style']}'>\n";
 665+ $barWidth = $this->format[$whichDataSet]['barWidth'] * $this->deltaTicksX;
 666+ $barOffset = $this->format[$whichDataSet]['barOffset'] * $barWidth;
 667+ $u = 0;
 668+ $v = 0;
 669+ foreach ($this->dataX as $i => $x) {
 670+ $y = $this->dataY[$whichDataSet][$i];
 671+ $u = $this->deltaTicksX * ($i + $this->offsetGridlinesX) - ($barWidth / 2) + $barOffset;
 672+ $v = $this->factorY * ($y - $this->dataMinY);
 673+ $v = $this->plotHeight - $v;
 674+ $height = $this->factorY * ($y - $this->dataMinY) - 1;
 675+
 676+ $this->svgPlot .= "<rect x='$u' y='$v' width='$barWidth' height='$height'/>\n";
 677+ }
 678+ $this->svgPlot .= "</g>\n";
 679+ return TRUE;
 680+ }
 681+
 682+ /**
 683+ * Find the maximum and minimum values for a set of data.<br>
 684+ * The $resolution variable is used for rounding maximum and minimum values.<br>
 685+ * If maximum value is 8645 then<br>
 686+ * If $resolution is 0, then maximum value becomes 9000.<br>
 687+ * If $resolution is 1, then maximum value becomes 8700.<br>
 688+ * If $resolution is 2, then maximum value becomes 8650.<br>
 689+ * If $resolution is 3, then maximum value becomes 8645.<br>
 690+ * @param $data Data to find the range for
 691+ * @param $min Minimum value to start at. If a lower number is found then this value is not used.
 692+ * @param $max Maximum value to start at. If a larger number is found then this value is not used.
 693+ * @param $resolution Resolution for range.
 694+ * @returns array
 695+ * @private
 696+ */
 697+ function _findRange($data, $min, $max, $resolution) {
 698+ if (sizeof($data) == 0 ) return array('min' => 0, 'max' => 0);
 699+ foreach ($data as $key => $value) {
 700+ if ($value=='none') continue;
 701+ if ($value > $max) $max = $value;
 702+ if ($value < $min) $min = $value;
 703+ }
 704+ if ($max == 0) {
 705+ $factor = 1;
 706+ } else {
 707+ if ($max < 0) $factor = - pow(10, (floor(log10(abs($max))) + $resolution) );
 708+ else $factor = pow(10, (floor(log10(abs($max))) - $resolution) );
 709+ }
 710+ $max = $factor * @ceil($max / $factor);
 711+ $min = $factor * @floor($min / $factor);
 712+
 713+ return array('min' => $min, 'max' => $max);
 714+ }
 715+
 716+ /**
 717+ * Generate SVG for entire graph.
 718+ * @returns void
 719+ */
 720+ function generateSVG() { //enableZoomAndPanControls='false'
 721+ $this->svg = "<?xml version='1.0' encoding='iso-8859-1'?>\n";
 722+ $this->svg .= "<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 20000303 Stylable//EN' ";
 723+ $this->svg .= "'http://www.w3.org/TR/2000/03/WD-SVG-20000303/DTD/svg-20000303-stylable.dtd'>\n";
 724+ $this->svg .= "<svg width='{$this->graphicWidth}' height='{$this->graphicHeight}'>\n";
 725+
 726+ if (!empty($this->extraSVG)) {
 727+ $this->svg .= "<!-- Extra SVG -->\n";
 728+ $this->svg .= $this->extraSVG."\n";
 729+ $this->svg .= "<!-- End Extra SVG -->\n";
 730+ }
 731+
 732+ if (!empty($this->svgText)) {
 733+ $this->svg .= "<!-- Outer Text -->\n";
 734+ $this->svg .= "<g>\n";
 735+ $this->svg .= $this->svgText."\n";
 736+ $this->svg .= "</g>\n" ;
 737+ $this->svg .= "<!-- End Outer Text -->\n";
 738+ }
 739+
 740+ $this->svg .= "<!-- Plot Area -->\n";
 741+ $this->svg .= "<g transform='translate({$this->plotOffsetX},{$this->plotOffsetY})'>\n";
 742+ $this->svg .= $this->svgPlot."\n";
 743+ $this->svg .= "</g>\n" ;
 744+ $this->svg .= "<!-- End Plot Area -->\n";
 745+
 746+ $this->svg .= "</svg>\n" ;
 747+ }
 748+
 749+ /**
 750+ * Output SVG as XML text including appropriate HTTP header information.
 751+ * @returns void
 752+ */
 753+ function outputSVG() {
 754+ if (empty($this->svg)) $this->generateSVG();
 755+ header("Content-type: image/svg+xml");
 756+ print $this->svg;
 757+ }
 758+
 759+}
 760+
 761+?>
Property changes on: trunk/extensions/FlaggedRevs/svggraph/svgGraph.php
___________________________________________________________________
Added: svn:eol-style
1762 + native
Index: trunk/extensions/FlaggedRevs/svggraph/test02.php
@@ -0,0 +1,58 @@
 2+<?php
 3+error_reporting(0);
 4+
 5+include 'svgGraph.php';
 6+include 'svgGraph1.php';
 7+
 8+$graph = new svgGraph1;
 9+$graph->graphicWidth = 400;
 10+$graph->graphicHeight = 300;
 11+$graph->plotWidth = 300;
 12+$graph->plotHeight = 200;
 13+$graph->plotOffsetX = 70;
 14+$graph->plotOffsetY = 50;
 15+$graph->numGridlinesY = 6;
 16+$graph->numTicksY = 6;
 17+
 18+$graph->innerPaddingX = 4;
 19+$graph->innerPaddingY = 4;
 20+$graph->outerPadding = 10;
 21+
 22+$graph->offsetGridlinesX = 0.5; // shift so that bars are inside plot area
 23+
 24+$graph->decimalPlacesY = 2;
 25+
 26+$graph->title = 'Sample Bar Graph';
 27+$graph->styleTitle = 'font-family: sans-serif; font-size: 12pt;';
 28+
 29+$graph->labelX = 'Day of the Week';
 30+$graph->styleLabelX = 'font-family: sans-serif; font-size: 10pt;';
 31+$graph->labelY = 'Some Parameters';
 32+$graph->styleLabelY = 'font-family: sans-serif; font-size: 10pt;';
 33+
 34+$graph->dataX = array('Fri', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri');
 35+$graph->dataY['alpha'] = array(8.610, 7.940, 3.670, 3.670, 6.940, 8.650);
 36+$graph->dataY['beta'] = array(1.456, 3.001, 5.145, 2.050, 1.998, 1.678);
 37+$graph->dataY['gamma'] = array(4.896, 4.500, 4.190, 3.050, 2.888, 3.678);
 38+
 39+$graph->styleTagsX = 'font-family: monospace; font-size: 8pt;';
 40+$graph->styleTagsY = 'font-family: monospace; font-size: 8pt;';
 41+
 42+$graph->format['alpha'] = array(
 43+ 'style' => 'fill:#F00', 'barWidth' => 0.25, 'barOffset' => -0.5);
 44+
 45+$graph->format['beta'] = array(
 46+ 'style' => 'fill:#0F0', 'barWidth' => 0.25, 'barOffset' => 0);
 47+
 48+$graph->format['gamma'] = array(
 49+ 'style' => 'fill:#00F', 'barWidth' => 0.25, 'barOffset' => 0.5);
 50+
 51+
 52+$graph->init() or die($graph->error);
 53+$graph->drawGraph();
 54+$graph->bar('gamma') or die($graph->error);
 55+$graph->bar('beta') or die($graph->error);
 56+$graph->bar('alpha') or die($graph->error);
 57+
 58+$graph->outputSVG();
 59+?>
\ No newline at end of file
Property changes on: trunk/extensions/FlaggedRevs/svggraph/test02.php
___________________________________________________________________
Added: svn:eol-style
160 + native
Index: trunk/extensions/FlaggedRevs/svggraph/svgGraph1.php
@@ -0,0 +1,62 @@
 2+<?php
 3+/**
 4+* Extension to svgGraph.
 5+* Defines default presentation attributes to use for all graphs instantiating this class.<br>
 6+* <pre>
 7+* Here are some style attributes to get started with.
 8+*
 9+* A &lt;color&gt; can be a numerical RGB specification.
 10+* eg: rgb(0-100%, 0-100%, 0-100%) | rgb(0..255,0..255,0..255) | #rgb | #rrggbb )
 11+*
 12+* Presentation attributes for filling and stroking:
 13+* fill (none | currentColor | &lt;color&gt; )
 14+* fill-opacity % Opacity Value;
 15+* stroke (none | currentColor | &lt;color&gt; )
 16+* stroke-dasharray % Stroke Dash Array
 17+* stroke-dashoffset % Stroke Dash Offset
 18+* stroke-linecap (butt | round | square | inherit)
 19+* stroke-linejoin (miter | round | bevel | inherit)
 20+* stroke-miterlimit % StrokeMiterLimitValue;
 21+* stroke-opacity % Opacity
 22+* stroke-width % Stroke Width
 23+*
 24+* Presentation attributes for graphics:
 25+* shape-rendering (auto | optimizeSpeed | crispEdges | geometricPrecision | inherit)
 26+* text-rendering (auto | optimizeSpeed | optimizeLegibility | geometricPrecision | inherit)
 27+*
 28+* Font Selection attributes:
 29+* font-family (serif | sans-serif | monospace)
 30+* font-style (normal | italic | oblique | inherit)
 31+* font-variant (normal | small-caps | inherit)
 32+* font-weight (normal | bold | bolder | lighter | 100..900 | inherit)
 33+*
 34+* </pre>
 35+*/
 36+class svgGraph1 extends svgGraph { var
 37+ $graphicWidth = 400,
 38+ $graphicHeight = 300,
 39+
 40+ $plotWidth = 300,
 41+ $plotHeight = 200,
 42+ $plotOffsetX = 60,
 43+ $plotOffsetY = 40,
 44+
 45+ $styleTitleDefault = 'text-rendering: optimizeSpeed; ',
 46+ $styleLabelXDefault = 'text-rendering: optimizeSpeed; ',
 47+ $styleLabelYDefault = 'text-rendering: optimizeSpeed; ',
 48+
 49+ $styleTagsXDefault = 'text-rendering: optimizeLegibility; ',
 50+ $styleTagsYDefault = 'text-rendering: optimizeLegibility; ',
 51+
 52+ $styleGridXDefault = 'shape-rendering: crispEdges; stroke:#ccc; stroke-width:1; ',
 53+ $styleGridYDefault = 'shape-rendering: crispEdges; stroke:#ccc; stroke-width:1; ',
 54+ $styleBoxDefault = 'shape-rendering: crispEdges; stroke:#000; stroke-width:1; ',
 55+
 56+ $styleLineDefault = 'shape-rendering: geometricPrecision; stroke-linecap: round; ', // smooth lines with round edges
 57+ $stylePolylineDefault = 'shape-rendering: geometricPrecision; fill:none; ', // don't fill area in
 58+ $styleBarDefault = 'shape-rendering: crispEdges; stroke:#000; stroke-width:1; ', //crisp black border
 59+
 60+ $error = '';
 61+}
 62+
 63+?>
\ No newline at end of file
Property changes on: trunk/extensions/FlaggedRevs/svggraph/svgGraph1.php
___________________________________________________________________
Added: svn:eol-style
164 + native
Index: trunk/extensions/FlaggedRevs/svggraph/test03.php
@@ -0,0 +1,93 @@
 2+<?php
 3+error_reporting(0);
 4+
 5+include 'svgGraph.php';
 6+include 'svgGraph2.php';
 7+
 8+$graph = new svgGraph2;
 9+$graph->graphicWidth = 400;
 10+$graph->graphicHeight = 300;
 11+$graph->plotWidth = 300;
 12+$graph->plotHeight = 180;
 13+$graph->plotOffsetX = 70;
 14+$graph->plotOffsetY = 50;
 15+$graph->numGridlinesY = 6;
 16+$graph->numTicksY = 6;
 17+
 18+$graph->innerPaddingX = 10;
 19+$graph->innerPaddingY = 6;
 20+$graph->outerPadding = 10;
 21+
 22+$graph->offsetGridlinesX = 0.2;
 23+
 24+$graph->decimalPlacesY = 2;
 25+
 26+$graph->rotTagsX = -30;
 27+$graph->rotTagsY = 0;
 28+
 29+
 30+$graph->title = 'Lines with Markers and Filters';
 31+$graph->styleTitle = 'font-family: sans-serif; font-size: 18pt;';
 32+
 33+$graph->labelX = 'Day of the Week';
 34+$graph->styleLabelX = 'font-family: sans-serif; font-size: 10pt;';
 35+$graph->labelY = 'Some Parameters';
 36+$graph->styleLabelY = 'font-family: sans-serif; font-size: 10pt;';
 37+
 38+$graph->dataX = array('Friday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday');
 39+$graph->dataY['alpha'] = array(8.610, 7.940, 3.670, 3.670, 6.940, 8.650);
 40+$graph->dataY['beta'] = array(1.456, 3.001, 5.145, 2.050, 1.998, 1.678);
 41+$graph->dataY['gamma'] = array(4.896, 4.500, 4.190, 3.050, 2.888, 3.678);
 42+
 43+$graph->styleTagsX = 'font-family: sans-serif; font-size: 8pt;';
 44+$graph->styleTagsY = 'font-family: sans-serif; font-size: 8pt;';
 45+
 46+$graph->format['alpha'] = array(
 47+ 'style' => 'stroke:#F00; stroke-width:2; filter:url(#dropShadow); ',
 48+ 'attributes' => "marker-end='url(#square)'");
 49+
 50+$graph->format['beta'] = array(
 51+ 'style' => 'stroke:#0F0; stroke-width:2; filter:url(#dropShadow); ',
 52+ 'attributes' => "marker-end='url(#circle)'");
 53+
 54+$graph->format['gamma'] = array(
 55+ 'style' => 'stroke:#00F; stroke-width:2; filter:url(#dropShadow); ',
 56+ 'attributes' => "marker-end='url(#triangle)'");
 57+
 58+// extra code for markers
 59+$graph->extraSVG = '
 60+<defs>
 61+ <marker id="square" style="stroke:#000; stroke-width:0; fill:#F00; "
 62+ viewBox="0 0 10 10" refX="5" refY="5" orient="0"
 63+ markerUnits="strokeWidth" markerWidth="4" markerHeight="4">
 64+ <rect x="0" y="0" width="10" height="10"/>
 65+ </marker>
 66+ <marker id="circle" style="stroke:#000; stroke-width:0; fill:#0F0; "
 67+ viewBox="0 0 10 10" refX="5" refY="5" orient="0"
 68+ markerUnits="strokeWidth" markerWidth="5" markerHeight="5">
 69+ <circle cx="5" cy="5" r="4"/>
 70+ </marker>
 71+ <marker id="triangle" style="stroke:#000; stroke-width:0; fill:#00F; "
 72+ viewBox="0 0 10 10" refX="5" refY="5" orient="-90"
 73+ markerUnits="strokeWidth" markerWidth="5" markerHeight="5">
 74+ <path d="M 2 0 L 10 5 L 2 10 z" />
 75+ </marker>
 76+</defs>
 77+<filter id="dropShadow" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="130%" height="130%">
 78+ <feGaussianBlur in="SourceAlpha" stdDeviation="2" result="blur"/>
 79+ <feOffset in="blur" dx="2" dy="2" result="offsetBlur"/>
 80+ <feMerge>
 81+ <feMergeNode in="offsetBlur"/>
 82+ <feMergeNode in="SourceGraphic"/>
 83+ </feMerge>
 84+</filter>
 85+';
 86+
 87+$graph->init() or die($graph->error);
 88+$graph->drawGraph();
 89+$graph->line('gamma') or die($graph->error);
 90+$graph->line('beta') or die($graph->error);
 91+$graph->line('alpha') or die($graph->error);
 92+
 93+$graph->outputSVG();
 94+?>
\ No newline at end of file
Property changes on: trunk/extensions/FlaggedRevs/svggraph/test03.php
___________________________________________________________________
Added: svn:eol-style
195 + native
Index: trunk/extensions/FlaggedRevs/svggraph/svgGraph2.php
@@ -0,0 +1,62 @@
 2+<?php
 3+/**
 4+* Extension to svgGraph.
 5+* Defines default presentation attributes to use for all graphs instantiating this class.<br>
 6+* <pre>
 7+* Here are some style attributes to get started with.
 8+*
 9+* A &lt;color&gt; can be a numerical RGB specification.
 10+* eg: rgb(0-100%, 0-100%, 0-100%) | rgb(0..255,0..255,0..255) | #rgb | #rrggbb )
 11+*
 12+* Presentation attributes for filling and stroking:
 13+* fill (none | currentColor | &lt;color&gt; )
 14+* fill-opacity % Opacity Value;
 15+* stroke (none | currentColor | &lt;color&gt; )
 16+* stroke-dasharray % Stroke Dash Array
 17+* stroke-dashoffset % Stroke Dash Offset
 18+* stroke-linecap (butt | round | square | inherit)
 19+* stroke-linejoin (miter | round | bevel | inherit)
 20+* stroke-miterlimit % StrokeMiterLimitValue;
 21+* stroke-opacity % Opacity
 22+* stroke-width % Stroke Width
 23+*
 24+* Presentation attributes for graphics:
 25+* shape-rendering (auto | optimizeSpeed | crispEdges | geometricPrecision | inherit)
 26+* text-rendering (auto | optimizeSpeed | optimizeLegibility | geometricPrecision | inherit)
 27+*
 28+* Font Selection attributes:
 29+* font-family (serif | sans-serif | monospace)
 30+* font-style (normal | italic | oblique | inherit)
 31+* font-variant (normal | small-caps | inherit)
 32+* font-weight (normal | bold | bolder | lighter | 100..900 | inherit)
 33+*
 34+* </pre>
 35+*/
 36+class svgGraph2 extends svgGraph { var
 37+ $graphicWidth = 400,
 38+ $graphicHeight = 300,
 39+
 40+ $plotWidth = 300,
 41+ $plotHeight = 200,
 42+ $plotOffsetX = 60,
 43+ $plotOffsetY = 40,
 44+
 45+ $styleTitleDefault = 'text-rendering: geometricPrecision; ',
 46+ $styleLabelXDefault = 'text-rendering: geometricPrecision; ',
 47+ $styleLabelYDefault = 'text-rendering: geometricPrecision; ',
 48+
 49+ $styleTagsXDefault = 'text-rendering: geometricPrecision; ',
 50+ $styleTagsYDefault = 'text-rendering: geometricPrecision; ',
 51+
 52+ $styleGridXDefault = 'shape-rendering: crispEdges; stroke:#ccc; stroke-width:1; ',
 53+ $styleGridYDefault = 'shape-rendering: crispEdges; stroke:#ccc; stroke-width:1; ',
 54+ $styleBoxDefault = 'shape-rendering: crispEdges; stroke:#000; stroke-width:1; ',
 55+
 56+ $styleLineDefault = 'shape-rendering: geometricPrecision; stroke-linecap: round; ', // smooth lines with round edges
 57+ $stylePolylineDefault = 'shape-rendering: geometricPrecision; fill:none; ', // don't fill area in
 58+ $styleBarDefault = 'shape-rendering: crispEdges; stroke:#000; stroke-width:1; ', //crisp black border
 59+
 60+ $error = '';
 61+}
 62+
 63+?>
\ No newline at end of file
Property changes on: trunk/extensions/FlaggedRevs/svggraph/svgGraph2.php
___________________________________________________________________
Added: svn:eol-style
164 + native
Index: trunk/extensions/FlaggedRevs/svggraph/LICENSE.LGPL
@@ -0,0 +1,18 @@
 2+(c) Herman Veluwenkamp, 2002 (LGPL)
 3+
 4+This library is free software; you can redistribute it and/or
 5+modify it under the terms of the GNU Lesser General Public
 6+License as published by the Free Software Foundation; either
 7+version 2.1 of the License, or (at your option) any later version.
 8+
 9+This library is distributed in the hope that it will be useful,
 10+but WITHOUT ANY WARRANTY; without even the implied warranty of
 11+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 12+Lesser General Public License for more details.
 13+
 14+You should have received a copy of the GNU Lesser General Public
 15+License along with this library; if not, write to the Free Software
 16+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 17+
 18+Copy of GNU Lesser General Public License at: http://www.gnu.org/copyleft/lesser.txt
 19+Contact author at: hveluwenkamp@myrealbox.com
Index: trunk/extensions/FlaggedRevs/specialpages/RatingHistory_body.php
@@ -97,21 +97,44 @@
9898 // If not, then generate a new one.
9999 $filePath = $this->getFilePath( $tag );
100100 $url = $this->getUrlPath( $tag );
101 - if( !file_exists($filePath) || $this->fileExpired($tag,$filePath) ) {
102 - $ok = $this->makeTagGraph( $tag, $filePath );
 101+ $ext = self::getCachedFileExtension();
 102+ if( $ext === 'svg' ) {
 103+ if( !$this->fileExpired($tag,$filePath) || $this->makeSvgGraph( $tag, $filePath ) ) {
 104+ $data = true;
 105+ $wgOut->addHTML( '<h2>' . wfMsgHtml("readerfeedback-$tag") . '</h2>' );
 106+ $wgOut->addHTML(
 107+ Xml::openElement( 'div', array('class' => 'reader_feedback_graph',
 108+ 'style' => "width:100%; overflow:scroll;") ) .
 109+ Xml::openElement( 'object', array('data' => $url, 'type' => 'image/svg+xml') ) .
 110+ Xml::closeElement( 'object' ) .
 111+ Xml::closeElement( 'div' ) . "\n"
 112+ );
 113+ }
 114+ } else if( $ext === 'png' ) {
 115+ if( !$this->fileExpired($tag,$filePath) || $this->makePngGraph( $tag, $filePath ) ) {
 116+ $data = true;
 117+ $wgOut->addHTML( '<h2>' . wfMsgHtml("readerfeedback-$tag") . '</h2>' );
 118+ $wgOut->addHTML(
 119+ Xml::openElement( 'div', array('class' => 'reader_feedback_graph',
 120+ 'style' => "width:100%; overflow:scroll;") ) .
 121+ Xml::openElement( 'img', array('src' => $url,'alt' => $tag) ) .
 122+ Xml::closeElement( 'img' ) .
 123+ Xml::closeElement( 'div' ) . "\n"
 124+ );
 125+ }
103126 } else {
104 - $ok = true;
105 - }
106 - // Output the image
107 - if( $ok ) {
108 - $wgOut->addHTML( '<h2>' . wfMsgHtml("readerfeedback-$tag") . '</h2>' );
109 - $wgOut->addHTML(
110 - Xml::openElement( 'div', array('class' => 'reader_feedback_graph','style' => "width:100%;overflow:scroll;") ) .
111 - Xml::openElement( 'img', array('src' => $url,'alt' => $tag) ) . Xml::closeElement( 'img' ) .
112 - Xml::closeElement( 'div' )
113 - );
114 - $data = true;
115 - }
 127+ if( !$this->fileExpired($tag,$filePath) ) {
 128+ $data = true;
 129+ $fp = @fopen( $filePath, 'r' );
 130+ $table = fread( $fp, filesize($filePath) );
 131+ $wgOut->addHTML( '<h2>' . wfMsgHtml("readerfeedback-$tag") . '</h2>' );
 132+ $wgOut->addHTML( $table . "\n" );
 133+ } else if( $table = $this->makeHTMLTable( $tag, $filePath ) ) {
 134+ $data = true;
 135+ $wgOut->addHTML( '<h2>' . wfMsgHtml("readerfeedback-$tag") . '</h2>' );
 136+ $wgOut->addHTML( $table . "\n" );
 137+ }
 138+ }
116139 }
117140 if( !$data ) {
118141 $wgOut->addHTML( wfMsg('ratinghistory-none') );
@@ -119,12 +142,83 @@
120143 }
121144
122145 /**
 146+ * Generate an HTML table for this tag
 147+ * @param string $tag
 148+ * @param string $filePath
 149+ * @returns string, html table
 150+ */
 151+ public function makeHTMLTable( $tag, $filePath ) {
 152+ $dir = dirname($filePath);
 153+ // Make sure directory exists
 154+ if( !is_dir($dir) && !wfMkdirParents( $dir, 0777 ) ) {
 155+ return false;
 156+ }
 157+ // Set cutoff time for period
 158+ $dbr = wfGetDB( DB_SLAVE );
 159+ $cutoff_unixtime = time() - ($this->period * 24 * 3600);
 160+ $cutoff_unixtime = $cutoff_unixtime - ($cutoff_unixtime % 86400);
 161+ $cutoff = $dbr->addQuotes( wfTimestamp( TS_MW, $cutoff_unixtime ) );
 162+ // Define the data using the DB rows
 163+ $totalVal = $totalCount = $n = 0;
 164+ $lastDay = 31; // init to not trigger first time
 165+ $lastMonth = 12; // init to not trigger first time
 166+ $lastYear = 9999; // init to not trigger first time
 167+ $res = $dbr->select( 'reader_feedback_history',
 168+ array( 'rfh_total', 'rfh_count', 'rfh_date' ),
 169+ array( 'rfh_page_id' => $this->page->getArticleId(),
 170+ 'rfh_tag' => $tag,
 171+ "rfh_date >= {$cutoff}"),
 172+ __METHOD__,
 173+ array( 'ORDER BY' => 'rfh_date ASC' ) );
 174+ // Label spacing
 175+ if( $row = $dbr->fetchObject( $res ) ) {
 176+ $lower = wfTimestamp( TS_UNIX, $row->rfh_date );
 177+ $res->seek( $dbr->numRows($res)-1 );
 178+ $upper = wfTimestamp( TS_UNIX, $dbr->fetchObject( $res )->rfh_date );
 179+ $days = intval( ($upper - $lower)/86400 );
 180+ $int = intval( ceil($days/10) ); // 10 labels at most
 181+ $res->seek( 0 );
 182+ }
 183+ $dates = $drating = $arating = "";
 184+ $n = 0;
 185+ while( $row = $dbr->fetchObject( $res ) ) {
 186+ $totalVal += (int)$row->rfh_total;
 187+ $totalCount += (int)$row->rfh_count;
 188+ $dayAve = sprintf( '%4.2f', (real)$row->rfh_total/(real)$row->rfh_count );
 189+ $cumAve = sprintf( '%4.2f', (real)$totalVal/(real)$totalCount );
 190+ $year = intval( substr( $row->rfh_date, 0, 4 ) );
 191+ $month = intval( substr( $row->rfh_date, 4, 2 ) );
 192+ $day = intval( substr( $row->rfh_date, 6, 2 ) );
 193+ $date = ($this->period > 31) ? "{$month}/{$day}/".substr( $year, 2, 2 ) : "{$month}/{$day}";
 194+ $dates .= "<th>$date</th>";
 195+ $drating .= "<td>$dayAve</td>";
 196+ $arating .= "<td>$cumAve</td>";
 197+ $n++;
 198+ }
 199+ // Minimum sample size
 200+ if( $n < 2 || $totalCount < 10 ) {
 201+ return "";
 202+ }
 203+ $chart = Xml::openElement( 'div', array('style' => "width:100%; overflow:scroll;") );
 204+ $chart .= "<table width='100%' class='wikitable' style='white-space:nowrap' border='1px'>\n";
 205+ $chart .= "<tr>$dates</tr>\n";
 206+ $chart .= "<tr align='center' class='fr-rating-dave'>$drating</tr>\n";
 207+ $chart .= "<tr align='center' class='fr-rating-rave'>$arating</tr>\n";
 208+ $chart .= "</table>\n";
 209+ $chart .= Xml::closeElement( 'div' );
 210+ // Write to file for cache
 211+ $fp = @fopen( $filePath, 'w' );
 212+ @fwrite($fp, $chart );
 213+ return $chart;
 214+ }
 215+
 216+ /**
123217 * Generate a graph for this tag
124218 * @param string $tag
125219 * @param string $filePath
126 - * @returns string, url path to file
 220+ * @returns bool, success
127221 */
128 - public function makeTagGraph( $tag, $filePath ) {
 222+ public function makePngGraph( $tag, $filePath ) {
129223 if( !function_exists( 'ImageCreate' ) ) {
130224 // GD is not installed
131225 return false;
@@ -215,6 +309,8 @@
216310 return false;
217311 }
218312 $plot->SetDataValues($data);
 313+ $plot->SetPointShapes('dot');
 314+ $plot->setPointSizes( 1 );
219315 $plot->SetBackgroundColor('#fffff0');
220316 // Turn off X axis ticks and labels because they get in the way:
221317 $plot->SetXTickLabelPos('none');
@@ -230,6 +326,138 @@
231327 }
232328
233329 /**
 330+ * Generate a graph for this tag
 331+ * @param string $tag
 332+ * @param string $filePath
 333+ * @returns bool, success
 334+ */
 335+ public function makeSvgGraph( $tag, $filePath ) {
 336+ global $wgSvgGraphDir;
 337+ require_once( "$wgSvgGraphDir/svggraph.php" ); // load classes
 338+ require_once( "$wgSvgGraphDir/svggraph2.php" ); // load classes
 339+ // Define the object
 340+ $plot = new svgGraph2(); // some CONST double redefine notices
 341+ // Set file path
 342+ $dir = dirname($filePath);
 343+ // Make sure directory exists
 344+ if( !is_dir($dir) && !wfMkdirParents( $dir, 0777 ) ) {
 345+ return false;
 346+ }
 347+ // Set some parameters
 348+ $plot->graphicWidth = 1000;
 349+ $plot->graphicHeight = 450;
 350+ $plot->plotWidth = 950;
 351+ $plot->plotHeight = 400;
 352+ $plot->decimalPlacesY = 2;
 353+ $plot->plotOffsetX = 40;
 354+ $plot->plotOffsetY = 10;
 355+ $plot->numGridlinesY = 5;
 356+ $plot->innerPaddingX = 5;
 357+ $plot->innerPaddingY = 0;
 358+ $plot->outerPadding = 0;
 359+ $plot->offsetGridlinesX = 0;
 360+ $plot->maxY = 4;
 361+ // Set cutoff time for period
 362+ $dbr = wfGetDB( DB_SLAVE );
 363+ $cutoff_unixtime = time() - ($this->period * 24 * 3600);
 364+ $cutoff_unixtime = $cutoff_unixtime - ($cutoff_unixtime % 86400);
 365+ $cutoff = $dbr->addQuotes( wfTimestamp( TS_MW, $cutoff_unixtime ) );
 366+ // Define the data using the DB rows
 367+ $dataX = $dave = $rave = array();
 368+ $totalVal = $totalCount = $n = 0;
 369+ $lastDay = 31; // init to not trigger first time
 370+ $lastMonth = 12; // init to not trigger first time
 371+ $lastYear = 9999; // init to not trigger first time
 372+ $res = $dbr->select( 'reader_feedback_history',
 373+ array( 'rfh_total', 'rfh_count', 'rfh_date' ),
 374+ array( 'rfh_page_id' => $this->page->getArticleId(),
 375+ 'rfh_tag' => $tag,
 376+ "rfh_date >= {$cutoff}"),
 377+ __METHOD__,
 378+ array( 'ORDER BY' => 'rfh_date ASC' ) );
 379+ // Label spacing
 380+ if( $row = $dbr->fetchObject( $res ) ) {
 381+ $lower = wfTimestamp( TS_UNIX, $row->rfh_date );
 382+ $res->seek( $dbr->numRows($res)-1 );
 383+ $upper = wfTimestamp( TS_UNIX, $dbr->fetchObject( $res )->rfh_date );
 384+ $days = intval( ($upper - $lower)/86400 );
 385+ $int = intval( ceil($days/10) ); // 10 labels at most
 386+ $res->seek( 0 );
 387+ }
 388+ while( $row = $dbr->fetchObject( $res ) ) {
 389+ $totalVal += (int)$row->rfh_total;
 390+ $totalCount += (int)$row->rfh_count;
 391+ $dayAve = (real)$row->rfh_total/(real)$row->rfh_count;
 392+ $cumAve = (real)$totalVal/(real)$totalCount;
 393+ $year = intval( substr( $row->rfh_date, 0, 4 ) );
 394+ $month = intval( substr( $row->rfh_date, 4, 2 ) );
 395+ $day = intval( substr( $row->rfh_date, 6, 2 ) );
 396+ # Fill in days with no votes to keep spacing even
 397+ # Year gaps...
 398+ for( $i=($lastYear + 1); $i < $year; $i++ ) {
 399+ for( $x=1; $x <= 365; $x++ ) {
 400+ $dataX[] = "";
 401+ $dave[] = $lastDAve;
 402+ $rave[] = $lastRAve;
 403+ $n++;
 404+ }
 405+ }
 406+ # Month gaps...
 407+ for( $i=($lastMonth + 1); $i < $month; $i++ ) {
 408+ for( $x=1; $x <= 31; $x++ ) {
 409+ $dataX[] = "";
 410+ $dave[] = $lastDAve;
 411+ $rave[] = $lastRAve;
 412+ $n++;
 413+ }
 414+ }
 415+ # Day gaps...
 416+ for( $x=($lastDay + 1); $x < $day; $x++ ) {
 417+ $dataX[] = "";
 418+ $dave[] = $lastDAve;
 419+ $rave[] = $lastRAve;
 420+ $n++;
 421+ }
 422+ # Label point?
 423+ if( $n >= $int || !count($dataX) ) {
 424+ $p = ($this->period > 31) ? "{$month}/{$day}/".substr( $year, 2, 2 ) : "{$month}/{$day}";
 425+ $n = 0;
 426+ } else {
 427+ $p = "";
 428+ $n++;
 429+ }
 430+ $dataX[] = $p;
 431+ $dave[] = $dayAve;
 432+ $rave[] = $cumAve;
 433+ $lastDay = $day;
 434+ $lastMonth = $month;
 435+ $lastYear = $year;
 436+ $lastDAve = $dayAve;
 437+ $lastRAve = $cumAve;
 438+ }
 439+ // Minimum sample size
 440+ if( count($dataX) < 2 || $totalCount < 10 ) {
 441+ return false;
 442+ }
 443+ $plot->dataX = $dataX;
 444+ $plot->dataY['dave'] = $dave;
 445+ $plot->dataY['rave'] = $rave;
 446+ $plot->styleTagsX = 'font-family: monospace; font-size: 8pt;';
 447+ $plot->format['dave'] = array( 'style' => 'stroke:blue; stroke-width:1;');
 448+ $plot->format['rave'] = array( 'style' => 'stroke:green; stroke-width:1;');
 449+ # Create the graph
 450+ $plot->init();
 451+ $plot->drawGraph();
 452+ $plot->line('dave');
 453+ $plot->line('rave');
 454+ $plot->generateSVG();
 455+ // Write to file for cache
 456+ $fp = @fopen( $filePath, 'w' );
 457+ @fwrite($fp, $plot->svg );
 458+ return true;
 459+ }
 460+
 461+ /**
234462 * Get the path to where the corresponding graph file should be
235463 * @param string $tag
236464 * @returns string
@@ -252,14 +480,28 @@
253481 }
254482
255483 public function getRelPath( $tag ) {
 484+ $ext = self::getCachedFileExtension();
256485 $pageId = $this->page->getArticleId();
257486 # Paranoid check. Should not be necessary, but here to be safe...
258487 if( !preg_match('/^[a-zA-Z]{1,20}$/',$tag) ) {
259488 throw new MWException( 'Invalid tag name!' );
260489 }
261 - return "{$pageId}/{$tag}/l{$this->period}d.png";
 490+ return "{$pageId}/{$tag}/l{$this->period}d.{$ext}";
262491 }
263492
 493+ public static function getCachedFileExtension() {
 494+ return 'png';
 495+ global $wgSvgGraphDir, $wgPHPlotDir;
 496+ if( $wgSvgGraphDir ) {
 497+ $ext = 'svg';
 498+ } else if( $wgPHPlotDir ) {
 499+ $ext = 'png';
 500+ } else {
 501+ $ext = 'html';
 502+ }
 503+ return $ext;
 504+ }
 505+
264506 /**
265507 * Check if a graph file is expired.
266508 * @param string $tag
@@ -267,6 +509,9 @@
268510 * @returns string
269511 */
270512 public function fileExpired( $tag, $path ) {
 513+ if( !file_exists($path) ) {
 514+ return true;
 515+ }
271516 $dbr = wfGetDB( DB_SLAVE );
272517 $tagTimestamp = $dbr->selectField( 'reader_feedback_pages',
273518 'rfp_touched',

Follow-up revisions

RevisionCommit summaryAuthorDate
r53745Use wfSuppressWarnings()/wfRestoreWarnings() per CR on r39789. Also remove tr...demon14:10, 25 July 2009

Comments

#Comment by Tim Starling (talk | contribs)   15:34, 25 May 2009

Don't use the error suppression (@) operator for any reason ever. It's broken when E_STRICT is enabled and it causes an unlogged, unexplained error if there is a fatal, which is hard to support. Use wfSuppressWarnings() and wfRestoreWarnings() instead.

Status & tagging log