Passed
Push — master ( 8f5e6a...061d3e )
by Felipe
03:26
created

PastelTheme::SetupPieGraph()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 13

Duplication

Lines 24
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 13
nc 1
nop 1
dl 24
loc 24
rs 8.9713
c 0
b 0
f 0
1
<?php
2
namespace Amenadiel\JpGraph\Themes;
3
4
/**
5
 * Pastel Theme class
6
 */
7 View Code Duplication
class PastelTheme extends Theme
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
8
{
9
    private $font_color       = '#0044CC';
10
    private $background_color = '#DDFFFF';
11
    private $axis_color       = '#0066CC';
12
    private $grid_color       = '#3366CC';
13
14
    public function GetColorList()
15
    {
16
        return array(
17
            '#FFAACC',
18
            '#AAEECC',
19
            '#AACCFF',
20
            '#CCAAFF',
21
            '#EEDDFF',
22
            '#FFCCAA',
23
            '#CCBBDD',
24
            '#CCFFAA',
25
            '#C7D7C2',
26
            '#FFEEDD',
27
            '#FFCCEE',
28
            '#BFECFA',
29
        );
30
    }
31
32
    public function SetupGraph($graph)
33
    {
34
35
        // graph
36
        /*
1 ignored issue
show
Unused Code Comprehensibility introduced by
54% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
37
        $img = $graph->img;
38
        $height = $img->height;
39
        $graph->SetMargin($img->left_margin, $img->right_margin, $img->top_margin, $height * 0.25);
40
         */
41
        $graph->SetFrame(false);
42
        $graph->SetMarginColor('white');
43
        $graph->SetBackgroundGradient($this->background_color, '#FFFFFF', GRAD_HOR, BGRAD_PLOT);
44
45
        // legend
46
        $graph->legend->SetFrameWeight(0);
47
        $graph->legend->Pos(0.5, 0.85, 'center', 'top');
48
        $graph->legend->SetFillColor('white');
49
        $graph->legend->SetLayout(LEGEND_HOR);
50
        $graph->legend->SetColumns(3);
51
        $graph->legend->SetShadow(false);
52
        $graph->legend->SetMarkAbsSize(5);
53
54
        // xaxis
55
        $graph->xaxis->title->SetColor($this->font_color);
56
        $graph->xaxis->SetColor($this->axis_color, $this->font_color);
57
        $graph->xaxis->SetTickSide(SIDE_BOTTOM);
58
        $graph->xaxis->SetLabelMargin(10);
59
60
        // yaxis
61
        $graph->yaxis->title->SetColor($this->font_color);
62
        $graph->yaxis->SetColor($this->axis_color, $this->font_color);
63
        $graph->yaxis->SetTickSide(SIDE_LEFT);
64
        $graph->yaxis->SetLabelMargin(8);
65
        $graph->yaxis->HideLine();
66
        $graph->yaxis->HideTicks();
67
        $graph->xaxis->SetTitleMargin(15);
68
69
        // grid
70
        $graph->ygrid->SetColor($this->grid_color);
71
        $graph->ygrid->SetLineStyle('dotted');
72
73
        // font
74
        $graph->title->SetColor($this->font_color);
75
        $graph->subtitle->SetColor($this->font_color);
76
        $graph->subsubtitle->SetColor($this->font_color);
77
78
        //        $graph->img->SetAntiAliasing();
1 ignored issue
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
79
    }
80
81
    public function SetupPieGraph($graph)
82
    {
83
84
        // graph
85
        $graph->SetFrame(false);
86
87
        // legend
88
        $graph->legend->SetFillColor('white');
89
90
        $graph->legend->SetFrameWeight(0);
91
        $graph->legend->Pos(0.5, 0.80, 'center', 'top');
92
        $graph->legend->SetLayout(LEGEND_HOR);
93
        $graph->legend->SetColumns(4);
94
95
        $graph->legend->SetShadow(false);
96
        $graph->legend->SetMarkAbsSize(5);
97
98
        // title
99
        $graph->title->SetColor($this->font_color);
100
        $graph->subtitle->SetColor($this->font_color);
101
        $graph->subsubtitle->SetColor($this->font_color);
102
103
        $graph->SetAntiAliasing();
104
    }
105
106
    public function PreStrokeApply($graph)
107
    {
108
        if ($graph->legend->HasItems()) {
109
            $img    = $graph->img;
110
            $height = $img->height;
111
            $graph->SetMargin($img->left_margin, $img->right_margin, $img->top_margin, $height * 0.25);
112
        }
113
    }
114
115
    public function ApplyPlot($plot)
116
    {
117
        switch (get_class($plot)) {
118
            case 'GroupBarPlot':
0 ignored issues
show
Coding Style introduced by
case statements should be defined using a colon.

As per the PSR-2 coding standard, case statements should not be wrapped in curly braces. There is no need for braces, since each case is terminated by the next break.

There is also the option to use a semicolon instead of a colon, this is discouraged because many programmers do not even know it works and the colon is universal between programming languages.

switch ($expr) {
    case "A": { //wrong
        doSomething();
        break;
    }
    case "B"; //wrong
        doSomething();
        break;
    case "C": //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
119
                {
120
                    foreach ($plot->plots as $_plot) {
121
                        $this->ApplyPlot($_plot);
122
                    }
123
                    break;
124
                }
125
126
            case 'AccBarPlot':
0 ignored issues
show
Coding Style introduced by
case statements should be defined using a colon.

As per the PSR-2 coding standard, case statements should not be wrapped in curly braces. There is no need for braces, since each case is terminated by the next break.

There is also the option to use a semicolon instead of a colon, this is discouraged because many programmers do not even know it works and the colon is universal between programming languages.

switch ($expr) {
    case "A": { //wrong
        doSomething();
        break;
    }
    case "B"; //wrong
        doSomething();
        break;
    case "C": //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
127
                {
128
                    foreach ($plot->plots as $_plot) {
129
                        $this->ApplyPlot($_plot);
130
                    }
131
                    break;
132
                }
133
134
            case 'BarPlot':
0 ignored issues
show
Coding Style introduced by
case statements should be defined using a colon.

As per the PSR-2 coding standard, case statements should not be wrapped in curly braces. There is no need for braces, since each case is terminated by the next break.

There is also the option to use a semicolon instead of a colon, this is discouraged because many programmers do not even know it works and the colon is universal between programming languages.

switch ($expr) {
    case "A": { //wrong
        doSomething();
        break;
    }
    case "B"; //wrong
        doSomething();
        break;
    case "C": //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
135
                {
136
                    $plot->Clear();
137
138
                    $color = $this->GetNextColor();
139
                    $plot->SetColor($color);
140
                    $plot->SetFillColor($color);
141
                    $plot->SetShadow('red', 3, 4, false);
142
                    break;
143
                }
144
145
            case 'LinePlot':
0 ignored issues
show
Coding Style introduced by
case statements should be defined using a colon.

As per the PSR-2 coding standard, case statements should not be wrapped in curly braces. There is no need for braces, since each case is terminated by the next break.

There is also the option to use a semicolon instead of a colon, this is discouraged because many programmers do not even know it works and the colon is universal between programming languages.

switch ($expr) {
    case "A": { //wrong
        doSomething();
        break;
    }
    case "B"; //wrong
        doSomething();
        break;
    case "C": //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
146
                {
147
                    $plot->Clear();
148
                    $plot->SetColor($this->GetNextColor() . '@0.4');
149
                    $plot->SetWeight(2);
150
                    //                $plot->SetBarCenter();
1 ignored issue
show
Unused Code Comprehensibility introduced by
72% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
151
                    break;
152
                }
153
154
            case 'PiePlot':
0 ignored issues
show
Coding Style introduced by
case statements should be defined using a colon.

As per the PSR-2 coding standard, case statements should not be wrapped in curly braces. There is no need for braces, since each case is terminated by the next break.

There is also the option to use a semicolon instead of a colon, this is discouraged because many programmers do not even know it works and the colon is universal between programming languages.

switch ($expr) {
    case "A": { //wrong
        doSomething();
        break;
    }
    case "B"; //wrong
        doSomething();
        break;
    case "C": //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
155
                {
156
                    $plot->SetCenter(0.5, 0.45);
157
                    $plot->ShowBorder(false);
158
                    $plot->SetSliceColors($this->GetThemeColors());
159
                    break;
160
                }
161
162
            case 'PiePlot3D':
0 ignored issues
show
Coding Style introduced by
case statements should be defined using a colon.

As per the PSR-2 coding standard, case statements should not be wrapped in curly braces. There is no need for braces, since each case is terminated by the next break.

There is also the option to use a semicolon instead of a colon, this is discouraged because many programmers do not even know it works and the colon is universal between programming languages.

switch ($expr) {
    case "A": { //wrong
        doSomething();
        break;
    }
    case "B"; //wrong
        doSomething();
        break;
    case "C": //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
163
                {
164
                    $plot->SetSliceColors($this->GetThemeColors());
165
                    break;
166
                }
167
168
            default:
0 ignored issues
show
Coding Style introduced by
DEFAULT statements must be defined using a colon

As per the PSR-2 coding standard, default statements should not be wrapped in curly braces.

switch ($expr) {
    default: { //wrong
        doSomething();
        break;
    }
}

switch ($expr) {
    default: //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
169
                {
170
                }
171
        }
172
    }
173
}
174