/Graph/tests/radar_axis_test.php

https://github.com/F5/zetacomponents · PHP · 212 lines · 140 code · 41 blank · 31 comment · 1 complexity · 4af3d67160e14fb3b9dd8a88918eb159 MD5 · raw file

  1. <?php
  2. /**
  3. * ezcGraphRadarChartAxisTest
  4. *
  5. * Licensed to the Apache Software Foundation (ASF) under one
  6. * or more contributor license agreements. See the NOTICE file
  7. * distributed with this work for additional information
  8. * regarding copyright ownership. The ASF licenses this file
  9. * to you under the Apache License, Version 2.0 (the
  10. * "License"); you may not use this file except in compliance
  11. * with the License. You may obtain a copy of the License at
  12. *
  13. * http://www.apache.org/licenses/LICENSE-2.0
  14. *
  15. * Unless required by applicable law or agreed to in writing,
  16. * software distributed under the License is distributed on an
  17. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  18. * KIND, either express or implied. See the License for the
  19. * specific language governing permissions and limitations
  20. * under the License.
  21. *
  22. * @package Graph
  23. * @version //autogen//
  24. * @subpackage Tests
  25. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
  26. */
  27. require_once dirname( __FILE__ ) . '/test_case.php';
  28. /**
  29. * Tests for ezcGraph class.
  30. *
  31. * @package Graph
  32. * @subpackage Tests
  33. */
  34. class ezcGraphRadarChartAxisTest extends ezcGraphTestCase
  35. {
  36. protected $basePath;
  37. protected $tempDir;
  38. public static function suite()
  39. {
  40. return new PHPUnit_Framework_TestSuite( "ezcGraphRadarChartAxisTest" );
  41. }
  42. protected function setUp()
  43. {
  44. static $i = 0;
  45. $this->tempDir = $this->createTempDir( __CLASS__ . sprintf( '_%03d_', ++$i ) ) . '/';
  46. $this->basePath = dirname( __FILE__ ) . '/data/';
  47. }
  48. protected function tearDown()
  49. {
  50. if ( !$this->hasFailed() )
  51. {
  52. $this->removeTempDir();
  53. }
  54. }
  55. public function testCenteredMultipleDirections()
  56. {
  57. $filename = $this->tempDir . __FUNCTION__ . '.svg';
  58. $chart = new ezcGraphRadarChart();
  59. $chart->palette = new ezcGraphPaletteEzBlue();
  60. $chart->legend = false;
  61. $chart->data['sample'] = new ezcGraphArrayDataSet( $this->getRandomData( 13 ) );
  62. $chart->axis->axisLabelRenderer = new ezcGraphAxisCenteredLabelRenderer();
  63. $chart->render( 500, 500, $filename );
  64. $this->compare(
  65. $filename,
  66. $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
  67. );
  68. }
  69. public function testBoxedMultipleDirections()
  70. {
  71. $filename = $this->tempDir . __FUNCTION__ . '.svg';
  72. $chart = new ezcGraphRadarChart();
  73. $chart->palette = new ezcGraphPaletteEzBlue();
  74. $chart->legend = false;
  75. $chart->data['sample'] = new ezcGraphArrayDataSet( $this->getRandomData( 13 ) );
  76. $chart->axis->axisLabelRenderer = new ezcGraphAxisBoxedLabelRenderer();
  77. $chart->render( 500, 500, $filename );
  78. $this->compare(
  79. $filename,
  80. $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
  81. );
  82. }
  83. public function testExactMultipleDirections()
  84. {
  85. $filename = $this->tempDir . __FUNCTION__ . '.svg';
  86. $chart = new ezcGraphRadarChart();
  87. $chart->palette = new ezcGraphPaletteEzBlue();
  88. $chart->legend = false;
  89. $chart->data['sample'] = new ezcGraphArrayDataSet( $this->getRandomData( 13 ) );
  90. $chart->axis->axisLabelRenderer = new ezcGraphAxisExactLabelRenderer();
  91. $chart->axis->axisLabelRenderer->showLastValue = false;
  92. $chart->render( 500, 500, $filename );
  93. $this->compare(
  94. $filename,
  95. $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
  96. );
  97. }
  98. public function testDateRotationAxis()
  99. {
  100. $filename = $this->tempDir . __FUNCTION__ . '.svg';
  101. $chart = new ezcGraphRadarChart();
  102. $chart->palette = new ezcGraphPaletteEzBlue();
  103. $chart->legend = false;
  104. $chart->data['sample'] = new ezcGraphArrayDataSet( array(
  105. strtotime( '2006-10-16' ) => 7.78507871321,
  106. strtotime( '2006-10-30' ) => 7.52224503765,
  107. strtotime( '2006-11-20' ) => 7.29226557153,
  108. strtotime( '2006-11-28' ) => 7.06228610541,
  109. strtotime( '2006-12-05' ) => 6.66803559206,
  110. strtotime( '2006-12-11' ) => 6.37234770705,
  111. strtotime( '2006-12-28' ) => 6.04517453799,
  112. ) );
  113. $chart->rotationAxis = new ezcGraphChartElementDateAxis();
  114. $chart->render( 400, 200, $filename );
  115. $this->compare(
  116. $filename,
  117. $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
  118. );
  119. }
  120. public function testNumericRotationAxis()
  121. {
  122. $filename = $this->tempDir . __FUNCTION__ . '.svg';
  123. $chart = new ezcGraphRadarChart();
  124. $chart->palette = new ezcGraphPaletteEzBlue();
  125. $chart->legend = false;
  126. $chart->data['sample'] = new ezcGraphArrayDataSet( $this->getRandomData( 9 ) );
  127. $chart->rotationAxis = new ezcGraphChartElementNumericAxis();
  128. $chart->render( 400, 200, $filename );
  129. $this->compare(
  130. $filename,
  131. $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
  132. );
  133. }
  134. public function testLabeledRotationAxis()
  135. {
  136. $filename = $this->tempDir . __FUNCTION__ . '.svg';
  137. $chart = new ezcGraphRadarChart();
  138. $chart->palette = new ezcGraphPaletteEzBlue();
  139. $chart->legend = false;
  140. $chart->data['sample'] = new ezcGraphArrayDataSet( $this->getRandomData( 9 ) );
  141. $chart->rotationAxis = new ezcGraphChartElementLabeledAxis();
  142. $chart->render( 400, 200, $filename );
  143. $this->compare(
  144. $filename,
  145. $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
  146. );
  147. }
  148. public function testLogarithmicalRotationAxis()
  149. {
  150. $filename = $this->tempDir . __FUNCTION__ . '.svg';
  151. $chart = new ezcGraphRadarChart();
  152. $chart->palette = new ezcGraphPaletteEzBlue();
  153. $chart->legend = false;
  154. $chart->data['sample'] = new ezcGraphArrayDataSet( array(
  155. 1 => 12,
  156. 5 => 7,
  157. 10 => 234,
  158. 132 => 34,
  159. 1125 => 12,
  160. 12346 => 6,
  161. 140596 => 1,
  162. ) );
  163. $chart->rotationAxis = new ezcGraphChartElementLogarithmicalAxis();
  164. $chart->render( 400, 200, $filename );
  165. $this->compare(
  166. $filename,
  167. $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
  168. );
  169. }
  170. }
  171. ?>