summaryrefslogtreecommitdiffstats
path: root/tests/radar_axis_test.php
blob: 8feba75e41fa826e3480b39f2c5112b321811972 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<?php
/**
 * ezcGraphRadarChartAxisTest 
 * 
 * @package Graph
 * @version //autogen//
 * @subpackage Tests
 * @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
 * @license http://ez.no/licenses/new_bsd New BSD License
 */

require_once dirname( __FILE__ ) . '/test_case.php';

/**
 * Tests for ezcGraph class.
 * 
 * @package Graph
 * @subpackage Tests
 */
class ezcGraphRadarChartAxisTest extends ezcGraphTestCase
{
    protected $basePath;

    protected $tempDir;

	public static function suite()
	{
		return new PHPUnit_Framework_TestSuite( "ezcGraphRadarChartAxisTest" );
	}

    protected function setUp()
    {
        static $i = 0;
        $this->tempDir = $this->createTempDir( __CLASS__ . sprintf( '_%03d_', ++$i ) ) . '/';
        $this->basePath = dirname( __FILE__ ) . '/data/';
    }

    protected function tearDown()
    {
        if ( !$this->hasFailed() )
        {
            $this->removeTempDir();
        }
    }

    public function testCenteredMultipleDirections()
    {
        $filename = $this->tempDir . __FUNCTION__ . '.svg';

        $chart = new ezcGraphRadarChart();
        $chart->palette = new ezcGraphPaletteEzBlue();
        $chart->legend = false;
        $chart->data['sample'] = new ezcGraphArrayDataSet( $this->getRandomData( 13 ) );

        $chart->axis->axisLabelRenderer = new ezcGraphAxisCenteredLabelRenderer();

        $chart->render( 500, 500, $filename );

        $this->compare(
            $filename,
            $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
        );
    }

    public function testBoxedMultipleDirections()
    {
        $filename = $this->tempDir . __FUNCTION__ . '.svg';

        $chart = new ezcGraphRadarChart();
        $chart->palette = new ezcGraphPaletteEzBlue();
        $chart->legend = false;
        $chart->data['sample'] = new ezcGraphArrayDataSet( $this->getRandomData( 13 ) );

        $chart->axis->axisLabelRenderer = new ezcGraphAxisBoxedLabelRenderer();

        $chart->render( 500, 500, $filename );

        $this->compare(
            $filename,
            $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
        );
    }

    public function testExactMultipleDirections()
    {
        $filename = $this->tempDir . __FUNCTION__ . '.svg';

        $chart = new ezcGraphRadarChart();
        $chart->palette = new ezcGraphPaletteEzBlue();
        $chart->legend = false;
        $chart->data['sample'] = new ezcGraphArrayDataSet( $this->getRandomData( 13 ) );

        $chart->axis->axisLabelRenderer = new ezcGraphAxisExactLabelRenderer();
        $chart->axis->axisLabelRenderer->showLastValue = false;

        $chart->render( 500, 500, $filename );

        $this->compare(
            $filename,
            $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
        );
    }

    public function testDateRotationAxis()
    {
        $filename = $this->tempDir . __FUNCTION__ . '.svg';

        $chart = new ezcGraphRadarChart();
        $chart->palette = new ezcGraphPaletteEzBlue();
        $chart->legend = false;
        $chart->data['sample'] = new ezcGraphArrayDataSet( array( 
            strtotime( '2006-10-16' ) => 7.78507871321,
            strtotime( '2006-10-30' ) => 7.52224503765,
            strtotime( '2006-11-20' ) => 7.29226557153,
            strtotime( '2006-11-28' ) => 7.06228610541,
            strtotime( '2006-12-05' ) => 6.66803559206,
            strtotime( '2006-12-11' ) => 6.37234770705,
            strtotime( '2006-12-28' ) => 6.04517453799,
        ) );

        $chart->rotationAxis = new ezcGraphChartElementDateAxis();

        $chart->render( 400, 200, $filename );

        $this->compare(
            $filename,
            $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
        );
    }

    public function testNumericRotationAxis()
    {
        $filename = $this->tempDir . __FUNCTION__ . '.svg';

        $chart = new ezcGraphRadarChart();
        $chart->palette = new ezcGraphPaletteEzBlue();
        $chart->legend = false;
        $chart->data['sample'] = new ezcGraphArrayDataSet( $this->getRandomData( 9 ) );

        $chart->rotationAxis = new ezcGraphChartElementNumericAxis();

        $chart->render( 400, 200, $filename );

        $this->compare(
            $filename,
            $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
        );
    }

    public function testLabeledRotationAxis()
    {
        $filename = $this->tempDir . __FUNCTION__ . '.svg';

        $chart = new ezcGraphRadarChart();
        $chart->palette = new ezcGraphPaletteEzBlue();
        $chart->legend = false;
        $chart->data['sample'] = new ezcGraphArrayDataSet( $this->getRandomData( 9 ) );

        $chart->rotationAxis = new ezcGraphChartElementLabeledAxis();

        $chart->render( 400, 200, $filename );

        $this->compare(
            $filename,
            $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
        );
    }

    public function testLogarithmicalRotationAxis()
    {
        $filename = $this->tempDir . __FUNCTION__ . '.svg';

        $chart = new ezcGraphRadarChart();
        $chart->palette = new ezcGraphPaletteEzBlue();
        $chart->legend = false;
        $chart->data['sample'] = new ezcGraphArrayDataSet( array(
            1 => 12,
            5 => 7,
            10 => 234,
            132 => 34,
            1125 => 12,
            12346 => 6,
            140596 => 1,
        ) );

        $chart->rotationAxis = new ezcGraphChartElementLogarithmicalAxis();

        $chart->render( 400, 200, $filename );

        $this->compare(
            $filename,
            $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
        );
    }
}
?>
OpenPOWER on IntegriCloud