PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.3.1
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.3.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 3.3.1, at classes/Visualizer/Render/Sidebar/Graph.php

476 lines 15.5 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 * Base class for sidebar settigns of graph based charts.
24 *
25 * @category Visualizer
26 * @package Render
27 * @subpackage Sidebar
28 *
29 * @since 1.0.0
30 * @abstract
31 */
32 abstract class Visualizer_Render_Sidebar_Graph extends Visualizer_Render_Sidebar_Google {
33
34 /**
35 * Determines whether we need to render vertical gridlines options or not.
36 *
37 * @since 1.0.0
38 *
39 * @access protected
40 * @var boolean
41 */
42 protected $_verticalGridLines;
43
44 /**
45 * Determines whether we need to render horizontal gridlines options or not.
46 *
47 * @since 1.0.0
48 *
49 * @access protected
50 * @var boolean
51 */
52 protected $_horizontalGridLines;
53
54 /**
55 * The array of available axis positions.
56 *
57 * @since 1.0.0
58 *
59 * @access protected
60 * @var array
61 */
62 protected $_positions;
63
64 /**
65 * Constructor.
66 *
67 * @since 1.0.0
68 *
69 * @access public
70 * @param array $data The data what has to be associated with this render.
71 */
72 public function __construct( $data = array() ) {
73 parent::__construct( $data );
74
75 $this->_verticalGridLines = true;
76 $this->_horizontalGridLines = true;
77
78 $this->_positions = array(
79 '' => '',
80 'in' => esc_html__( 'Inside the chart', 'visualizer' ),
81 'out' => esc_html__( 'Outside the chart', 'visualizer' ),
82 'none' => esc_html__( 'None', 'visualizer' ),
83 );
84 }
85
86 /**
87 * Renders chart title settings.
88 *
89 * @since 1.0.0
90 *
91 * @access protected
92 */
93 protected function _renderChartTitleSettings() {
94 self::_renderTextItem(
95 esc_html__( 'Chart Title', 'visualizer' ),
96 'title',
97 $this->title,
98 esc_html__( 'Text to display above the chart.', 'visualizer' )
99 );
100
101 self::_renderSelectItem(
102 esc_html__( 'Chart Title Position', 'visualizer' ),
103 'titlePosition',
104 $this->titlePosition,
105 $this->_positions,
106 esc_html__( 'Where to place the chart title, compared to the chart area.', 'visualizer' )
107 );
108
109 self::_renderColorPickerItem(
110 esc_html__( 'Chart Title Color', 'visualizer' ),
111 'titleTextStyle[color]',
112 isset( $this->titleTextStyle['color'] ) ? $this->titleTextStyle['color'] : null,
113 '#000'
114 );
115
116 echo '<div class="viz-section-delimiter"></div>';
117
118 self::_renderSelectItem(
119 esc_html__( 'Axes Titles Position', 'visualizer' ),
120 'axisTitlesPosition',
121 $this->axisTitlesPosition,
122 $this->_positions,
123 esc_html__( 'Determines where to place the axis titles, compared to the chart area.', 'visualizer' )
124 );
125 }
126
127 /**
128 * Renders general settings block for horizontal axis settings.
129 *
130 * @since 1.4.0
131 *
132 * @access protected
133 */
134 protected function _renderHorizontalAxisGeneralSettings() {
135 self::_renderTextItem(
136 esc_html__( 'Axis Title', 'visualizer' ),
137 'hAxis[title]',
138 isset( $this->hAxis['title'] ) ? $this->hAxis['title'] : '',
139 esc_html__( 'The title of the horizontal axis.', 'visualizer' )
140 );
141
142 self::_renderSelectItem(
143 esc_html__( 'Text Position', 'visualizer' ),
144 'hAxis[textPosition]',
145 isset( $this->hAxis['textPosition'] ) ? $this->hAxis['textPosition'] : '',
146 $this->_positions,
147 esc_html__( 'Position of the horizontal axis text, relative to the chart area.', 'visualizer' )
148 );
149
150 self::_renderSelectItem(
151 esc_html__( 'Direction', 'visualizer' ),
152 'hAxis[direction]',
153 isset( $this->hAxis['direction'] ) ? $this->hAxis['direction'] : '',
154 array(
155 '' => '',
156 '1' => esc_html__( 'Identical Direction', 'visualizer' ),
157 '-1' => esc_html__( 'Reverse Direction', 'visualizer' ),
158 ),
159 esc_html__( 'The direction in which the values along the horizontal axis grow.', 'visualizer' )
160 );
161
162 self::_renderColorPickerItem(
163 esc_html__( 'Base Line Color', 'visualizer' ),
164 'vAxis[baselineColor]',
165 isset( $this->vAxis['baselineColor'] ) ? $this->vAxis['baselineColor'] : null,
166 '#000'
167 );
168 }
169
170 /**
171 * Renders horizontal axis settings.
172 *
173 * @since 1.2.0
174 *
175 * @access protected
176 */
177 protected function _renderHorizontalAxisSettings() {
178 self::_renderGroupStart( esc_html__( 'Horizontal Axis Settings', 'visualizer' ) );
179 self::_renderSectionStart( esc_html__( 'General Settings', 'visualizer' ), false );
180 $this->_renderHorizontalAxisGeneralSettings();
181 self::_renderSectionEnd();
182
183 if ( $this->_horizontalGridLines ) {
184 self::_renderSectionStart( esc_html__( 'Grid Lines', 'visualizer' ), false );
185 self::_renderTextItem(
186 esc_html__( 'Count', 'visualizer' ),
187 'hAxis[gridlines][count]',
188 isset( $this->hAxis['gridlines']['count'] ) ? $this->hAxis['gridlines']['count'] : '',
189 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' ),
190 5
191 );
192
193 self::_renderColorPickerItem(
194 esc_html__( 'Color', 'visualizer' ),
195 'hAxis[gridlines][color]',
196 isset( $this->hAxis['gridlines']['color'] ) ? $this->hAxis['gridlines']['color'] : null,
197 '#ccc'
198 );
199 self::_renderSectionEnd();
200
201 self::_renderSectionStart( esc_html__( 'Minor Grid Lines', 'visualizer' ), false );
202 self::_renderTextItem(
203 esc_html__( 'Count', 'visualizer' ),
204 'vAxis[minorGridlines][count]',
205 isset( $this->vAxis['minorGridlines']['count'] ) ? $this->vAxis['minorGridlines']['count'] : '',
206 esc_html__( 'The number of horizontal minor gridlines between two regular gridlines.', 'visualizer' ),
207 0
208 );
209
210 self::_renderColorPickerItem(
211 esc_html__( 'Color', 'visualizer' ),
212 'vAxis[minorGridlines][color]',
213 isset( $this->vAxis['minorGridlines']['color'] ) ? $this->vAxis['minorGridlines']['color'] : null,
214 null
215 );
216 self::_renderSectionEnd();
217 }
218
219 if ( $this->_verticalGridLines ) {
220 self::_renderSectionStart( esc_html__( 'View Window', 'visualizer' ), false );
221 self::_renderTextItem(
222 esc_html__( 'Maximum Value', 'visualizer' ),
223 'hAxis[viewWindow][max]',
224 isset( $this->hAxis['viewWindow']['max'] ) ? $this->hAxis['viewWindow']['max'] : '',
225 'The maximum vertical data value to render.'
226 );
227
228 self::_renderTextItem(
229 esc_html__( 'Minimum Value', 'visualizer' ),
230 'hAxis[viewWindow][min]',
231 isset( $this->hAxis['viewWindow']['min'] ) ? $this->hAxis['viewWindow']['min'] : '',
232 'The minimum vertical data value to render.'
233 );
234 self::_renderSectionEnd();
235 }
236 self::_renderGroupEnd();
237 }
238
239 /**
240 * Renders general settings block for vertical axis settings.
241 *
242 * @since 1.4.0
243 *
244 * @access protected
245 */
246 protected function _renderVerticalAxisGeneralSettings() {
247 self::_renderTextItem(
248 esc_html__( 'Axis Title', 'visualizer' ),
249 'vAxis[title]',
250 isset( $this->vAxis['title'] ) ? $this->vAxis['title'] : '',
251 esc_html__( 'The title of the vertical axis.', 'visualizer' )
252 );
253
254 self::_renderSelectItem(
255 esc_html__( 'Text Position', 'visualizer' ),
256 'vAxis[textPosition]',
257 isset( $this->vAxis['textPosition'] ) ? $this->vAxis['textPosition'] : '',
258 $this->_positions,
259 esc_html__( 'Position of the vertical axis text, relative to the chart area.', 'visualizer' )
260 );
261
262 self::_renderSelectItem(
263 esc_html__( 'Direction', 'visualizer' ),
264 'vAxis[direction]',
265 isset( $this->vAxis['direction'] ) ? $this->vAxis['direction'] : '',
266 array(
267 '' => '',
268 '1' => esc_html__( 'Identical Direction', 'visualizer' ),
269 '-1' => esc_html__( 'Reverse Direction', 'visualizer' ),
270 ),
271 esc_html__( 'The direction in which the values along the vertical axis grow.', 'visualizer' )
272 );
273
274 self::_renderColorPickerItem(
275 esc_html__( 'Base Line Color', 'visualizer' ),
276 'hAxis[baselineColor]',
277 isset( $this->hAxis['baselineColor'] ) ? $this->hAxis['baselineColor'] : null,
278 '#000'
279 );
280 }
281
282 /**
283 * Renders vertical axis settings.
284 *
285 * @since 1.2.0
286 *
287 * @access protected
288 */
289 protected function _renderVerticalAxisSettings() {
290 self::_renderGroupStart( esc_html__( 'Vertical Axis Settings', 'visualizer' ) );
291 self::_renderSectionStart( esc_html__( 'General Settings', 'visualizer' ), false );
292 $this->_renderVerticalAxisGeneralSettings();
293 self::_renderSectionEnd();
294
295 if ( $this->_verticalGridLines ) {
296 self::_renderSectionStart( esc_html__( 'Grid Lines', 'visualizer' ), false );
297 self::_renderTextItem(
298 esc_html__( 'Count', 'visualizer' ),
299 'vAxis[gridlines][count]',
300 isset( $this->vAxis['gridlines']['count'] ) ? $this->vAxis['gridlines']['count'] : '',
301 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' ),
302 5
303 );
304
305 self::_renderColorPickerItem(
306 esc_html__( 'Color', 'visualizer' ),
307 'vAxis[gridlines][color]',
308 isset( $this->vAxis['gridlines']['color'] ) ? $this->vAxis['gridlines']['color'] : null,
309 '#ccc'
310 );
311 self::_renderSectionEnd();
312
313 self::_renderSectionStart( esc_html__( 'Minor Grid Lines', 'visualizer' ), false );
314 self::_renderTextItem(
315 esc_html__( 'Count', 'visualizer' ),
316 'hAxis[minorGridlines][count]',
317 isset( $this->hAxis['minorGridlines']['count'] ) ? $this->hAxis['minorGridlines']['count'] : '',
318 esc_html__( 'The number of vertical minor gridlines between two regular gridlines.', 'visualizer' ),
319 0
320 );
321
322 self::_renderColorPickerItem(
323 esc_html__( 'Color', 'visualizer' ),
324 'hAxis[minorGridlines][color]',
325 isset( $this->hAxis['minorGridlines']['color'] ) ? $this->hAxis['minorGridlines']['color'] : null,
326 null
327 );
328 self::_renderSectionEnd();
329 }
330
331 if ( $this->_horizontalGridLines ) {
332 self::_renderSectionStart( esc_html__( 'View Window', 'visualizer' ), false );
333 self::_renderTextItem(
334 esc_html__( 'Maximum Value', 'visualizer' ),
335 'vAxis[viewWindow][max]',
336 isset( $this->vAxis['viewWindow']['max'] ) ? $this->vAxis['viewWindow']['max'] : '',
337 'The maximum vertical data value to render.'
338 );
339
340 self::_renderTextItem(
341 esc_html__( 'Minimum Value', 'visualizer' ),
342 'vAxis[viewWindow][min]',
343 isset( $this->vAxis['viewWindow']['min'] ) ? $this->vAxis['viewWindow']['min'] : '',
344 'The minimum vertical data value to render.'
345 );
346 self::_renderSectionEnd();
347 }
348 self::_renderGroupEnd();
349 }
350
351 /**
352 * Renders chart axes settings.
353 *
354 * @since 1.0.0
355 *
356 * @access protected
357 */
358 protected function _renderAxesSettings() {
359 $this->_renderHorizontalAxisSettings();
360 $this->_renderVerticalAxisSettings();
361 }
362
363 /**
364 * Renders series settings group.
365 *
366 * @since 1.0.0
367 *
368 * @access protected
369 */
370 protected function _renderSeriesSettings() {
371 self::_renderGroupStart( esc_html__( 'Series Settings', 'visualizer' ) );
372 self::_renderSectionStart();
373 self::_renderSectionDescription( esc_html__( 'If you have just updated/modified the chart data, you may need to save it before the new data reflects in the settings.', 'visualizer' ), 'viz-info-msg' );
374 self::_renderSectionEnd();
375
376 for ( $i = 1, $cnt = count( $this->__series ); $i < $cnt; $i++ ) {
377 if ( ! empty( $this->__series[ $i ]['label'] ) ) {
378 self::_renderSectionStart( esc_html( $this->__series[ $i ]['label'] ), false );
379 $this->_renderSeries( $i - 1 );
380 self::_renderSectionEnd();
381 }
382 }
383 self::_renderGroupEnd();
384 }
385
386 /**
387 * Renders concreate series settings.
388 *
389 * @since 1.0.0
390 *
391 * @access protected
392 * @param int $index The series index.
393 */
394 protected function _renderSeries( $index ) {
395 self::_renderSelectItem(
396 esc_html__( 'Visible In Legend', 'visualizer' ),
397 'series[' . $index . '][visibleInLegend]',
398 isset( $this->series[ $index ]['visibleInLegend'] ) ? $this->series[ $index ]['visibleInLegend'] : '',
399 array(
400 '' => '',
401 '0' => esc_html__( 'No', 'visualizer' ),
402 '1' => esc_html__( 'Yes', 'visualizer' ),
403 ),
404 esc_html__( 'Determines whether the series has to be presented in the legend or not.', 'visualizer' )
405 );
406
407 $this->_renderFormatField( $index );
408
409 self::_renderColorPickerItem(
410 esc_html__( 'Color', 'visualizer' ),
411 'series[' . $index . '][color]',
412 isset( $this->series[ $index ]['color'] ) ? $this->series[ $index ]['color'] : null,
413 null
414 );
415 }
416
417 /**
418 * Renders format field for horizontal axis.
419 *
420 * @since 1.4.3
421 *
422 * @access protected
423 */
424 protected function _renderHorizontalAxisFormatField() {
425 self::_renderTextItem(
426 esc_html__( 'Number Format', 'visualizer' ),
427 'hAxis[format]',
428 isset( $this->hAxis['format'] ) ? $this->hAxis['format'] : '',
429 sprintf(
430 '%s<br><br>%s<br><br>%s',
431 esc_html__( 'Enter custom format pattern to apply to horizontal axis labels.', 'visualizer' ),
432 sprintf(
433 esc_html__( 'For number axis labels, this is a subset of the decimal formatting %1$sICU pattern set%2$s. For instance, $#,###.## will display values $1,234.56 for value 1234.56. Pay attention that if you use #&#37;&#37; percentage format then your values will be multiplied by 100.', 'visualizer' ),
434 '<a href="http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details" target="_blank">',
435 '</a>'
436 ),
437 sprintf(
438 esc_html__( 'For date axis labels, this is a subset of the date formatting %1$sICU date and time format%2$s.', 'visualizer' ),
439 '<a href="http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax" target="_blank">',
440 '</a>'
441 )
442 )
443 );
444 }
445
446 /**
447 * Renders format field for vertical axis settings.
448 *
449 * @since 1.4.3
450 *
451 * @access protected
452 */
453 protected function _renderVerticalAxisFormatField() {
454 self::_renderTextItem(
455 esc_html__( 'Number Format', 'visualizer' ),
456 'vAxis[format]',
457 isset( $this->vAxis['format'] ) ? $this->vAxis['format'] : '',
458 sprintf(
459 '%s<br><br>%s<br><br>%s',
460 esc_html__( 'Enter custom format pattern to apply to vertical axis labels.', 'visualizer' ),
461 sprintf(
462 esc_html__( 'For number axis labels, this is a subset of the decimal formatting %1$sICU pattern set%2$s. For instance, $#,###.## will display values $1,234.56 for value 1234.56. Pay attention that if you use #&#37;&#37; percentage format then your values will be multiplied by 100.', 'visualizer' ),
463 '<a href="http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details" target="_blank">',
464 '</a>'
465 ),
466 sprintf(
467 esc_html__( 'For date axis labels, this is a subset of the date formatting %1$sICU date and time format%2$s.', 'visualizer' ),
468 '<a href="http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax" target="_blank">',
469 '</a>'
470 )
471 )
472 );
473 }
474
475 }
476