PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.4.4
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.4.4
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 +341 -0 3.1.33.4.4 View file →
@@ -31,13 +31,54 @@
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 + if ( ! in_array( $this->get_chart_type( false ), array( 'Pie' ), true ) ) {
71 + $this->_legendPositions['in'] = esc_html__( 'Inside the chart', 'visualizer' );
72 + }
73 +
74 + $this->_alignments = array(
75 + '' => '',
76 + 'start' => esc_html__( 'Aligned to the start of the allocated area', 'visualizer' ),
77 + 'center' => esc_html__( 'Centered in the allocated area', 'visualizer' ),
78 + 'end' => esc_html__( 'Aligned to the end of the allocated area', 'visualizer' ),
79 + );
80 +
40 81 }
41 82
42 83 /**
43 84 * Registers additional hooks.
@@ -82,6 +123,306 @@
82 123 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 );
83 124 return 'visualizer-render-google-lib';
84 125 }
85 126
127 + /**
128 + * Renders the role field.
129 + *
130 + * @since 3.4.0
131 + *
132 + * @access protected
133 + */
134 + protected function _renderRoleField( $index ) {
135 + self::_renderSelectItem(
136 + esc_html__( 'Special Role', 'visualizer' ),
137 + 'series[' . $index . '][role]',
138 + isset( $this->series[ $index ]['role'] ) ? $this->series[ $index ]['role'] : '',
139 + array(
140 + '' => esc_html__( 'Default (Data)', 'visualizer' ),
141 + 'annotation' => esc_html__( 'Annotation', 'visualizer' ),
142 + 'annotationText' => esc_html__( 'Annotation Text', 'visualizer' ),
143 + 'certainty' => esc_html__( 'Certainty', 'visualizer' ),
144 + 'emphasis' => esc_html__( 'Emphasis', 'visualizer' ),
145 + 'scope' => esc_html__( 'Scope', 'visualizer' ),
146 + 'style' => esc_html__( 'Style', 'visualizer' ),
147 + 'tooltip' => esc_html__( 'Tooltip', 'visualizer' ),
148 + ),
149 + 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>' )
150 + );
151 + }
86 152
153 + /**
154 + * Renders chart general settings group.
155 + *
156 + * @since 1.0.0
157 + *
158 + * @access protected
159 + */
160 + protected function _renderGeneralSettings() {
161 + self::_renderGroupStart( esc_html__( 'General Settings', 'visualizer' ) );
162 + self::_renderSectionStart();
163 + self::_renderSectionDescription( esc_html__( 'Configure title, font styles, tooltip, legend and else settings for the chart.', 'visualizer' ) );
164 + self::_renderSectionEnd();
165 +
166 + self::_renderSectionStart( esc_html__( 'Title', 'visualizer' ), false );
167 + $this->_renderChartTitleSettings();
168 + self::_renderSectionEnd();
169 +
170 + self::_renderSectionStart( esc_html__( 'Font Styles', 'visualizer' ), false );
171 + echo '<div class="viz-section-item">';
172 + echo '<a class="more-info" href="javascript:;">[?]</a>';
173 + echo '<b>', esc_html__( 'Family And Size', 'visualizer' ), '</b>';
174 +
175 + echo '<table class="viz-section-table" cellspacing="0" cellpadding="0" border="0">';
176 + echo '<tr>';
177 + echo '<td class="viz-section-table-column">';
178 + echo '<select name="fontName" class="control-select">';
179 + echo '<option></option>';
180 + foreach ( self::$_fontFamilies as $font => $label ) {
181 + echo '<option value="', $font, '"', selected( $font, $this->fontName, false ), '>';
182 + echo $label;
183 + echo '</option>';
184 + }
185 + echo '</select>';
186 + echo '</td>';
187 + echo '<td class="viz-section-table-column">';
188 + echo '<select name="fontSize" class="control-select">';
189 + echo '<option></option>';
190 + for ( $i = 7; $i <= 20; $i++ ) {
191 + echo '<option value="', $i, '"', selected( $i, $this->fontSize, false ), '>', $i, '</option>';
192 + }
193 + echo '</select>';
194 + echo '</td>';
195 + echo '</tr>';
196 + echo '</table>';
197 +
198 + echo '<p class="viz-section-description">';
199 + esc_html_e( 'The default font family and size for all text in the chart.', 'visualizer' );
200 + echo '</p>';
201 + echo '</div>';
202 + self::_renderSectionEnd();
203 +
204 + self::_renderSectionStart( esc_html__( 'Legend', 'visualizer' ), false );
205 + self::_renderSelectItem(
206 + esc_html__( 'Position', 'visualizer' ),
207 + 'legend[position]',
208 + $this->legend['position'],
209 + $this->_legendPositions,
210 + esc_html__( 'Determines where to place the legend, compared to the chart area.', 'visualizer' )
211 + );
212 +
213 + self::_renderSelectItem(
214 + esc_html__( 'Alignment', 'visualizer' ),
215 + 'legend[alignment]',
216 + $this->legend['alignment'],
217 + $this->_alignments,
218 + esc_html__( 'Determines the alignment of the legend.', 'visualizer' )
219 + );
220 +
221 + self::_renderColorPickerItem(
222 + esc_html__( 'Font Color', 'visualizer' ),
223 + 'legend[textStyle][color]',
224 + isset( $this->legend['textStyle']['color'] ) ? $this->legend['textStyle']['color'] : null,
225 + '#000'
226 + );
227 + self::_renderSectionEnd();
228 +
229 + self::_renderSectionStart( esc_html__( 'Tooltip', 'visualizer' ), false );
230 + $this->_renderTooltipSettigns();
231 + self::_renderSectionEnd();
232 +
233 + $this->_renderAnimationSettings();
234 +
235 + do_action( 'visualizer_chart_settings', get_class( $this ), $this->_data, 'general', array( 'generic' => true ) );
236 +
237 + self::_renderGroupEnd();
238 + }
239 +
240 + /**
241 + * Renders animation settings section.
242 + *
243 + * @access protected
244 + */
245 + protected function _renderAnimationSettings() {
246 + if ( ! $this->_supportsAnimation ) {
247 + return;
248 + }
249 +
250 + self::_renderSectionStart( esc_html__( 'Animation', 'visualizer' ), false );
251 +
252 + self::_renderCheckboxItem(
253 + esc_html__( 'Animate on startup', 'visualizer' ),
254 + 'animation[startup]',
255 + isset( $this->animation['startup'] ) ? $this->animation['startup'] : 0,
256 + true,
257 + esc_html__( 'Determines if the chart will animate on the initial draw.', 'visualizer' )
258 + );
259 +
260 + self::_renderTextItem(
261 + esc_html__( 'Duration', 'visualizer' ),
262 + 'animation[duration]',
263 + isset( $this->animation['duration'] ) ? $this->animation['duration'] : 0,
264 + esc_html__( 'The duration of the animation, in milliseconds', 'visualizer' ),
265 + 0,
266 + 'number'
267 + );
268 +
269 + self::_renderSelectItem(
270 + esc_html__( 'Easing', 'visualizer' ),
271 + 'animation[easing]',
272 + isset( $this->animation['easing'] ) ? $this->animation['easing'] : null,
273 + array(
274 + 'linear' => esc_html__( 'Constant speed', 'visualizer' ),
275 + 'in' => esc_html__( 'Start slow and speed up', 'visualizer' ),
276 + 'out' => esc_html__( 'Start fast and slow down', 'visualizer' ),
277 + 'inAndOut' => esc_html__( 'Start slow, speed up, then slow down', 'visualizer' ),
278 + ),
279 + esc_html__( 'The easing function applied to the animation.', 'visualizer' )
280 + );
281 +
282 + self::_renderSectionEnd();
283 +
284 + }
285 +
286 + /**
287 + * Renders tooltip settings section.
288 + *
289 + * @since 1.4.0
290 + *
291 + * @access protected
292 + */
293 + protected function _renderTooltipSettigns() {
294 + self::_renderSelectItem(
295 + esc_html__( 'Trigger', 'visualizer' ),
296 + 'tooltip[trigger]',
297 + isset( $this->tooltip['trigger'] ) ? $this->tooltip['trigger'] : null,
298 + array(
299 + '' => '',
300 + 'focus' => esc_html__( 'The tooltip will be displayed when the user hovers over an element', 'visualizer' ),
301 + 'selection' => esc_html__( 'The tooltip will be displayed when the user selects an element', 'visualizer' ),
302 + 'none' => esc_html__( 'The tooltip will not be displayed', 'visualizer' ),
303 + ),
304 + esc_html__( 'Determines the user interaction that causes the tooltip to be displayed.', 'visualizer' )
305 + );
306 +
307 + self::_renderSelectItem(
308 + esc_html__( 'Show Color Code', 'visualizer' ),
309 + 'tooltip[showColorCode]',
310 + isset( $this->tooltip['showColorCode'] ) ? $this->tooltip['showColorCode'] : null,
311 + $this->_yesno,
312 + esc_html__( 'If set to yes, will show colored squares next to the slice information in the tooltip.', 'visualizer' )
313 + );
314 + }
315 +
316 + /**
317 + * Renders chart view settings group.
318 + *
319 + * @since 1.0.0
320 + *
321 + * @access protected
322 + */
323 + protected function _renderViewSettings() {
324 + self::_renderGroupStart( esc_html__( 'Chart Size & Placement', 'visualizer' ) );
325 + self::_renderSectionStart( esc_html__( 'Chart Size/Layout', 'visualizer' ), false );
326 + 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' ) );
327 +
328 + echo '<div class="viz-section-item">';
329 + echo '<a class="more-info" href="javascript:;">[?]</a>';
330 + echo '<b>', esc_html__( 'Width And Height Of Chart', 'visualizer' ), '</b>';
331 +
332 + echo '<table class="viz-section-table" cellspacing="0" cellpadding="0" border="0">';
333 + echo '<tr>';
334 + echo '<td class="viz-section-table-column">';
335 + echo '<input type="text" name="width" class="control-text" value="', esc_attr( $this->width ), '" placeholder="100%">';
336 + echo '</td>';
337 + echo '<td class="viz-section-table-column">';
338 + echo '<input type="text" name="height" class="control-text" value="', esc_attr( $this->height ), '" placeholder="400">';
339 + echo '</td>';
340 + echo '</tr>';
341 + echo '</table>';
342 +
343 + echo '<p class="viz-section-description">';
344 + esc_html_e( 'Determines the total width and height of the chart. This will only show in the front-end.', 'visualizer' );
345 + echo '</p>';
346 + echo '</div>';
347 +
348 + echo '<div class="viz-section-delimiter"></div>';
349 +
350 + self::_renderSectionDescription( esc_html__( 'Configure the background color for the main area of the chart and the chart border width and color.', 'visualizer' ) );
351 +
352 + self::_renderTextItem(
353 + esc_html__( 'Stroke Width', 'visualizer' ),
354 + 'backgroundColor[strokeWidth]',
355 + isset( $this->backgroundColor['strokeWidth'] ) ? $this->backgroundColor['strokeWidth'] : null,
356 + esc_html__( 'The chart border width in pixels.', 'visualizer' ),
357 + '0'
358 + );
359 +
360 + self::_renderColorPickerItem(
361 + esc_html__( 'Stroke Color', 'visualizer' ),
362 + 'backgroundColor[stroke]',
363 + ! empty( $this->backgroundColor['stroke'] ) ? $this->backgroundColor['stroke'] : null,
364 + '#666'
365 + );
366 +
367 + $background_color = ! empty( $this->backgroundColor['fill'] ) ? $this->backgroundColor['fill'] : null;
368 + self::_renderColorPickerItem(
369 + esc_html__( 'Background Color', 'visualizer' ),
370 + 'backgroundColor[fill]',
371 + $background_color,
372 + '#fff'
373 + );
374 +
375 + echo '<div class="viz-section-item">';
376 + echo '<label>';
377 + echo '<input type="checkbox" class="control-checkbox" name="backgroundColor[fill]" value="transparent"', checked( $background_color, 'transparent', false ), '> ';
378 + esc_html_e( 'Transparent background', 'visualizer' );
379 + echo '</label>';
380 + echo '</div>';
381 + self::_renderSectionEnd();
382 +
383 + self::_renderSectionStart( esc_html__( 'Placement', 'visualizer' ), false );
384 + 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' ) );
385 +
386 + echo '<div class="viz-section-item">';
387 + echo '<a class="more-info" href="javascript:;">[?]</a>';
388 + echo '<b>', esc_html__( 'Left And Top Margins', 'visualizer' ), '</b>';
389 +
390 + echo '<table class="viz-section-table" cellspacing="0" cellpadding="0" border="0">';
391 + echo '<tr>';
392 + echo '<td class="viz-section-table-column">';
393 + echo '<input type="text" name="chartArea[left]" class="control-text" value="', $this->chartArea['left'] || $this->chartArea['left'] === '0' ? esc_attr( $this->chartArea['left'] ) : '', '" placeholder="20%">';
394 + echo '</td>';
395 + echo '<td class="viz-section-table-column">';
396 + echo '<input type="text" name="chartArea[top]" class="control-text" value="', $this->chartArea['top'] || $this->chartArea['top'] === '0' ? esc_attr( $this->chartArea['top'] ) : '', '" placeholder="20%">';
397 + echo '</td>';
398 + echo '</tr>';
399 + echo '</table>';
400 +
401 + echo '<p class="viz-section-description">';
402 + esc_html_e( 'Determines how far to draw the chart from the left and top borders.', 'visualizer' );
403 + echo '</p>';
404 + echo '</div>';
405 +
406 + echo '<div class="viz-section-item">';
407 + echo '<a class="more-info" href="javascript:;">[?]</a>';
408 + echo '<b>', esc_html__( 'Width And Height Of Chart Area', 'visualizer' ), '</b>';
409 +
410 + echo '<table class="viz-section-table" cellspacing="0" cellpadding="0" border="0">';
411 + echo '<tr>';
412 + echo '<td class="viz-section-table-column">';
413 + echo '<input type="text" name="chartArea[width]" class="control-text" value="', ! empty( $this->chartArea['width'] ) ? esc_attr( $this->chartArea['width'] ) : '', '" placeholder="60%">';
414 + echo '</td>';
415 + echo '<td class="viz-section-table-column">';
416 + echo '<input type="text" name="chartArea[height]" class="control-text" value="', ! empty( $this->chartArea['height'] ) ? esc_attr( $this->chartArea['height'] ) : '', '" placeholder="60%">';
417 + echo '</td>';
418 + echo '</tr>';
419 + echo '</table>';
420 +
421 + echo '<p class="viz-section-description">';
422 + esc_html_e( 'Determines the width and hight of the chart area.', 'visualizer' );
423 + echo '</p>';
424 + echo '</div>';
425 + self::_renderSectionEnd();
426 + self::_renderGroupEnd();
427 + }
87 428 }