PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 1.4.1
Visualizer – Tables & Charts Manager with Built-in AI Generator v1.4.1
4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 3.10.4 All 148 releases
visualizer / classes / Visualizer / Render / Sidebar / Graph.php

Graph.php in Visualizer – Tables & Charts Manager with Built-in AI Generator 1.4.1, at classes/Visualizer/Render/Sidebar/Graph.php

415 lines 13.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // +----------------------------------------------------------------------+
4 // | Copyright 2013 Madpixels (email : visualizer@madpixels.net) |
5 // +----------------------------------------------------------------------+
6 // | This program is free software; you can redistribute it and/or modify |
7 // | it under the terms of the GNU General Public License, version 2, as |
8 // | published by the Free Software Foundation. |
9 // | |
10 // | This program is distributed in the hope that it will be useful, |
11 // | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 // | GNU General Public License for more details. |
14 // | |
15 // | You should have received a copy of the GNU General Public License |
16 // | along with this program; if not, write to the Free Software |
17 // | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, |
18 // | MA 02110-1301 USA |
19 // +----------------------------------------------------------------------+
20 // | Author: Eugene Manuilov <eugene@manuilov.org> |
21 // +----------------------------------------------------------------------+
22
23
24 /**
25 * Base class for sidebar settigns of graph based charts.
26 *
27 * @category Visualizer
28 * @package Render
29 * @subpackage Sidebar
30 *
31 * @since 1.0.0
32 * @abstract
33 */
34 abstract class Visualizer_Render_Sidebar_Graph extends Visualizer_Render_Sidebar {
35
36 /**
37 * Determines whether we need to render vertical gridlines options or not.
38 *
39 * @since 1.0.0
40 *
41 * @access protected
42 * @var boolean
43 */
44 protected $_verticalGridLines;
45
46 /**
47 * Determines whether we need to render horizontal gridlines options or not.
48 *
49 * @since 1.0.0
50 *
51 * @access protected
52 * @var boolean
53 */
54 protected $_horizontalGridLines;
55
56 /**
57 * The array of available axis positions.
58 *
59 * @since 1.0.0
60 *
61 * @access protected
62 * @var array
63 */
64 protected $_positions;
65
66 /**
67 * Constructor.
68 *
69 * @since 1.0.0
70 *
71 * @access public
72 * @param array $data The data what has to be associated with this render.
73 */
74 public function __construct( $data = array() ) {
75 parent::__construct( $data );
76
77 $this->_verticalGridLines = true;
78 $this->_horizontalGridLines = true;
79
80 $this->_positions = array(
81 '' => '',
82 'in' => esc_html__( 'Inside the chart', Visualizer_Plugin::NAME ),
83 'out' => esc_html__( 'Outside the chart', Visualizer_Plugin::NAME ),
84 'none' => esc_html__( 'None', Visualizer_Plugin::NAME ),
85 );
86 }
87
88 /**
89 * Renders chart title settings.
90 *
91 * @since 1.0.0
92 *
93 * @access protected
94 */
95 protected function _renderChartTitleSettings() {
96 self::_renderTextItem(
97 esc_html__( 'Chart Title', Visualizer_Plugin::NAME ),
98 'title',
99 $this->title,
100 esc_html__( 'Text to display above the chart.', Visualizer_Plugin::NAME )
101 );
102
103 self::_renderSelectItem(
104 esc_html__( 'Chart Title Position', Visualizer_Plugin::NAME ),
105 'titlePosition',
106 $this->titlePosition,
107 $this->_positions,
108 esc_html__( 'Where to place the chart title, compared to the chart area.', Visualizer_Plugin::NAME )
109 );
110
111 self::_renderColorPickerItem(
112 esc_html__( 'Chart Title Color', Visualizer_Plugin::NAME ),
113 'titleTextStyle[color]',
114 isset( $this->titleTextStyle['color'] ) ? $this->titleTextStyle['color'] : null,
115 '#000'
116 );
117
118 echo '<div class="section-delimiter"></div>';
119
120 self::_renderSelectItem(
121 esc_html__( 'Axes Titles Position', Visualizer_Plugin::NAME ),
122 'axisTitlesPosition',
123 $this->axisTitlesPosition,
124 $this->_positions,
125 esc_html__( 'Determines where to place the axis titles, compared to the chart area.', Visualizer_Plugin::NAME )
126 );
127 }
128
129 /**
130 * Renders general settings block for horizontal axis settings.
131 *
132 * @since 1.4.0
133 *
134 * @access protected
135 */
136 protected function _renderHorizontalAxisGeneratSettings() {
137 self::_renderTextItem(
138 esc_html__( 'Axis Title', Visualizer_Plugin::NAME ),
139 'hAxis[title]',
140 isset( $this->hAxis['title'] ) ? $this->hAxis['title'] : '',
141 esc_html__( 'The title of the horizontal axis.', Visualizer_Plugin::NAME )
142 );
143
144 self::_renderSelectItem(
145 esc_html__( 'Text Position', Visualizer_Plugin::NAME ),
146 'vAxis[textPosition]',
147 isset( $this->vAxis['textPosition'] ) ? $this->vAxis['textPosition'] : '',
148 $this->_positions,
149 esc_html__( 'Position of the horizontal axis text, relative to the chart area.', Visualizer_Plugin::NAME )
150 );
151
152 self::_renderSelectItem(
153 esc_html__( 'Direction', Visualizer_Plugin::NAME ),
154 'hAxis[direction]',
155 isset( $this->hAxis['direction'] ) ? $this->hAxis['direction'] : '',
156 array(
157 '' => '',
158 '1' => esc_html__( 'Identical Direction', Visualizer_Plugin::NAME ),
159 '-1' => esc_html__( 'Reverse Direction', Visualizer_Plugin::NAME ),
160 ),
161 esc_html__( 'The direction in which the values along the horizontal axis grow.', Visualizer_Plugin::NAME )
162 );
163
164 self::_renderColorPickerItem(
165 esc_html__( 'Base Line Color', Visualizer_Plugin::NAME ),
166 'vAxis[baselineColor]',
167 isset( $this->vAxis['baselineColor'] ) ? $this->vAxis['baselineColor'] : null,
168 '#000'
169 );
170 }
171
172 /**
173 * Renders horizontal axis settings.
174 *
175 * @since 1.2.0
176 *
177 * @access protected
178 */
179 protected function _renderHorizontalAxisSettings() {
180 self::_renderGroupStart( esc_html__( 'Horizontal Axis Settings', Visualizer_Plugin::NAME ) );
181 self::_renderSectionStart( esc_html__( 'General Settings', Visualizer_Plugin::NAME ), false );
182 $this->_renderHorizontalAxisGeneratSettings();
183 self::_renderSectionEnd();
184
185 if ( $this->_horizontalGridLines ) {
186 self::_renderSectionStart( esc_html__( 'Grid Lines', Visualizer_Plugin::NAME ), false );
187 self::_renderTextItem(
188 esc_html__( 'Count', Visualizer_Plugin::NAME ),
189 'vAxis[gridlines][count]',
190 isset( $this->vAxis['gridlines']['count'] ) ? $this->vAxis['gridlines']['count'] : '',
191 esc_html__( 'The number of horizontal gridlines inside the chart area. Minimum value is 2. Specify -1 to automatically compute the number of gridlines.', Visualizer_Plugin::NAME ),
192 5
193 );
194
195 self::_renderColorPickerItem(
196 esc_html__( 'Color', Visualizer_Plugin::NAME ),
197 'vAxis[gridlines][color]',
198 isset( $this->vAxis['gridlines']['color'] ) ? $this->vAxis['gridlines']['color'] : null,
199 '#ccc'
200 );
201 self::_renderSectionEnd();
202
203 self::_renderSectionStart( esc_html__( 'Minor Grid Lines', Visualizer_Plugin::NAME ), false );
204 self::_renderTextItem(
205 esc_html__( 'Count', Visualizer_Plugin::NAME ),
206 'vAxis[minorGridlines][count]',
207 isset( $this->vAxis['minorGridlines']['count'] ) ? $this->vAxis['minorGridlines']['count'] : '',
208 esc_html__( 'The number of horizontal minor gridlines between two regular gridlines.', Visualizer_Plugin::NAME ),
209 0
210 );
211
212 self::_renderColorPickerItem(
213 esc_html__( 'Color', Visualizer_Plugin::NAME ),
214 'vAxis[minorGridlines][color]',
215 isset( $this->vAxis['minorGridlines']['color'] ) ? $this->vAxis['minorGridlines']['color'] : null,
216 null
217 );
218 self::_renderSectionEnd();
219 }
220
221 if ( $this->_verticalGridLines ) {
222 self::_renderSectionStart( esc_html__( 'View Window', Visualizer_Plugin::NAME ), false );
223 self::_renderTextItem(
224 esc_html__( 'Maximum Value', Visualizer_Plugin::NAME ),
225 'hAxis[viewWindow][max]',
226 isset( $this->hAxis['viewWindow']['max'] ) ? $this->hAxis['viewWindow']['max'] : '',
227 'The maximum vertical data value to render.'
228 );
229
230 self::_renderTextItem(
231 esc_html__( 'Minimum Value', Visualizer_Plugin::NAME ),
232 'hAxis[viewWindow][min]',
233 isset( $this->hAxis['viewWindow']['min'] ) ? $this->hAxis['viewWindow']['min'] : '',
234 'The minimum vertical data value to render.'
235 );
236 self::_renderSectionEnd();
237 }
238 self::_renderGroupEnd();
239 }
240
241 /**
242 * Renders general settings block for vertical axis settings.
243 *
244 * @since 1.4.0
245 *
246 * @access protected
247 */
248 protected function _renderVerticalAxisGeneralSettings() {
249 self::_renderTextItem(
250 esc_html__( 'Axis Title', Visualizer_Plugin::NAME ),
251 'vAxis[title]',
252 isset( $this->vAxis['title'] ) ? $this->vAxis['title'] : '',
253 esc_html__( 'The title of the vertical axis.', Visualizer_Plugin::NAME )
254 );
255
256 self::_renderSelectItem(
257 esc_html__( 'Text Position', Visualizer_Plugin::NAME ),
258 'hAxis[textPosition]',
259 isset( $this->hAxis['textPosition'] ) ? $this->hAxis['textPosition'] : '',
260 $this->_positions,
261 esc_html__( 'Position of the vertical axis text, relative to the chart area.', Visualizer_Plugin::NAME )
262 );
263
264 self::_renderSelectItem(
265 esc_html__( 'Direction', Visualizer_Plugin::NAME ),
266 'vAxis[direction]',
267 isset( $this->vAxis['direction'] ) ? $this->vAxis['direction'] : '',
268 array(
269 '' => '',
270 '1' => esc_html__( 'Identical Direction', Visualizer_Plugin::NAME ),
271 '-1' => esc_html__( 'Reverse Direction', Visualizer_Plugin::NAME ),
272 ),
273 esc_html__( 'The direction in which the values along the vertical axis grow.', Visualizer_Plugin::NAME )
274 );
275
276 self::_renderColorPickerItem(
277 esc_html__( 'Base Line Color', Visualizer_Plugin::NAME ),
278 'hAxis[baselineColor]',
279 isset( $this->hAxis['baselineColor'] ) ? $this->hAxis['baselineColor'] : null,
280 '#000'
281 );
282 }
283
284 /**
285 * Renders vertical axis settings.
286 *
287 * @since 1.2.0
288 *
289 * @access protected
290 */
291 protected function _renderVerticalAxisSettings() {
292 self::_renderGroupStart( esc_html__( 'Vertical Axis Settings', Visualizer_Plugin::NAME ) );
293 self::_renderSectionStart( esc_html__( 'General Settings', Visualizer_Plugin::NAME ), false );
294 $this->_renderVerticalAxisGeneralSettings();
295 self::_renderSectionEnd();
296
297 if ( $this->_verticalGridLines ) {
298 self::_renderSectionStart( esc_html__( 'Grid Lines', Visualizer_Plugin::NAME ), false );
299 self::_renderTextItem(
300 esc_html__( 'Count', Visualizer_Plugin::NAME ),
301 'hAxis[gridlines][count]',
302 isset( $this->hAxis['gridlines']['count'] ) ? $this->hAxis['gridlines']['count'] : '',
303 esc_html__( 'The number of vertical gridlines inside the chart area. Minimum value is 2. Specify -1 to automatically compute the number of gridlines.', Visualizer_Plugin::NAME ),
304 5
305 );
306
307 self::_renderColorPickerItem(
308 esc_html__( 'Color', Visualizer_Plugin::NAME ),
309 'hAxis[gridlines][color]',
310 isset( $this->hAxis['gridlines']['color'] ) ? $this->hAxis['gridlines']['color'] : null,
311 '#ccc'
312 );
313 self::_renderSectionEnd();
314
315 self::_renderSectionStart( esc_html__( 'Minor Grid Lines', Visualizer_Plugin::NAME ), false );
316 self::_renderTextItem(
317 esc_html__( 'Count', Visualizer_Plugin::NAME ),
318 'hAxis[minorGridlines][count]',
319 isset( $this->hAxis['minorGridlines']['count'] ) ? $this->hAxis['minorGridlines']['count'] : '',
320 esc_html__( 'The number of vertical minor gridlines between two regular gridlines.', Visualizer_Plugin::NAME ),
321 0
322 );
323
324 self::_renderColorPickerItem(
325 esc_html__( 'Color', Visualizer_Plugin::NAME ),
326 'hAxis[minorGridlines][color]',
327 isset( $this->hAxis['minorGridlines']['color'] ) ? $this->hAxis['minorGridlines']['color'] : null,
328 null
329 );
330 self::_renderSectionEnd();
331 }
332
333 if ( $this->_horizontalGridLines ) {
334 self::_renderSectionStart( esc_html__( 'View Window', Visualizer_Plugin::NAME ), false );
335 self::_renderTextItem(
336 esc_html__( 'Maximum Value', Visualizer_Plugin::NAME ),
337 'vAxis[viewWindow][max]',
338 isset( $this->vAxis['viewWindow']['max'] ) ? $this->vAxis['viewWindow']['max'] : '',
339 'The maximum vertical data value to render.'
340 );
341
342 self::_renderTextItem(
343 esc_html__( 'Minimum Value', Visualizer_Plugin::NAME ),
344 'vAxis[viewWindow][min]',
345 isset( $this->vAxis['viewWindow']['min'] ) ? $this->vAxis['viewWindow']['min'] : '',
346 'The minimum vertical data value to render.'
347 );
348 self::_renderSectionEnd();
349 }
350 self::_renderGroupEnd();
351 }
352
353 /**
354 * Renders chart axes settings.
355 *
356 * @since 1.0.0
357 *
358 * @access protected
359 */
360 protected function _renderAxesSettings() {
361 $this->_renderHorizontalAxisSettings();
362 $this->_renderVerticalAxisSettings();
363 }
364
365 /**
366 * Renders series settings group.
367 *
368 * @since 1.0.0
369 *
370 * @access protected
371 */
372 protected function _renderSeriesSettings() {
373 self::_renderGroupStart( esc_html__( 'Series Settings', Visualizer_Plugin::NAME ) );
374 for ( $i = 1, $cnt = count( $this->__series ); $i < $cnt; $i++ ) {
375 if ( !empty( $this->__series[$i]['label'] ) ) {
376 self::_renderSectionStart( esc_html( $this->__series[$i]['label'] ), false );
377 $this->_renderSeries( $i - 1 );
378 self::_renderSectionEnd();
379 }
380 }
381 self::_renderGroupEnd();
382 }
383
384 /**
385 * Renders concreate series settings.
386 *
387 * @since 1.0.0
388 *
389 * @access protected
390 * @param int $index The series index.
391 */
392 protected function _renderSeries( $index ) {
393 self::_renderSelectItem(
394 esc_html__( 'Visible In Legend', Visualizer_Plugin::NAME ),
395 'series[' . $index . '][visibleInLegend]',
396 isset( $this->series[$index]['visibleInLegend'] ) ? $this->series[$index]['visibleInLegend'] : '',
397 array(
398 '' => '',
399 '0' => esc_html__( 'No', Visualizer_Plugin::NAME ),
400 '1' => esc_html__( 'Yes', Visualizer_Plugin::NAME ),
401 ),
402 esc_html__( 'Determines whether the series has to be presented in the legend or not.', Visualizer_Plugin::NAME )
403 );
404
405 $this->_renderFormatField( $index );
406
407 self::_renderColorPickerItem(
408 esc_html__( 'Color', Visualizer_Plugin::NAME ),
409 'series[' . $index . '][color]',
410 isset( $this->series[$index]['color'] ) ? $this->series[$index]['color'] : null,
411 null
412 );
413 }
414
415 }