Permalink
Browse files

Adding charting library and improving the charting of the application.

  • Loading branch information...
1 parent 837eb80 commit 8c4fd3a7914ad06000799a6304342b30c48cddeb @brandonsavage brandonsavage committed Nov 8, 2011
Showing with 29,625 additions and 8 deletions.
  1. +3 −1 Bugzilla.php
  2. +52 −5 BugzillaOutput.class.php
  3. BIN charts/.DS_Store
  4. BIN pchart/.DS_Store
  5. +675 −0 pchart/GPLv3.txt
  6. BIN pchart/change.log
  7. BIN pchart/class/.DS_Store
  8. +184 −0 pchart/class/pBarcode128.class.php
  9. +200 −0 pchart/class/pBarcode39.class.php
  10. +326 −0 pchart/class/pBubble.class.php
  11. +280 −0 pchart/class/pCache.class.php
  12. +787 −0 pchart/class/pData.class.php
  13. +6,193 −0 pchart/class/pDraw.class.php
  14. +472 −0 pchart/class/pImage.class.php
  15. +241 −0 pchart/class/pIndicator.class.php
  16. +1,500 −0 pchart/class/pPie.class.php
  17. +681 −0 pchart/class/pRadar.class.php
  18. +1,158 −0 pchart/class/pScatter.class.php
  19. +131 −0 pchart/class/pSplit.class.php
  20. +868 −0 pchart/class/pSpring.class.php
  21. +216 −0 pchart/class/pStock.class.php
  22. +315 −0 pchart/class/pSurface.class.php
  23. BIN pchart/data/.DS_Store
  24. +107 −0 pchart/data/128B.db
  25. +44 −0 pchart/data/39.db
  26. +52 −0 pchart/examples/buildAll.cmd
  27. +228 −0 pchart/examples/delayedLoader/delayedLoading.js
  28. +34 −0 pchart/examples/delayedLoader/draw.php
  29. +91 −0 pchart/examples/delayedLoader/index.php
  30. BIN pchart/examples/delayedLoader/wait.gif
  31. +69 −0 pchart/examples/example.Combo.area.lines.php
  32. +76 −0 pchart/examples/example.Combo.php
  33. +87 −0 pchart/examples/example.Mixed.classes.php
  34. +56 −0 pchart/examples/example.addRandomValues.php
  35. +77 −0 pchart/examples/example.barcode.php
  36. +48 −0 pchart/examples/example.barcode128.php
  37. +48 −0 pchart/examples/example.barcode39.php
  38. +32 −0 pchart/examples/example.basic.php
  39. +56 −0 pchart/examples/example.cache.php
  40. +73 −0 pchart/examples/example.createFunctionSerie.php
  41. +95 −0 pchart/examples/example.createFunctionSerie.scatter.php
  42. +56 −0 pchart/examples/example.draw2DPie.labels.php
  43. +68 −0 pchart/examples/example.draw2DPie.php
  44. +56 −0 pchart/examples/example.draw2DRing.php
  45. +56 −0 pchart/examples/example.draw2DRingValues.php
  46. +53 −0 pchart/examples/example.draw3DPie.labels.php
  47. +73 −0 pchart/examples/example.draw3DPie.php
  48. +40 −0 pchart/examples/example.draw3DPie.transparent.php
  49. +55 −0 pchart/examples/example.draw3DRing.php
  50. +55 −0 pchart/examples/example.draw3DRingValues.php
  51. +106 −0 pchart/examples/example.drawAnscombeQuartet.php
  52. +35 −0 pchart/examples/example.drawAntialiasPixel.php
  53. +67 −0 pchart/examples/example.drawAreaChart.enhanced.php
  54. +62 −0 pchart/examples/example.drawAreaChart.php
  55. +54 −0 pchart/examples/example.drawAreaChart.simple.php
  56. +71 −0 pchart/examples/example.drawAreaChart.threshold.php
  57. +63 −0 pchart/examples/example.drawAreaMirror.php
  58. +40 −0 pchart/examples/example.drawArrow.php
  59. +48 −0 pchart/examples/example.drawArrowLabel.php
  60. +52 −0 pchart/examples/example.drawBarChart.borders.php
  61. +41 −0 pchart/examples/example.drawBarChart.can.php
  62. +45 −0 pchart/examples/example.drawBarChart.floating.php
  63. +49 −0 pchart/examples/example.drawBarChart.palette.php
  64. +65 −0 pchart/examples/example.drawBarChart.php
  65. +42 −0 pchart/examples/example.drawBarChart.poll.php
  66. +40 −0 pchart/examples/example.drawBarChart.shaded.php
  67. +50 −0 pchart/examples/example.drawBarChart.simple.php
  68. +52 −0 pchart/examples/example.drawBarChart.spacing.php
  69. +46 −0 pchart/examples/example.drawBarChart.span.php
  70. +40 −0 pchart/examples/example.drawBarChart.vertical.php
  71. +57 −0 pchart/examples/example.drawBestfit.php
  72. +40 −0 pchart/examples/example.drawBezier.php
  73. +79 −0 pchart/examples/example.drawBubbleChart.php
  74. +58 −0 pchart/examples/example.drawBubbleChart.simple.php
  75. +58 −0 pchart/examples/example.drawBubbleChart.square.php
  76. +54 −0 pchart/examples/example.drawCircle.php
  77. +61 −0 pchart/examples/example.drawContour.php
  78. +61 −0 pchart/examples/example.drawDerivative.php
  79. +47 −0 pchart/examples/example.drawDerivative.simple.php
  80. +54 −0 pchart/examples/example.drawFilledCircle.php
  81. +57 −0 pchart/examples/example.drawFilledRectangle.php
  82. +74 −0 pchart/examples/example.drawFilledSplineChart.php
  83. +73 −0 pchart/examples/example.drawFilledSplineChart.threshold.php
  84. +65 −0 pchart/examples/example.drawFilledStepChart.php
  85. +47 −0 pchart/examples/example.drawFromGIF.php
  86. +47 −0 pchart/examples/example.drawFromJPG.php
  87. +47 −0 pchart/examples/example.drawFromPNG.php
  88. +59 −0 pchart/examples/example.drawGeometricMean.php
  89. +53 −0 pchart/examples/example.drawGradientArea.php
  90. +59 −0 pchart/examples/example.drawHarmonicMean.php
  91. +66 −0 pchart/examples/example.drawIndicator.php
  92. +71 −0 pchart/examples/example.drawLabel.barchart.php
  93. +87 −0 pchart/examples/example.drawLabel.bubble.php
  94. +67 −0 pchart/examples/example.drawLabel.caption.php
  95. +70 −0 pchart/examples/example.drawLabel.php
  96. +87 −0 pchart/examples/example.drawLabel.scatter.php
  97. +43 −0 pchart/examples/example.drawLabel.stacked.php
  98. +51 −0 pchart/examples/example.drawLabel.vertical.php
  99. +76 −0 pchart/examples/example.drawLegend.php
  100. +42 −0 pchart/examples/example.drawLine.php
  101. +66 −0 pchart/examples/example.drawLineChart.php
  102. +67 −0 pchart/examples/example.drawLineChart.plots.php
  103. +73 −0 pchart/examples/example.drawLineChart.reversed.php
  104. +56 −0 pchart/examples/example.drawLineChart.simple.php
  105. +55 −0 pchart/examples/example.drawMedian.php
  106. +67 −0 pchart/examples/example.drawPieLegend.php
  107. +69 −0 pchart/examples/example.drawPlotChart.icon.php
  108. +64 −0 pchart/examples/example.drawPlotChart.php
  109. +53 −0 pchart/examples/example.drawPlotChart.simple.php
  110. +55 −0 pchart/examples/example.drawPolygon.php
  111. +65 −0 pchart/examples/example.drawProgress.php
  112. +56 −0 pchart/examples/example.drawRectangle.php
  113. +62 −0 pchart/examples/example.drawRoundedFilledRectangle.php
  114. +56 −0 pchart/examples/example.drawRoundedRectangle.php
  115. +70 −0 pchart/examples/example.drawScale.color.php
  116. +59 −0 pchart/examples/example.drawScale.custom.php
  117. +56 −0 pchart/examples/example.drawScale.dates.php
  118. +52 −0 pchart/examples/example.drawScale.floating.php
  119. +65 −0 pchart/examples/example.drawScale.labels.php
  120. +54 −0 pchart/examples/example.drawScale.manual.php
  121. +64 −0 pchart/examples/example.drawScale.multiple.php
  122. +53 −0 pchart/examples/example.drawScale.php
  123. +49 −0 pchart/examples/example.drawScale.reverse.php
  124. +69 −0 pchart/examples/example.drawScatter.shape.php
  125. +67 −0 pchart/examples/example.drawScatter.simple.php
  126. +81 −0 pchart/examples/example.drawScatterBestFit.php
  127. +80 −0 pchart/examples/example.drawScatterLineChart.php
  128. +75 −0 pchart/examples/example.drawScatterLineChart.trigo.php
  129. +80 −0 pchart/examples/example.drawScatterPlotChart.php
  130. +61 −0 pchart/examples/example.drawScatterScale.manual.php
  131. +62 −0 pchart/examples/example.drawScatterScale.php
  132. +81 −0 pchart/examples/example.drawScatterSplineChart.php
  133. +46 −0 pchart/examples/example.drawSimple.php
  134. +42 −0 pchart/examples/example.drawSpline.php
  135. +66 −0 pchart/examples/example.drawSplineChart.php
  136. +67 −0 pchart/examples/example.drawSplineChart.reversed.php
  137. +61 −0 pchart/examples/example.drawSplineChart.simple.php
  138. +45 −0 pchart/examples/example.drawStackedAreaChart.normalized.php
  139. +69 −0 pchart/examples/example.drawStackedAreaChart.php
  140. +40 −0 pchart/examples/example.drawStackedAreaChart.simple.php
  141. +42 −0 pchart/examples/example.drawStackedBarChart.border.php
  142. +42 −0 pchart/examples/example.drawStackedBarChart.can.php
  143. +65 −0 pchart/examples/example.drawStackedBarChart.php
  144. +40 −0 pchart/examples/example.drawStackedBarChart.pyramid.php
  145. +53 −0 pchart/examples/example.drawStackedBarChart.rounded.php
  146. +42 −0 pchart/examples/example.drawStackedBarChart.shaded.php
  147. +79 −0 pchart/examples/example.drawStandardDeviation.php
  148. +65 −0 pchart/examples/example.drawStepChart.php
  149. +44 −0 pchart/examples/example.drawStepChart.simple.php
  150. +50 −0 pchart/examples/example.drawStockChart.median.php
  151. +65 −0 pchart/examples/example.drawStockChart.php
  152. +49 −0 pchart/examples/example.drawStockChart.simple.php
  153. +63 −0 pchart/examples/example.drawSurface.palette.php
  154. +57 −0 pchart/examples/example.drawSurface.php
  155. +58 −0 pchart/examples/example.drawSurface.simple.php
  156. +55 −0 pchart/examples/example.drawText.php
  157. +56 −0 pchart/examples/example.drawThreshold.labels.php
  158. +66 −0 pchart/examples/example.drawThreshold.php
  159. +67 −0 pchart/examples/example.drawThresholdArea.php
  160. +67 −0 pchart/examples/example.drawXThreshold.php
  161. +67 −0 pchart/examples/example.drawXThresholdArea.php
  162. +64 −0 pchart/examples/example.drawZoneChart.php
  163. +50 −0 pchart/examples/example.drawingObjects.php
  164. +42 −0 pchart/examples/example.normalize.php
  165. +65 −0 pchart/examples/example.polar.php
  166. +51 −0 pchart/examples/example.polar.values.php
  167. +55 −0 pchart/examples/example.radar.fixedmax.php
  168. +50 −0 pchart/examples/example.radar.labels.php
  169. +67 −0 pchart/examples/example.radar.php
  170. +50 −0 pchart/examples/example.radar.values.php
  171. +56 −0 pchart/examples/example.setFontProperties.php
  172. +44 −0 pchart/examples/example.setShadow.php
  173. +30 −0 pchart/examples/example.singlebarcode128.php
  174. +30 −0 pchart/examples/example.singlebarcode39.php
  175. +62 −0 pchart/examples/example.split.php
  176. +66 −0 pchart/examples/example.spring.complex.php
  177. +67 −0 pchart/examples/example.spring.labels.php
  178. +65 −0 pchart/examples/example.spring.php
  179. +70 −0 pchart/examples/example.spring.relations.php
  180. +67 −0 pchart/examples/example.text.alignment.php
  181. +36 −0 pchart/examples/example.transparent.background.php
  182. +46 −0 pchart/examples/example.writeBounds.php
  183. +264 −0 pchart/examples/imageMap/imagemap.js
  184. +186 −0 pchart/examples/imageMap/index.php
  185. +58 −0 pchart/examples/imageMap/scripts/2DPie.php
  186. +58 −0 pchart/examples/imageMap/scripts/2DRing.php
  187. +55 −0 pchart/examples/imageMap/scripts/3DPie.php
  188. +55 −0 pchart/examples/imageMap/scripts/3DRing.php
  189. +76 −0 pchart/examples/imageMap/scripts/AreaChart.php
  190. +76 −0 pchart/examples/imageMap/scripts/BarChart.labels.php
  191. +67 −0 pchart/examples/imageMap/scripts/BarChart.php
  192. +76 −0 pchart/examples/imageMap/scripts/BubbleChart.php
  193. +75 −0 pchart/examples/imageMap/scripts/LineChart.php
  194. +71 −0 pchart/examples/imageMap/scripts/PlotChart.php
  195. +56 −0 pchart/examples/imageMap/scripts/PolarChart.php
  196. +57 −0 pchart/examples/imageMap/scripts/RadarChart.php
  197. +90 −0 pchart/examples/imageMap/scripts/ScatterLineChart.php
  198. +89 −0 pchart/examples/imageMap/scripts/ScatterPlotChart.php
  199. +90 −0 pchart/examples/imageMap/scripts/ScatterSplineChart.php
  200. +91 −0 pchart/examples/imageMap/scripts/Shapes.php
  201. +75 −0 pchart/examples/imageMap/scripts/SplineChart.php
  202. +67 −0 pchart/examples/imageMap/scripts/StackedBarChart.php
  203. +71 −0 pchart/examples/imageMap/scripts/StepChart.php
  204. +59 −0 pchart/examples/imageMap/scripts/StockChart.php
  205. +365 −0 pchart/examples/index.php
  206. BIN pchart/examples/resources/accept.png
  207. BIN pchart/examples/resources/application_view_list.png
  208. BIN pchart/examples/resources/application_view_tile.png
  209. BIN pchart/examples/resources/blocnote.png
  210. BIN pchart/examples/resources/chart_bar.png
  211. BIN pchart/examples/resources/chart_line.png
  212. BIN pchart/examples/resources/computer.gif
  213. BIN pchart/examples/resources/dash-explorer-blank.png
  214. BIN pchart/examples/resources/dash-explorer-last.png
  215. BIN pchart/examples/resources/dash-explorer-noleaf.png
  216. BIN pchart/examples/resources/dash-explorer.png
  217. BIN pchart/examples/resources/dash.png
  218. +25 −0 pchart/examples/resources/dataset.txt
  219. BIN pchart/examples/resources/folder.png
  220. BIN pchart/examples/resources/hologram.png
  221. BIN pchart/examples/resources/landscape1.jpg
  222. BIN pchart/examples/resources/landscape2.jpg
  223. +6 −0 pchart/examples/resources/palette.txt
  224. BIN pchart/examples/resources/serie1.png
  225. BIN pchart/examples/resources/serie2.png
  226. BIN pchart/examples/resources/wait.gif
  227. BIN pchart/examples/sandbox/graphix/accept.png
  228. BIN pchart/examples/sandbox/graphix/application_form.png
  229. BIN pchart/examples/sandbox/graphix/background.console.png
  230. BIN pchart/examples/sandbox/graphix/chart_bar.png
  231. BIN pchart/examples/sandbox/graphix/chart_bar_edit.png
  232. BIN pchart/examples/sandbox/graphix/chart_curve.png
  233. BIN pchart/examples/sandbox/graphix/chart_line.png
  234. BIN pchart/examples/sandbox/graphix/cog.png
  235. BIN pchart/examples/sandbox/graphix/color_swatch.png
  236. BIN pchart/examples/sandbox/graphix/comment.png
  237. BIN pchart/examples/sandbox/graphix/database_table.png
  238. BIN pchart/examples/sandbox/graphix/layout_edit.png
  239. BIN pchart/examples/sandbox/graphix/page_edit.png
  240. BIN pchart/examples/sandbox/graphix/paintcan.png
  241. BIN pchart/examples/sandbox/graphix/shape_flip_vertical.png
  242. BIN pchart/examples/sandbox/graphix/tab.png
  243. BIN pchart/examples/sandbox/graphix/vector.png
  244. BIN pchart/examples/sandbox/graphix/wait.gif
  245. BIN pchart/examples/sandbox/graphix/wand.png
  246. BIN pchart/examples/sandbox/graphix/wrench.png
  247. BIN pchart/examples/sandbox/includes/arrow.gif
  248. +61 −0 pchart/examples/sandbox/includes/constants.txt
  249. BIN pchart/examples/sandbox/includes/cross.gif
  250. +656 −0 pchart/examples/sandbox/includes/functions.js
  251. BIN pchart/examples/sandbox/includes/hs.png
  252. BIN pchart/examples/sandbox/includes/hv.png
  253. +841 −0 pchart/examples/sandbox/includes/jscolor.js
  254. +285 −0 pchart/examples/sandbox/includes/rounded_corners_lite.inc.js
  255. +707 −0 pchart/examples/sandbox/index.php
  256. +891 −0 pchart/examples/sandbox/script/render.php
  257. +24 −0 pchart/examples/sandbox/script/session.php
  258. +89 −0 pchart/examples/sandbox/style.css
  259. BIN pchart/fonts/Bedizen.ttf
  260. BIN pchart/fonts/Forgotte.ttf
  261. BIN pchart/fonts/GeosansLight.ttf
  262. BIN pchart/fonts/MankSans.ttf
  263. BIN pchart/fonts/Silkscreen.ttf
  264. BIN pchart/fonts/advent_light.ttf
  265. BIN pchart/fonts/calibri.ttf
  266. BIN pchart/fonts/pf_arma_five.ttf
  267. BIN pchart/fonts/verdana.ttf
  268. +6 −0 pchart/index.php
  269. BIN pchart/palettes/.DS_Store
  270. +6 −0 pchart/palettes/autumn.color
  271. +6 −0 pchart/palettes/blind.color
  272. +6 −0 pchart/palettes/evening.color
  273. +6 −0 pchart/palettes/kitchen.color
  274. +7 −0 pchart/palettes/light.color
  275. +6 −0 pchart/palettes/navy.color
  276. +6 −0 pchart/palettes/shade.color
  277. +6 −0 pchart/palettes/spring.color
  278. +6 −0 pchart/palettes/summer.color
  279. BIN pchart/readme.txt
  280. +4 −2 templates/count/bar.tpl
View
@@ -150,4 +150,6 @@ function BugzillaRender($input, array $args, Parser $parser ) {
$wgBugzillaSmartyConfigDir = dirname(__FILE__) . '/configs/';
$wgBugzillaSmartyCacheDir = '/tmp/';
-
+$wgBugzillaChartStorage = realpath($cwd . '/charts');
+$wgBugzillaFontStorage = $cwd . '/pchart/fonts';
+$wgBugzillaChartUrl = $wgScriptPath . '/extensions/Bugzilla/charts';
View
@@ -4,6 +4,9 @@
abstract class BugzillaOutput {
+ public $response;
+ public $cache;
+
public function __construct($config, $options, $title='') {
$this->title = $title;
$this->config = $config;
@@ -59,6 +62,19 @@ public function render() {
return $this->smarty->fetch($this->template);
}
+
+ protected function _getCache()
+ {
+ global $wgCacheObject;
+ if(!$this->cache) {
+ $this->cache = new $wgCacheObject;
+ }
+
+ return $this->cache;
+ }
+
+ abstract public function _setup_template_data();
+
}
class BugzillaTable extends BugzillaOutput {
@@ -72,14 +88,45 @@ class BugzillaGraph extends BugzillaOutput {
}
+include 'pchart/class/pDraw.class.php';
+include 'pchart/class/pImage.class.php';
+include 'pchart/class/pData.class.php';
+
class BugzillaBarGraph extends BugzillaGraph {
+ public function generate_chart($chart_name)
+ {
+ global $wgBugzillaChartStorage, $wgBugzillaFontStorage;
+ $pData = new pData();
+ $pData->addPoints($this->query->data->data, 'Counts');
+ $pData->setAxisName(0, 'Bugs');
+ $pData->addPoints($this->query->data->x_labels, "Bugs");
+ $pData->setSerieDescription("Bugs", "Bugs");
+ $pData->setAbscissa("Bugs");
+
+ $pImage = new pImage(600,300, $pData);
+ $pImage->setFontProperties(array('FontName' => $wgBugzillaFontStorage . '/verdana.ttf', 'FontSize' => 6));
+ $pImage->setGraphArea(75, 30, 580, 280);
+ $pImage->drawScale(array("CycleBackground"=>TRUE,"DrawSubTicks"=>FALSE,"GridR"=>0,"GridG"=>0,"GridB"=>0,"GridAlpha"=>10, "Pos"=>SCALE_POS_TOPBOTTOM));
+
+ $pImage->drawBarChart();
+ $pImage->render($wgBugzillaChartStorage . '/' . $chart_name . '.png');
+ $cache = $this->_getCache();
+ $cache->set($chart_name, $chart_name . '.png');
+ return $chart_name;
+ }
+
public function _setup_template_data() {
- $this->smarty->assign('type', 'bhs');
- #$smarty->assign('type', 'p');
- $this->smarty->assign('size', '200x300');
- $this->smarty->assign('x_labels', implode('|', $this->query->data->x_labels));
- $this->smarty->assign('data', implode(',', $this->query->data->data));
+ global $wgBugzillaChartUrl;
+ $key = md5($this->query->id . '_bar_chart');
+ $cache = $this->_getCache();
+ if($result = $cache->get($key)) {
+ $image = $result['data'];
+ $this->response->image = $wgBugzillaChartUrl . '/' . $image;
+ } else {
+ $this->response->image = $wgBugzillaChartUrl . '/' . $this->generate_chart($key) . '.png';
+ }
+
}
}
View
Binary file not shown.
View
Binary file not shown.
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
Binary file not shown.
View
Binary file not shown.
@@ -0,0 +1,184 @@
+<?php
+ /*
+ pBarcode128 - class to create barcodes (128B)
+
+ Version : 2.1.3
+ Made by : Jean-Damien POGOLOTTI
+ Last Update : 09/09/11
+
+ This file can be distributed under the license you can find at :
+
+ http://www.pchart.net/license
+
+ You can find the whole class documentation on the pChart web site.
+ */
+
+ /* pData class definition */
+ class pBarcode128
+ {
+ var $Codes;
+ var $Reverse;
+ var $Result;
+ var $pChartObject;
+ var $CRC;
+
+ /* Class creator */
+ function pBarcode128($BasePath="")
+ {
+ $this->Codes = "";
+ $this->Reverse = "";
+
+ $FileHandle = @fopen($BasePath."data/128B.db", "r");
+
+ if (!$FileHandle) { die("Cannot find barcode database (".$BasePath."128B.db)."); }
+
+ while (!feof($FileHandle))
+ {
+ $Buffer = fgets($FileHandle,4096);
+ $Buffer = str_replace(chr(10),"",$Buffer);
+ $Buffer = str_replace(chr(13),"",$Buffer);
+ $Values = preg_split("/;/",$Buffer);
+
+ $this->Codes[$Values[1]]["ID"] = $Values[0];
+ $this->Codes[$Values[1]]["Code"] = $Values[2];
+ $this->Reverse[$Values[0]]["Code"] = $Values[2];
+ $this->Reverse[$Values[0]]["Asc"] = $Values[1];
+ }
+ fclose($FileHandle);
+ }
+
+ /* Return the projected size of a barcode */
+ function getSize($TextString,$Format="")
+ {
+ $Angle = isset($Format["Angle"]) ? $Format["Angle"] : 0;
+ $ShowLegend = isset($Format["ShowLegend"]) ? $Format["ShowLegend"] : FALSE;
+ $LegendOffset = isset($Format["LegendOffset"]) ? $Format["LegendOffset"] : 5;
+ $DrawArea = isset($Format["DrawArea"]) ? $Format["DrawArea"] : FALSE;
+ $FontSize = isset($Format["FontSize"]) ? $Format["FontSize"] : 12;
+ $Height = isset($Format["Height"]) ? $Format["Height"] : 30;
+
+ $TextString = $this->encode128($TextString);
+ $BarcodeLength = strlen($this->Result);
+
+ if ( $DrawArea ) { $WOffset = 20; } else { $WOffset = 0; }
+ if ( $ShowLegend ) { $HOffset = $FontSize+$LegendOffset+$WOffset; } else { $HOffset = 0; }
+
+ $X1 = cos($Angle * PI / 180) * ($WOffset+$BarcodeLength);
+ $Y1 = sin($Angle * PI / 180) * ($WOffset+$BarcodeLength);
+
+ $X2 = $X1 + cos(($Angle+90) * PI / 180) * ($HOffset+$Height);
+ $Y2 = $Y1 + sin(($Angle+90) * PI / 180) * ($HOffset+$Height);
+
+
+ $AreaWidth = max(abs($X1),abs($X2));
+ $AreaHeight = max(abs($Y1),abs($Y2));
+
+ return(array("Width"=>$AreaWidth,"Height"=>$AreaHeight));
+ }
+
+ function encode128($Value,$Format="")
+ {
+ $this->Result = "11010010000";
+ $this->CRC = 104;
+ $TextString = "";
+
+ for($i=1;$i<=strlen($Value);$i++)
+ {
+ $CharCode = ord($this->mid($Value,$i,1));
+ if ( isset($this->Codes[$CharCode]) )
+ {
+ $this->Result = $this->Result.$this->Codes[$CharCode]["Code"];
+ $this->CRC = $this->CRC + $i*$this->Codes[$CharCode]["ID"];
+ $TextString = $TextString.chr($CharCode);
+ }
+ }
+ $this->CRC = $this->CRC - floor($this->CRC/103)*103;
+
+ $this->Result = $this->Result.$this->Reverse[$this->CRC]["Code"];
+ $this->Result = $this->Result."1100011101011";
+
+ return($TextString);
+ }
+
+ /* Create the encoded string */
+ function draw($Object,$Value,$X,$Y,$Format="")
+ {
+ $this->pChartObject = $Object;
+
+ $R = isset($Format["R"]) ? $Format["R"] : 0;
+ $G = isset($Format["G"]) ? $Format["G"] : 0;
+ $B = isset($Format["B"]) ? $Format["B"] : 0;
+ $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
+ $Height = isset($Format["Height"]) ? $Format["Height"] : 30;
+ $Angle = isset($Format["Angle"]) ? $Format["Angle"] : 0;
+ $ShowLegend = isset($Format["ShowLegend"]) ? $Format["ShowLegend"] : FALSE;
+ $LegendOffset = isset($Format["LegendOffset"]) ? $Format["LegendOffset"] : 5;
+ $DrawArea = isset($Format["DrawArea"]) ? $Format["DrawArea"] : FALSE;
+ $AreaR = isset($Format["AreaR"]) ? $Format["AreaR"] : 255;
+ $AreaG = isset($Format["AreaG"]) ? $Format["AreaG"] : 255;
+ $AreaB = isset($Format["AreaB"]) ? $Format["AreaB"] : 255;
+ $AreaBorderR = isset($Format["AreaBorderR"]) ? $Format["AreaBorderR"] : $AreaR;
+ $AreaBorderG = isset($Format["AreaBorderG"]) ? $Format["AreaBorderG"] : $AreaG;
+ $AreaBorderB = isset($Format["AreaBorderB"]) ? $Format["AreaBorderB"] : $AreaB;
+
+ $TextString = $this->encode128($Value);
+
+ if ( $DrawArea )
+ {
+ $X1 = $X + cos(($Angle-135) * PI / 180) * 10;
+ $Y1 = $Y + sin(($Angle-135) * PI / 180) * 10;
+
+ $X2 = $X1 + cos($Angle * PI / 180) * (strlen($this->Result)+20);
+ $Y2 = $Y1 + sin($Angle * PI / 180) * (strlen($this->Result)+20);
+
+ if ( $ShowLegend )
+ {
+ $X3 = $X2 + cos(($Angle+90) * PI / 180) * ($Height+$LegendOffset+$this->pChartObject->FontSize+10);
+ $Y3 = $Y2 + sin(($Angle+90) * PI / 180) * ($Height+$LegendOffset+$this->pChartObject->FontSize+10);
+ }
+ else
+ {
+ $X3 = $X2 + cos(($Angle+90) * PI / 180) * ($Height+20);
+ $Y3 = $Y2 + sin(($Angle+90) * PI / 180) * ($Height+20);
+ }
+
+ $X4 = $X3 + cos(($Angle+180) * PI / 180) * (strlen($this->Result)+20);
+ $Y4 = $Y3 + sin(($Angle+180) * PI / 180) * (strlen($this->Result)+20);
+
+ $Polygon = array($X1,$Y1,$X2,$Y2,$X3,$Y3,$X4,$Y4);
+ $Settings = array("R"=>$AreaR,"G"=>$AreaG,"B"=>$AreaB,"BorderR"=>$AreaBorderR,"BorderG"=>$AreaBorderG,"BorderB"=>$AreaBorderB);
+ $this->pChartObject->drawPolygon($Polygon,$Settings);
+ }
+
+ for($i=1;$i<=strlen($this->Result);$i++)
+ {
+ if ( $this->mid($this->Result,$i,1) == 1 )
+ {
+ $X1 = $X + cos($Angle * PI / 180) * $i;
+ $Y1 = $Y + sin($Angle * PI / 180) * $i;
+ $X2 = $X1 + cos(($Angle+90) * PI / 180) * $Height;
+ $Y2 = $Y1 + sin(($Angle+90) * PI / 180) * $Height;
+
+ $Settings = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha);
+ $this->pChartObject->drawLine($X1,$Y1,$X2,$Y2,$Settings);
+ }
+ }
+
+ if ( $ShowLegend )
+ {
+ $X1 = $X + cos($Angle * PI / 180) * (strlen($this->Result)/2);
+ $Y1 = $Y + sin($Angle * PI / 180) * (strlen($this->Result)/2);
+
+ $LegendX = $X1 + cos(($Angle+90) * PI / 180) * ($Height+$LegendOffset);
+ $LegendY = $Y1 + sin(($Angle+90) * PI / 180) * ($Height+$LegendOffset);
+
+ $Settings = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Angle"=>-$Angle,"Align"=>TEXT_ALIGN_TOPMIDDLE);
+ $this->pChartObject->drawText($LegendX,$LegendY,$TextString,$Settings);
+ }
+ }
+
+ function left($value,$NbChar) { return substr($value,0,$NbChar); }
+ function right($value,$NbChar) { return substr($value,strlen($value)-$NbChar,$NbChar); }
+ function mid($value,$Depart,$NbChar) { return substr($value,$Depart-1,$NbChar); }
+ }
+?>
Oops, something went wrong.

0 comments on commit 8c4fd3a

Please sign in to comment.