/ui/obminclude/Artichow-1.1.0-php4+5/examples/site/bar-002.php

https://github.com/goldoraf/OBM · PHP · 80 lines · 52 code · 21 blank · 7 comment · 2 complexity · c8093a4b8285bf56a2e2beeee6119f78 MD5 · raw file

  1. <?php
  2. /*
  3. * This work is hereby released into the Public Domain.
  4. * To view a copy of the public domain dedication,
  5. * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
  6. * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
  7. *
  8. */
  9. require_once "../../BarPlot.class.php";
  10. $graph = new Graph(280, 280);
  11. $graph->setAntiAliasing(TRUE);
  12. $group = new PlotGroup;
  13. $group->setSpace(6, 6, 5, 5);
  14. $group->setBackgroundGradient(
  15. new LinearGradient(
  16. new Color(235, 235, 235),
  17. new White(),
  18. 0
  19. )
  20. );
  21. $group->setPadding(40, 10, 10, 50);
  22. $group->axis->left->setLabelPrecision(2);
  23. $group->axis->bottom->label->hide(TRUE);
  24. $group->axis->bottom->hideTicks(TRUE);
  25. $group->grid->setType(LINE_DASHED);
  26. $group->grid->hideHorizontal(TRUE);
  27. $gradients = array(
  28. new LinearGradient(
  29. new Color(30, 30, 160, 10), new Color(120, 120, 160, 10), 0
  30. ),
  31. new LinearGradient(
  32. new Color(30, 160, 30, 10), new Color(120, 160, 120, 10), 0
  33. ),
  34. new LinearGradient(
  35. new Color(160, 30, 30, 10), new Color(160, 120, 120, 10), 0
  36. )
  37. );
  38. for($n = 0; $n < 3; $n++) {
  39. $x = array();
  40. for($i = 0; $i < 6; $i++) {
  41. $x[] = (cos($i * M_PI / 100) / ($n + 1) * mt_rand(600, 900) / 1000 - 0.5) * (($n%2) ? -0.5 : 1) + (($n%2) ? -0.4 : 0);
  42. }
  43. $plot = new BarPlot($x, $n + 1, 3);
  44. $plot->setXAxis(PLOT_BOTTOM);
  45. $plot->barShadow->setSize(1);
  46. $plot->barShadow->setPosition(SHADOW_RIGHT_TOP);
  47. $plot->barShadow->setColor(new Color(160, 160, 160, 10));
  48. $plot->barBorder->setColor($gradients[$n]->from);
  49. $plot->setBarGradient($gradients[$n]);
  50. $plot->setBarSpace(2);
  51. $group->legend->add($plot, 'Bar#'.($n + 1), LEGEND_BACKGROUND);
  52. $group->add($plot);
  53. }
  54. $group->legend->setModel(LEGEND_MODEL_BOTTOM);
  55. $group->legend->setPosition(NULL, 0.86);
  56. $group->legend->shadow->hide();
  57. $graph->add($group);
  58. $graph->draw();
  59. ?>