PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.17.0 4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 All 256 releases
← All changes | includes/admin/reports/class-give-graph.php +50 -40 2.3.0 → 4.16.9 View file →
@@ -5,9 +5,9 @@
5 5 * This class handles building pretty report graphs
6 6 *
7 7 * @package Give
8 8 * @subpackage Admin/Reports
9 - * @copyright Copyright (c) 2012, WordImpress
9 + * @copyright Copyright (c) 2012, GiveWP
10 10 * @license https://opensource.org/licenses/gpl-license GNU Public License
11 11 * @since 1.0
12 12 */
13 13
@@ -23,9 +23,8 @@
23 23 */
24 24 class Give_Graph {
25 25
26 26 /*
27 -
28 27 Simple example:
29 28
30 29 data format for each point: array( location on x, location on y )
31 30
@@ -82,33 +81,36 @@
82 81 * @param array $options
83 82 */
84 83 public function __construct( $_data, $options = array() ) {
85 84
86 - $this->data = $_data;
85 + $this->data = $_data;
87 86
88 87 // Generate unique ID
89 88 $this->id = md5( rand() );
90 89
91 90 // Setup default options;
92 - $this->options = apply_filters( 'give_graph_args', array(
93 - 'y_mode' => null,
94 - 'x_mode' => null,
95 - 'y_decimals' => 0,
96 - 'x_decimals' => 0,
97 - 'y_position' => 'right',
98 - 'time_format' => '%d/%b',
99 - 'ticksize_unit' => 'day',
100 - 'ticksize_num' => 1,
101 - 'multiple_y_axes' => false,
102 - 'bgcolor' => '#f9f9f9',
103 - 'bordercolor' => '#eee',
104 - 'color' => '#bbb',
105 - 'borderwidth' => 1,
106 - 'bars' => true,
107 - 'lines' => false,
108 - 'points' => true,
109 - 'dataType' => array()
110 - ) );
91 + $this->options = apply_filters(
92 + 'give_graph_args',
93 + array(
94 + 'y_mode' => null,
95 + 'x_mode' => null,
96 + 'y_decimals' => 0,
97 + 'x_decimals' => 0,
98 + 'y_position' => 'right',
99 + 'time_format' => '%d/%b',
100 + 'ticksize_unit' => 'day',
101 + 'ticksize_num' => 1,
102 + 'multiple_y_axes' => false,
103 + 'bgcolor' => '#f9f9f9',
104 + 'bordercolor' => '#eee',
105 + 'color' => '#bbb',
106 + 'borderwidth' => 1,
107 + 'bars' => true,
108 + 'lines' => false,
109 + 'points' => true,
110 + 'dataType' => array(),
111 + )
112 + );
111 113
112 114 $this->options = wp_parse_args( $options, $this->options );
113 115 }
114 116
@@ -152,18 +154,18 @@
152 154 public function load_scripts() {
153 155 // Use minified libraries if SCRIPT_DEBUG is turned off
154 156 $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
155 157
156 - wp_register_script( 'jquery-flot-orderbars', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.orderBars' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION );
158 + wp_register_script( 'jquery-flot-orderbars', GIVE_PLUGIN_URL . 'build/assets/js/plugins/jquery.flot.orderBars' . $suffix . '.js', array( 'jquery-flot' ), GIVE_VERSION );
157 159 wp_enqueue_script( 'jquery-flot-orderbars' );
158 160
159 - wp_register_script( 'jquery-flot-time', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.time' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION );
161 + wp_register_script( 'jquery-flot-time', GIVE_PLUGIN_URL . 'build/assets/js/plugins/jquery.flot.time' . $suffix . '.js', array( 'jquery-flot' ), GIVE_VERSION );
160 162 wp_enqueue_script( 'jquery-flot-time' );
161 163
162 - wp_register_script( 'jquery-flot-resize', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.resize' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION );
164 + wp_register_script( 'jquery-flot-resize', GIVE_PLUGIN_URL . 'build/assets/js/plugins/jquery.flot.resize' . $suffix . '.js', array( 'jquery-flot' ), GIVE_VERSION );
163 165 wp_enqueue_script( 'jquery-flot-resize' );
164 166
165 - wp_register_script( 'jquery-flot', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot' . $suffix . '.js', false, GIVE_VERSION );
167 + wp_register_script( 'jquery-flot', GIVE_PLUGIN_URL . 'build/assets/js/plugins/jquery.flot' . $suffix . '.js', false, GIVE_VERSION );
166 168 wp_enqueue_script( 'jquery-flot' );
167 169
168 170 }
169 171
@@ -187,16 +189,21 @@
187 189 $( "#give-graph-<?php echo $this->id; ?>" ),
188 190 [
189 191 <?php
190 192 $order = 0;
191 - foreach( $this->get_data() as $label => $data ) :
192 - ?>
193 + foreach ( $this->get_data() as $label => $data ) :
194 + ?>
193 195 {
194 196 label : "<?php echo esc_attr( $label ); ?>",
195 197 id : "<?php echo sanitize_key( $label ); ?>",
196 - dataType : '<?php echo ( ! empty( $this->options['dataType'][$order] ) ? $this->options['dataType'][$order] : 'count' ); ?>',
198 + dataType : '<?php echo ( ! empty( $this->options['dataType'][ $order ] ) ? $this->options['dataType'][ $order ] : 'count' ); ?>',
197 199 // data format is: [ point on x, value on y ]
198 - data : [<?php foreach( $data as $point ) { echo '[' . implode( ',', $point ) . '],'; } ?>],
200 + data : [
201 + <?php
202 + foreach ( $data as $point ) {
203 + echo '[' . implode( ',', $point ) . '],'; }
204 + ?>
205 + ],
199 206 points: {
200 207 show: <?php echo $this->options['points'] ? 'true' : 'false'; ?>,
201 208 },
202 209 bars : {
@@ -209,15 +216,18 @@
209 216 show : <?php echo $this->options['lines'] ? 'true' : 'false'; ?>,
210 217 fill : true,
211 218 fillColor: {colors: [{opacity: 0.4}, {opacity: 0.1}]}
212 219 },
213 - <?php if( $this->options[ 'multiple_y_axes' ] ) : ?>
220 + <?php if ( $this->options['multiple_y_axes'] ) : ?>
214 221 yaxis : <?php echo $yaxis_count; ?>
215 222 <?php endif; ?>
216 223
217 224 },
218 225
219 - <?php $yaxis_count++; endforeach; ?>
226 + <?php
227 + $yaxis_count++;
228 +endforeach;
229 + ?>
220 230
221 231 ],
222 232 {
223 233 // Options
@@ -223,23 +233,23 @@
223 233 // Options
224 234 grid: {
225 235 show : true,
226 236 aboveData : false,
227 - color : "<?php echo $this->options[ 'color' ]; ?>",
228 - backgroundColor: "<?php echo $this->options[ 'bgcolor' ]; ?>",
229 - borderColor : "<?php echo $this->options[ 'bordercolor' ]; ?>",
230 - borderWidth : <?php echo absint( $this->options[ 'borderwidth' ] ); ?>,
237 + color : "<?php echo $this->options['color']; ?>",
238 + backgroundColor: "<?php echo $this->options['bgcolor']; ?>",
239 + borderColor : "<?php echo $this->options['bordercolor']; ?>",
240 + borderWidth : <?php echo absint( $this->options['borderwidth'] ); ?>,
231 241 clickable : false,
232 242 hoverable : true
233 243 },
234 244
235 - colors: ["#66bb6a", "#546e7a"], //Give Colors
245 + colors: ["#69B868", "#546e7a"], //Give Colors
236 246
237 247 xaxis: {
238 248 mode : "<?php echo $this->options['x_mode']; ?>",
239 249 timeFormat : "<?php echo $this->options['x_mode'] == 'time' ? $this->options['time_format'] : ''; ?>",
240 250 tickSize : "<?php echo $this->options['x_mode'] == 'time' ? '' : 1; ?>",
241 - <?php if( $this->options['x_mode'] != 'time' ) : ?>
251 + <?php if ( $this->options['x_mode'] != 'time' ) : ?>
242 252 tickDecimals: <?php echo $this->options['x_decimals']; ?>
243 253 <?php endif; ?>
244 254 },
245 255 yaxis: {
@@ -246,9 +256,9 @@
246 256 position : 'right',
247 257 min : 0,
248 258 mode : "<?php echo $this->options['y_mode']; ?>",
249 259 timeFormat : "<?php echo $this->options['y_mode'] == 'time' ? $this->options['time_format'] : ''; ?>",
250 - <?php if( $this->options['y_mode'] != 'time' ) : ?>
260 + <?php if ( $this->options['y_mode'] != 'time' ) : ?>
251 261 tickDecimals: <?php echo $this->options['y_decimals']; ?>,
252 262 <?php endif; ?>
253 263 tickFormatter: function(val) {
254 264 return val.toString().replace(/\B(?=(?:\d{3})+(?!\d))/g, give_vars.thousands_separator);
@@ -279,9 +289,9 @@
279 289 if ( previousPoint !== item.dataIndex ) {
280 290 previousPoint = item.dataIndex;
281 291 $( "#give-flot-tooltip" ).remove();
282 292 var x = item.datapoint[0].toFixed( 2 ),
283 - y = accounting.formatMoney( item.datapoint[1].toFixed( give_vars.currency_decimals ), '', give_vars.currency_decimals, give_vars.thousands_separator, give_vars.decimal_separator );
293 + y = accounting.formatMoney( item.datapoint[1].toFixed( give_vars.currency_decimals ), '', give_vars.currency_decimals, give_vars.thousands_separator, give_vars.decimal_separator );
284 294
285 295 if ( item.series.dataType.length && item.series.dataType === 'amount' ) {
286 296
287 297 if ( give_vars.currency_pos === 'before' ) {