Skip to content

Commit ea128d2

Browse files
Merge pull request #703 from contactashish13/issue-702
Google Pie charts should not show Inside the Chart option for legend position
2 parents 00621a5 + 1dd2b58 commit ea128d2

File tree

3 files changed

+328
-313
lines changed

3 files changed

+328
-313
lines changed

classes/Visualizer/Render/Sidebar.php

Lines changed: 0 additions & 313 deletions
Original file line numberDiff line numberDiff line change
@@ -63,26 +63,6 @@ abstract class Visualizer_Render_Sidebar extends Visualizer_Render {
6363
*/
6464
protected $_yesno;
6565

66-
/**
67-
* The array of available legend positions.
68-
*
69-
* @since 1.0.0
70-
*
71-
* @access protected
72-
* @var array
73-
*/
74-
protected $_legendPositions;
75-
76-
/**
77-
* The array of available alignments.
78-
*
79-
* @since 1.0.0
80-
*
81-
* @access protected
82-
* @var array
83-
*/
84-
protected $_alignments;
85-
8666
/**
8767
* Whether this chart supports animation or not.
8868
*
@@ -110,23 +90,6 @@ abstract class Visualizer_Render_Sidebar extends Visualizer_Render {
11090
public function __construct( $data = array() ) {
11191
parent::__construct( $data );
11292

113-
$this->_legendPositions = array(
114-
'' => '',
115-
'left' => esc_html__( 'Left of the chart', 'visualizer' ),
116-
'right' => esc_html__( 'Right of the chart', 'visualizer' ),
117-
'top' => esc_html__( 'Above the chart', 'visualizer' ),
118-
'bottom' => esc_html__( 'Below the chart', 'visualizer' ),
119-
'in' => esc_html__( 'Inside the chart', 'visualizer' ),
120-
'none' => esc_html__( 'Omit the legend', 'visualizer' ),
121-
);
122-
123-
$this->_alignments = array(
124-
'' => '',
125-
'start' => esc_html__( 'Aligned to the start of the allocated area', 'visualizer' ),
126-
'center' => esc_html__( 'Centered in the allocated area', 'visualizer' ),
127-
'end' => esc_html__( 'Aligned to the end of the allocated area', 'visualizer' ),
128-
);
129-
13093
$this->_yesno = array(
13194
'' => '',
13295
'1' => esc_html__( 'Yes', 'visualizer' ),
@@ -291,282 +254,6 @@ private static function is_excel_enabled() {
291254
return class_exists( 'PhpOffice\PhpSpreadsheet\Spreadsheet' ) && extension_loaded( 'zip' ) && extension_loaded( 'xml' ) && extension_loaded( 'fileinfo' );
292255
}
293256

294-
/**
295-
* Renders chart general settings group.
296-
*
297-
* @since 1.0.0
298-
*
299-
* @access protected
300-
*/
301-
protected function _renderGeneralSettings() {
302-
self::_renderGroupStart( esc_html__( 'General Settings', 'visualizer' ) );
303-
self::_renderSectionStart();
304-
self::_renderSectionDescription( esc_html__( 'Configure title, font styles, tooltip, legend and else settings for the chart.', 'visualizer' ) );
305-
self::_renderSectionEnd();
306-
307-
self::_renderSectionStart( esc_html__( 'Title', 'visualizer' ), false );
308-
$this->_renderChartTitleSettings();
309-
self::_renderSectionEnd();
310-
311-
self::_renderSectionStart( esc_html__( 'Font Styles', 'visualizer' ), false );
312-
echo '<div class="viz-section-item">';
313-
echo '<a class="more-info" href="javascript:;">[?]</a>';
314-
echo '<b>', esc_html__( 'Family And Size', 'visualizer' ), '</b>';
315-
316-
echo '<table class="viz-section-table" cellspacing="0" cellpadding="0" border="0">';
317-
echo '<tr>';
318-
echo '<td class="viz-section-table-column">';
319-
echo '<select name="fontName" class="control-select">';
320-
echo '<option></option>';
321-
foreach ( self::$_fontFamilies as $font => $label ) {
322-
echo '<option value="', $font, '"', selected( $font, $this->fontName, false ), '>';
323-
echo $label;
324-
echo '</option>';
325-
}
326-
echo '</select>';
327-
echo '</td>';
328-
echo '<td class="viz-section-table-column">';
329-
echo '<select name="fontSize" class="control-select">';
330-
echo '<option></option>';
331-
for ( $i = 7; $i <= 20; $i++ ) {
332-
echo '<option value="', $i, '"', selected( $i, $this->fontSize, false ), '>', $i, '</option>';
333-
}
334-
echo '</select>';
335-
echo '</td>';
336-
echo '</tr>';
337-
echo '</table>';
338-
339-
echo '<p class="viz-section-description">';
340-
esc_html_e( 'The default font family and size for all text in the chart.', 'visualizer' );
341-
echo '</p>';
342-
echo '</div>';
343-
self::_renderSectionEnd();
344-
345-
self::_renderSectionStart( esc_html__( 'Legend', 'visualizer' ), false );
346-
self::_renderSelectItem(
347-
esc_html__( 'Position', 'visualizer' ),
348-
'legend[position]',
349-
$this->legend['position'],
350-
$this->_legendPositions,
351-
esc_html__( 'Determines where to place the legend, compared to the chart area.', 'visualizer' )
352-
);
353-
354-
self::_renderSelectItem(
355-
esc_html__( 'Alignment', 'visualizer' ),
356-
'legend[alignment]',
357-
$this->legend['alignment'],
358-
$this->_alignments,
359-
esc_html__( 'Determines the alignment of the legend.', 'visualizer' )
360-
);
361-
362-
self::_renderColorPickerItem(
363-
esc_html__( 'Font Color', 'visualizer' ),
364-
'legend[textStyle][color]',
365-
isset( $this->legend['textStyle']['color'] ) ? $this->legend['textStyle']['color'] : null,
366-
'#000'
367-
);
368-
self::_renderSectionEnd();
369-
370-
self::_renderSectionStart( esc_html__( 'Tooltip', 'visualizer' ), false );
371-
$this->_renderTooltipSettigns();
372-
self::_renderSectionEnd();
373-
374-
$this->_renderAnimationSettings();
375-
376-
do_action( 'visualizer_chart_settings', get_class( $this ), $this->_data, 'general', array( 'generic' => true ) );
377-
378-
self::_renderGroupEnd();
379-
}
380-
381-
/**
382-
* Renders animation settings section.
383-
*
384-
* @access protected
385-
*/
386-
protected function _renderAnimationSettings() {
387-
if ( ! $this->_supportsAnimation ) {
388-
return;
389-
}
390-
391-
self::_renderSectionStart( esc_html__( 'Animation', 'visualizer' ), false );
392-
393-
self::_renderCheckboxItem(
394-
esc_html__( 'Animate on startup', 'visualizer' ),
395-
'animation[startup]',
396-
isset( $this->animation['startup'] ) ? $this->animation['startup'] : 0,
397-
true,
398-
esc_html__( 'Determines if the chart will animate on the initial draw.', 'visualizer' )
399-
);
400-
401-
self::_renderTextItem(
402-
esc_html__( 'Duration', 'visualizer' ),
403-
'animation[duration]',
404-
isset( $this->animation['duration'] ) ? $this->animation['duration'] : 0,
405-
esc_html__( 'The duration of the animation, in milliseconds', 'visualizer' ),
406-
0,
407-
'number'
408-
);
409-
410-
self::_renderSelectItem(
411-
esc_html__( 'Easing', 'visualizer' ),
412-
'animation[easing]',
413-
isset( $this->animation['easing'] ) ? $this->animation['easing'] : null,
414-
array(
415-
'linear' => esc_html__( 'Constant speed', 'visualizer' ),
416-
'in' => esc_html__( 'Start slow and speed up', 'visualizer' ),
417-
'out' => esc_html__( 'Start fast and slow down', 'visualizer' ),
418-
'inAndOut' => esc_html__( 'Start slow, speed up, then slow down', 'visualizer' ),
419-
),
420-
esc_html__( 'The easing function applied to the animation.', 'visualizer' )
421-
);
422-
423-
self::_renderSectionEnd();
424-
425-
}
426-
427-
/**
428-
* Renders tooltip settings section.
429-
*
430-
* @since 1.4.0
431-
*
432-
* @access protected
433-
*/
434-
protected function _renderTooltipSettigns() {
435-
self::_renderSelectItem(
436-
esc_html__( 'Trigger', 'visualizer' ),
437-
'tooltip[trigger]',
438-
isset( $this->tooltip['trigger'] ) ? $this->tooltip['trigger'] : null,
439-
array(
440-
'' => '',
441-
'focus' => esc_html__( 'The tooltip will be displayed when the user hovers over an element', 'visualizer' ),
442-
'selection' => esc_html__( 'The tooltip will be displayed when the user selects an element', 'visualizer' ),
443-
'none' => esc_html__( 'The tooltip will not be displayed', 'visualizer' ),
444-
),
445-
esc_html__( 'Determines the user interaction that causes the tooltip to be displayed.', 'visualizer' )
446-
);
447-
448-
self::_renderSelectItem(
449-
esc_html__( 'Show Color Code', 'visualizer' ),
450-
'tooltip[showColorCode]',
451-
isset( $this->tooltip['showColorCode'] ) ? $this->tooltip['showColorCode'] : null,
452-
$this->_yesno,
453-
esc_html__( 'If set to yes, will show colored squares next to the slice information in the tooltip.', 'visualizer' )
454-
);
455-
}
456-
457-
/**
458-
* Renders chart view settings group.
459-
*
460-
* @since 1.0.0
461-
*
462-
* @access protected
463-
*/
464-
protected function _renderViewSettings() {
465-
self::_renderGroupStart( esc_html__( 'Chart Size & Placement', 'visualizer' ) );
466-
self::_renderSectionStart( esc_html__( 'Chart Size/Layout', 'visualizer' ), false );
467-
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' ) );
468-
469-
echo '<div class="viz-section-item">';
470-
echo '<a class="more-info" href="javascript:;">[?]</a>';
471-
echo '<b>', esc_html__( 'Width And Height Of Chart', 'visualizer' ), '</b>';
472-
473-
echo '<table class="viz-section-table" cellspacing="0" cellpadding="0" border="0">';
474-
echo '<tr>';
475-
echo '<td class="viz-section-table-column">';
476-
echo '<input type="text" name="width" class="control-text" value="', esc_attr( $this->width ), '" placeholder="100%">';
477-
echo '</td>';
478-
echo '<td class="viz-section-table-column">';
479-
echo '<input type="text" name="height" class="control-text" value="', esc_attr( $this->height ), '" placeholder="400">';
480-
echo '</td>';
481-
echo '</tr>';
482-
echo '</table>';
483-
484-
echo '<p class="viz-section-description">';
485-
esc_html_e( 'Determines the total width and height of the chart. This will only show in the front-end.', 'visualizer' );
486-
echo '</p>';
487-
echo '</div>';
488-
489-
echo '<div class="viz-section-delimiter"></div>';
490-
491-
self::_renderSectionDescription( esc_html__( 'Configure the background color for the main area of the chart and the chart border width and color.', 'visualizer' ) );
492-
493-
self::_renderTextItem(
494-
esc_html__( 'Stroke Width', 'visualizer' ),
495-
'backgroundColor[strokeWidth]',
496-
isset( $this->backgroundColor['strokeWidth'] ) ? $this->backgroundColor['strokeWidth'] : null,
497-
esc_html__( 'The chart border width in pixels.', 'visualizer' ),
498-
'0'
499-
);
500-
501-
self::_renderColorPickerItem(
502-
esc_html__( 'Stroke Color', 'visualizer' ),
503-
'backgroundColor[stroke]',
504-
! empty( $this->backgroundColor['stroke'] ) ? $this->backgroundColor['stroke'] : null,
505-
'#666'
506-
);
507-
508-
$background_color = ! empty( $this->backgroundColor['fill'] ) ? $this->backgroundColor['fill'] : null;
509-
self::_renderColorPickerItem(
510-
esc_html__( 'Background Color', 'visualizer' ),
511-
'backgroundColor[fill]',
512-
$background_color,
513-
'#fff'
514-
);
515-
516-
echo '<div class="viz-section-item">';
517-
echo '<label>';
518-
echo '<input type="checkbox" class="control-checkbox" name="backgroundColor[fill]" value="transparent"', checked( $background_color, 'transparent', false ), '> ';
519-
esc_html_e( 'Transparent background', 'visualizer' );
520-
echo '</label>';
521-
echo '</div>';
522-
self::_renderSectionEnd();
523-
524-
self::_renderSectionStart( esc_html__( 'Placement', 'visualizer' ), false );
525-
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' ) );
526-
527-
echo '<div class="viz-section-item">';
528-
echo '<a class="more-info" href="javascript:;">[?]</a>';
529-
echo '<b>', esc_html__( 'Left And Top Margins', 'visualizer' ), '</b>';
530-
531-
echo '<table class="viz-section-table" cellspacing="0" cellpadding="0" border="0">';
532-
echo '<tr>';
533-
echo '<td class="viz-section-table-column">';
534-
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%">';
535-
echo '</td>';
536-
echo '<td class="viz-section-table-column">';
537-
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%">';
538-
echo '</td>';
539-
echo '</tr>';
540-
echo '</table>';
541-
542-
echo '<p class="viz-section-description">';
543-
esc_html_e( 'Determines how far to draw the chart from the left and top borders.', 'visualizer' );
544-
echo '</p>';
545-
echo '</div>';
546-
547-
echo '<div class="viz-section-item">';
548-
echo '<a class="more-info" href="javascript:;">[?]</a>';
549-
echo '<b>', esc_html__( 'Width And Height Of Chart Area', 'visualizer' ), '</b>';
550-
551-
echo '<table class="viz-section-table" cellspacing="0" cellpadding="0" border="0">';
552-
echo '<tr>';
553-
echo '<td class="viz-section-table-column">';
554-
echo '<input type="text" name="chartArea[width]" class="control-text" value="', ! empty( $this->chartArea['width'] ) ? esc_attr( $this->chartArea['width'] ) : '', '" placeholder="60%">';
555-
echo '</td>';
556-
echo '<td class="viz-section-table-column">';
557-
echo '<input type="text" name="chartArea[height]" class="control-text" value="', ! empty( $this->chartArea['height'] ) ? esc_attr( $this->chartArea['height'] ) : '', '" placeholder="60%">';
558-
echo '</td>';
559-
echo '</tr>';
560-
echo '</table>';
561-
562-
echo '<p class="viz-section-description">';
563-
esc_html_e( 'Determines the width and hight of the chart area.', 'visualizer' );
564-
echo '</p>';
565-
echo '</div>';
566-
self::_renderSectionEnd();
567-
self::_renderGroupEnd();
568-
}
569-
570257
/**
571258
* Renders select item.
572259
*

classes/Visualizer/Render/Sidebar/ChartJS.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@
1212
*/
1313
abstract class Visualizer_Render_Sidebar_ChartJS extends Visualizer_Render_Sidebar {
1414

15+
/**
16+
* The array of available legend positions.
17+
*
18+
* @since 1.0.0
19+
*
20+
* @access protected
21+
* @var array
22+
*/
23+
protected $_legendPositions;
24+
25+
1526
/**
1627
* The constructor.
1728
*/

0 commit comments

Comments
 (0)