PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.5.1
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.5.1
4.0.8 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 All 149 releases
← All changes | classes/Visualizer/Render/Sidebar/Google.php +365 -6 3.1.33.5.1 View file →
@@ -31,13 +31,59 @@
31 31 */
32 32 abstract class Visualizer_Render_Sidebar_Google extends Visualizer_Render_Sidebar {
33 33
34 34 /**
35 + * The array of available legend positions.
36 + *
37 + * @since 1.0.0
38 + *
39 + * @access protected
40 + * @var array
41 + */
42 + protected $_legendPositions;
43 +
44 + /**
45 + * The array of available alignments.
46 + *
47 + * @since 1.0.0
48 + *
49 + * @access protected
50 + * @var array
51 + */
52 + protected $_alignments;
53 +
54 + /**
35 55 * The constructor.
36 56 */
37 57 public function __construct( $data = array() ) {
38 58 $this->_library = 'google';
39 59 parent::__construct( $data );
60 +
61 + $this->_legendPositions = array(
62 + '' => '',
63 + 'left' => esc_html__( 'Left of the chart', 'visualizer' ),
64 + 'right' => esc_html__( 'Right of the chart', 'visualizer' ),
65 + 'top' => esc_html__( 'Above the chart', 'visualizer' ),
66 + 'bottom' => esc_html__( 'Below the chart', 'visualizer' ),
67 + 'none' => esc_html__( 'Omit the legend', 'visualizer' ),
68 + );
69 +
70 + $chart_type = $this->get_chart_type( false );
71 + if ( ! in_array( $chart_type, array( 'Pie' ), true ) ) {
72 + $this->_legendPositions['in'] = esc_html__( 'Inside the chart', 'visualizer' );
73 + }
74 +
75 + if ( in_array( $chart_type, array( 'Bubble' ), true ) ) {
76 + unset( $this->_legendPositions['left'] );
77 + }
78 +
79 + $this->_alignments = array(
80 + '' => '',
81 + 'start' => esc_html__( 'Aligned to the start of the allocated area', 'visualizer' ),
82 + 'center' => esc_html__( 'Centered in the allocated area', 'visualizer' ),
83 + 'end' => esc_html__( 'Aligned to the end of the allocated area', 'visualizer' ),
84 + );
85 +
40 86 }
41 87
42 88 /**
43 89 * Registers additional hooks.
@@ -53,15 +99,14 @@
53 99 /**
54 100 * Loads the assets.
55 101 */
56 102 function load_google_assets( $deps, $is_frontend ) {
57 - wp_register_script( 'google-jsapi-new', '//www.gstatic.com/charts/loader.js', array(), null, true );
58 - wp_register_script( 'google-jsapi-old', '//www.google.com/jsapi', array( 'google-jsapi-new' ), null, true );
103 + wp_register_script( 'google-jsapi', '//www.gstatic.com/charts/loader.js', array(), null, true );
59 104 wp_register_script(
60 105 'visualizer-render-google-lib',
61 106 VISUALIZER_ABSURL . 'js/render-google.js',
62 107 array(
63 - 'google-jsapi-old',
108 + 'google-jsapi',
64 109 ),
65 110 Visualizer_Plugin::VERSION,
66 111 true
67 112 );
@@ -76,12 +121,326 @@
76 121 /**
77 122 * Enqueue assets.
78 123 */
79 124 public static function enqueue_assets( $deps = array() ) {
80 - wp_enqueue_script( 'visualizer-google-jsapi-new', '//www.gstatic.com/charts/loader.js', array(), null, true );
81 - wp_enqueue_script( 'visualizer-google-jsapi-old', '//www.google.com/jsapi', array( 'visualizer-google-jsapi-new' ), null, true );
82 - wp_enqueue_script( 'visualizer-render-google-lib', VISUALIZER_ABSURL . 'js/render-google.js', array_merge( $deps, array( 'visualizer-google-jsapi-old' ) ), Visualizer_Plugin::VERSION, true );
125 + wp_enqueue_script( 'visualizer-google-jsapi', '//www.gstatic.com/charts/loader.js', array(), null, true );
126 + wp_enqueue_script( 'visualizer-render-google-lib', VISUALIZER_ABSURL . 'js/render-google.js', array_merge( $deps, array( 'visualizer-google-jsapi' ) ), Visualizer_Plugin::VERSION, true );
83 127 return 'visualizer-render-google-lib';
84 128 }
85 129
130 + /**
131 + * Renders the role field.
132 + *
133 + * @since 3.4.0
134 + *
135 + * @access protected
136 + */
137 + protected function _renderRoleField( $index ) {
138 + self::_renderSelectItem(
139 + esc_html__( 'Special Role', 'visualizer' ),
140 + 'series[' . $index . '][role]',
141 + isset( $this->series[ $index ]['role'] ) ? $this->series[ $index ]['role'] : '',
142 + array(
143 + '' => esc_html__( 'Default (Data)', 'visualizer' ),
144 + 'annotation' => esc_html__( 'Annotation', 'visualizer' ),
145 + 'annotationText' => esc_html__( 'Annotation Text', 'visualizer' ),
146 + 'certainty' => esc_html__( 'Certainty', 'visualizer' ),
147 + 'emphasis' => esc_html__( 'Emphasis', 'visualizer' ),
148 + 'scope' => esc_html__( 'Scope', 'visualizer' ),
149 + 'style' => esc_html__( 'Style', 'visualizer' ),
150 + 'tooltip' => esc_html__( 'Tooltip', 'visualizer' ),
151 + ),
152 + sprintf( esc_html__( 'Determines whether the series has to be used for a special role as mentioned in %1$shere%2$s. You can view a few examples %3$shere%4$s.', 'visualizer' ), '<a href="https://developers.google.com/chart/interactive/docs/roles#what-roles-are-available" target="_blank">', '</a>', '<a href="https://docs.themeisle.com/article/1160-roles-for-series-visualizer" target="_blank">', '</a>' )
153 + );
154 + }
86 155
156 + /**
157 + * Renders chart general settings group.
158 + *
159 + * @since 1.0.0
160 + *
161 + * @access protected
162 + */
163 + protected function _renderGeneralSettings() {
164 + self::_renderGroupStart( esc_html__( 'General Settings', 'visualizer' ) );
165 + self::_renderSectionStart();
166 + self::_renderSectionDescription( esc_html__( 'Configure title, font styles, tooltip, legend and else settings for the chart.', 'visualizer' ) );
167 + self::_renderSectionEnd();
168 +
169 + self::_renderSectionStart( esc_html__( 'Title', 'visualizer' ), false );
170 + $this->_renderChartTitleSettings();
171 + self::_renderSectionEnd();
172 +
173 + self::_renderSectionStart( esc_html__( 'Font Styles', 'visualizer' ), false );
174 + echo '<div class="viz-section-item">';
175 + echo '<a class="more-info" href="javascript:;">[?]</a>';
176 + echo '<b>', esc_html__( 'Family And Size', 'visualizer' ), '</b>';
177 +
178 + echo '<table class="viz-section-table" cellspacing="0" cellpadding="0" border="0">';
179 + echo '<tr>';
180 + echo '<td class="viz-section-table-column">';
181 + echo '<select name="fontName" class="control-select">';
182 + echo '<option></option>';
183 + foreach ( self::$_fontFamilies as $font => $label ) {
184 + echo '<option value="', $font, '"', selected( $font, $this->fontName, false ), '>';
185 + echo $label;
186 + echo '</option>';
187 + }
188 + echo '</select>';
189 + echo '</td>';
190 + echo '<td class="viz-section-table-column">';
191 + echo '<select name="fontSize" class="control-select">';
192 + echo '<option></option>';
193 + for ( $i = 7; $i <= 20; $i++ ) {
194 + echo '<option value="', $i, '"', selected( $i, $this->fontSize, false ), '>', $i, '</option>';
195 + }
196 + echo '</select>';
197 + echo '</td>';
198 + echo '</tr>';
199 + echo '</table>';
200 +
201 + echo '<p class="viz-section-description">';
202 + esc_html_e( 'The default font family and size for all text in the chart.', 'visualizer' );
203 + echo '</p>';
204 + echo '</div>';
205 + self::_renderSectionEnd();
206 +
207 + self::_renderSectionStart( esc_html__( 'Legend', 'visualizer' ), false );
208 + self::_renderSelectItem(
209 + esc_html__( 'Position', 'visualizer' ),
210 + 'legend[position]',
211 + isset( $this->legend['position'] ) ? $this->legend['position'] : '',
212 + $this->_legendPositions,
213 + esc_html__( 'Determines where to place the legend, compared to the chart area.', 'visualizer' )
214 + );
215 +
216 + self::_renderSelectItem(
217 + esc_html__( 'Alignment', 'visualizer' ),
218 + 'legend[alignment]',
219 + isset( $this->legend['alignment'] ) ? $this->legend['alignment'] : '',
220 + $this->_alignments,
221 + esc_html__( 'Determines the alignment of the legend.', 'visualizer' )
222 + );
223 +
224 + self::_renderColorPickerItem(
225 + esc_html__( 'Font Color', 'visualizer' ),
226 + 'legend[textStyle][color]',
227 + isset( $this->legend['textStyle']['color'] ) ? $this->legend['textStyle']['color'] : null,
228 + '#000'
229 + );
230 + self::_renderSectionEnd();
231 +
232 + self::_renderSectionStart( esc_html__( 'Tooltip', 'visualizer' ), false );
233 + $this->_renderTooltipSettigns();
234 + self::_renderSectionEnd();
235 +
236 + $this->_renderAnimationSettings();
237 + self::_renderSectionStart( esc_html__( 'License & Creator', 'visualizer' ), false );
238 + self::_renderTextItem(
239 + esc_html__( 'License', 'visualizer' ),
240 + 'license',
241 + $this->license,
242 + ''
243 + );
244 + self::_renderTextItem(
245 + esc_html__( 'Creator', 'visualizer' ),
246 + 'creator',
247 + $this->creator,
248 + ''
249 + );
250 + self::_renderSectionEnd();
251 + do_action( 'visualizer_chart_settings', get_class( $this ), $this->_data, 'general', array( 'generic' => true ) );
252 +
253 + self::_renderGroupEnd();
254 + }
255 +
256 + /**
257 + * Renders animation settings section.
258 + *
259 + * @access protected
260 + */
261 + protected function _renderAnimationSettings() {
262 + if ( ! $this->_supportsAnimation ) {
263 + return;
264 + }
265 +
266 + self::_renderSectionStart( esc_html__( 'Animation', 'visualizer' ), false );
267 +
268 + self::_renderCheckboxItem(
269 + esc_html__( 'Animate on startup', 'visualizer' ),
270 + 'animation[startup]',
271 + isset( $this->animation['startup'] ) ? $this->animation['startup'] : 0,
272 + true,
273 + esc_html__( 'Determines if the chart will animate on the initial draw.', 'visualizer' )
274 + );
275 +
276 + self::_renderTextItem(
277 + esc_html__( 'Duration', 'visualizer' ),
278 + 'animation[duration]',
279 + isset( $this->animation['duration'] ) ? $this->animation['duration'] : 0,
280 + esc_html__( 'The duration of the animation, in milliseconds', 'visualizer' ),
281 + 0,
282 + 'number'
283 + );
284 +
285 + self::_renderSelectItem(
286 + esc_html__( 'Easing', 'visualizer' ),
287 + 'animation[easing]',
288 + isset( $this->animation['easing'] ) ? $this->animation['easing'] : null,
289 + array(
290 + 'linear' => esc_html__( 'Constant speed', 'visualizer' ),
291 + 'in' => esc_html__( 'Start slow and speed up', 'visualizer' ),
292 + 'out' => esc_html__( 'Start fast and slow down', 'visualizer' ),
293 + 'inAndOut' => esc_html__( 'Start slow, speed up, then slow down', 'visualizer' ),
294 + ),
295 + esc_html__( 'The easing function applied to the animation.', 'visualizer' )
296 + );
297 +
298 + self::_renderSectionEnd();
299 +
300 + }
301 +
302 + /**
303 + * Renders tooltip settings section.
304 + *
305 + * @since 1.4.0
306 + *
307 + * @access protected
308 + */
309 + protected function _renderTooltipSettigns() {
310 + self::_renderSelectItem(
311 + esc_html__( 'Trigger', 'visualizer' ),
312 + 'tooltip[trigger]',
313 + isset( $this->tooltip['trigger'] ) ? $this->tooltip['trigger'] : null,
314 + array(
315 + '' => '',
316 + 'focus' => esc_html__( 'The tooltip will be displayed when the user hovers over an element', 'visualizer' ),
317 + 'selection' => esc_html__( 'The tooltip will be displayed when the user selects an element', 'visualizer' ),
318 + 'none' => esc_html__( 'The tooltip will not be displayed', 'visualizer' ),
319 + ),
320 + esc_html__( 'Determines the user interaction that causes the tooltip to be displayed.', 'visualizer' )
321 + );
322 +
323 + self::_renderSelectItem(
324 + esc_html__( 'Show Color Code', 'visualizer' ),
325 + 'tooltip[showColorCode]',
326 + isset( $this->tooltip['showColorCode'] ) ? $this->tooltip['showColorCode'] : null,
327 + $this->_yesno,
328 + esc_html__( 'If set to yes, will show colored squares next to the slice information in the tooltip.', 'visualizer' )
329 + );
330 + }
331 +
332 + /**
333 + * Renders chart view settings group.
334 + *
335 + * @since 1.0.0
336 + *
337 + * @access protected
338 + */
339 + protected function _renderViewSettings() {
340 + self::_renderGroupStart( esc_html__( 'Chart Size & Placement', 'visualizer' ) );
341 + self::_renderSectionStart( esc_html__( 'Chart Size/Layout', 'visualizer' ), false );
342 + self::_renderSectionDescription( esc_html__( 'Configure the total size of the chart. Two formats are supported: a number, or a number followed by %. A simple number is a value in pixels; a number followed by % is a percentage.', 'visualizer' ) );
343 +
344 + echo '<div class="viz-section-item">';
345 + echo '<a class="more-info" href="javascript:;">[?]</a>';
346 + echo '<b>', esc_html__( 'Width And Height Of Chart', 'visualizer' ), '</b>';
347 +
348 + echo '<table class="viz-section-table" cellspacing="0" cellpadding="0" border="0">';
349 + echo '<tr>';
350 + echo '<td class="viz-section-table-column">';
351 + echo '<input type="text" name="width" class="control-text" value="', esc_attr( $this->width ), '" placeholder="100%">';
352 + echo '</td>';
353 + echo '<td class="viz-section-table-column">';
354 + echo '<input type="text" name="height" class="control-text" value="', esc_attr( $this->height ), '" placeholder="400">';
355 + echo '</td>';
356 + echo '</tr>';
357 + echo '</table>';
358 +
359 + echo '<p class="viz-section-description">';
360 + esc_html_e( 'Determines the total width and height of the chart. This will only show in the front-end.', 'visualizer' );
361 + echo '</p>';
362 + echo '</div>';
363 +
364 + echo '<div class="viz-section-delimiter"></div>';
365 +
366 + self::_renderSectionDescription( esc_html__( 'Configure the background color for the main area of the chart and the chart border width and color.', 'visualizer' ) );
367 +
368 + self::_renderTextItem(
369 + esc_html__( 'Stroke Width', 'visualizer' ),
370 + 'backgroundColor[strokeWidth]',
371 + isset( $this->backgroundColor['strokeWidth'] ) ? $this->backgroundColor['strokeWidth'] : null,
372 + esc_html__( 'The chart border width in pixels.', 'visualizer' ),
373 + '0'
374 + );
375 +
376 + self::_renderColorPickerItem(
377 + esc_html__( 'Stroke Color', 'visualizer' ),
378 + 'backgroundColor[stroke]',
379 + ! empty( $this->backgroundColor['stroke'] ) ? $this->backgroundColor['stroke'] : null,
380 + '#666'
381 + );
382 +
383 + $background_color = ! empty( $this->backgroundColor['fill'] ) ? $this->backgroundColor['fill'] : null;
384 + self::_renderColorPickerItem(
385 + esc_html__( 'Background Color', 'visualizer' ),
386 + 'backgroundColor[fill]',
387 + $background_color,
388 + '#fff'
389 + );
390 +
391 + echo '<div class="viz-section-item">';
392 + echo '<label>';
393 + echo '<input type="checkbox" class="control-checkbox" name="backgroundColor[fill]" value="transparent"', checked( $background_color, 'transparent', false ), '> ';
394 + esc_html_e( 'Transparent background', 'visualizer' );
395 + echo '</label>';
396 + echo '</div>';
397 + self::_renderSectionEnd();
398 +
399 + self::_renderSectionStart( esc_html__( 'Placement', 'visualizer' ), false );
400 + self::_renderSectionDescription( esc_html__( 'Configure the placement and size of the chart area (where the chart itself is drawn, excluding axis and legends). Two formats are supported: a number, or a number followed by %. A simple number is a value in pixels; a number followed by % is a percentage.', 'visualizer' ) );
401 +
402 + echo '<div class="viz-section-item">';
403 + echo '<a class="more-info" href="javascript:;">[?]</a>';
404 + echo '<b>', esc_html__( 'Left And Top Margins', 'visualizer' ), '</b>';
405 +
406 + echo '<table class="viz-section-table" cellspacing="0" cellpadding="0" border="0">';
407 + echo '<tr>';
408 + echo '<td class="viz-section-table-column">';
409 + $chartarea_left = isset( $this->chartArea['left'] ) ? $this->chartArea['left'] : '';
410 + echo '<input type="text" name="chartArea[left]" class="control-text" value="', $chartarea_left || '0' === $chartarea_left ? esc_attr( $chartarea_left ) : '', '" placeholder="20%">';
411 + echo '</td>';
412 + echo '<td class="viz-section-table-column">';
413 + $chartarea_top = isset( $this->chartArea['top'] ) ? $this->chartArea['top'] : '';
414 + echo '<input type="text" name="chartArea[top]" class="control-text" value="', $chartarea_top || '0' === $chartarea_top ? esc_attr( $chartarea_top ) : '', '" placeholder="20%">';
415 + echo '</td>';
416 + echo '</tr>';
417 + echo '</table>';
418 +
419 + echo '<p class="viz-section-description">';
420 + esc_html_e( 'Determines how far to draw the chart from the left and top borders.', 'visualizer' );
421 + echo '</p>';
422 + echo '</div>';
423 +
424 + echo '<div class="viz-section-item">';
425 + echo '<a class="more-info" href="javascript:;">[?]</a>';
426 + echo '<b>', esc_html__( 'Width And Height Of Chart Area', 'visualizer' ), '</b>';
427 +
428 + echo '<table class="viz-section-table" cellspacing="0" cellpadding="0" border="0">';
429 + echo '<tr>';
430 + echo '<td class="viz-section-table-column">';
431 + echo '<input type="text" name="chartArea[width]" class="control-text" value="', ! empty( $this->chartArea['width'] ) ? esc_attr( $this->chartArea['width'] ) : '', '" placeholder="60%">';
432 + echo '</td>';
433 + echo '<td class="viz-section-table-column">';
434 + echo '<input type="text" name="chartArea[height]" class="control-text" value="', ! empty( $this->chartArea['height'] ) ? esc_attr( $this->chartArea['height'] ) : '', '" placeholder="60%">';
435 + echo '</td>';
436 + echo '</tr>';
437 + echo '</table>';
438 +
439 + echo '<p class="viz-section-description">';
440 + esc_html_e( 'Determines the width and hight of the chart area.', 'visualizer' );
441 + echo '</p>';
442 + echo '</div>';
443 + self::_renderSectionEnd();
444 + self::_renderGroupEnd();
445 + }
87 446 }