| 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 |
|
| 24 |
/** |
| 25 |
* Base class for sidebar settings of linear based charts. |
| 26 |
* |
| 27 |
* @category Visualizer |
| 28 |
* @package Render |
| 29 |
* @subpackage Sidebar |
| 30 |
* |
| 31 |
* @since 1.0.0 |
| 32 |
* @abstract |
| 33 |
*/ |
| 34 |
abstract class Visualizer_Render_Sidebar_Linear extends Visualizer_Render_Sidebar_Graph { |
| 35 |
|
| 36 |
/** |
| 37 |
* Determines whether we need to render curve type option or not. |
| 38 |
* |
| 39 |
* @since 1.0.0 |
| 40 |
* |
| 41 |
* @access protected |
| 42 |
* @var boolean |
| 43 |
*/ |
| 44 |
protected $_includeCurveTypes; |
| 45 |
|
| 46 |
/** |
| 47 |
* The array of available curve types. |
| 48 |
* |
| 49 |
* @since 1.0.0 |
| 50 |
* |
| 51 |
* @access protected |
| 52 |
* @var array |
| 53 |
*/ |
| 54 |
protected $_curveTypes; |
| 55 |
|
| 56 |
/** |
| 57 |
* Determines whether we need to render focus target option or not. |
| 58 |
* |
| 59 |
* @since 1.0.0 |
| 60 |
* |
| 61 |
* @access protected |
| 62 |
* @var boolean |
| 63 |
*/ |
| 64 |
protected $_includeFocusTarget; |
| 65 |
|
| 66 |
/** |
| 67 |
* Constructor. |
| 68 |
* |
| 69 |
* @since 1.0.0 |
| 70 |
* |
| 71 |
* @access public |
| 72 |
* @param array $data The data what has to be associated with this render. |
| 73 |
*/ |
| 74 |
public function __construct( $data = array() ) { |
| 75 |
parent::__construct( $data ); |
| 76 |
|
| 77 |
$this->_includeCurveTypes = true; |
| 78 |
$this->_includeFocusTarget = true; |
| 79 |
|
| 80 |
$this->_curveTypes = array( |
| 81 |
'' => '', |
| 82 |
'none' => esc_html__( 'Straight line without curve', Visualizer_Plugin::NAME ), |
| 83 |
'function' => esc_html__( 'The angles of the line will be smoothed', Visualizer_Plugin::NAME ), |
| 84 |
); |
| 85 |
} |
| 86 |
|
| 87 |
/** |
| 88 |
* Renders line settings items. |
| 89 |
* |
| 90 |
* @since 1.0.0 |
| 91 |
* |
| 92 |
* @access protected |
| 93 |
*/ |
| 94 |
protected function _renderLineSettingsItems() { |
| 95 |
echo '<div class="section-item">'; |
| 96 |
echo '<a class="more-info" href="javascript:;">[?]</a>'; |
| 97 |
echo '<b>', esc_html__( 'Line Width And Point Size', Visualizer_Plugin::NAME ), '</b>'; |
| 98 |
|
| 99 |
echo '<table class="section-table" cellspacing="0" cellpadding="0" border="0">'; |
| 100 |
echo '<tr>'; |
| 101 |
echo '<td class="section-table-column">'; |
| 102 |
echo '<input type="text" name="lineWidth" class="control-text" value="', esc_attr( $this->lineWidth ), '" placeholder="2">'; |
| 103 |
echo '</td>'; |
| 104 |
echo '<td class="section-table-column">'; |
| 105 |
echo '<input type="text" name="pointSize" class="control-text" value="', esc_attr( $this->pointSize ), '" placeholder="0">'; |
| 106 |
echo '</td>'; |
| 107 |
echo '</tr>'; |
| 108 |
echo '</table>'; |
| 109 |
|
| 110 |
echo '<p class="section-description">'; |
| 111 |
esc_html_e( 'Data line width and diameter of displayed points in pixels. Use zero to hide all lines or points.', Visualizer_Plugin::NAME ); |
| 112 |
echo '</p>'; |
| 113 |
echo '</div>'; |
| 114 |
|
| 115 |
if ( $this->_includeCurveTypes ) { |
| 116 |
self::_renderSelectItem( |
| 117 |
esc_html__( 'Curve Type', Visualizer_Plugin::NAME ), |
| 118 |
'curveType', |
| 119 |
$this->curveType, |
| 120 |
$this->_curveTypes, |
| 121 |
esc_html__( 'Determines whether the series has to be presented in the legend or not.', Visualizer_Plugin::NAME ) |
| 122 |
); |
| 123 |
} |
| 124 |
|
| 125 |
if ( $this->_includeFocusTarget ) { |
| 126 |
self::_renderSelectItem( |
| 127 |
esc_html__( 'Focus Target', Visualizer_Plugin::NAME ), |
| 128 |
'focusTarget', |
| 129 |
$this->focusTarget, |
| 130 |
array( |
| 131 |
'' => '', |
| 132 |
'datum' => esc_html__( 'Focus on a single data point.', Visualizer_Plugin::NAME ), |
| 133 |
'category' => esc_html__( 'Focus on a grouping of all data points along the major axis.', Visualizer_Plugin::NAME ), |
| 134 |
), |
| 135 |
esc_html__( 'The type of the entity that receives focus on mouse hover. Also affects which entity is selected by mouse click.', Visualizer_Plugin::NAME ) |
| 136 |
); |
| 137 |
} |
| 138 |
} |
| 139 |
|
| 140 |
/** |
| 141 |
* Renders lines settings. |
| 142 |
* |
| 143 |
* @since 1.0.0 |
| 144 |
* |
| 145 |
* @access protected |
| 146 |
*/ |
| 147 |
protected function _renderLineSettings() { |
| 148 |
self::_renderGroupStart( esc_html__( 'Lines Settings', Visualizer_Plugin::NAME ) ); |
| 149 |
self::_renderSectionStart(); |
| 150 |
$this->_renderLineSettingsItems(); |
| 151 |
self::_renderSectionEnd(); |
| 152 |
self::_renderGroupEnd(); |
| 153 |
} |
| 154 |
|
| 155 |
/** |
| 156 |
* Renders concreate series settings. |
| 157 |
* |
| 158 |
* @since 1.0.0 |
| 159 |
* |
| 160 |
* @access protected |
| 161 |
* @param int $index The series index. |
| 162 |
*/ |
| 163 |
protected function _renderSeries( $index ) { |
| 164 |
self::_renderSelectItem( |
| 165 |
esc_html__( 'Visible In Legend', Visualizer_Plugin::NAME ), |
| 166 |
'series[' . $index . '][visibleInLegend]', |
| 167 |
isset( $this->series[$index]['visibleInLegend'] ) ? $this->series[$index]['visibleInLegend'] : '', |
| 168 |
array( |
| 169 |
'' => '', |
| 170 |
'0' => esc_html__( 'No', Visualizer_Plugin::NAME ), |
| 171 |
'1' => esc_html__( 'Yes', Visualizer_Plugin::NAME ), |
| 172 |
), |
| 173 |
esc_html__( 'Determines whether the series has to be presented in the legend or not.', Visualizer_Plugin::NAME ) |
| 174 |
); |
| 175 |
|
| 176 |
echo '<div class="section-item">'; |
| 177 |
echo '<a class="more-info" href="javascript:;">[?]</a>'; |
| 178 |
echo '<b>', esc_html__( 'Line Width And Point Size', Visualizer_Plugin::NAME ), '</b>'; |
| 179 |
|
| 180 |
echo '<table class="section-table" cellspacing="0" cellpadding="0" border="0">'; |
| 181 |
echo '<tr>'; |
| 182 |
echo '<td class="section-table-column">'; |
| 183 |
$line_width = isset( $this->series[$index]['lineWidth'] ) ? $this->series[$index]['lineWidth'] : ''; |
| 184 |
echo '<input type="text" name="series[', $index, '][lineWidth]" class="control-text" value="', esc_attr( $line_width ), '" placeholder="2">'; |
| 185 |
echo '</td>'; |
| 186 |
echo '<td class="section-table-column">'; |
| 187 |
$point_size = isset( $this->series[$index]['pointSize'] ) ? $this->series[$index]['pointSize'] : ''; |
| 188 |
echo '<input type="text" name="series[', $index, '][pointSize]" class="control-text" value="', esc_attr( $point_size ), '" placeholder="0">'; |
| 189 |
echo '</td>'; |
| 190 |
echo '</tr>'; |
| 191 |
echo '</table>'; |
| 192 |
|
| 193 |
echo '<p class="section-description">'; |
| 194 |
esc_html_e( 'Overrides the global line width and point size values for this series.', Visualizer_Plugin::NAME ); |
| 195 |
echo '</p>'; |
| 196 |
echo '</div>'; |
| 197 |
|
| 198 |
$this->_renderFormatField( $index ); |
| 199 |
|
| 200 |
if ( $this->_includeCurveTypes ) { |
| 201 |
self::_renderSelectItem( |
| 202 |
esc_html__( 'Curve Type', Visualizer_Plugin::NAME ), |
| 203 |
'series[' . $index . '][curveType]', |
| 204 |
isset( $this->series[$index]['curveType'] ) ? $this->series[$index]['curveType'] : '', |
| 205 |
$this->_curveTypes, |
| 206 |
esc_html__( 'Determines whether the series has to be presented in the legend or not.', Visualizer_Plugin::NAME ) |
| 207 |
); |
| 208 |
} |
| 209 |
|
| 210 |
self::_renderColorPickerItem( |
| 211 |
esc_html__( 'Color', Visualizer_Plugin::NAME ), |
| 212 |
'series[' . $index . '][color]', |
| 213 |
isset( $this->series[$index]['color'] ) ? $this->series[$index]['color'] : null, |
| 214 |
null |
| 215 |
); |
| 216 |
} |
| 217 |
|
| 218 |
} |