Welcome to mirror list, hosted at ThFree Co, Russian Federation.

OpenFlashChart.php « Visualization « modules - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fe85d348b72cebbae08969cc2d80fe328e750734 (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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
<?php
require_once "iView.php";
abstract class Piwik_Visualization_OpenFlashChart implements iView
{	
	// Original class provided by Open Flash Chart
    function __construct()
    {
		$this->data = array();
		$this->x_labels = array();
		$this->y_min = 0;
		$this->y_max = 20;
		$this->y_steps = 5;
		$this->title = '';
		$this->title_style = '';

		$this->x_tick_size = -1;

		$this->y2_max = '';
		$this->y2_min = '';
		
		// GRID styles:
		$this->x_axis_colour = '';
		$this->x_axis_3d = '';
		$this->x_grid_colour = '';
		$this->x_axis_steps = 1;
		$this->y_axis_colour = '';
		$this->y_grid_colour = '';
		$this->y2_axis_colour = '';
    
		// AXIS LABEL styles:         
		$this->x_label_style = '';
		$this->y_label_style = '';
		$this->y_label_style_right = '';
		

		// AXIS LEGEND styles:
		$this->x_legend = '';
		$this->x_legend_size = 20;
		$this->x_legend_colour = '#000000';

		$this->y_legend = '';
		$this->y_legend_right = '';
		//$this->y_legend_size = 20;
		//$this->y_legend_colour = '#000000';

		$this->lines = array();
		$this->line_default = '&line=3,#87421F&'. "\r\n";

		$this->bg_colour = '';
		$this->bg_image = '';

		$this->inner_bg_colour = '';
		$this->inner_bg_colour_2 = '';
		$this->inner_bg_angle = '';

		// PIE chart ------------
		$this->pie = '';
		$this->pie_values = '';
		$this->pie_colours = '';
		$this->pie_labels = '';

		$this->tool_tip = '';
		
		// which data lines are attached to the
		// right Y axis?
		$this->y2_lines = array();
    }

    function set_data( $a )
    {
    	if( count( $this->data ) == 0 )
        	$this->data[] = '&values='.implode(',',$a).'&'."\r\n";
        else
        	$this->data[] = '&values_'. (count( $this->data )+1) .'='.implode(',',$a).'&'."\r\n";
    }

    function set_tool_tip( $tip )
    {
        $this->tool_tip = $tip;
    }
    
    function set_x_labels( $a )
    {
        $this->x_labels = $a;
    }
    
    function set_x_label_style( $size, $colour='', $orientation=0, $step=-1, $grid_colour='' )
    {
        
        $this->x_label_style = '&x_label_style='. $size;
        
        if( strlen( $colour ) > 0 )
            $this->x_label_style .= ','. $colour;

        if( $orientation > -1 )
            $this->x_label_style .= ','. $orientation;

        if( $step > 0 )
            $this->x_label_style .= ','. $step;
        
        if( strlen( $grid_colour ) > 0 )
            $this->x_label_style .= ','. $grid_colour;
            
        $this->x_label_style .= "&\r\n";
    }

    function set_bg_colour( $colour )
    {
        $this->bg_colour = $colour;
    }

    function set_bg_image( $url, $x='center', $y='center' )
    {
        $this->bg_image = $url;
        $this->bg_image_x = $x;
        $this->bg_image_y = $y;
    }

	function attach_to_y_right_axis( $data_number )
	{
		$this->y2_lines[] = $data_number;
	}
    
    function set_inner_background( $col, $col2='', $angle=-1 )
    {

         $this->inner_bg_colour = $col;


         if( strlen($col2) > 0 )
             $this->inner_bg_colour_2 = $col2;

         if( $angle != -1 )
             $this->inner_bg_angle = $angle;

    }

    function _set_y_label_style( $name, $size, $colour )
    {
    	$tmp = '&'. $name .'='. $size;
    	
    	if( strlen( $colour ) > 0 )
                $tmp .= ','. $colour;
    	
    	return $tmp;
	}
	
    function set_y_label_style( $size, $colour='' )
    {
        $this->y_label_style = $this->_set_y_label_style( 'y_label_style', $size, $colour );
    }
    
    function set_y_right_label_style( $size, $colour='' )
    {
        $this->y_label_style_right = $this->_set_y_label_style( 'y2_label_style', $size, $colour );
    }
    
    function set_y_max( $max )
    {

        $this->y_max = intval( $max );
    }

    function set_y_min( $min )
    {

        $this->y_min = intval( $min );
    }
        
    function set_y_right_max( $max )
    {
    	$this->y2_max = '&y2_max='. $max .'&'."\r\n";
	}
    
    function set_y_right_min( $min )
    {
    	$this->y2_min = '&y2_min='. $min .'&'."\r\n";
	}
	
    function y_label_steps( $val )
    {
         $this->y_steps = intval( $val );
    }
    
    function title( $title, $style='' )
    {
        $this->title = $title;
        if( strlen( $style ) > 0 )
                $this->title_style = $style;
    }
    
    function set_x_legend( $text, $size=-1, $colour='' )
    {
         $this->x_legend = $text;
         if( $size > -1 )
                $this->x_legend_size = $size;
                
         if( strlen( $colour )>0 )
                $this->x_legend_colour = $colour;
    }
    
    function set_x_tick_size( $size )
    {
        if( $size > 0 )
                $this->x_tick_size = $size;
    }

    function set_x_axis_steps( $steps )
    {
        if ( $steps > 0 )
            $this->x_axis_steps = $steps;
    }
    
    function set_x_axis_3d( $size )
    {
    	if( $size > 0 )
    		$this->x_axis_3d = '&x_axis_3d='. $size ."&\r\n";
	}
	
	// PRIVATE METHOD
	function _set_y_legend( $label, $text, $size, $colour )
	{
		$tmp = '&'. $label .'=';
		$tmp .= $text;
    	
         if( $size > -1 )
         	$tmp .= ','. $size;

         if( strlen( $colour )>0 )
         	$tmp .= ','. $colour;
                
         $tmp .= "&\r\n";
         
         return $tmp;
	}

    function set_y_legend( $text, $size=-1, $colour='' )
    {
    	$this->y_legend = $this->_set_y_legend( 'y_legend', $text, $size, $colour );
    }
    
    function set_y_right_legend( $text, $size=-1, $colour='' )
    {
    	$this->y_legend_right = $this->_set_y_legend( 'y2_legend', $text, $size, $colour );
    }
    
    function line( $width, $colour='', $text='', $size=-1, $circles=-1 )
    {
    	$tmp = '&line';
    	
    	if( count( $this->lines ) > 0 )
        	$tmp .= '_'. (count( $this->lines )+1);
        	
    	$tmp .= '=';
    	
        if( $width > 0 )
        {
                $tmp .= $width;
                $tmp .= ','. $colour;
        }
                
        if( strlen( $text ) > 0 )
        {
                $tmp .= ','. $text;
                $tmp .= ','. $size;
        }
        
        if( $circles > 0 )
                $tmp .= ','. $circles;
        
        $tmp .= "&\r\n";;
        
        $this->lines[] = $tmp;
    }

    function line_dot( $width, $dot_size, $colour, $text='', $font_size='' )
    {
    	$tmp = '&line_dot';
    	
    	if( count( $this->lines ) > 0 )
        	$tmp .= '_'. (count( $this->lines )+1);
        	
    	$tmp .= "=$width,$colour,$text";

        if( strlen( $font_size ) > 0 )
            $tmp .= ",$font_size,$dot_size";
        
        $tmp .= "&\r\n";
        
        $this->lines[] = $tmp;
    }

    function line_hollow( $width, $dot_size, $colour, $text='', $font_size='' )
    {
    	$tmp = '&line_hollow';
    	
    	if( count( $this->lines ) > 0 )
        	$tmp .= '_'. (count( $this->lines )+1);
        	
    	$tmp .= "=$width,$colour,$text";

        if( strlen( $font_size ) > 0 )
            $tmp .= ",$font_size,$dot_size";
        
        $tmp .= "&\r\n";
        $this->lines[] = $tmp;
    }

    function area_hollow( $width, $dot_size, $colour, $alpha, $text='', $font_size='', $fill_colour='' )
    {
    	$tmp = '&area_hollow';
    	
    	if( count( $this->lines ) > 0 )
        	$tmp .= '_'. (count( $this->lines )+1);
        	
    	$tmp .= "=$width,$dot_size,$colour,$alpha";

        if( strlen( $text ) > 0 )
            $tmp .= ",$text,$font_size";
            
        if( strlen( $fill_colour ) > 0 )
        	$tmp .= ','. $fill_colour;

        $tmp .= "&\r\n";
        
        $this->lines[] = $tmp;
    }


    function bar( $alpha, $colour='', $text='', $size=-1 )
    {
    	$tmp = '&bar';
    	
    	if( count( $this->lines ) > 0 )
        	$tmp .= '_'. (count( $this->lines )+1);
        	
    	$tmp .= '=';
        $tmp .= $alpha .','. $colour .','. $text .','. $size;
        $tmp .= "&\r\n";;
        
        $this->lines[] = $tmp;
    }

    function bar_filled( $alpha, $colour, $colour_outline, $text='', $size=-1 )
    {
    	$tmp = '&filled_bar';
    	
    	if( count( $this->lines ) > 0 )
        	$tmp .= '_'. (count( $this->lines )+1);
        	
    	$tmp .= "=$alpha,$colour,$colour_outline,$text,$size&\r\n";
        
        $this->lines[] = $tmp;
    }
    
    function bar_3D( $alpha, $colour='', $text='', $size=-1 )
    {
    	$tmp = '&bar_3d';
    	
    	if( count( $this->lines ) > 0 )
        	$tmp .= '_'. (count( $this->lines )+1);
        	
    	$tmp .= '=';
        $tmp .= $alpha .','. $colour .','. $text .','. $size;
        $tmp .= "&\r\n";;
        
        $this->lines[] = $tmp;
    }
    
	function bar_glass( $alpha, $colour, $outline_colour, $text='', $size=-1 )
	{
		$tmp = '&bar_glass';

		if( count( $this->lines ) > 0 )
			$tmp .= '_'. (count( $this->lines )+1);

		$tmp .= '=';
		$tmp .= $alpha .','. $colour .','. $outline_colour .','. $text .','. $size;
		$tmp .= "&\r\n";;

		$this->lines[] = $tmp;
	}
	
	function bar_fade( $alpha, $colour='', $text='', $size=-1 )
	{
		$tmp = '&bar_fade';

		if( count( $this->lines ) > 0 )
			$tmp .= '_'. (count( $this->lines )+1);

		$tmp .= '=';
		$tmp .= $alpha .','. $colour .','. $text .','. $size;
		$tmp .= "&\r\n";;

		$this->lines[] = $tmp;
	}
    
    function x_axis_colour( $axis, $grid='' )
    {
		$this->x_axis_colour = $axis;
		$this->x_grid_colour = $grid;
	}
		
    function y_axis_colour( $axis, $grid='' )
    {
    	$this->y_axis_colour = '&y_axis_colour='. $axis .'&'."\r\n";
		
		if( strlen( $grid ) > 0 )
			$this->y_grid_colour = '&y_grid_colour='. $grid .'&'."\r\n";
    }
    
    function y_right_axis_colour( $colour )
    {
         $this->y2_axis_colour = '&y2_axis_colour='. $colour .'&'."\r\n";
    }
    

    function pie( $alpha, $line_colour, $label_colour )
    {
         $this->pie = $alpha.','.$line_colour.','.$label_colour;

    }

    function pie_values( $values, $labels )
    {
         $this->pie_values = implode(',',$values);
         $this->pie_labels = implode(',',$labels);
    }


    function pie_slice_colours( $colours )
    {
        $this->pie_colours = implode(',',$colours);
    }

    

    function render()
    {
        //$tmp = "&padding=70,5,50,40&\r\n";
        $tmp = '';
        
        if( strlen( $this->title ) > 0 )
        {
                $tmp .= '&title='. $this->title .',';
                $tmp .= $this->title_style .'&';
                $tmp .= "\r\n";
        }
        
        if( strlen( $this->x_legend ) > 0 )
        {
                $tmp .= '&x_legend='. $this->x_legend .',';
                $tmp .= $this->x_legend_size .',';
                $tmp .= $this->x_legend_colour ."&\r\n";
        }

        if( strlen( $this->x_label_style ) > 0 )
            $tmp .= $this->x_label_style;
            
        if( $this->x_tick_size > 0 )
                $tmp .= "&x_ticks=". $this->x_tick_size ."&\r\n";
                
        if( $this->x_axis_steps > 0 )
        	$tmp .= "&x_axis_steps=". $this->x_axis_steps ."&\r\n";

		if( strlen( $this->x_axis_3d ) > 0 )
			$tmp .= $this->x_axis_3d;
        
        $tmp .= $this->y_legend;	
        $tmp .= $this->y_legend_right;

        if( strlen( $this->y_label_style ) > 0 )
            $tmp .= $this->y_label_style;

        $tmp .= '&y_ticks=5,10,'. $this->y_steps .'&'."\r\n";
        
        if( count( $this->lines ) == 0 )
        {
			$tmp .= $this->line_default;	
        }
        else
        {
			foreach( $this->lines as $line )
				$tmp .= $line;	
        }

        foreach( $this->data as $data )
				$tmp .= $data;
		
		if( count( $this->y2_lines ) > 0 )
		{
			$tmp .= '&y2_lines=';
			$tmp .= implode( ',', $this->y2_lines );
			$tmp .= '&'."\r\n";
			//
			// Should this be an option? I think so...
			//
			$tmp .= '&show_y2=true&'."\r\n";
		}	
        
        if( count( $this->x_labels ) > 0 )
                $tmp .= '&x_labels='.implode(',',$this->x_labels).'&'."\r\n";
                
        $tmp .= '&y_min='. $this->y_min .'&'."\r\n";
        $tmp .= '&y_max='. $this->y_max .'&'."\r\n";
        
        $tmp .= $this->y2_max;
		$tmp .= $this->y2_min;
        
        if( strlen( $this->bg_colour ) > 0 )
        	$tmp .= '&bg_colour='. $this->bg_colour .'&'."\r\n";

        if( strlen( $this->bg_image ) > 0 )
        {
                $tmp .= '&bg_image='. $this->bg_image .'&'."\r\n";
                $tmp .= '&bg_image_x='. $this->bg_image_x .'&'."\r\n";
                $tmp .= '&bg_image_y='. $this->bg_image_y .'&'."\r\n";
        }


        if( strlen( $this->x_axis_colour ) > 0 )
        {
            $tmp .= '&x_axis_colour='. $this->x_axis_colour .'&'."\r\n";
            $tmp .= '&x_grid_colour='. $this->x_grid_colour .'&'."\r\n";
        }

        if( strlen( $this->y_axis_colour ) > 0 )
        	$tmp .= $this->y_axis_colour;
		
		if( strlen( $this->y_grid_colour ) > 0 )
			$tmp .= $this->y_grid_colour;
			
		if( strlen( $this->y2_axis_colour ) > 0 )    
			$tmp .= $this->y2_axis_colour;

        if( strlen( $this->inner_bg_colour ) > 0 )
        {
            $tmp .= '&inner_background='.$this->inner_bg_colour;
            if( strlen( $this->inner_bg_colour_2 ) > 0 )
            {
             
                $tmp .= ','. $this->inner_bg_colour_2;
                $tmp .= ','. $this->inner_bg_angle;
            }
            $tmp .= '&'."\r\n";
        }

        if( strlen( $this->pie ) > 0 )
        {

             $tmp .= '&pie='.        $this->pie .'&'."\r\n";
             $tmp .= '&values='.     $this->pie_values .'&'."\r\n";
             $tmp .= '&pie_labels='. $this->pie_labels .'&'."\r\n";
             $tmp .= '&colours='.    $this->pie_colours .'&'."\r\n";
        }

        if( strlen( $this->tool_tip ) > 0 )
        {
             $tmp .= '&tool_tip='. $this->tool_tip .'&'."\r\n";
        }

        return $tmp;
    }
}
?>