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

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