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

496 lines 16.4 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 echo '<div class="viz-section-delimiter"></div>';
127
128 self::_renderTextAreaItem(
129 esc_html__( 'Chart Description', 'visualizer' ),
130 'description',
131 $this->description,
132 sprintf( esc_html__( 'Description to display in the structured data schema as explained %1$shere%2$s', 'visualizer' ), '<a href="https://developers.google.com/search/docs/data-types/dataset#dataset" target="_blank">', '</a>' )
133 );
134
135 }
136
137 /**
138 * Renders general settings block for horizontal axis settings.
139 *
140 * @since 1.4.0
141 *
142 * @access protected
143 */
144 protected function _renderHorizontalAxisGeneralSettings() {
145 self::_renderTextItem(
146 esc_html__( 'Axis Title', 'visualizer' ),
147 'hAxis[title]',
148 isset( $this->hAxis['title'] ) ? $this->hAxis['title'] : '',
149 esc_html__( 'The title of the horizontal axis.', 'visualizer' )
150 );
151
152 self::_renderSelectItem(
153 esc_html__( 'Text Position', 'visualizer' ),
154 'hAxis[textPosition]',
155 isset( $this->hAxis['textPosition'] ) ? $this->hAxis['textPosition'] : '',
156 $this->_positions,
157 esc_html__( 'Position of the horizontal axis text, relative to the chart area.', 'visualizer' )
158 );
159
160 self::_renderSelectItem(
161 esc_html__( 'Direction', 'visualizer' ),
162 'hAxis[direction]',
163 isset( $this->hAxis['direction'] ) ? $this->hAxis['direction'] : '',
164 array(
165 '' => '',
166 '1' => esc_html__( 'Identical Direction', 'visualizer' ),
167 '-1' => esc_html__( 'Reverse Direction', 'visualizer' ),
168 ),
169 esc_html__( 'The direction in which the values along the horizontal axis grow.', 'visualizer' )
170 );
171
172 self::_renderColorPickerItem(
173 esc_html__( 'Base Line Color', 'visualizer' ),
174 'vAxis[baselineColor]',
175 isset( $this->vAxis['baselineColor'] ) ? $this->vAxis['baselineColor'] : null,
176 '#000'
177 );
178 }
179
180 /**
181 * Renders horizontal axis settings.
182 *
183 * @since 1.2.0
184 *
185 * @access protected
186 */
187 protected function _renderHorizontalAxisSettings() {
188 self::_renderGroupStart( esc_html__( 'Horizontal Axis Settings', 'visualizer' ) );
189 self::_renderSectionStart( esc_html__( 'General Settings', 'visualizer' ), false );
190 $this->_renderHorizontalAxisGeneralSettings();
191 self::_renderSectionEnd();
192 if ( $this->_horizontalGridLines ) {
193 self::_renderSectionStart( esc_html__( 'Grid Lines', 'visualizer' ), false );
194 self::_renderTextItem(
195 esc_html__( 'Count', 'visualizer' ),
196 'hAxis[gridlines][count]',
197 isset( $this->hAxis['gridlines']['count'] ) ? $this->hAxis['gridlines']['count'] : '',
198 esc_html__( 'The approximate number of horizontal gridlines inside the chart area. You can specify a value of -1 to automatically compute the number of gridlines, 0 or 1 to draw no gridlines, or 2 or more to only draw gridline. Any number greater than 2 will be used to compute the minSpacing between gridlines.', 'visualizer' ),
199 5,
200 'number',
201 array( 'min' => -1, 'max' => 1000, 'step' => 1 )
202 );
203
204 self::_renderColorPickerItem(
205 esc_html__( 'Color', 'visualizer' ),
206 'hAxis[gridlines][color]',
207 isset( $this->hAxis['gridlines']['color'] ) ? $this->hAxis['gridlines']['color'] : null,
208 '#ccc'
209 );
210 self::_renderSectionEnd();
211
212 self::_renderSectionStart( esc_html__( 'Minor Grid Lines', 'visualizer' ), false );
213 self::_renderTextItem(
214 esc_html__( 'Count', 'visualizer' ),
215 'hAxis[minorGridlines][count]',
216 isset( $this->hAxis['minorGridlines']['count'] ) ? $this->hAxis['minorGridlines']['count'] : '',
217 esc_html__( 'Specify 0 to disable the minor gridlines.', 'visualizer' ),
218 0,
219 'number',
220 array( 'min' => 0, 'max' => 1, 'step' => 1 )
221 );
222
223 self::_renderColorPickerItem(
224 esc_html__( 'Color', 'visualizer' ),
225 'hAxis[minorGridlines][color]',
226 isset( $this->hAxis['minorGridlines']['color'] ) ? $this->hAxis['minorGridlines']['color'] : null,
227 null
228 );
229 self::_renderSectionEnd();
230 }
231
232 if ( $this->_horizontalGridLines ) {
233 self::_renderSectionStart( esc_html__( 'View Window', 'visualizer' ), false );
234 self::_renderTextItem(
235 esc_html__( 'Maximum Value', 'visualizer' ),
236 'hAxis[viewWindow][max]',
237 isset( $this->hAxis['viewWindow']['max'] ) ? $this->hAxis['viewWindow']['max'] : '',
238 'The maximum vertical data value to render.'
239 );
240
241 self::_renderTextItem(
242 esc_html__( 'Minimum Value', 'visualizer' ),
243 'hAxis[viewWindow][min]',
244 isset( $this->hAxis['viewWindow']['min'] ) ? $this->hAxis['viewWindow']['min'] : '',
245 'The minimum vertical data value to render.'
246 );
247 self::_renderSectionEnd();
248 }
249 self::_renderGroupEnd();
250 }
251
252 /**
253 * Renders general settings block for vertical axis settings.
254 *
255 * @since 1.4.0
256 *
257 * @access protected
258 */
259 protected function _renderVerticalAxisGeneralSettings() {
260 self::_renderTextItem(
261 esc_html__( 'Axis Title', 'visualizer' ),
262 'vAxis[title]',
263 isset( $this->vAxis['title'] ) ? $this->vAxis['title'] : '',
264 esc_html__( 'The title of the vertical axis.', 'visualizer' )
265 );
266
267 self::_renderSelectItem(
268 esc_html__( 'Text Position', 'visualizer' ),
269 'vAxis[textPosition]',
270 isset( $this->vAxis['textPosition'] ) ? $this->vAxis['textPosition'] : '',
271 $this->_positions,
272 esc_html__( 'Position of the vertical axis text, relative to the chart area.', 'visualizer' )
273 );
274
275 self::_renderSelectItem(
276 esc_html__( 'Direction', 'visualizer' ),
277 'vAxis[direction]',
278 isset( $this->vAxis['direction'] ) ? $this->vAxis['direction'] : '',
279 array(
280 '' => '',
281 '1' => esc_html__( 'Identical Direction', 'visualizer' ),
282 '-1' => esc_html__( 'Reverse Direction', 'visualizer' ),
283 ),
284 esc_html__( 'The direction in which the values along the vertical axis grow.', 'visualizer' )
285 );
286
287 self::_renderColorPickerItem(
288 esc_html__( 'Base Line Color', 'visualizer' ),
289 'hAxis[baselineColor]',
290 isset( $this->hAxis['baselineColor'] ) ? $this->hAxis['baselineColor'] : null,
291 '#000'
292 );
293 }
294
295 /**
296 * Renders vertical axis settings.
297 *
298 * @since 1.2.0
299 *
300 * @access protected
301 */
302 protected function _renderVerticalAxisSettings() {
303 self::_renderGroupStart( esc_html__( 'Vertical Axis Settings', 'visualizer' ) );
304 self::_renderSectionStart( esc_html__( 'General Settings', 'visualizer' ), false );
305 $this->_renderVerticalAxisGeneralSettings();
306 self::_renderSectionEnd();
307
308 if ( $this->_verticalGridLines ) {
309 self::_renderSectionStart( esc_html__( 'Grid Lines', 'visualizer' ), false );
310 self::_renderTextItem(
311 esc_html__( 'Count', 'visualizer' ),
312 'vAxis[gridlines][count]',
313 isset( $this->vAxis['gridlines']['count'] ) ? $this->vAxis['gridlines']['count'] : '',
314 esc_html__( 'The approximate number of vertical gridlines inside the chart area. You can specify a value of -1 to automatically compute the number of gridlines, 0 or 1 to draw no gridlines, or 2 or more to only draw gridline. Any number greater than 2 will be used to compute the minSpacing between gridlines.', 'visualizer' ),
315 5,
316 'number',
317 array( 'min' => -1, 'max' => 1000, 'step' => 1 )
318 );
319
320 self::_renderColorPickerItem(
321 esc_html__( 'Color', 'visualizer' ),
322 'vAxis[gridlines][color]',
323 isset( $this->vAxis['gridlines']['color'] ) ? $this->vAxis['gridlines']['color'] : null,
324 '#ccc'
325 );
326 self::_renderSectionEnd();
327
328 self::_renderSectionStart( esc_html__( 'Minor Grid Lines', 'visualizer' ), false );
329 self::_renderTextItem(
330 esc_html__( 'Count', 'visualizer' ),
331 'vAxis[minorGridlines][count]',
332 isset( $this->vAxis['minorGridlines']['count'] ) ? $this->vAxis['minorGridlines']['count'] : '',
333 esc_html__( 'Specify 0 to disable the minor gridlines.', 'visualizer' ),
334 0,
335 'number',
336 array( 'min' => 0, 'max' => 1, 'step' => 1 )
337 );
338
339 self::_renderColorPickerItem(
340 esc_html__( 'Color', 'visualizer' ),
341 'vAxis[minorGridlines][color]',
342 isset( $this->vAxis['minorGridlines']['color'] ) ? $this->vAxis['minorGridlines']['color'] : null,
343 null
344 );
345 self::_renderSectionEnd();
346 }
347
348 if ( $this->_verticalGridLines ) {
349 self::_renderSectionStart( esc_html__( 'View Window', 'visualizer' ), false );
350 self::_renderTextItem(
351 esc_html__( 'Maximum Value', 'visualizer' ),
352 'vAxis[viewWindow][max]',
353 isset( $this->vAxis['viewWindow']['max'] ) ? $this->vAxis['viewWindow']['max'] : '',
354 'The maximum vertical data value to render.'
355 );
356
357 self::_renderTextItem(
358 esc_html__( 'Minimum Value', 'visualizer' ),
359 'vAxis[viewWindow][min]',
360 isset( $this->vAxis['viewWindow']['min'] ) ? $this->vAxis['viewWindow']['min'] : '',
361 'The minimum vertical data value to render.'
362 );
363 self::_renderSectionEnd();
364 }
365 self::_renderGroupEnd();
366 }
367
368 /**
369 * Renders chart axes settings.
370 *
371 * @since 1.0.0
372 *
373 * @access protected
374 */
375 protected function _renderAxesSettings() {
376 $this->_renderHorizontalAxisSettings();
377 $this->_renderVerticalAxisSettings();
378 }
379
380 /**
381 * Renders series settings group.
382 *
383 * @since 1.0.0
384 *
385 * @access protected
386 */
387 protected function _renderSeriesSettings() {
388 self::_renderGroupStart( esc_html__( 'Series Settings', 'visualizer' ) );
389 self::_renderSectionStart();
390 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' );
391 self::_renderSectionEnd();
392
393 for ( $i = 1, $cnt = count( $this->__series ); $i < $cnt; $i++ ) {
394 if ( ! empty( $this->__series[ $i ]['label'] ) ) {
395 self::_renderSectionStart( esc_html( $this->__series[ $i ]['label'] ), false );
396 $this->_renderSeries( $i - 1 );
397 self::_renderSectionEnd();
398 }
399 }
400 self::_renderGroupEnd();
401 }
402
403 /**
404 * Renders concreate series settings.
405 *
406 * @since 1.0.0
407 *
408 * @access protected
409 * @param int $index The series index.
410 */
411 protected function _renderSeries( $index ) {
412 self::_renderSelectItem(
413 esc_html__( 'Visible In Legend', 'visualizer' ),
414 'series[' . $index . '][visibleInLegend]',
415 isset( $this->series[ $index ]['visibleInLegend'] ) ? $this->series[ $index ]['visibleInLegend'] : '',
416 array(
417 '' => '',
418 '0' => esc_html__( 'No', 'visualizer' ),
419 '1' => esc_html__( 'Yes', 'visualizer' ),
420 ),
421 esc_html__( 'Determines whether the series has to be presented in the legend or not.', 'visualizer' )
422 );
423
424 $this->_renderFormatField( $index );
425
426 self::_renderColorPickerItem(
427 esc_html__( 'Color', 'visualizer' ),
428 'series[' . $index . '][color]',
429 isset( $this->series[ $index ]['color'] ) ? $this->series[ $index ]['color'] : null,
430 null
431 );
432
433 $this->_renderRoleField( $index );
434
435 }
436
437 /**
438 * Renders format field for horizontal axis.
439 *
440 * @since 1.4.3
441 *
442 * @access protected
443 */
444 protected function _renderHorizontalAxisFormatField() {
445 self::_renderTextItem(
446 esc_html__( 'Number Format', 'visualizer' ),
447 'hAxis[format]',
448 isset( $this->hAxis['format'] ) ? $this->hAxis['format'] : '',
449 sprintf(
450 '%s<br><br>%s<br><br>%s',
451 esc_html__( 'Enter custom format pattern to apply to horizontal axis labels.', 'visualizer' ),
452 sprintf(
453 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' ),
454 '<a href="http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details" target="_blank">',
455 '</a>'
456 ),
457 sprintf(
458 esc_html__( 'For date axis labels, this is a subset of the date formatting %1$sICU date and time format%2$s.', 'visualizer' ),
459 '<a href="http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax" target="_blank">',
460 '</a>'
461 )
462 )
463 );
464 }
465
466 /**
467 * Renders format field for vertical axis settings.
468 *
469 * @since 1.4.3
470 *
471 * @access protected
472 */
473 protected function _renderVerticalAxisFormatField() {
474 self::_renderTextItem(
475 esc_html__( 'Number Format', 'visualizer' ),
476 'vAxis[format]',
477 isset( $this->vAxis['format'] ) ? $this->vAxis['format'] : '',
478 sprintf(
479 '%s<br><br>%s<br><br>%s',
480 esc_html__( 'Enter custom format pattern to apply to vertical axis labels.', 'visualizer' ),
481 sprintf(
482 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' ),
483 '<a href="http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details" target="_blank">',
484 '</a>'
485 ),
486 sprintf(
487 esc_html__( 'For date axis labels, this is a subset of the date formatting %1$sICU date and time format%2$s.', 'visualizer' ),
488 '<a href="http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax" target="_blank">',
489 '</a>'
490 )
491 )
492 );
493 }
494
495 }
496