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

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