Post Views Counter - Version 1.2.4

Version Description

  • New: Advanced crawler detection
  • Tweak: Chart.js script update to 2.4.0
Download this release

Release Info

Developer dfactory
Plugin Icon 128x128 Post Views Counter
Version 1.2.4
Comparing to
See all releases

Code changes from version 1.2.3 to 1.2.4

includes/columns.php CHANGED
@@ -5,6 +5,8 @@ if ( ! defined( 'ABSPATH' ) )
5
 
6
  /**
7
  * Post_Views_Counter_Columns class.
 
 
8
  */
9
  class Post_Views_Counter_Columns {
10
 
@@ -14,7 +16,7 @@ class Post_Views_Counter_Columns {
14
  add_action( 'post_submitbox_misc_actions', array( $this, 'submitbox_views' ) );
15
  add_action( 'save_post', array( $this, 'save_post' ), 10, 2 );
16
  add_action( 'bulk_edit_custom_box', array( $this, 'quick_edit_custom_box' ), 10, 2 );
17
- add_action( 'quick_edit_custom_box', array( $this, 'quick_edit_custom_box') , 10, 2 );
18
  add_action( 'wp_ajax_save_bulk_post_views', array( $this, 'save_bulk_post_views' ) );
19
  }
20
 
@@ -22,8 +24,6 @@ class Post_Views_Counter_Columns {
22
  * Output post views for single post.
23
  *
24
  * @global object $post
25
- * @global object $wpbd
26
- *
27
  * @return mixed
28
  */
29
  public function submitbox_views() {
@@ -33,21 +33,13 @@ class Post_Views_Counter_Columns {
33
 
34
  if ( ! in_array( $post->post_type, (array) $post_types ) )
35
  return;
36
-
37
  // break if current user can't edit this post
38
  if ( ! current_user_can( 'edit_post', $post->ID ) )
39
  return;
40
 
41
- global $wpdb;
42
-
43
  // get total post views
44
- $count = $wpdb->get_var(
45
- $wpdb->prepare( "
46
- SELECT count
47
- FROM " . $wpdb->prefix . "post_views
48
- WHERE id = %d AND type = 4", absint( $post->ID )
49
- )
50
- );
51
  ?>
52
 
53
  <div class="misc-pub-section" id="post-views">
@@ -55,20 +47,19 @@ class Post_Views_Counter_Columns {
55
  <?php wp_nonce_field( 'post_views_count', 'pvc_nonce' ); ?>
56
 
57
  <span id="post-views-display">
58
-
59
  <?php echo __( 'Post Views', 'post-views-counter' ) . ': <b>' . number_format_i18n( (int) $count ) . '</b>'; ?>
60
-
61
  </span>
62
-
63
- <?php // restrict editing
 
64
  $restrict = (bool) Post_Views_Counter()->options['general']['restrict_edit_views'];
65
-
66
  if ( $restrict === false || ( $restrict === true && current_user_can( apply_filters( 'pvc_restrict_edit_capability', 'manage_options' ) ) ) ) {
67
  ?>
68
  <a href="#post-views" class="edit-post-views hide-if-no-js"><?php _e( 'Edit', 'post-views-counter' ); ?></a>
69
-
70
  <div id="post-views-input-container" class="hide-if-js">
71
-
72
  <p><?php _e( 'Adjust the views count for this post.', 'post-views-counter' ); ?></p>
73
  <input type="hidden" name="current_post_views" id="post-views-current" value="<?php echo (int) $count; ?>" />
74
  <input type="text" name="post_views" id="post-views-input" value="<?php echo (int) $count; ?>"/><br />
@@ -76,7 +67,7 @@ class Post_Views_Counter_Columns {
76
  <a href="#post-views" class="save-post-views hide-if-no-js button"><?php _e( 'OK', 'post-views-counter' ); ?></a>
77
  <a href="#post-views" class="cancel-post-views hide-if-no-js"><?php _e( 'Cancel', 'post-views-counter' ); ?></a>
78
  </p>
79
-
80
  </div>
81
  <?php
82
  }
@@ -111,13 +102,13 @@ class Post_Views_Counter_Columns {
111
 
112
  if ( ! in_array( $post->post_type, (array) $post_types ) )
113
  return $post_id;
114
-
115
  // break if views editing is restricted
116
  $restrict = (bool) Post_Views_Counter()->options['general']['restrict_edit_views'];
117
-
118
  if ( $restrict === true && ! current_user_can( apply_filters( 'pvc_restrict_edit_capability', 'manage_options' ) ) )
119
  return $post_id;
120
-
121
  // validate data
122
  if ( ! isset( $_POST['pvc_nonce'] ) || ! wp_verify_nonce( $_POST['pvc_nonce'], 'post_views_count' ) )
123
  return $post_id;
@@ -129,9 +120,9 @@ class Post_Views_Counter_Columns {
129
  // insert or update db post views count
130
  $wpdb->query(
131
  $wpdb->prepare( "
132
- INSERT INTO " . $wpdb->prefix . "post_views (id, type, period, count)
133
- VALUES (%d, %d, %s, %d)
134
- ON DUPLICATE KEY UPDATE count = %d", $post_id, 4, 'total', $count, $count
135
  )
136
  );
137
 
@@ -143,7 +134,7 @@ class Post_Views_Counter_Columns {
143
  */
144
  public function register_new_column() {
145
  $post_types = Post_Views_Counter()->options['general']['post_types_count'];
146
-
147
  if ( ! empty( $post_types ) ) {
148
  foreach ( $post_types as $post_type ) {
149
  // actions
@@ -205,78 +196,58 @@ class Post_Views_Counter_Columns {
205
  /**
206
  * Add post views column content.
207
  *
208
- * @global object $wpdb
209
  * @param string $column_name
210
  * @param int $id
211
  * @return muxed
212
  */
213
  public function add_new_column_content( $column_name, $id ) {
214
-
215
  if ( $column_name === 'post_views' ) {
216
-
217
- global $wpdb;
218
-
219
  // get total post views
220
- $count = $wpdb->get_var(
221
- $wpdb->prepare( "
222
- SELECT count
223
- FROM " . $wpdb->prefix . "post_views
224
- WHERE id = %d AND type = 4", $id
225
- )
226
- );
227
-
228
- echo (int) $count;
229
  }
230
  }
231
-
232
  /**
233
  * Handle quick edit.
234
  *
235
  * @global string $pagenow
236
- * @global object $wpdb
237
  * @param string $column_name
238
  * @return mixed
239
  */
240
- function quick_edit_custom_box( $column_name, $post_type ) {
241
- global $pagenow, $post;
242
-
243
- if ( $pagenow !== 'edit.php' )
244
- return;
245
-
246
- if ( ! Post_Views_Counter()->options['general']['post_views_column'] || ! in_array( $post_type, Post_Views_Counter()->options['general']['post_types_count'] ) )
247
- return;
248
-
249
- // break if views editing is restricted
 
 
 
250
  $restrict = (bool) Post_Views_Counter()->options['general']['restrict_edit_views'];
251
-
252
  if ( $restrict === true && ! current_user_can( apply_filters( 'pvc_restrict_edit_capability', 'manage_options' ) ) )
253
  return;
254
 
255
- if ( $column_name != 'post_views' )
256
- return;
257
-
258
- global $wpdb;
259
-
260
  // get total post views
261
- $count = $wpdb->get_var(
262
- $wpdb->prepare( "
263
- SELECT count
264
- FROM " . $wpdb->prefix . "post_views
265
- WHERE id = %d AND type = 4", $post->ID
266
- )
267
- );
268
- ?>
269
- <fieldset class="inline-edit-col-left">
270
- <div id="inline-edit-post_views" class="inline-edit-col">
271
- <label class="inline-edit-group">
272
- <span class="title"><?php _e( 'Post Views', 'post-views-counter' ); ?></span>
273
- <span class="input-text-wrap"><input type="text" name="post_views" class="title text" value="<?php echo absint( $count ); ?>"></span>
274
- <?php wp_nonce_field( 'post_views_count', 'pvc_nonce' ); ?>
275
- </label>
276
- </div>
277
- </fieldset>
278
- <?php
279
- }
280
 
281
  /**
282
  * Bulk save post views.
@@ -285,23 +256,23 @@ class Post_Views_Counter_Columns {
285
  * @return type
286
  */
287
  function save_bulk_post_views() {
288
-
289
- $post_ids = ( ! empty( $_POST[ 'post_ids' ] ) && is_array( $_POST['post_ids'] ) ) ? array_map( 'absint', $_POST[ 'post_ids' ] ) : array();
290
- $count = ( ! empty( $_POST[ 'post_views' ] ) ) ? absint( $_POST[ 'post_views' ] ) : null;
291
-
292
  // break if views editing is restricted
293
  $restrict = (bool) Post_Views_Counter()->options['general']['restrict_edit_views'];
294
 
295
  if ( $restrict === true && ! current_user_can( apply_filters( 'pvc_restrict_edit_capability', 'manage_options' ) ) )
296
  die();
297
-
298
  if ( ! empty( $post_ids ) ) {
299
  foreach ( $post_ids as $post_id ) {
300
-
301
  // break if current user can't edit this post
302
  if ( ! current_user_can( 'edit_post', $post_id ) )
303
  continue;
304
-
305
  global $wpdb;
306
 
307
  // insert or update db post views count
5
 
6
  /**
7
  * Post_Views_Counter_Columns class.
8
+ *
9
+ * @class Post_Views_Counter_Columns
10
  */
11
  class Post_Views_Counter_Columns {
12
 
16
  add_action( 'post_submitbox_misc_actions', array( $this, 'submitbox_views' ) );
17
  add_action( 'save_post', array( $this, 'save_post' ), 10, 2 );
18
  add_action( 'bulk_edit_custom_box', array( $this, 'quick_edit_custom_box' ), 10, 2 );
19
+ add_action( 'quick_edit_custom_box', array( $this, 'quick_edit_custom_box' ), 10, 2 );
20
  add_action( 'wp_ajax_save_bulk_post_views', array( $this, 'save_bulk_post_views' ) );
21
  }
22
 
24
  * Output post views for single post.
25
  *
26
  * @global object $post
 
 
27
  * @return mixed
28
  */
29
  public function submitbox_views() {
33
 
34
  if ( ! in_array( $post->post_type, (array) $post_types ) )
35
  return;
36
+
37
  // break if current user can't edit this post
38
  if ( ! current_user_can( 'edit_post', $post->ID ) )
39
  return;
40
 
 
 
41
  // get total post views
42
+ $count = pvc_get_post_views( $post->ID );
 
 
 
 
 
 
43
  ?>
44
 
45
  <div class="misc-pub-section" id="post-views">
47
  <?php wp_nonce_field( 'post_views_count', 'pvc_nonce' ); ?>
48
 
49
  <span id="post-views-display">
 
50
  <?php echo __( 'Post Views', 'post-views-counter' ) . ': <b>' . number_format_i18n( (int) $count ) . '</b>'; ?>
 
51
  </span>
52
+
53
+ <?php
54
+ // restrict editing
55
  $restrict = (bool) Post_Views_Counter()->options['general']['restrict_edit_views'];
56
+
57
  if ( $restrict === false || ( $restrict === true && current_user_can( apply_filters( 'pvc_restrict_edit_capability', 'manage_options' ) ) ) ) {
58
  ?>
59
  <a href="#post-views" class="edit-post-views hide-if-no-js"><?php _e( 'Edit', 'post-views-counter' ); ?></a>
60
+
61
  <div id="post-views-input-container" class="hide-if-js">
62
+
63
  <p><?php _e( 'Adjust the views count for this post.', 'post-views-counter' ); ?></p>
64
  <input type="hidden" name="current_post_views" id="post-views-current" value="<?php echo (int) $count; ?>" />
65
  <input type="text" name="post_views" id="post-views-input" value="<?php echo (int) $count; ?>"/><br />
67
  <a href="#post-views" class="save-post-views hide-if-no-js button"><?php _e( 'OK', 'post-views-counter' ); ?></a>
68
  <a href="#post-views" class="cancel-post-views hide-if-no-js"><?php _e( 'Cancel', 'post-views-counter' ); ?></a>
69
  </p>
70
+
71
  </div>
72
  <?php
73
  }
102
 
103
  if ( ! in_array( $post->post_type, (array) $post_types ) )
104
  return $post_id;
105
+
106
  // break if views editing is restricted
107
  $restrict = (bool) Post_Views_Counter()->options['general']['restrict_edit_views'];
108
+
109
  if ( $restrict === true && ! current_user_can( apply_filters( 'pvc_restrict_edit_capability', 'manage_options' ) ) )
110
  return $post_id;
111
+
112
  // validate data
113
  if ( ! isset( $_POST['pvc_nonce'] ) || ! wp_verify_nonce( $_POST['pvc_nonce'], 'post_views_count' ) )
114
  return $post_id;
120
  // insert or update db post views count
121
  $wpdb->query(
122
  $wpdb->prepare( "
123
+ INSERT INTO " . $wpdb->prefix . "post_views (id, type, period, count)
124
+ VALUES (%d, %d, %s, %d)
125
+ ON DUPLICATE KEY UPDATE count = %d", $post_id, 4, 'total', $count, $count
126
  )
127
  );
128
 
134
  */
135
  public function register_new_column() {
136
  $post_types = Post_Views_Counter()->options['general']['post_types_count'];
137
+
138
  if ( ! empty( $post_types ) ) {
139
  foreach ( $post_types as $post_type ) {
140
  // actions
196
  /**
197
  * Add post views column content.
198
  *
 
199
  * @param string $column_name
200
  * @param int $id
201
  * @return muxed
202
  */
203
  public function add_new_column_content( $column_name, $id ) {
 
204
  if ( $column_name === 'post_views' ) {
 
 
 
205
  // get total post views
206
+ $count = pvc_get_post_views( $id );
207
+
208
+ echo $count;
 
 
 
 
 
 
209
  }
210
  }
211
+
212
  /**
213
  * Handle quick edit.
214
  *
215
  * @global string $pagenow
 
216
  * @param string $column_name
217
  * @return mixed
218
  */
219
+ function quick_edit_custom_box( $column_name, $post_type ) {
220
+ global $pagenow, $post;
221
+
222
+ if ( $pagenow !== 'edit.php' )
223
+ return;
224
+
225
+ if ( $column_name != 'post_views' )
226
+ return;
227
+
228
+ if ( ! Post_Views_Counter()->options['general']['post_views_column'] || ! in_array( $post_type, Post_Views_Counter()->options['general']['post_types_count'] ) )
229
+ return;
230
+
231
+ // break if views editing is restricted
232
  $restrict = (bool) Post_Views_Counter()->options['general']['restrict_edit_views'];
233
+
234
  if ( $restrict === true && ! current_user_can( apply_filters( 'pvc_restrict_edit_capability', 'manage_options' ) ) )
235
  return;
236
 
 
 
 
 
 
237
  // get total post views
238
+ $count = $count = pvc_get_post_views( $post->ID );
239
+ ?>
240
+ <fieldset class="inline-edit-col-left">
241
+ <div id="inline-edit-post_views" class="inline-edit-col">
242
+ <label class="inline-edit-group">
243
+ <span class="title"><?php _e( 'Post Views', 'post-views-counter' ); ?></span>
244
+ <span class="input-text-wrap"><input type="text" name="post_views" class="title text" value="<?php echo absint( $count ); ?>"></span>
245
+ <?php wp_nonce_field( 'post_views_count', 'pvc_nonce' ); ?>
246
+ </label>
247
+ </div>
248
+ </fieldset>
249
+ <?php
250
+ }
 
 
 
 
 
 
251
 
252
  /**
253
  * Bulk save post views.
256
  * @return type
257
  */
258
  function save_bulk_post_views() {
259
+
260
+ $post_ids = ( ! empty( $_POST['post_ids'] ) && is_array( $_POST['post_ids'] ) ) ? array_map( 'absint', $_POST['post_ids'] ) : array();
261
+ $count = ( ! empty( $_POST['post_views'] ) ) ? absint( $_POST['post_views'] ) : null;
262
+
263
  // break if views editing is restricted
264
  $restrict = (bool) Post_Views_Counter()->options['general']['restrict_edit_views'];
265
 
266
  if ( $restrict === true && ! current_user_can( apply_filters( 'pvc_restrict_edit_capability', 'manage_options' ) ) )
267
  die();
268
+
269
  if ( ! empty( $post_ids ) ) {
270
  foreach ( $post_ids as $post_id ) {
271
+
272
  // break if current user can't edit this post
273
  if ( ! current_user_can( 'edit_post', $post_id ) )
274
  continue;
275
+
276
  global $wpdb;
277
 
278
  // insert or update db post views count
includes/counter.php CHANGED
@@ -5,6 +5,8 @@ if ( ! defined( 'ABSPATH' ) )
5
 
6
  /**
7
  * Post_Views_Counter_Counter class.
 
 
8
  */
9
  class Post_Views_Counter_Counter {
10
 
@@ -30,16 +32,16 @@ class Post_Views_Counter_Counter {
30
  /**
31
  * Check if IPv4 is in range.
32
  *
33
- * @param string $ip IP address
34
- * @param string $range IP range
35
- * @return boolean Whether IP is in range
36
  */
37
  function ipv4_in_range( $ip, $range ) {
38
  $start = str_replace( '*', '0', $range );
39
  $end = str_replace( '*', '255', $range );
40
- $ip = (float)sprintf( "%u", ip2long( $ip ) );
41
 
42
- return ( $ip >= (float)sprintf( "%u", ip2long( $start ) ) && $ip <= (float)sprintf( "%u", ip2long( $end ) ) );
43
  }
44
 
45
  /**
@@ -89,7 +91,7 @@ class Post_Views_Counter_Counter {
89
  return;
90
 
91
  // whether to count robots
92
- if ( $this->is_robot() )
93
  return;
94
 
95
  // cookie already existed?
@@ -107,14 +109,15 @@ class Post_Views_Counter_Counter {
107
  // set new cookie
108
  $this->save_cookie( $id );
109
 
 
 
110
  // count visit
111
- $this->count_visit( $id );
 
112
  }
113
-
114
  /**
115
  * Check whether to count visit via PHP request.
116
- *
117
- * @param int $id
118
  */
119
  public function check_post_php() {
120
  // do not count admin entries
@@ -124,7 +127,7 @@ class Post_Views_Counter_Counter {
124
  // do we use PHP as counter?
125
  if ( Post_Views_Counter()->options['general']['counter_mode'] != 'php' )
126
  return;
127
-
128
  $post_types = Post_Views_Counter()->options['general']['post_types_count'];
129
 
130
  // whether to count this post type
@@ -133,17 +136,17 @@ class Post_Views_Counter_Counter {
133
 
134
  $this->check_post( get_the_ID() );
135
  }
136
-
137
  /**
138
  * Check whether to count visit via AJAX request.
139
  */
140
  public function check_post_ajax() {
141
  if ( isset( $_POST['action'], $_POST['post_id'], $_POST['pvc_nonce'], $_POST['post_type'] ) && $_POST['action'] === 'pvc-check-post' && ($post_id = (int) $_POST['post_id']) > 0 && wp_verify_nonce( $_POST['pvc_nonce'], 'pvc-check-post' ) !== false ) {
142
-
143
  // do we use Ajax as counter?
144
  if ( Post_Views_Counter()->options['general']['counter_mode'] != 'js' )
145
  exit;
146
-
147
  // get countable post types
148
  $post_types = Post_Views_Counter()->options['general']['post_types_count'];
149
 
@@ -153,9 +156,8 @@ class Post_Views_Counter_Counter {
153
  // whether to count this post type or not
154
  if ( empty( $post_types ) || empty( $post_type ) || $post_type !== $_POST['post_type'] || ! in_array( $post_type, $post_types, true ) )
155
  exit;
156
-
157
  $this->check_post( $post_id );
158
-
159
  }
160
 
161
  exit;
@@ -288,26 +290,27 @@ class Post_Views_Counter_Counter {
288
 
289
  $cache_key_names = array();
290
  $using_object_cache = $this->using_object_cache();
 
291
 
292
  // get day, week, month and year
293
  $date = explode( '-', date( 'W-d-m-Y', current_time( 'timestamp' ) ) );
294
 
295
- foreach( array(
296
- 0 => $date[3] . $date[2] . $date[1], // day like 20140324
297
- 1 => $date[3] . $date[0], // week like 201439
298
- 2 => $date[3] . $date[2], // month like 201405
299
- 3 => $date[3], // year like 2014
300
- 4 => 'total' // total views
301
  ) as $type => $period ) {
302
  if ( $using_object_cache ) {
303
  $cache_key = $id . self::CACHE_KEY_SEPARATOR . $type . self::CACHE_KEY_SEPARATOR . $period;
304
  wp_cache_add( $cache_key, 0, self::GROUP );
305
- wp_cache_incr( $cache_key, 1, self::GROUP );
306
  $cache_key_names[] = $cache_key;
307
  } else {
308
  // hit the db directly
309
  // @TODO: investigate queueing these queries on the 'shutdown' hook instead instead of running them instantly?
310
- $this->db_insert( $id, $type, $period, 1 );
311
  }
312
  }
313
 
@@ -320,10 +323,11 @@ class Post_Views_Counter_Counter {
320
 
321
  return true;
322
  }
323
-
324
  /**
325
  * Remove post views from database when post is deleted.
326
  *
 
327
  * @param int $post_id
328
  */
329
  public function delete_post_views( $post_id ) {
@@ -333,7 +337,6 @@ class Post_Views_Counter_Counter {
333
  }
334
 
335
  /**
336
- *
337
  * Get timestamp convertion.
338
  *
339
  * @param string $type
@@ -351,9 +354,9 @@ class Post_Views_Counter_Counter {
351
  'years' => 946080000
352
  );
353
 
354
- return ($timestamp ? current_time( 'timestamp', true ) : 0) + $number * $converter[$type];
355
  }
356
-
357
  /**
358
  * Check if object cache is in use.
359
  *
@@ -435,7 +438,7 @@ class Post_Views_Counter_Counter {
435
  $key_names = explode( '|', $key_names );
436
  }
437
 
438
- foreach( $key_names as $key_name ) {
439
  // get values stored within the key name itself
440
  list( $id, $type, $period ) = explode( self::CACHE_KEY_SEPARATOR, $key_name );
441
  // get the cached count value
@@ -476,14 +479,14 @@ class Post_Views_Counter_Counter {
476
  }
477
 
478
  return $wpdb->query(
479
- $wpdb->prepare( "
480
- INSERT INTO " . $wpdb->prefix . "post_views (id, type, period, count)
481
- VALUES (%d, %d, %s, %d)
482
- ON DUPLICATE KEY UPDATE count = count + %d", $id, $type, $period, $count, $count
483
- )
484
  );
485
  }
486
-
487
  /**
488
  * Check whether user has excluded roles.
489
  *
@@ -508,23 +511,4 @@ class Post_Views_Counter_Counter {
508
  return false;
509
  }
510
 
511
- /**
512
- * Check whether visitor is a bot.
513
- */
514
- private function is_robot() {
515
- if ( ! isset( $_SERVER['HTTP_USER_AGENT'] ) || (isset( $_SERVER['HTTP_USER_AGENT'] ) && trim( $_SERVER['HTTP_USER_AGENT'] ) === '') )
516
- return false;
517
-
518
- $robots = array(
519
- 'bot', 'b0t', 'Acme.Spider', 'Ahoy! The Homepage Finder', 'Alkaline', 'Anthill', 'Walhello appie', 'Arachnophilia', 'Arale', 'Araneo', 'ArchitextSpider', 'Aretha', 'ARIADNE', 'arks', 'AskJeeves', 'ASpider (Associative Spider)', 'ATN Worldwide', 'AURESYS', 'BackRub', 'Bay Spider', 'Big Brother', 'Bjaaland', 'BlackWidow', 'Die Blinde Kuh', 'Bloodhound', 'BSpider', 'CACTVS Chemistry Spider', 'Calif', 'Cassandra', 'Digimarc Marcspider/CGI', 'ChristCrawler.com', 'churl', 'cIeNcIaFiCcIoN.nEt', 'CMC/0.01', 'Collective', 'Combine System', 'Web Core / Roots', 'Cusco', 'CyberSpyder Link Test', 'CydralSpider', 'Desert Realm Spider', 'DeWeb(c) Katalog/Index', 'DienstSpider', 'Digger', 'Direct Hit Grabber', 'DownLoad Express', 'DWCP (Dridus\' Web Cataloging Project)', 'e-collector', 'EbiNess', 'Emacs-w3 Search Engine', 'ananzi', 'esculapio', 'Esther', 'Evliya Celebi', 'FastCrawler', 'Felix IDE', 'Wild Ferret Web Hopper #1, #2, #3', 'FetchRover', 'fido', 'KIT-Fireball', 'Fish search', 'Fouineur', 'Freecrawl', 'FunnelWeb', 'gammaSpider, FocusedCrawler', 'gazz', 'GCreep', 'GetURL', 'Golem', 'Grapnel/0.01 Experiment', 'Griffon', 'Gromit', 'Northern Light Gulliver', 'Harvest', 'havIndex', 'HI (HTML Index) Search', 'Hometown Spider Pro', 'ht://Dig', 'HTMLgobble', 'Hyper-Decontextualizer', 'IBM_Planetwide', 'Popular Iconoclast', 'Ingrid', 'Imagelock', 'IncyWincy', 'Informant', 'Infoseek Sidewinder', 'InfoSpiders', 'Inspector Web', 'IntelliAgent', 'Iron33', 'Israeli-search', 'JavaBee', 'JCrawler', 'Jeeves', 'JumpStation', 'image.kapsi.net', 'Katipo', 'KDD-Explorer', 'Kilroy', 'LabelGrabber', 'larbin', 'legs', 'Link Validator', 'LinkScan', 'LinkWalker', 'Lockon', 'logo.gif Crawler', 'Lycos', 'Mac WWWWorm', 'Magpie', 'marvin/infoseek', 'Mattie', 'MediaFox', 'MerzScope', 'NEC-MeshExplorer', 'MindCrawler', 'mnoGoSearch search engine software', 'moget', 'MOMspider', 'Monster', 'Motor', 'Muncher', 'Muninn', 'Muscat Ferret', 'Mwd.Search', 'Internet Shinchakubin', 'NDSpider', 'Nederland.zoek', 'NetCarta WebMap Engine', 'NetMechanic', 'NetScoop', 'newscan-online', 'NHSE Web Forager', 'Nomad', 'nzexplorer', 'ObjectsSearch', 'Occam', 'HKU WWW Octopus', 'OntoSpider', 'Openfind data gatherer', 'Orb Search', 'Pack Rat', 'PageBoy', 'ParaSite', 'Patric', 'pegasus', 'The Peregrinator', 'PerlCrawler 1.0', 'Phantom', 'PhpDig', 'PiltdownMan', 'Pioneer', 'html_analyzer', 'Portal Juice Spider', 'PGP Key Agent', 'PlumtreeWebAccessor', 'Poppi', 'PortalB Spider', 'GetterroboPlus Puu', 'Raven Search', 'RBSE Spider', 'RoadHouse Crawling System', 'ComputingSite Robi/1.0', 'RoboCrawl Spider', 'RoboFox', 'Robozilla', 'RuLeS', 'Scooter', 'Sleek', 'Search.Aus-AU.COM', 'SearchProcess', 'Senrigan', 'SG-Scout', 'ShagSeeker', 'Shai\'Hulud', 'Sift', 'Site Valet', 'SiteTech-Rover', 'Skymob.com', 'SLCrawler', 'Inktomi Slurp', 'Smart Spider', 'Snooper', 'Spanner', 'Speedy Spider', 'spider_monkey', 'Spiderline Crawler', 'SpiderMan', 'SpiderView(tm)', 'Site Searcher', 'Suke', 'suntek search engine', 'Sven', 'Sygol', 'TACH Black Widow', 'Tarantula', 'tarspider', 'Templeton', 'TeomaTechnologies', 'TITAN', 'TitIn', 'TLSpider', 'UCSD Crawl', 'UdmSearch', 'URL Check', 'URL Spider Pro', 'Valkyrie', 'Verticrawl', 'Victoria', 'vision-search', 'Voyager', 'W3M2', 'WallPaper (alias crawlpaper)', 'the World Wide Web Wanderer', 'w@pSpider by wap4.com', 'WebBandit Web Spider', 'WebCatcher', 'WebCopy', 'webfetcher', 'Webinator', 'weblayers', 'WebLinker', 'WebMirror', 'The Web Moose', 'WebQuest', 'Digimarc MarcSpider', 'WebReaper', 'webs', 'Websnarf', 'WebSpider', 'WebVac', 'webwalk', 'WebWalker', 'WebWatch', 'Wget', 'whatUseek Winona', 'Wired Digital', 'Weblog Monitor', 'w3mir', 'WebStolperer', 'The Web Wombat', 'The World Wide Web Worm', 'WWWC Ver 0.2.5', 'WebZinger', 'XGET'
520
- );
521
-
522
- foreach( $robots as $robot ) {
523
- if ( stripos( $_SERVER['HTTP_USER_AGENT'], $robot ) !== false )
524
- return true;
525
- }
526
-
527
- return false;
528
- }
529
-
530
  }
5
 
6
  /**
7
  * Post_Views_Counter_Counter class.
8
+ *
9
+ * @class Post_Views_Counter_Counter
10
  */
11
  class Post_Views_Counter_Counter {
12
 
32
  /**
33
  * Check if IPv4 is in range.
34
  *
35
+ * @param string $ip IP address
36
+ * @param string $range IP range
37
+ * @return boolean Whether IP is in range
38
  */
39
  function ipv4_in_range( $ip, $range ) {
40
  $start = str_replace( '*', '0', $range );
41
  $end = str_replace( '*', '255', $range );
42
+ $ip = (float) sprintf( "%u", ip2long( $ip ) );
43
 
44
+ return ( $ip >= (float) sprintf( "%u", ip2long( $start ) ) && $ip <= (float) sprintf( "%u", ip2long( $end ) ) );
45
  }
46
 
47
  /**
91
  return;
92
 
93
  // whether to count robots
94
+ if ( in_array( 'robots', $groups, true ) && Post_Views_Counter()->crawler_detect->is_crawler() )
95
  return;
96
 
97
  // cookie already existed?
109
  // set new cookie
110
  $this->save_cookie( $id );
111
 
112
+ $count_visit = (bool) apply_filters( 'pvc_count_visit', true, $id );
113
+
114
  // count visit
115
+ if ( $count_visit )
116
+ $this->count_visit( $id );
117
  }
118
+
119
  /**
120
  * Check whether to count visit via PHP request.
 
 
121
  */
122
  public function check_post_php() {
123
  // do not count admin entries
127
  // do we use PHP as counter?
128
  if ( Post_Views_Counter()->options['general']['counter_mode'] != 'php' )
129
  return;
130
+
131
  $post_types = Post_Views_Counter()->options['general']['post_types_count'];
132
 
133
  // whether to count this post type
136
 
137
  $this->check_post( get_the_ID() );
138
  }
139
+
140
  /**
141
  * Check whether to count visit via AJAX request.
142
  */
143
  public function check_post_ajax() {
144
  if ( isset( $_POST['action'], $_POST['post_id'], $_POST['pvc_nonce'], $_POST['post_type'] ) && $_POST['action'] === 'pvc-check-post' && ($post_id = (int) $_POST['post_id']) > 0 && wp_verify_nonce( $_POST['pvc_nonce'], 'pvc-check-post' ) !== false ) {
145
+
146
  // do we use Ajax as counter?
147
  if ( Post_Views_Counter()->options['general']['counter_mode'] != 'js' )
148
  exit;
149
+
150
  // get countable post types
151
  $post_types = Post_Views_Counter()->options['general']['post_types_count'];
152
 
156
  // whether to count this post type or not
157
  if ( empty( $post_types ) || empty( $post_type ) || $post_type !== $_POST['post_type'] || ! in_array( $post_type, $post_types, true ) )
158
  exit;
159
+
160
  $this->check_post( $post_id );
 
161
  }
162
 
163
  exit;
290
 
291
  $cache_key_names = array();
292
  $using_object_cache = $this->using_object_cache();
293
+ $increment_amount = (int) apply_filters( 'pvc_views_increment_amount', 1, $id );
294
 
295
  // get day, week, month and year
296
  $date = explode( '-', date( 'W-d-m-Y', current_time( 'timestamp' ) ) );
297
 
298
+ foreach ( array(
299
+ 0 => $date[3] . $date[2] . $date[1], // day like 20140324
300
+ 1 => $date[3] . $date[0], // week like 201439
301
+ 2 => $date[3] . $date[2], // month like 201405
302
+ 3 => $date[3], // year like 2014
303
+ 4 => 'total' // total views
304
  ) as $type => $period ) {
305
  if ( $using_object_cache ) {
306
  $cache_key = $id . self::CACHE_KEY_SEPARATOR . $type . self::CACHE_KEY_SEPARATOR . $period;
307
  wp_cache_add( $cache_key, 0, self::GROUP );
308
+ wp_cache_incr( $cache_key, $increment_amount, self::GROUP );
309
  $cache_key_names[] = $cache_key;
310
  } else {
311
  // hit the db directly
312
  // @TODO: investigate queueing these queries on the 'shutdown' hook instead instead of running them instantly?
313
+ $this->db_insert( $id, $type, $period, $increment_amount );
314
  }
315
  }
316
 
323
 
324
  return true;
325
  }
326
+
327
  /**
328
  * Remove post views from database when post is deleted.
329
  *
330
+ * @global object $wpdb
331
  * @param int $post_id
332
  */
333
  public function delete_post_views( $post_id ) {
337
  }
338
 
339
  /**
 
340
  * Get timestamp convertion.
341
  *
342
  * @param string $type
354
  'years' => 946080000
355
  );
356
 
357
+ return ( $timestamp ? current_time( 'timestamp', true ) : 0 ) + $number * $converter[$type];
358
  }
359
+
360
  /**
361
  * Check if object cache is in use.
362
  *
438
  $key_names = explode( '|', $key_names );
439
  }
440
 
441
+ foreach ( $key_names as $key_name ) {
442
  // get values stored within the key name itself
443
  list( $id, $type, $period ) = explode( self::CACHE_KEY_SEPARATOR, $key_name );
444
  // get the cached count value
479
  }
480
 
481
  return $wpdb->query(
482
+ $wpdb->prepare( "
483
+ INSERT INTO " . $wpdb->prefix . "post_views (id, type, period, count)
484
+ VALUES (%d, %d, %s, %d)
485
+ ON DUPLICATE KEY UPDATE count = count + %d", $id, $type, $period, $count, $count
486
+ )
487
  );
488
  }
489
+
490
  /**
491
  * Check whether user has excluded roles.
492
  *
511
  return false;
512
  }
513
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
514
  }
includes/crawler-detect.php ADDED
@@ -0,0 +1,968 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // exit if accessed directly
3
+ if ( ! defined( 'ABSPATH' ) )
4
+ exit;
5
+
6
+ /**
7
+ * Post_Views_Counter_Crawler_Detect class.
8
+ *
9
+ * Based on CrawlerDetect php class adjusted to PHP 5.2
10
+ * https://github.com/JayBizzle/Crawler-Detect/blob/master/src/CrawlerDetect.php
11
+ *
12
+ * @since 1.2.4
13
+ * @class Post_Views_Counter_Crawler_Detect
14
+ */
15
+ class Post_Views_Counter_Crawler_Detect {
16
+
17
+ /**
18
+ * The user agent.
19
+ *
20
+ * @var null
21
+ */
22
+ protected $user_agent = null;
23
+
24
+ /**
25
+ * Headers that contain a user agent.
26
+ *
27
+ * @var array
28
+ */
29
+ protected $http_headers = array();
30
+
31
+ /**
32
+ * Store regex matches.
33
+ *
34
+ * @var array
35
+ */
36
+ protected $matches = array();
37
+
38
+ /**
39
+ * Crawlers object.
40
+ *
41
+ * @var object
42
+ */
43
+ protected $crawlers;
44
+
45
+ /**
46
+ * Exclusions object.
47
+ *
48
+ * @var object
49
+ */
50
+ protected $exclusions;
51
+
52
+ /**
53
+ * Headers object.
54
+ *
55
+ * @var object
56
+ */
57
+ protected $ua_http_headers;
58
+
59
+ /**
60
+ * Class constructor.
61
+ */
62
+ public function __construct() {
63
+ add_action( 'after_setup_theme', array( $this, 'init' ) );
64
+ }
65
+
66
+ /**
67
+ * Initialize class.
68
+ */
69
+ public function init() {
70
+ // break on admin side
71
+ if ( is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) )
72
+ return;
73
+
74
+ $this->crawlers = $this->get_crawlers_list();
75
+ $this->exclusions = $this->get_exclusions_list();
76
+ $this->ua_http_headers = $this->get_headers_list();
77
+ $this->set_http_headers();
78
+ $this->set_user_agent();
79
+ }
80
+
81
+ /**
82
+ * Set HTTP headers.
83
+ *
84
+ * @param array $http_headers
85
+ */
86
+ public function set_http_headers( $http_headers = null ) {
87
+ // use global _SERVER if $http_headers aren't defined
88
+ if ( ! is_array( $http_headers ) || ! count( $http_headers ) ) {
89
+ $http_headers = $_SERVER;
90
+ }
91
+ // clear existing headers
92
+ $this->http_headers = array();
93
+ // only save HTTP headers - in PHP land, that means only _SERVER vars that start with HTTP_.
94
+ foreach ( $http_headers as $key => $value ) {
95
+ if ( substr( $key, 0, 5 ) === 'HTTP_' ) {
96
+ $this->http_headers[$key] = $value;
97
+ }
98
+ }
99
+ }
100
+
101
+ /**
102
+ * Return user agent headers.
103
+ *
104
+ * @return array
105
+ */
106
+ public function get_ua_http_headers() {
107
+ return $this->ua_http_headers;
108
+ }
109
+
110
+ /**
111
+ * Return the user agent.
112
+ *
113
+ * @return string
114
+ */
115
+ public function get_user_agent() {
116
+ return $this->user_agent;
117
+ }
118
+
119
+ /**
120
+ * Set the user agent.
121
+ *
122
+ * @param string $user_agent
123
+ */
124
+ public function set_user_agent( $user_agent = null ) {
125
+ if ( false === empty( $user_agent ) ) {
126
+ return $this->user_agent = $user_agent;
127
+ } else {
128
+ $this->user_agent = null;
129
+ foreach ( $this->get_ua_http_headers() as $alt_header ) {
130
+ if ( false === empty( $this->http_headers[$alt_header] ) ) { // @todo: should use get_http_header(), but it would be slow.
131
+ $this->user_agent .= $this->http_headers[$alt_header] . ' ';
132
+ }
133
+ }
134
+ return $this->user_agent = ( ! empty( $this->user_agent ) ? trim( $this->user_agent ) : null);
135
+ }
136
+ }
137
+
138
+ /**
139
+ * Build the user agent regex.
140
+ *
141
+ * @return string
142
+ */
143
+ public function get_regex() {
144
+ return '(' . implode( '|', $this->crawlers ) . ')';
145
+ }
146
+
147
+ /**
148
+ * Build the replacement regex.
149
+ *
150
+ * @return string
151
+ */
152
+ public function get_exclusions() {
153
+ return '(' . implode( '|', $this->exclusions ) . ')';
154
+ }
155
+
156
+ /**
157
+ * Check user agent string against the regex.
158
+ *
159
+ * @param string $user_agent
160
+ *
161
+ * @return bool
162
+ */
163
+ public function is_crawler( $user_agent = null ) {
164
+ $agent = is_null( $user_agent ) ? $this->user_agent : $user_agent;
165
+ $agent = preg_replace( '/' . $this->get_exclusions() . '/i', '', $agent );
166
+ if ( strlen( trim( $agent ) ) == 0 ) {
167
+ return false;
168
+ } else {
169
+ $result = preg_match( '/' . $this->get_regex() . '/i', trim( $agent ), $matches );
170
+ }
171
+ if ( $matches ) {
172
+ $this->matches = $matches;
173
+ }
174
+ return (bool) $result;
175
+ }
176
+
177
+ /**
178
+ * Return the matches.
179
+ *
180
+ * @return string
181
+ */
182
+ public function get_matches() {
183
+ return isset( $this->matches[0] ) ? $this->matches[0] : null;
184
+ }
185
+
186
+ /**
187
+ * Return the regular expressions to match against the user agent.
188
+ *
189
+ * @return array
190
+ */
191
+ protected function get_crawlers_list() {
192
+ $data = array(
193
+ '.*Java.*outbrain',
194
+ '008\/',
195
+ '192.comAgent',
196
+ '2ip\.ru',
197
+ '404checker',
198
+ '^bluefish ',
199
+ '^FDM ',
200
+ '^Goose\/',
201
+ '^Java\/',
202
+ '^Mget',
203
+ '^NG\/[0-9\.]',
204
+ '^NING\/',
205
+ '^PHP\/[0-9]',
206
+ '^RMA\/',
207
+ '^Ruby|Ruby\/[0-9]',
208
+ '^scrutiny\/',
209
+ '^VSE\/[0-9]',
210
+ '^WordPress\.com',
211
+ '^XRL\/[0-9]',
212
+ 'a3logics\.in',
213
+ 'A6-Indexer',
214
+ 'a\.pr-cy\.ru',
215
+ 'Aboundex',
216
+ 'aboutthedomain',
217
+ 'Accoona-AI-Agent',
218
+ 'acoon',
219
+ 'acrylicapps\.com\/pulp',
220
+ 'adbeat',
221
+ 'AddThis',
222
+ 'ADmantX',
223
+ 'adressendeutschland',
224
+ 'Advanced Email Extractor v',
225
+ 'agentslug',
226
+ 'AHC',
227
+ 'aihit',
228
+ 'aiohttp\/',
229
+ 'Airmail',
230
+ 'akula\/',
231
+ 'alertra',
232
+ 'alexa site audit',
233
+ 'alyze\.info',
234
+ 'amagit',
235
+ 'AndroidDownloadManager',
236
+ 'Anemone',
237
+ 'Ant\.com',
238
+ 'Anturis Agent',
239
+ 'AnyEvent-HTTP\/',
240
+ 'Apache-HttpClient\/',
241
+ 'AportWorm\/[0-9]',
242
+ 'AppEngine-Google',
243
+ 'Arachmo',
244
+ 'arachnode',
245
+ 'Arachnophilia',
246
+ 'archive-com',
247
+ 'aria2',
248
+ 'asafaweb.com',
249
+ 'AskQuickly',
250
+ 'Astute',
251
+ 'autocite',
252
+ 'Autonomy',
253
+ 'B-l-i-t-z-B-O-T',
254
+ 'Backlink-Ceck\.de',
255
+ 'Bad-Neighborhood',
256
+ 'baidu\.com',
257
+ 'baypup\/[0-9]',
258
+ 'baypup\/colbert',
259
+ 'BazQux',
260
+ 'BCKLINKS',
261
+ 'BDFetch',
262
+ 'BegunAdvertising\/',
263
+ 'bibnum\.bnf',
264
+ 'BigBozz',
265
+ 'biglotron',
266
+ 'BingLocalSearch',
267
+ 'BingPreview',
268
+ 'binlar',
269
+ 'biz_Directory',
270
+ 'Blackboard Safeassign',
271
+ 'Bloglovin',
272
+ 'BlogPulseLive',
273
+ 'BlogSearch',
274
+ 'Blogtrottr',
275
+ 'boitho\.com-dc',
276
+ 'BPImageWalker',
277
+ 'Braintree-Webhooks',
278
+ 'Branch Metrics API',
279
+ 'Branch-Passthrough',
280
+ 'Browsershots',
281
+ 'BUbiNG',
282
+ 'Butterfly\/',
283
+ 'BuzzSumo',
284
+ 'CakePHP',
285
+ 'CapsuleChecker',
286
+ 'CaretNail',
287
+ 'cb crawl',
288
+ 'CC Metadata Scaper',
289
+ 'Cerberian Drtrs',
290
+ 'CERT\.at-Statistics-Survey',
291
+ 'cg-eye',
292
+ 'changedetection',
293
+ 'Charlotte',
294
+ 'CheckHost',
295
+ 'chkme\.com',
296
+ 'CirrusExplorer\/',
297
+ 'CISPA Vulnerability Notification',
298
+ 'CJNetworkQuality',
299
+ 'clips\.ua\.ac\.be',
300
+ 'Cloud mapping experiment',
301
+ 'CloudFlare-AlwaysOnline',
302
+ 'Cloudinary\/[0-9]',
303
+ 'cmcm\.com',
304
+ 'coccoc',
305
+ 'CommaFeed',
306
+ 'Commons-HttpClient',
307
+ 'Comodo SSL Checker',
308
+ 'contactbigdatafr',
309
+ 'convera',
310
+ 'copyright sheriff',
311
+ 'cosmos\/[0-9]',
312
+ 'Covario-IDS',
313
+ 'CrawlForMe\/[0-9]',
314
+ 'cron-job\.org',
315
+ 'Crowsnest',
316
+ 'curb',
317
+ 'Curious George',
318
+ 'curl',
319
+ 'cuwhois\/[0-9]',
320
+ 'CyberPatrol',
321
+ 'cybo\.com',
322
+ 'DareBoost',
323
+ 'DataparkSearch',
324
+ 'dataprovider',
325
+ 'Daum(oa)?[ \/][0-9]',
326
+ 'DeuSu',
327
+ 'developers\.google\.com\/\+\/web\/snippet\/',
328
+ 'Digg',
329
+ 'Dispatch\/',
330
+ 'dlvr',
331
+ 'DNS-Tools Header-Analyzer',
332
+ 'DNSPod-reporting',
333
+ 'docoloc',
334
+ 'DomainAppender',
335
+ 'dotSemantic',
336
+ 'downforeveryoneorjustme',
337
+ 'downnotifier\.com',
338
+ 'DowntimeDetector',
339
+ 'Dragonfly File Reader',
340
+ 'drupact',
341
+ 'Drupal (\+http:\/\/drupal\.org\/)',
342
+ 'dubaiindex',
343
+ 'EARTHCOM',
344
+ 'Easy-Thumb',
345
+ 'ec2linkfinder',
346
+ 'eCairn-Grabber',
347
+ 'ECCP',
348
+ 'ElectricMonk',
349
+ 'elefent',
350
+ 'EMail Exractor',
351
+ 'EmailWolf',
352
+ 'Embed PHP Library',
353
+ 'Embedly',
354
+ 'europarchive\.org',
355
+ 'evc-batch\/[0-9]',
356
+ 'EventMachine HttpClient',
357
+ 'Evidon',
358
+ 'Evrinid',
359
+ 'ExactSearch',
360
+ 'ExaleadCloudview',
361
+ 'Excel\/',
362
+ 'Exploratodo',
363
+ 'ezooms',
364
+ 'facebookexternalhit',
365
+ 'facebookplatform',
366
+ 'fairshare',
367
+ 'Faraday v',
368
+ 'Faveeo',
369
+ 'Favicon downloader',
370
+ 'FavOrg',
371
+ 'Feed Wrangler',
372
+ 'Feedbin',
373
+ 'FeedBooster',
374
+ 'FeedBucket',
375
+ 'FeedBurner',
376
+ 'FeedChecker',
377
+ 'Feedly',
378
+ 'Feedspot',
379
+ 'feeltiptop',
380
+ 'Fetch API',
381
+ 'Fetch\/[0-9]',
382
+ 'Fever\/[0-9]',
383
+ 'findlink',
384
+ 'findthatfile',
385
+ 'Flamingo_SearchEngine',
386
+ 'FlipboardBrowserProxy',
387
+ 'FlipboardProxy',
388
+ 'FlipboardRSS',
389
+ 'fluffy',
390
+ 'flynxapp',
391
+ 'forensiq',
392
+ 'FoundSeoTool\/[0-9]',
393
+ 'free thumbnails',
394
+ 'FreeWebMonitoring SiteChecker',
395
+ 'Funnelback',
396
+ 'g00g1e\.net',
397
+ 'GAChecker',
398
+ 'geek-tools',
399
+ 'Genderanalyzer',
400
+ 'Genieo',
401
+ 'GentleSource',
402
+ 'GetLinkInfo',
403
+ 'getprismatic\.com',
404
+ 'GetURLInfo\/[0-9]',
405
+ 'GigablastOpenSource',
406
+ 'Go [\d\.]* package http',
407
+ 'Go-http-client',
408
+ 'GomezAgent',
409
+ 'gooblog',
410
+ 'Goodzer\/[0-9]',
411
+ 'Google favicon',
412
+ 'Google Keyword Suggestion',
413
+ 'Google Keyword Tool',
414
+ 'Google Page Speed Insights',
415
+ 'Google PP Default',
416
+ 'Google Search Console',
417
+ 'Google Web Preview',
418
+ 'Google-Adwords',
419
+ 'Google-Apps-Script',
420
+ 'Google-Calendar-Importer',
421
+ 'Google-HTTP-Java-Client',
422
+ 'Google-Publisher-Plugin',
423
+ 'Google-SearchByImage',
424
+ 'Google-Site-Verification',
425
+ 'Google-Structured-Data-Testing-Tool',
426
+ 'google_partner_monitoring',
427
+ 'GoogleDocs',
428
+ 'GoogleHC\/',
429
+ 'GoogleProducer',
430
+ 'GoScraper',
431
+ 'GoSpotCheck',
432
+ 'GoSquared-Status-Checker',
433
+ 'gosquared-thumbnailer',
434
+ 'GotSiteMonitor',
435
+ 'Grammarly',
436
+ 'grouphigh',
437
+ 'grub-client',
438
+ 'GTmetrix',
439
+ 'Hatena',
440
+ 'hawkReader',
441
+ 'HEADMasterSEO',
442
+ 'HeartRails_Capture',
443
+ 'heritrix',
444
+ 'hledejLevne\.cz\/[0-9]',
445
+ 'Holmes',
446
+ 'HootSuite Image proxy',
447
+ 'Hootsuite-WebFeed\/[0-9]',
448
+ 'HostTracker',
449
+ 'ht:\/\/check',
450
+ 'htdig',
451
+ 'HTMLParser\/',
452
+ 'HTTP-Header-Abfrage',
453
+ 'http-kit',
454
+ 'HTTP-Tiny',
455
+ 'HTTP_Compression_Test',
456
+ 'http_request2',
457
+ 'http_requester',
458
+ 'HttpComponents',
459
+ 'httphr',
460
+ 'HTTPMon',
461
+ 'httpscheck',
462
+ 'httpssites_power',
463
+ 'httpunit',
464
+ 'HttpUrlConnection',
465
+ 'httrack',
466
+ 'hosterstats',
467
+ 'huaweisymantec',
468
+ 'HubPages.*crawlingpolicy',
469
+ 'HubSpot Connect',
470
+ 'HubSpot Marketing Grader',
471
+ 'HyperZbozi.cz Feeder',
472
+ 'ichiro',
473
+ 'IdeelaborPlagiaat',
474
+ 'IDG Twitter Links Resolver',
475
+ 'IDwhois\/[0-9]',
476
+ 'Iframely',
477
+ 'igdeSpyder',
478
+ 'IlTrovatore',
479
+ 'ImageEngine\/',
480
+ 'Imagga',
481
+ 'InAGist',
482
+ 'inbound\.li parser',
483
+ 'InDesign%20CC',
484
+ 'infegy',
485
+ 'infohelfer',
486
+ 'InfoWizards Reciprocal Link System PRO',
487
+ 'inpwrd\.com',
488
+ 'Integrity',
489
+ 'integromedb',
490
+ 'internet_archive',
491
+ 'InternetSeer',
492
+ 'internetVista monitor',
493
+ 'IODC',
494
+ 'IOI',
495
+ 'ips-agent',
496
+ 'iqdb\/',
497
+ 'Irokez',
498
+ 'isitup\.org',
499
+ 'iskanie',
500
+ 'iZSearch',
501
+ 'janforman',
502
+ 'Jigsaw',
503
+ 'Jobboerse',
504
+ 'jobo',
505
+ 'Jobrapido',
506
+ 'KeepRight OpenStreetMap Checker',
507
+ 'KimonoLabs\/',
508
+ 'knows\.is',
509
+ 'kouio',
510
+ 'KrOWLer',
511
+ 'kulturarw3',
512
+ 'KumKie',
513
+ 'L\.webis',
514
+ 'Larbin',
515
+ 'LayeredExtractor',
516
+ 'LibVLC',
517
+ 'libwww',
518
+ 'link checker',
519
+ 'Link Valet',
520
+ 'link_thumbnailer',
521
+ 'linkCheck',
522
+ 'linkdex',
523
+ 'LinkExaminer',
524
+ 'linkfluence',
525
+ 'linkpeek',
526
+ 'LinkTiger',
527
+ 'LinkWalker',
528
+ 'Lipperhey',
529
+ 'livedoor ScreenShot',
530
+ 'LoadImpactPageAnalyzer',
531
+ 'LoadImpactRload',
532
+ 'LongURL API',
533
+ 'looksystems\.net',
534
+ 'ltx71',
535
+ 'lwp-trivial',
536
+ 'lycos',
537
+ 'LYT\.SR',
538
+ 'mabontland',
539
+ 'MagpieRSS',
540
+ 'Mail.Ru',
541
+ 'MailChimp\.com',
542
+ 'Mandrill',
543
+ 'marketinggrader',
544
+ 'Mediapartners-Google',
545
+ 'MegaIndex\.ru',
546
+ 'Melvil Rawi\/',
547
+ 'MergeFlow-PageReader',
548
+ 'MetaInspector',
549
+ 'Metaspinner',
550
+ 'MetaURI',
551
+ 'Microsearch',
552
+ 'Microsoft Office ',
553
+ 'Microsoft Windows Network Diagnostics',
554
+ 'Mindjet',
555
+ 'Miniflux',
556
+ 'Mnogosearch',
557
+ 'mogimogi',
558
+ 'Mojolicious (Perl)',
559
+ 'monitis',
560
+ 'Monitority\/[0-9]',
561
+ 'montastic',
562
+ 'MonTools',
563
+ 'Moreover',
564
+ 'Morning Paper',
565
+ 'mowser',
566
+ 'Mrcgiguy',
567
+ 'mShots',
568
+ 'MVAClient',
569
+ 'nagios',
570
+ 'Najdi\.si\/',
571
+ 'NETCRAFT',
572
+ 'NetLyzer FastProbe',
573
+ 'netresearch',
574
+ 'NetShelter ContentScan',
575
+ 'NetTrack',
576
+ 'Netvibes',
577
+ 'Neustar WPM',
578
+ 'NeutrinoAPI',
579
+ 'NewsBlur .*Finder',
580
+ 'NewsGator',
581
+ 'newsme',
582
+ 'newspaper\/',
583
+ 'NG-Search',
584
+ 'nineconnections\.com',
585
+ 'NLNZ_IAHarvester',
586
+ 'Nmap Scripting Engine',
587
+ 'node-superagent',
588
+ 'node\.io',
589
+ 'nominet\.org\.uk',
590
+ 'Norton-Safeweb',
591
+ 'Notifixious',
592
+ 'notifyninja',
593
+ 'nuhk',
594
+ 'nutch',
595
+ 'Nuzzel',
596
+ 'nWormFeedFinder',
597
+ 'Nymesis',
598
+ 'Ocelli\/[0-9]',
599
+ 'oegp',
600
+ 'okhttp',
601
+ 'Omea Reader',
602
+ 'omgili',
603
+ 'Online Domain Tools',
604
+ 'OpenCalaisSemanticProxy',
605
+ 'Openstat\/',
606
+ 'OpenVAS',
607
+ 'Optimizer',
608
+ 'Orbiter',
609
+ 'OrgProbe\/[0-9]',
610
+ 'ow\.ly',
611
+ 'ownCloud News',
612
+ 'Page Analyzer',
613
+ 'Page Valet',
614
+ 'page2rss',
615
+ 'page_verifier',
616
+ 'PagePeeker',
617
+ 'Pagespeed\/[0-9]',
618
+ 'Panopta',
619
+ 'panscient',
620
+ 'parsijoo',
621
+ 'PayPal IPN',
622
+ 'Pcore-HTTP',
623
+ 'Pearltrees',
624
+ 'peerindex',
625
+ 'Peew',
626
+ 'PhantomJS\/',
627
+ 'Photon\/',
628
+ 'phpcrawl',
629
+ 'phpservermon',
630
+ 'Pi-Monster',
631
+ 'Pingdom\.com',
632
+ 'Pingoscope',
633
+ 'PingSpot',
634
+ 'Pinterest',
635
+ 'Pizilla',
636
+ 'Ploetz \+ Zeller',
637
+ 'Plukkie',
638
+ 'PocketParser',
639
+ 'Pompos',
640
+ 'Porkbun',
641
+ 'Port Monitor',
642
+ 'postano',
643
+ 'PostPost',
644
+ 'postrank',
645
+ 'PowerPoint\/',
646
+ 'Priceonomics Analysis Engine',
647
+ 'Prlog',
648
+ 'probethenet',
649
+ 'Project 25499',
650
+ 'Promotion_Tools_www.searchenginepromotionhelp.com',
651
+ 'prospectb2b',
652
+ 'Protopage',
653
+ 'proximic',
654
+ 'PTST ',
655
+ 'PTST\/[0-9]+',
656
+ 'Pulsepoint XT3 web scraper',
657
+ 'Python-httplib2',
658
+ 'python-requests',
659
+ 'Python-urllib',
660
+ 'Qirina Hurdler',
661
+ 'Qseero',
662
+ 'Qualidator.com SiteAnalyzer',
663
+ 'Quora Link Preview',
664
+ 'Qwantify',
665
+ 'Radian6',
666
+ 'RankSonicSiteAuditor',
667
+ 'Readability',
668
+ 'RealPlayer%20Downloader',
669
+ 'RebelMouse',
670
+ 'redback\/',
671
+ 'Redirect Checker Tool',
672
+ 'ReederForMac',
673
+ 'ResponseCodeTest\/[0-9]',
674
+ 'RestSharp',
675
+ 'RetrevoPageAnalyzer',
676
+ 'Riddler',
677
+ 'Rival IQ',
678
+ 'Robosourcer',
679
+ 'Robozilla\/[0-9]',
680
+ 'ROI Hunter',
681
+ 'SalesIntelligent',
682
+ 'SauceNAO',
683
+ 'SBIder',
684
+ 'Scoop',
685
+ 'scooter',
686
+ 'ScoutJet',
687
+ 'ScoutURLMonitor',
688
+ 'Scrapy',
689
+ 'Scrubby',
690
+ 'SearchSight',
691
+ 'semanticdiscovery',
692
+ 'semanticjuice',
693
+ 'SEO Browser',
694
+ 'Seo Servis',
695
+ 'seo-nastroj.cz',
696
+ 'Seobility',
697
+ 'SEOCentro',
698
+ 'SeoCheck',
699
+ 'SeopultContentAnalyzer',
700
+ 'SEOstats',
701
+ 'Server Density Service Monitoring',
702
+ 'servernfo\.com',
703
+ 'Seznam screenshot-generator',
704
+ 'Shelob',
705
+ 'Shoppimon Analyzer',
706
+ 'ShoppimonAgent\/[0-9]',
707
+ 'ShopWiki',
708
+ 'ShortLinkTranslate',
709
+ 'shrinktheweb',
710
+ 'SilverReader',
711
+ 'SimplePie',
712
+ 'SimplyFast',
713
+ 'Site-Shot\/',
714
+ 'Site24x7',
715
+ 'SiteBar',
716
+ 'SiteCondor',
717
+ 'siteexplorer\.info',
718
+ 'SiteGuardian',
719
+ 'Siteimprove\.com',
720
+ 'Sitemap(s)? Generator',
721
+ 'Siteshooter B0t',
722
+ 'SiteTruth',
723
+ 'sitexy\.com',
724
+ 'SkypeUriPreview',
725
+ 'slider\.com',
726
+ 'slurp',
727
+ 'SMRF URL Expander',
728
+ 'Snappy',
729
+ 'SniffRSS',
730
+ 'sniptracker',
731
+ 'Snoopy',
732
+ 'sogou web',
733
+ 'SortSite',
734
+ 'spaziodati',
735
+ 'Specificfeeds',
736
+ 'speedy',
737
+ 'SPEng',
738
+ 'Spinn3r',
739
+ 'spray-can',
740
+ 'Sprinklr ',
741
+ 'spyonweb',
742
+ 'Sqworm',
743
+ 'SSL Labs',
744
+ 'StackRambler',
745
+ 'Statastico\/',
746
+ 'StatusCake',
747
+ 'Stratagems Kumo',
748
+ 'Stroke.cz',
749
+ 'StudioFACA',
750
+ 'suchen',
751
+ 'summify',
752
+ 'Super Monitoring',
753
+ 'Surphace Scout',
754
+ 'SwiteScraper',
755
+ 'Symfony2 BrowserKit',
756
+ 'Sysomos',
757
+ 'T0PHackTeam',
758
+ 'Tarantula\/',
759
+ 'teoma',
760
+ 'terrainformatica\.com',
761
+ 'The Expert HTML Source Viewer',
762
+ 'theinternetrules',
763
+ 'theoldreader\.com',
764
+ 'Thumbshots',
765
+ 'ThumbSniper',
766
+ 'TinEye',
767
+ 'Tiny Tiny RSS',
768
+ 'topster',
769
+ 'touche.com',
770
+ 'Traackr.com',
771
+ 'truwoGPS',
772
+ 'tweetedtimes\.com',
773
+ 'Tweetminster',
774
+ 'Twikle',
775
+ 'Twingly',
776
+ 'Typhoeus',
777
+ 'ubermetrics-technologies',
778
+ 'uclassify',
779
+ 'UdmSearch',
780
+ 'UnwindFetchor',
781
+ 'updated',
782
+ 'Upflow',
783
+ 'URLChecker',
784
+ 'URLitor.com',
785
+ 'urlresolver',
786
+ 'Urlstat',
787
+ 'UrlTrends Ranking Updater',
788
+ 'Vagabondo',
789
+ 'via ggpht\.com GoogleImageProxy',
790
+ 'visionutils',
791
+ 'vkShare',
792
+ 'voltron',
793
+ 'Vortex\/[0-9]',
794
+ 'voyager\/',
795
+ 'VSAgent\/[0-9]',
796
+ 'VSB-TUO\/[0-9]',
797
+ 'VYU2',
798
+ 'w3af\.org',
799
+ 'W3C-checklink',
800
+ 'W3C-mobileOK',
801
+ 'W3C_I18n-Checker',
802
+ 'W3C_Unicorn',
803
+ 'wangling',
804
+ 'Wappalyzer',
805
+ 'WatchMouse',
806
+ 'WbSrch\/',
807
+ 'web-capture\.net',
808
+ 'Web-Monitoring',
809
+ 'Web-sniffer',
810
+ 'Webauskunft',
811
+ 'WebCapture',
812
+ 'webcollage',
813
+ 'WebCookies',
814
+ 'WebCorp',
815
+ 'WebDoc',
816
+ 'WebFetch',
817
+ 'WebImages',
818
+ 'WebIndex',
819
+ 'webkit2png',
820
+ 'webmastercoffee',
821
+ 'webmon ',
822
+ 'webscreenie',
823
+ 'Webshot',
824
+ 'Website Analyzer\/',
825
+ 'websitepulse[+ ]checker',
826
+ 'Websnapr\/',
827
+ 'Websquash\.com',
828
+ 'Webthumb\/[0-9]',
829
+ 'WebThumbnail',
830
+ 'WeCrawlForThePeace',
831
+ 'WeLikeLinks',
832
+ 'WEPA',
833
+ 'WeSEE',
834
+ 'wf84',
835
+ 'wget',
836
+ 'WhatsApp',
837
+ 'WhatsMyIP',
838
+ 'WhatWeb',
839
+ 'Whibse',
840
+ 'Whynder Magnet',
841
+ 'Windows-RSS-Platform',
842
+ 'WinHttpRequest',
843
+ 'wkhtmlto',
844
+ 'wmtips',
845
+ 'Woko',
846
+ 'WomlpeFactory',
847
+ 'Word\/',
848
+ 'WordPress\/',
849
+ 'wotbox',
850
+ 'WP Engine Install Performance API',
851
+ 'WPScan',
852
+ 'wscheck',
853
+ 'WWW-Mechanize',
854
+ 'www\.monitor\.us',
855
+ 'XaxisSemanticsClassifier',
856
+ 'Xenu Link Sleuth',
857
+ 'XING-contenttabreceiver\/[0-9]',
858
+ 'XmlSitemapGenerator',
859
+ 'xpymep([0-9]?)\.exe',
860
+ 'Y!J-(ASR|BSC)',
861
+ 'Yaanb',
862
+ 'yacy',
863
+ 'Yahoo Ad monitoring',
864
+ 'Yahoo Link Preview',
865
+ 'YahooCacheSystem',
866
+ 'YahooSeeker',
867
+ 'YahooYSMcm',
868
+ 'YandeG',
869
+ 'yandex',
870
+ 'yanga',
871
+ 'yeti',
872
+ 'Yo-yo',
873
+ 'Yoleo Consumer',
874
+ 'yoogliFetchAgent',
875
+ 'YottaaMonitor',
876
+ 'yourls\.org',
877
+ 'Zao',
878
+ 'Zemanta Aggregator',
879
+ 'Zend\\\\Http\\\\Client',
880
+ 'Zend_Http_Client',
881
+ 'zgrab',
882
+ 'ZnajdzFoto',
883
+ 'ZyBorg',
884
+ '[a-z0-9\-_]*((?<!cu)bot|crawler|archiver|transcoder|spider|uptime|validator|fetcher)',
885
+ );
886
+
887
+ return $data;
888
+ }
889
+
890
+ /**
891
+ * Return the list of strings to remove from the user agent before running the crawler regex.
892
+ *
893
+ * @return array
894
+ */
895
+ public function get_exclusions_list() {
896
+ $data = array(
897
+ 'Safari.[\d\.]*',
898
+ 'Firefox.[\d\.]*',
899
+ 'Chrome.[\d\.]*',
900
+ 'Chromium.[\d\.]*',
901
+ 'MSIE.[\d\.]',
902
+ 'Opera\/[\d\.]*',
903
+ 'Mozilla.[\d\.]*',
904
+ 'AppleWebKit.[\d\.]*',
905
+ 'Trident.[\d\.]*',
906
+ 'Windows NT.[\d\.]*',
907
+ 'Android [\d\.]*',
908
+ 'Macintosh.',
909
+ 'Ubuntu',
910
+ 'Linux',
911
+ '[ ]Intel',
912
+ 'Mac OS X [\d_]*',
913
+ '(like )?Gecko(.[\d\.]*)?',
914
+ 'KHTML,',
915
+ 'CriOS.[\d\.]*',
916
+ 'CPU iPhone OS ([0-9_])* like Mac OS X',
917
+ 'CPU OS ([0-9_])* like Mac OS X',
918
+ 'iPod',
919
+ 'compatible',
920
+ 'x86_..',
921
+ 'i686',
922
+ 'x64',
923
+ 'X11',
924
+ 'rv:[\d\.]*',
925
+ 'Version.[\d\.]*',
926
+ 'WOW64',
927
+ 'Win64',
928
+ 'Dalvik.[\d\.]*',
929
+ ' \.NET CLR [\d\.]*',
930
+ 'Presto.[\d\.]*',
931
+ 'Media Center PC',
932
+ 'BlackBerry',
933
+ 'Build',
934
+ 'Opera Mini\/\d{1,2}\.\d{1,2}\.[\d\.]*\/\d{1,2}\.',
935
+ 'Opera',
936
+ ' \.NET[\d\.]*',
937
+ '\(|\)|;|,', // remove the following characters ( ) : ,
938
+ );
939
+
940
+ return $data;
941
+ }
942
+
943
+ /**
944
+ * Return all possible HTTP headers that represent the User-Agent string.
945
+ *
946
+ * @return array
947
+ */
948
+ public function get_headers_list() {
949
+ $data = array(
950
+ // the default User-Agent string.
951
+ 'HTTP_USER_AGENT',
952
+ // header can occur on devices using Opera Mini.
953
+ 'HTTP_X_OPERAMINI_PHONE_UA',
954
+ // vodafone specific header: http://www.seoprinciple.com/mobile-web-community-still-angry-at-vodafone/24/
955
+ 'HTTP_X_DEVICE_USER_AGENT',
956
+ 'HTTP_X_ORIGINAL_USER_AGENT',
957
+ 'HTTP_X_SKYFIRE_PHONE',
958
+ 'HTTP_X_BOLT_PHONE_UA',
959
+ 'HTTP_DEVICE_STOCK_UA',
960
+ 'HTTP_X_UCBROWSER_DEVICE_UA',
961
+ // sometimes, bots (especially Google) use a genuine user agent, but fill this header in with their email address
962
+ 'HTTP_FROM',
963
+ );
964
+
965
+ return $data;
966
+ }
967
+
968
+ }
includes/cron.php CHANGED
@@ -5,6 +5,8 @@ if ( ! defined( 'ABSPATH' ) )
5
 
6
  /**
7
  * Post_Views_Counter_Cron class.
 
 
8
  */
9
  class Post_Views_Counter_Cron {
10
 
5
 
6
  /**
7
  * Post_Views_Counter_Cron class.
8
+ *
9
+ * @class Post_Views_Counter_Cron
10
  */
11
  class Post_Views_Counter_Cron {
12
 
includes/dashboard.php CHANGED
@@ -5,6 +5,8 @@ if ( ! defined( 'ABSPATH' ) )
5
 
6
  /**
7
  * Post_Views_Counter_Dashboard class.
 
 
8
  */
9
  class Post_Views_Counter_Dashboard {
10
 
@@ -14,7 +16,7 @@ class Post_Views_Counter_Dashboard {
14
  add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts_styles' ) );
15
  add_action( 'wp_ajax_pvc_dashboard_chart', array( $this, 'dashboard_widget_chart' ) );
16
  }
17
-
18
  /**
19
  * Initialize widget.
20
  */
@@ -23,11 +25,11 @@ class Post_Views_Counter_Dashboard {
23
  if ( ! apply_filters( 'pvc_user_can_see_stats', current_user_can( 'publish_posts' ) ) ) {
24
  return;
25
  }
26
-
27
  // add dashboard widget
28
- wp_add_dashboard_widget( 'pvc_dashboard', __( 'Post Views', 'post-views-counter' ), array( $this, 'dashboard_widget' ) /*, array( $this, 'dashboard_widget_control' ) */ );
29
  }
30
-
31
  /**
32
  * Render dashboard widget.
33
  *
@@ -40,7 +42,7 @@ class Post_Views_Counter_Dashboard {
40
  </div>
41
  <?php
42
  }
43
-
44
  /**
45
  * Dashboard widget settings.
46
  *
@@ -49,78 +51,79 @@ class Post_Views_Counter_Dashboard {
49
  public function dashboard_widget_control() {
50
 
51
  }
52
-
53
  /**
54
  * Dashboard widget chart data function.
55
  *
 
56
  */
57
  public function dashboard_widget_chart() {
58
-
59
  if ( ! apply_filters( 'pvc_user_can_see_stats', current_user_can( 'publish_posts' ) ) )
60
  wp_die( _( 'You do not have permission to access this page.', 'post-views-counter' ) );
61
 
62
  if ( ! check_ajax_referer( 'dashboard-chart', 'nonce' ) )
63
  wp_die( __( 'You do not have permission to access this page.', 'post-views-counter' ) );
64
-
65
  $period = isset( $_REQUEST['period'] ) ? esc_attr( $_REQUEST['period'] ) : 'this_month';
66
-
67
  $post_types = Post_Views_Counter()->options['general']['post_types_count'];
68
-
69
  // get stats
70
  $query_args = array(
71
- 'post_type' => $post_types,
72
- 'posts_per_page' => -1,
73
- 'paged' => false,
74
- 'orderby' => 'post_views',
75
- 'suppress_filters' => false,
76
- 'no_found_rows' => true
77
  );
78
 
79
  // set range
80
  $range = 'this_month';
81
  $now = getdate( current_time( 'timestamp', get_option( 'gmt_offset' ) ) );
82
-
83
  // set chart labels
84
  switch ( $range ) {
85
  case 'this_week' :
86
  $data = array(
87
- 'text' => array(
88
- 'xAxes' => date_i18n( 'F Y' ),
89
- 'yAxes' => __( 'Post Views', 'post-views-counter' )
90
  )
91
  );
92
-
93
- for ( $day = 0; $day <= 6; $day ++ ) {
94
-
95
  $date = strtotime( $now['mday'] . '-' . $now['mon'] . '-' . $now['year'] . ' + ' . $day . ' days - ' . $now['wday'] . ' days' );
96
  $query = new WP_Query( wp_parse_args( $query_args, array( 'views_query' => array( 'year' => date( 'Y', $date ), 'month' => date( 'n', $date ), 'day' => date( 'd', $date ) ) ) ) );
97
 
98
- $data['data']['labels'][] = date_i18n( 'j', $date );
99
- $data['data']['datasets'][$type_name]['label'] = __( 'Post Views', 'post-views-counter');
100
  $data['data']['datasets'][0]['data'][] = $query->total_views;
101
  }
102
  break;
103
-
104
  case 'this month' :
105
  default :
106
  $data = array(
107
- 'text' => array(
108
- 'xAxes' => date_i18n( 'F Y' ),
109
- 'yAxes' => __( 'Post Views', 'post-views-counter' ),
110
  ),
111
  'design' => array(
112
- 'fill' => true,
113
- 'backgroundColor' => 'rgba(50, 143, 186, 0.2)',
114
- 'borderColor' => 'rgba(50, 143, 186, 1)',
115
- 'borderWidth' => 2,
116
- 'borderDash' => array(),
117
- 'pointBorderColor' => 'rgba(50, 143, 186, 1)',
118
- 'pointBackgroundColor' => 'rgba(255, 255, 255, 1)',
119
- 'pointBorderWidth' => 1.2
120
  )
121
  );
122
 
123
- $data['data']['datasets'][0]['label'] = __( 'Total Views', 'post-views-counter');
124
 
125
  // get data for specific post types
126
  $empty_post_type_views = array();
@@ -140,35 +143,33 @@ class Post_Views_Counter_Dashboard {
140
  $rev_post_types = array_flip( $post_types );
141
 
142
  // this month day loop
143
- for ( $i = 1; $i <= date( 't' ); $i++ ) {
144
-
145
  if ( $i <= $now['mday'] ) {
146
-
147
  $query = new WP_Query( wp_parse_args( $query_args, array( 'views_query' => array( 'year' => date( 'Y' ), 'month' => date( 'n' ), 'day' => str_pad( $i, 2, '0', STR_PAD_LEFT ) ) ) ) );
148
-
149
  // get data for specific post types
150
  $post_type_views = $empty_post_type_views;
151
-
152
  if ( ! empty( $query->posts ) ) {
153
  foreach ( $query->posts as $index => $post ) {
154
  $post_type_views[$post->post_type] += $post->post_views;
155
  }
156
  }
157
-
158
  } else {
159
-
160
  $post_type_views = $empty_post_type_views;
161
-
162
  foreach ( $post_types as $id => $post_type ) {
163
- $post_type_views[$post_type ] = 0;
164
  }
165
-
166
  $query->total_views = 0;
167
-
168
  }
169
 
170
  // generate chart data
171
- $data['data']['labels'][] = str_pad( $i, 2, '0', STR_PAD_LEFT );
172
  $data['data']['dates'][] = date_i18n( get_option( 'date_format' ), strtotime( date( 'Y' ) . '-' . date( 'n' ) . '-' . str_pad( $i, 2, '0', STR_PAD_LEFT ) ) );
173
  $data['data']['datasets'][0]['data'][] = $query->total_views;
174
 
@@ -185,7 +186,7 @@ class Post_Views_Counter_Dashboard {
185
 
186
  exit;
187
  }
188
-
189
  /**
190
  * Enqueue admin scripts and styles.
191
  *
@@ -194,37 +195,37 @@ class Post_Views_Counter_Dashboard {
194
  public function admin_scripts_styles( $pagenow ) {
195
  if ( $pagenow != 'index.php' )
196
  return;
197
-
198
  // filter user_can_see_stats
199
  if ( ! apply_filters( 'pvc_user_can_see_stats', current_user_can( 'publish_posts' ) ) ) {
200
  return;
201
  }
202
-
203
  wp_register_style(
204
- 'pvc-admin-dashboard', POST_VIEWS_COUNTER_URL . '/css/admin-dashboard.css'
205
  );
206
  wp_enqueue_style( 'pvc-admin-dashboard' );
207
 
208
  wp_register_script(
209
- 'pvc-admin-dashboard', POST_VIEWS_COUNTER_URL . '/js/admin-dashboard.js', array( 'jquery', 'pvc-chart' ), Post_Views_Counter()->defaults['version'], true
210
  );
211
-
212
  wp_register_script(
213
- 'pvc-chart', POST_VIEWS_COUNTER_URL . '/js/chart.min.js', array( 'jquery' ), Post_Views_Counter()->defaults['version'], true
214
  );
215
 
216
  // set ajax args
217
  $ajax_args = array(
218
- 'ajaxURL' => admin_url( 'admin-ajax.php' ),
219
- 'nonce' => wp_create_nonce( 'dashboard-chart' )
220
  );
221
 
222
  wp_enqueue_script( 'pvc-admin-dashboard' );
223
  // wp_enqueue_script( 'pvc-chart' );
224
 
225
  wp_localize_script(
226
- 'pvc-admin-dashboard', 'pvcArgs', $ajax_args
227
  );
228
-
229
  }
230
- }
 
5
 
6
  /**
7
  * Post_Views_Counter_Dashboard class.
8
+ *
9
+ * @class Post_Views_Counter_Dashboard
10
  */
11
  class Post_Views_Counter_Dashboard {
12
 
16
  add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts_styles' ) );
17
  add_action( 'wp_ajax_pvc_dashboard_chart', array( $this, 'dashboard_widget_chart' ) );
18
  }
19
+
20
  /**
21
  * Initialize widget.
22
  */
25
  if ( ! apply_filters( 'pvc_user_can_see_stats', current_user_can( 'publish_posts' ) ) ) {
26
  return;
27
  }
28
+
29
  // add dashboard widget
30
+ wp_add_dashboard_widget( 'pvc_dashboard', __( 'Post Views', 'post-views-counter' ), array( $this, 'dashboard_widget' ) /* , array( $this, 'dashboard_widget_control' ) */ );
31
  }
32
+
33
  /**
34
  * Render dashboard widget.
35
  *
42
  </div>
43
  <?php
44
  }
45
+
46
  /**
47
  * Dashboard widget settings.
48
  *
51
  public function dashboard_widget_control() {
52
 
53
  }
54
+
55
  /**
56
  * Dashboard widget chart data function.
57
  *
58
+ * @return mixed
59
  */
60
  public function dashboard_widget_chart() {
61
+
62
  if ( ! apply_filters( 'pvc_user_can_see_stats', current_user_can( 'publish_posts' ) ) )
63
  wp_die( _( 'You do not have permission to access this page.', 'post-views-counter' ) );
64
 
65
  if ( ! check_ajax_referer( 'dashboard-chart', 'nonce' ) )
66
  wp_die( __( 'You do not have permission to access this page.', 'post-views-counter' ) );
67
+
68
  $period = isset( $_REQUEST['period'] ) ? esc_attr( $_REQUEST['period'] ) : 'this_month';
69
+
70
  $post_types = Post_Views_Counter()->options['general']['post_types_count'];
71
+
72
  // get stats
73
  $query_args = array(
74
+ 'post_type' => $post_types,
75
+ 'posts_per_page' => -1,
76
+ 'paged' => false,
77
+ 'orderby' => 'post_views',
78
+ 'suppress_filters' => false,
79
+ 'no_found_rows' => true
80
  );
81
 
82
  // set range
83
  $range = 'this_month';
84
  $now = getdate( current_time( 'timestamp', get_option( 'gmt_offset' ) ) );
85
+
86
  // set chart labels
87
  switch ( $range ) {
88
  case 'this_week' :
89
  $data = array(
90
+ 'text' => array(
91
+ 'xAxes' => date_i18n( 'F Y' ),
92
+ 'yAxes' => __( 'Post Views', 'post-views-counter' )
93
  )
94
  );
95
+
96
+ for ( $day = 0; $day <= 6; $day ++ ) {
97
+
98
  $date = strtotime( $now['mday'] . '-' . $now['mon'] . '-' . $now['year'] . ' + ' . $day . ' days - ' . $now['wday'] . ' days' );
99
  $query = new WP_Query( wp_parse_args( $query_args, array( 'views_query' => array( 'year' => date( 'Y', $date ), 'month' => date( 'n', $date ), 'day' => date( 'd', $date ) ) ) ) );
100
 
101
+ $data['data']['labels'][] = date_i18n( 'j', $date );
102
+ $data['data']['datasets'][$type_name]['label'] = __( 'Post Views', 'post-views-counter' );
103
  $data['data']['datasets'][0]['data'][] = $query->total_views;
104
  }
105
  break;
106
+
107
  case 'this month' :
108
  default :
109
  $data = array(
110
+ 'text' => array(
111
+ 'xAxes' => date_i18n( 'F Y' ),
112
+ 'yAxes' => __( 'Post Views', 'post-views-counter' ),
113
  ),
114
  'design' => array(
115
+ 'fill' => true,
116
+ 'backgroundColor' => 'rgba(50, 143, 186, 0.2)',
117
+ 'borderColor' => 'rgba(50, 143, 186, 1)',
118
+ 'borderWidth' => 2,
119
+ 'borderDash' => array(),
120
+ 'pointBorderColor' => 'rgba(50, 143, 186, 1)',
121
+ 'pointBackgroundColor' => 'rgba(255, 255, 255, 1)',
122
+ 'pointBorderWidth' => 1.2
123
  )
124
  );
125
 
126
+ $data['data']['datasets'][0]['label'] = __( 'Total Views', 'post-views-counter' );
127
 
128
  // get data for specific post types
129
  $empty_post_type_views = array();
143
  $rev_post_types = array_flip( $post_types );
144
 
145
  // this month day loop
146
+ for ( $i = 1; $i <= date( 't' ); $i ++ ) {
147
+
148
  if ( $i <= $now['mday'] ) {
149
+
150
  $query = new WP_Query( wp_parse_args( $query_args, array( 'views_query' => array( 'year' => date( 'Y' ), 'month' => date( 'n' ), 'day' => str_pad( $i, 2, '0', STR_PAD_LEFT ) ) ) ) );
151
+
152
  // get data for specific post types
153
  $post_type_views = $empty_post_type_views;
154
+
155
  if ( ! empty( $query->posts ) ) {
156
  foreach ( $query->posts as $index => $post ) {
157
  $post_type_views[$post->post_type] += $post->post_views;
158
  }
159
  }
 
160
  } else {
161
+
162
  $post_type_views = $empty_post_type_views;
163
+
164
  foreach ( $post_types as $id => $post_type ) {
165
+ $post_type_views[$post_type] = 0;
166
  }
167
+
168
  $query->total_views = 0;
 
169
  }
170
 
171
  // generate chart data
172
+ $data['data']['labels'][] = ( $i % 2 === 0 ? '' : $i );
173
  $data['data']['dates'][] = date_i18n( get_option( 'date_format' ), strtotime( date( 'Y' ) . '-' . date( 'n' ) . '-' . str_pad( $i, 2, '0', STR_PAD_LEFT ) ) );
174
  $data['data']['datasets'][0]['data'][] = $query->total_views;
175
 
186
 
187
  exit;
188
  }
189
+
190
  /**
191
  * Enqueue admin scripts and styles.
192
  *
195
  public function admin_scripts_styles( $pagenow ) {
196
  if ( $pagenow != 'index.php' )
197
  return;
198
+
199
  // filter user_can_see_stats
200
  if ( ! apply_filters( 'pvc_user_can_see_stats', current_user_can( 'publish_posts' ) ) ) {
201
  return;
202
  }
203
+
204
  wp_register_style(
205
+ 'pvc-admin-dashboard', POST_VIEWS_COUNTER_URL . '/css/admin-dashboard.css'
206
  );
207
  wp_enqueue_style( 'pvc-admin-dashboard' );
208
 
209
  wp_register_script(
210
+ 'pvc-admin-dashboard', POST_VIEWS_COUNTER_URL . '/js/admin-dashboard.js', array( 'jquery', 'pvc-chart' ), Post_Views_Counter()->defaults['version'], true
211
  );
212
+
213
  wp_register_script(
214
+ 'pvc-chart', POST_VIEWS_COUNTER_URL . '/js/chart.min.js', array( 'jquery' ), Post_Views_Counter()->defaults['version'], true
215
  );
216
 
217
  // set ajax args
218
  $ajax_args = array(
219
+ 'ajaxURL' => admin_url( 'admin-ajax.php' ),
220
+ 'nonce' => wp_create_nonce( 'dashboard-chart' )
221
  );
222
 
223
  wp_enqueue_script( 'pvc-admin-dashboard' );
224
  // wp_enqueue_script( 'pvc-chart' );
225
 
226
  wp_localize_script(
227
+ 'pvc-admin-dashboard', 'pvcArgs', $ajax_args
228
  );
 
229
  }
230
+
231
+ }
includes/frontend.php CHANGED
@@ -5,6 +5,8 @@ if ( ! defined( 'ABSPATH' ) )
5
 
6
  /**
7
  * Post_Views_Counter_Frontend class.
 
 
8
  */
9
  class Post_Views_Counter_Frontend {
10
 
@@ -37,22 +39,21 @@ class Post_Views_Counter_Frontend {
37
 
38
  return pvc_post_views( $args['id'], false );
39
  }
40
-
41
  /**
42
  * Set up plugin hooks.
43
  */
44
  public function run() {
45
-
46
  if ( is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) )
47
  return;
48
-
49
  $filter = apply_filters( 'pvc_shortcode_filter_hook', Post_Views_Counter()->options['display']['position'] );
50
-
51
  if ( ! empty( $filter ) && in_array( $filter, array( 'before', 'after' ) ) ) {
52
  // post content
53
  add_filter( 'the_content', array( $this, 'add_post_views_count' ) );
54
  // add_filter( 'the_excerpt', array( $this, 'add_post_views_count' ) );
55
-
56
  // bbpress
57
  add_filter( 'bbp_get_topic_content', array( $this, 'add_post_views_count' ) );
58
  add_filter( 'bbp_get_reply_content', array( $this, 'add_post_views_count' ) );
@@ -66,17 +67,19 @@ class Post_Views_Counter_Frontend {
66
  /**
67
  * Add post views counter to content.
68
  *
 
 
69
  * @param mixed $content
70
  * @return mixed
71
  */
72
  public function add_post_views_count( $content = '' ) {
73
  global $post, $wp_current_filter;
74
-
75
  $display = false;
76
 
77
  // get post types
78
  $post_types = Post_Views_Counter()->options['display']['post_types_display'];
79
-
80
  // get pages
81
  $pages = Post_Views_Counter()->options['display']['page_types_display'];
82
 
@@ -85,16 +88,20 @@ class Post_Views_Counter_Frontend {
85
  foreach ( $pages as $page ) {
86
  switch ( $page ) {
87
  case 'singular' :
88
- if ( is_singular( $post_types ) ) $display = true;
 
89
  break;
90
  case 'archive' :
91
- if ( is_archive() ) $display = true;
 
92
  break;
93
  case 'search' :
94
- if ( is_search() ) $display = true;
 
95
  break;
96
  case 'home' :
97
- if ( is_home() || is_front_page() ) $display = true;
 
98
  break;
99
  }
100
  }
@@ -115,15 +122,15 @@ class Post_Views_Counter_Frontend {
115
  // exclude guests?
116
  elseif ( in_array( 'guests', $groups, true ) )
117
  $display = false;
118
-
119
  // we don't want to mess custom loops
120
  if ( ! in_the_loop() )
121
  $display = false;
122
-
123
  if ( apply_filters( 'pvc_display_views_count', $display ) === true ) {
124
 
125
  $filter = apply_filters( 'pvc_shortcode_filter_hook', Post_Views_Counter()->options['display']['position'] );
126
-
127
  switch ( $filter ) {
128
  case 'after':
129
  $content = $content . do_shortcode( '[post-views]' );
@@ -148,11 +155,13 @@ class Post_Views_Counter_Frontend {
148
  public function frontend_scripts_styles() {
149
  $post_types = Post_Views_Counter()->options['display']['post_types_display'];
150
 
151
- // load dashicons
152
- wp_enqueue_style( 'dashicons' );
 
153
 
154
- // load style
155
- wp_enqueue_style( 'post-views-counter-frontend', POST_VIEWS_COUNTER_URL . '/css/frontend.css' );
 
156
 
157
  if ( Post_Views_Counter()->options['general']['counter_mode'] === 'js' ) {
158
  $post_types = Post_Views_Counter()->options['general']['post_types_count'];
@@ -162,21 +171,20 @@ class Post_Views_Counter_Frontend {
162
  return;
163
 
164
  wp_register_script(
165
- 'post-views-counter-frontend', POST_VIEWS_COUNTER_URL . '/js/frontend.js', array( 'jquery' )
166
  );
167
 
168
  wp_enqueue_script( 'post-views-counter-frontend' );
169
 
170
  wp_localize_script(
171
- 'post-views-counter-frontend',
172
- 'pvcArgsFrontend',
173
- array(
174
- 'ajaxURL' => admin_url( 'admin-ajax.php' ),
175
- 'postID' => get_the_ID(),
176
- 'nonce' => wp_create_nonce( 'pvc-check-post' ),
177
- 'postType' => get_post_type()
178
- )
179
  );
180
  }
181
  }
 
182
  }
5
 
6
  /**
7
  * Post_Views_Counter_Frontend class.
8
+ *
9
+ * @class Post_Views_Counter_Frontend
10
  */
11
  class Post_Views_Counter_Frontend {
12
 
39
 
40
  return pvc_post_views( $args['id'], false );
41
  }
42
+
43
  /**
44
  * Set up plugin hooks.
45
  */
46
  public function run() {
47
+
48
  if ( is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) )
49
  return;
50
+
51
  $filter = apply_filters( 'pvc_shortcode_filter_hook', Post_Views_Counter()->options['display']['position'] );
52
+
53
  if ( ! empty( $filter ) && in_array( $filter, array( 'before', 'after' ) ) ) {
54
  // post content
55
  add_filter( 'the_content', array( $this, 'add_post_views_count' ) );
56
  // add_filter( 'the_excerpt', array( $this, 'add_post_views_count' ) );
 
57
  // bbpress
58
  add_filter( 'bbp_get_topic_content', array( $this, 'add_post_views_count' ) );
59
  add_filter( 'bbp_get_reply_content', array( $this, 'add_post_views_count' ) );
67
  /**
68
  * Add post views counter to content.
69
  *
70
+ * @global object $post
71
+ * @global string $wp_current_filter
72
  * @param mixed $content
73
  * @return mixed
74
  */
75
  public function add_post_views_count( $content = '' ) {
76
  global $post, $wp_current_filter;
77
+
78
  $display = false;
79
 
80
  // get post types
81
  $post_types = Post_Views_Counter()->options['display']['post_types_display'];
82
+
83
  // get pages
84
  $pages = Post_Views_Counter()->options['display']['page_types_display'];
85
 
88
  foreach ( $pages as $page ) {
89
  switch ( $page ) {
90
  case 'singular' :
91
+ if ( is_singular( $post_types ) )
92
+ $display = true;
93
  break;
94
  case 'archive' :
95
+ if ( is_archive() )
96
+ $display = true;
97
  break;
98
  case 'search' :
99
+ if ( is_search() )
100
+ $display = true;
101
  break;
102
  case 'home' :
103
+ if ( is_home() || is_front_page() )
104
+ $display = true;
105
  break;
106
  }
107
  }
122
  // exclude guests?
123
  elseif ( in_array( 'guests', $groups, true ) )
124
  $display = false;
125
+
126
  // we don't want to mess custom loops
127
  if ( ! in_the_loop() )
128
  $display = false;
129
+
130
  if ( apply_filters( 'pvc_display_views_count', $display ) === true ) {
131
 
132
  $filter = apply_filters( 'pvc_shortcode_filter_hook', Post_Views_Counter()->options['display']['position'] );
133
+
134
  switch ( $filter ) {
135
  case 'after':
136
  $content = $content . do_shortcode( '[post-views]' );
155
  public function frontend_scripts_styles() {
156
  $post_types = Post_Views_Counter()->options['display']['post_types_display'];
157
 
158
+ if ( (bool) apply_filters( 'pvc_enqueue_styles', true ) === true ) {
159
+ // load dashicons
160
+ wp_enqueue_style( 'dashicons' );
161
 
162
+ // load style
163
+ wp_enqueue_style( 'post-views-counter-frontend', POST_VIEWS_COUNTER_URL . '/css/frontend.css' );
164
+ }
165
 
166
  if ( Post_Views_Counter()->options['general']['counter_mode'] === 'js' ) {
167
  $post_types = Post_Views_Counter()->options['general']['post_types_count'];
171
  return;
172
 
173
  wp_register_script(
174
+ 'post-views-counter-frontend', POST_VIEWS_COUNTER_URL . '/js/frontend.js', array( 'jquery' )
175
  );
176
 
177
  wp_enqueue_script( 'post-views-counter-frontend' );
178
 
179
  wp_localize_script(
180
+ 'post-views-counter-frontend', 'pvcArgsFrontend', array(
181
+ 'ajaxURL' => admin_url( 'admin-ajax.php' ),
182
+ 'postID' => get_the_ID(),
183
+ 'nonce' => wp_create_nonce( 'pvc-check-post' ),
184
+ 'postType' => get_post_type()
185
+ )
 
 
186
  );
187
  }
188
  }
189
+
190
  }
includes/functions.php CHANGED
@@ -4,19 +4,19 @@
4
  *
5
  * Override any of those functions by copying it to your theme or replace it via plugin
6
  *
7
- * @author Digital Factory
8
  * @package Post Views Counter
9
  * @since 1.0.0
10
  */
11
-
12
  if ( ! defined( 'ABSPATH' ) )
13
  exit;
14
 
15
  /**
16
  * Get post views for a post or array of posts.
17
  *
18
- * @param int|array $post_id
19
- * @return int
20
  */
21
  if ( ! function_exists( 'pvc_get_post_views' ) ) {
22
 
@@ -32,9 +32,9 @@ if ( ! function_exists( 'pvc_get_post_views' ) ) {
32
  global $wpdb;
33
 
34
  $post_views = (int) $wpdb->get_var( "
35
- SELECT SUM(count) AS views
36
- FROM " . $wpdb->prefix . "post_views
37
- WHERE id IN (" . $post_id . ") AND type = 4"
38
  );
39
 
40
  return apply_filters( 'pvc_get_post_views', $post_views, $post_id );
@@ -45,14 +45,14 @@ if ( ! function_exists( 'pvc_get_post_views' ) ) {
45
  /**
46
  * Display post views for a given post.
47
  *
48
- * @param int|array $post_id
49
- * @param bool $display
50
- * @return mixed
51
  */
52
  if ( ! function_exists( 'pvc_post_views' ) ) {
53
 
54
  function pvc_post_views( $post_id = 0, $echo = true ) {
55
-
56
  // get all data
57
  $post_id = (int) ( empty( $post_id ) ? get_the_ID() : $post_id );
58
  $options = Post_Views_Counter()->options['display'];
@@ -64,11 +64,11 @@ if ( ! function_exists( 'pvc_post_views' ) ) {
64
  $icon = apply_filters( 'pvc_post_views_icon', '<span class="post-views-icon dashicons ' . $icon_class . '"></span>', $post_id );
65
 
66
  $html = apply_filters(
67
- 'pvc_post_views_html', '<div class="post-views post-' . $post_id . ' entry-meta">
68
- ' . ($options['display_style']['icon'] && $icon_class !== '' ? $icon : '') . '
69
- ' . ($options['display_style']['text'] ? '<span class="post-views-label">' . $label . ' </span>' : '') . '
70
- <span class="post-views-count">' . number_format_i18n( $views ) . '</span>
71
- </div>', $post_id, $views, $label, $icon
72
  );
73
 
74
  if ( $echo )
@@ -82,18 +82,18 @@ if ( ! function_exists( 'pvc_post_views' ) ) {
82
  /**
83
  * Get most viewed posts.
84
  *
85
- * @param array $args
86
- * @return array
87
  */
88
  if ( ! function_exists( 'pvc_get_most_viewed_posts' ) ) {
89
 
90
  function pvc_get_most_viewed_posts( $args = array() ) {
91
  $args = array_merge(
92
- array(
93
  'posts_per_page' => 10,
94
  'order' => 'desc',
95
  'post_type' => 'post'
96
- ), $args
97
  );
98
 
99
  $args = apply_filters( 'pvc_get_most_viewed_posts_args', $args );
@@ -115,22 +115,22 @@ if ( ! function_exists( 'pvc_get_most_viewed_posts' ) ) {
115
  /**
116
  * Display a list of most viewed posts.
117
  *
118
- * @param array $post_id
119
- * @param bool $display
120
- * @return mixed
121
  */
122
  if ( ! function_exists( 'pvc_most_viewed_posts' ) ) {
123
 
124
  function pvc_most_viewed_posts( $args = array(), $display = true ) {
125
  $defaults = array(
126
- 'number_of_posts' => 5,
127
- 'post_type' => array( 'post' ),
128
- 'order' => 'desc',
129
- 'thumbnail_size' => 'thumbnail',
130
- 'show_post_views' => true,
131
- 'show_post_thumbnail' => false,
132
- 'show_post_excerpt' => false,
133
- 'no_posts_message' => __( 'No Posts', 'post-views-counter' )
134
  );
135
 
136
  $args = apply_filters( 'pvc_most_viewed_posts_args', wp_parse_args( $args, $defaults ) );
@@ -140,32 +140,32 @@ if ( ! function_exists( 'pvc_most_viewed_posts' ) ) {
140
  $args['show_post_excerpt'] = (bool) $args['show_post_excerpt'];
141
 
142
  $posts = pvc_get_most_viewed_posts(
143
- array(
144
- 'posts_per_page' => (isset( $args['number_of_posts'] ) ? (int) $args['number_of_posts'] : $defaults['number_of_posts']),
145
- 'order' => (isset( $args['order'] ) ? $args['order'] : $defaults['order']),
146
- 'post_type' => (isset( $args['post_type'] ) ? $args['post_type'] : $defaults['post_type'])
147
- )
148
  );
149
 
150
  if ( ! empty( $posts ) ) {
151
  $html = '
152
- <ul>';
153
 
154
  foreach ( $posts as $post ) {
155
  setup_postdata( $post );
156
 
157
  $html .= '
158
- <li>';
159
 
160
  if ( $args['show_post_thumbnail'] && has_post_thumbnail( $post->ID ) ) {
161
  $html .= '
162
- <span class="post-thumbnail">
163
- ' . get_the_post_thumbnail( $post->ID, $args['thumbnail_size'] ) . '
164
- </span>';
165
  }
166
 
167
  $html .= '
168
- <a class="post-title" href="' . get_permalink( $post->ID ) . '">' . get_the_title( $post->ID ) . '</a>' . ($args['show_post_views'] ? ' <span class="count">(' . number_format_i18n( pvc_get_post_views( $post->ID ) ) . ')</span>' : '');
169
 
170
  $excerpt = '';
171
 
@@ -181,16 +181,16 @@ if ( ! function_exists( 'pvc_most_viewed_posts' ) ) {
181
 
182
  if ( ! empty( $excerpt ) )
183
  $html .= '
184
- <div class="post-excerpt">' . esc_html( $excerpt ) . '</div>';
185
 
186
  $html .= '
187
- </li>';
188
  }
189
 
190
  wp_reset_postdata();
191
 
192
  $html .= '
193
- </ul>';
194
  } else
195
  $html = $args['no_posts_message'];
196
 
@@ -207,17 +207,17 @@ if ( ! function_exists( 'pvc_most_viewed_posts' ) ) {
207
  /**
208
  * View post manually function.
209
  *
210
- * @since 1.2.0
211
- * @param int $post_id
212
- * @return bool
213
  */
214
  function pvc_view_post( $post_id = 0 ) {
215
  $post_id = (int) ( empty( $post_id ) ? get_the_ID() : $post_id );
216
-
217
  if ( ! $post_id )
218
  return false;
219
-
220
  Post_Views_Counter()->counter->check_post( $post_id );
221
-
222
  return true;
223
- }
4
  *
5
  * Override any of those functions by copying it to your theme or replace it via plugin
6
  *
7
+ * @author Digital Factory
8
  * @package Post Views Counter
9
  * @since 1.0.0
10
  */
11
+ // exit if accessed directly
12
  if ( ! defined( 'ABSPATH' ) )
13
  exit;
14
 
15
  /**
16
  * Get post views for a post or array of posts.
17
  *
18
+ * @param int|array $post_id
19
+ * @return int
20
  */
21
  if ( ! function_exists( 'pvc_get_post_views' ) ) {
22
 
32
  global $wpdb;
33
 
34
  $post_views = (int) $wpdb->get_var( "
35
+ SELECT SUM(count) AS views
36
+ FROM " . $wpdb->prefix . "post_views
37
+ WHERE id IN (" . $post_id . ") AND type = 4"
38
  );
39
 
40
  return apply_filters( 'pvc_get_post_views', $post_views, $post_id );
45
  /**
46
  * Display post views for a given post.
47
  *
48
+ * @param int|array $post_id
49
+ * @param bool $display
50
+ * @return mixed
51
  */
52
  if ( ! function_exists( 'pvc_post_views' ) ) {
53
 
54
  function pvc_post_views( $post_id = 0, $echo = true ) {
55
+
56
  // get all data
57
  $post_id = (int) ( empty( $post_id ) ? get_the_ID() : $post_id );
58
  $options = Post_Views_Counter()->options['display'];
64
  $icon = apply_filters( 'pvc_post_views_icon', '<span class="post-views-icon dashicons ' . $icon_class . '"></span>', $post_id );
65
 
66
  $html = apply_filters(
67
+ 'pvc_post_views_html', '<div class="post-views post-' . $post_id . ' entry-meta">
68
+ ' . ($options['display_style']['icon'] && $icon_class !== '' ? $icon : '') . '
69
+ ' . ($options['display_style']['text'] ? '<span class="post-views-label">' . $label . ' </span>' : '') . '
70
+ <span class="post-views-count">' . number_format_i18n( $views ) . '</span>
71
+ </div>', $post_id, $views, $label, $icon
72
  );
73
 
74
  if ( $echo )
82
  /**
83
  * Get most viewed posts.
84
  *
85
+ * @param array $args
86
+ * @return array
87
  */
88
  if ( ! function_exists( 'pvc_get_most_viewed_posts' ) ) {
89
 
90
  function pvc_get_most_viewed_posts( $args = array() ) {
91
  $args = array_merge(
92
+ array(
93
  'posts_per_page' => 10,
94
  'order' => 'desc',
95
  'post_type' => 'post'
96
+ ), $args
97
  );
98
 
99
  $args = apply_filters( 'pvc_get_most_viewed_posts_args', $args );
115
  /**
116
  * Display a list of most viewed posts.
117
  *
118
+ * @param array $post_id
119
+ * @param bool $display
120
+ * @return mixed
121
  */
122
  if ( ! function_exists( 'pvc_most_viewed_posts' ) ) {
123
 
124
  function pvc_most_viewed_posts( $args = array(), $display = true ) {
125
  $defaults = array(
126
+ 'number_of_posts' => 5,
127
+ 'post_type' => array( 'post' ),
128
+ 'order' => 'desc',
129
+ 'thumbnail_size' => 'thumbnail',
130
+ 'show_post_views' => true,
131
+ 'show_post_thumbnail' => false,
132
+ 'show_post_excerpt' => false,
133
+ 'no_posts_message' => __( 'No Posts', 'post-views-counter' )
134
  );
135
 
136
  $args = apply_filters( 'pvc_most_viewed_posts_args', wp_parse_args( $args, $defaults ) );
140
  $args['show_post_excerpt'] = (bool) $args['show_post_excerpt'];
141
 
142
  $posts = pvc_get_most_viewed_posts(
143
+ array(
144
+ 'posts_per_page' => (isset( $args['number_of_posts'] ) ? (int) $args['number_of_posts'] : $defaults['number_of_posts']),
145
+ 'order' => (isset( $args['order'] ) ? $args['order'] : $defaults['order']),
146
+ 'post_type' => (isset( $args['post_type'] ) ? $args['post_type'] : $defaults['post_type'])
147
+ )
148
  );
149
 
150
  if ( ! empty( $posts ) ) {
151
  $html = '
152
+ <ul>';
153
 
154
  foreach ( $posts as $post ) {
155
  setup_postdata( $post );
156
 
157
  $html .= '
158
+ <li>';
159
 
160
  if ( $args['show_post_thumbnail'] && has_post_thumbnail( $post->ID ) ) {
161
  $html .= '
162
+ <span class="post-thumbnail">
163
+ ' . get_the_post_thumbnail( $post->ID, $args['thumbnail_size'] ) . '
164
+ </span>';
165
  }
166
 
167
  $html .= '
168
+ <a class="post-title" href="' . get_permalink( $post->ID ) . '">' . get_the_title( $post->ID ) . '</a>' . ($args['show_post_views'] ? ' <span class="count">(' . number_format_i18n( pvc_get_post_views( $post->ID ) ) . ')</span>' : '');
169
 
170
  $excerpt = '';
171
 
181
 
182
  if ( ! empty( $excerpt ) )
183
  $html .= '
184
+ <div class="post-excerpt">' . esc_html( $excerpt ) . '</div>';
185
 
186
  $html .= '
187
+ </li>';
188
  }
189
 
190
  wp_reset_postdata();
191
 
192
  $html .= '
193
+ </ul>';
194
  } else
195
  $html = $args['no_posts_message'];
196
 
207
  /**
208
  * View post manually function.
209
  *
210
+ * @since 1.2.0
211
+ * @param int $post_id
212
+ * @return bool
213
  */
214
  function pvc_view_post( $post_id = 0 ) {
215
  $post_id = (int) ( empty( $post_id ) ? get_the_ID() : $post_id );
216
+
217
  if ( ! $post_id )
218
  return false;
219
+
220
  Post_Views_Counter()->counter->check_post( $post_id );
221
+
222
  return true;
223
+ }
includes/query.php CHANGED
@@ -5,6 +5,8 @@ if ( ! defined( 'ABSPATH' ) )
5
 
6
  /**
7
  * Post_Views_Counter_Query class.
 
 
8
  */
9
  class Post_Views_Counter_Query {
10
 
@@ -56,48 +58,48 @@ class Post_Views_Counter_Query {
56
 
57
  if ( ! empty( $query->query['views_query'] ) ) {
58
  if ( isset( $query->query['views_query']['year'] ) )
59
- $year = (int)$query->query['views_query']['year'];
60
 
61
  if ( isset( $query->query['views_query']['month'] ) )
62
- $month = (int)$query->query['views_query']['month'];
63
 
64
  if ( isset( $query->query['views_query']['week'] ) )
65
- $week = (int)$query->query['views_query']['week'];
66
 
67
  if ( isset( $query->query['views_query']['day'] ) )
68
- $day = (int)$query->query['views_query']['day'];
69
 
70
  // year
71
  if ( isset( $year ) ) {
72
  // year, week
73
  if ( isset( $week ) && $this->is_valid_date( 'yw', $year, 0, 0, $week ) ) {
74
  $sql = " AND pvc.type = 1 AND pvc.period = '" . str_pad( $year, 4, 0, STR_PAD_LEFT ) . str_pad( $week, 2, 0, STR_PAD_LEFT ) . "'";
75
- // year, month
76
  } elseif ( isset( $month ) ) {
77
  // year, month, day
78
  if ( isset( $day ) && $this->is_valid_date( 'ymd', $year, $month, $day ) ) {
79
  $sql = " AND pvc.type = 0 AND pvc.period = '" . str_pad( $year, 4, 0, STR_PAD_LEFT ) . str_pad( $month, 2, 0, STR_PAD_LEFT ) . str_pad( $day, 2, 0, STR_PAD_LEFT ) . "'";
80
- // year, month
81
  } elseif ( $this->is_valid_date( 'ym', $year, $month ) ) {
82
  $sql = " AND pvc.type = 2 AND pvc.period = '" . str_pad( $year, 4, 0, STR_PAD_LEFT ) . str_pad( $month, 2, 0, STR_PAD_LEFT ) . "'";
83
  }
84
- // year
85
  } elseif ( $this->is_valid_date( 'y', $year ) ) {
86
  $sql = " AND pvc.type = 3 AND pvc.period = '" . str_pad( $year, 4, 0, STR_PAD_LEFT ) . "'";
87
  }
88
- // month
89
  } elseif ( isset( $month ) ) {
90
  // month, day
91
  if ( isset( $day ) && $this->is_valid_date( 'md', 0, $month, $day ) ) {
92
  $sql = " AND pvc.type = 0 AND RIGHT( pvc.period, 4 ) = '" . str_pad( $month, 2, 0, STR_PAD_LEFT ) . str_pad( $day, 2, 0, STR_PAD_LEFT ) . "'";
93
- // month
94
  } elseif ( $this->is_valid_date( 'm', 0, $month ) ) {
95
  $sql = " AND pvc.type = 2 AND RIGHT( pvc.period, 2 ) = '" . str_pad( $month, 2, 0, STR_PAD_LEFT ) . "'";
96
  }
97
- // week
98
  } elseif ( isset( $week ) && $this->is_valid_date( 'w', 0, 0, 0, $week ) ) {
99
  $sql = " AND pvc.type = 1 AND RIGHT( pvc.period, 2 ) = '" . str_pad( $week, 2, 0, STR_PAD_LEFT ) . "'";
100
- // day
101
  } elseif ( isset( $day ) && $this->is_valid_date( 'd', 0, 0, $day ) ) {
102
  $sql = " AND pvc.type = 0 AND RIGHT( pvc.period, 2 ) = '" . str_pad( $day, 2, 0, STR_PAD_LEFT ) . "'";
103
  }
@@ -216,7 +218,7 @@ class Post_Views_Counter_Query {
216
  * @return bool
217
  */
218
  private function is_valid_date( $type, $year = 0, $month = 0, $day = 0, $week = 0 ) {
219
- switch( $type ) {
220
  case 'y':
221
  $bool = ( $year >= 1 && $year <= 32767 );
222
  break;
@@ -252,4 +254,5 @@ class Post_Views_Counter_Query {
252
 
253
  return $bool;
254
  }
255
- }
 
5
 
6
  /**
7
  * Post_Views_Counter_Query class.
8
+ *
9
+ * @class Post_Views_Counter_Query
10
  */
11
  class Post_Views_Counter_Query {
12
 
58
 
59
  if ( ! empty( $query->query['views_query'] ) ) {
60
  if ( isset( $query->query['views_query']['year'] ) )
61
+ $year = (int) $query->query['views_query']['year'];
62
 
63
  if ( isset( $query->query['views_query']['month'] ) )
64
+ $month = (int) $query->query['views_query']['month'];
65
 
66
  if ( isset( $query->query['views_query']['week'] ) )
67
+ $week = (int) $query->query['views_query']['week'];
68
 
69
  if ( isset( $query->query['views_query']['day'] ) )
70
+ $day = (int) $query->query['views_query']['day'];
71
 
72
  // year
73
  if ( isset( $year ) ) {
74
  // year, week
75
  if ( isset( $week ) && $this->is_valid_date( 'yw', $year, 0, 0, $week ) ) {
76
  $sql = " AND pvc.type = 1 AND pvc.period = '" . str_pad( $year, 4, 0, STR_PAD_LEFT ) . str_pad( $week, 2, 0, STR_PAD_LEFT ) . "'";
77
+ // year, month
78
  } elseif ( isset( $month ) ) {
79
  // year, month, day
80
  if ( isset( $day ) && $this->is_valid_date( 'ymd', $year, $month, $day ) ) {
81
  $sql = " AND pvc.type = 0 AND pvc.period = '" . str_pad( $year, 4, 0, STR_PAD_LEFT ) . str_pad( $month, 2, 0, STR_PAD_LEFT ) . str_pad( $day, 2, 0, STR_PAD_LEFT ) . "'";
82
+ // year, month
83
  } elseif ( $this->is_valid_date( 'ym', $year, $month ) ) {
84
  $sql = " AND pvc.type = 2 AND pvc.period = '" . str_pad( $year, 4, 0, STR_PAD_LEFT ) . str_pad( $month, 2, 0, STR_PAD_LEFT ) . "'";
85
  }
86
+ // year
87
  } elseif ( $this->is_valid_date( 'y', $year ) ) {
88
  $sql = " AND pvc.type = 3 AND pvc.period = '" . str_pad( $year, 4, 0, STR_PAD_LEFT ) . "'";
89
  }
90
+ // month
91
  } elseif ( isset( $month ) ) {
92
  // month, day
93
  if ( isset( $day ) && $this->is_valid_date( 'md', 0, $month, $day ) ) {
94
  $sql = " AND pvc.type = 0 AND RIGHT( pvc.period, 4 ) = '" . str_pad( $month, 2, 0, STR_PAD_LEFT ) . str_pad( $day, 2, 0, STR_PAD_LEFT ) . "'";
95
+ // month
96
  } elseif ( $this->is_valid_date( 'm', 0, $month ) ) {
97
  $sql = " AND pvc.type = 2 AND RIGHT( pvc.period, 2 ) = '" . str_pad( $month, 2, 0, STR_PAD_LEFT ) . "'";
98
  }
99
+ // week
100
  } elseif ( isset( $week ) && $this->is_valid_date( 'w', 0, 0, 0, $week ) ) {
101
  $sql = " AND pvc.type = 1 AND RIGHT( pvc.period, 2 ) = '" . str_pad( $week, 2, 0, STR_PAD_LEFT ) . "'";
102
+ // day
103
  } elseif ( isset( $day ) && $this->is_valid_date( 'd', 0, 0, $day ) ) {
104
  $sql = " AND pvc.type = 0 AND RIGHT( pvc.period, 2 ) = '" . str_pad( $day, 2, 0, STR_PAD_LEFT ) . "'";
105
  }
218
  * @return bool
219
  */
220
  private function is_valid_date( $type, $year = 0, $month = 0, $day = 0, $week = 0 ) {
221
+ switch ( $type ) {
222
  case 'y':
223
  $bool = ( $year >= 1 && $year <= 32767 );
224
  break;
254
 
255
  return $bool;
256
  }
257
+
258
+ }
includes/settings.php CHANGED
@@ -5,6 +5,8 @@ if ( ! defined( 'ABSPATH' ) )
5
 
6
  /**
7
  * Post_Views_Counter_Settings class.
 
 
8
  */
9
  class Post_Views_Counter_Settings {
10
 
@@ -31,10 +33,10 @@ class Post_Views_Counter_Settings {
31
  * Load default settings.
32
  */
33
  public function load_defaults() {
34
-
35
  if ( ! is_admin() )
36
  return;
37
-
38
  $this->modes = array(
39
  'php' => __( 'PHP', 'post-views-counter' ),
40
  'js' => __( 'JavaScript', 'post-views-counter' )
@@ -83,7 +85,7 @@ class Post_Views_Counter_Settings {
83
  );
84
 
85
  $this->user_roles = $this->get_user_roles();
86
-
87
  $this->page_types = apply_filters( 'pvc_page_types_display_options', array(
88
  'home' => __( 'Home', 'post-views-counter' ),
89
  'archive' => __( 'Archives', 'post-views-counter' ),
@@ -96,10 +98,10 @@ class Post_Views_Counter_Settings {
96
  * Get post types avaiable for counting.
97
  */
98
  public function load_post_types() {
99
-
100
  if ( ! is_admin() )
101
  return;
102
-
103
  $post_types = array();
104
 
105
  // built in public post types
@@ -121,6 +123,8 @@ class Post_Views_Counter_Settings {
121
 
122
  /**
123
  * Get all user roles.
 
 
124
  */
125
  public function get_user_roles() {
126
  global $wp_roles;
@@ -141,52 +145,54 @@ class Post_Views_Counter_Settings {
141
  */
142
  public function admin_menu_options() {
143
  add_options_page(
144
- __( 'Post Views Counter', 'post-views-counter' ), __( 'Post Views Counter', 'post-views-counter' ), 'manage_options', 'post-views-counter', array( $this, 'options_page' )
145
  );
146
  }
147
 
148
  /**
149
  * Options page callback.
 
 
150
  */
151
  public function options_page() {
152
  $tab_key = (isset( $_GET['tab'] ) ? $_GET['tab'] : 'general');
153
 
154
  echo '
155
- <div class="wrap">' . screen_icon() . '
156
- <h2>' . __( 'Post Views Counter', 'post-views-counter' ) . '</h2>
157
- <h2 class="nav-tab-wrapper">';
158
 
159
  foreach ( $this->tabs as $key => $name ) {
160
  echo '
161
- <a class="nav-tab ' . ($tab_key == $key ? 'nav-tab-active' : '') . '" href="' . esc_url( admin_url( 'options-general.php?page=post-views-counter&tab=' . $key ) ) . '">' . $name['name'] . '</a>';
162
  }
163
 
164
  echo '
165
- </h2>
166
- <div class="post-views-counter-settings">
167
- <div class="df-credits">
168
- <h3 class="hndle">' . __( 'Post Views Counter', 'post-views-counter' ) . ' ' . Post_Views_Counter()->defaults['version'] . '</h3>
169
- <div class="inside">
170
- <h4 class="inner">' . __( 'Need support?', 'post-views-counter' ) . '</h4>
171
- <p class="inner">' . __( 'If you are having problems with this plugin, please talk about them in the', 'post-views-counter' ) . ' <a href="http://www.dfactory.eu/support/?utm_source=post-views-counter-settings&utm_medium=link&utm_campaign=support" target="_blank" title="' . __( 'Support forum', 'post-views-counter' ) . '">' . __( 'Support forum', 'post-views-counter' ) . '</a></p>
172
- <hr />
173
- <h4 class="inner">' . __( 'Do you like this plugin?', 'post-views-counter' ) . '</h4>
174
- <p class="inner"><a href="http://wordpress.org/support/view/plugin-reviews/post-views-counter" target="_blank" title="' . __( 'Rate it 5', 'post-views-counter' ) . '">' . __( 'Rate it 5', 'post-views-counter' ) . '</a> ' . __( 'on WordPress.org', 'post-views-counter' ) . '<br />' .
175
  __( 'Blog about it & link to the', 'post-views-counter' ) . ' <a href="http://www.dfactory.eu/plugins/post-views-counter/?utm_source=post-views-counter-settings&utm_medium=link&utm_campaign=blog-about" target="_blank" title="' . __( 'plugin page', 'post-views-counter' ) . '">' . __( 'plugin page', 'post-views-counter' ) . '</a><br/>' .
176
  __( 'Check out our other', 'post-views-counter' ) . ' <a href="http://www.dfactory.eu/plugins/?utm_source=post-views-counter-settings&utm_medium=link&utm_campaign=other-plugins" target="_blank" title="' . __( 'WordPress plugins', 'post-views-counter' ) . '">' . __( 'WordPress plugins', 'post-views-counter' ) . '</a>
177
- </p>
178
- <hr />
179
- <p class="df-link inner">' . __( 'Created by', 'post-views-counter' ) . ' <a href="http://www.dfactory.eu/?utm_source=post-views-counter-settings&utm_medium=link&utm_campaign=created-by" target="_blank" title="dFactory - Quality plugins for WordPress"><img src="' . POST_VIEWS_COUNTER_URL . '/images/logo-dfactory.png' . '" title="dFactory - Quality plugins for WordPress" alt="dFactory - Quality plugins for WordPress" /></a></p>
180
- </div>
181
- </div>
182
- <form action="options.php" method="post">';
183
 
184
  wp_nonce_field( 'update-options' );
185
  settings_fields( $this->tabs[$tab_key]['key'] );
186
  do_settings_sections( $this->tabs[$tab_key]['key'] );
187
 
188
  echo '
189
- <p class="submit">';
190
 
191
  submit_button( '', 'primary', $this->tabs[$tab_key]['submit'], false );
192
 
@@ -195,11 +201,11 @@ class Post_Views_Counter_Settings {
195
  submit_button( __( 'Reset to defaults', 'post-views-counter' ), 'secondary reset_pvc_settings', $this->tabs[$tab_key]['reset'], false );
196
 
197
  echo '
198
- </p>
199
- </form>
200
- </div>
201
- <div class="clear"></div>
202
- </div>';
203
  }
204
 
205
  /**
@@ -213,12 +219,12 @@ class Post_Views_Counter_Settings {
213
  add_settings_field( 'pvc_counter_mode', __( 'Counter Mode', 'post-views-counter' ), array( $this, 'counter_mode' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
214
  add_settings_field( 'pvc_post_views_column', __( 'Post Views Column', 'post-views-counter' ), array( $this, 'post_views_column' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
215
  add_settings_field( 'pvc_restrict_edit_views', __( 'Restrict Edit', 'post-views-counter' ), array( $this, 'restrict_edit_views' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
216
- add_settings_field( 'pvc_time_between_counts', __( 'Time Between Counts', 'post-views-counter' ), array( $this, 'time_between_counts' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
217
  add_settings_field( 'pvc_reset_counts', __( 'Reset Data Interval', 'post-views-counter' ), array( $this, 'reset_counts' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
218
  add_settings_field( 'pvc_flush_interval', __( 'Flush Object Cache Interval', 'post-views-counter' ), array( $this, 'flush_interval' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
219
  add_settings_field( 'pvc_exclude', __( 'Exclude Visitors', 'post-views-counter' ), array( $this, 'exclude' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
220
  add_settings_field( 'pvc_exclude_ips', __( 'Exclude IPs', 'post-views-counter' ), array( $this, 'exclude_ips' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
221
- add_settings_field( 'pvc_wp_postviews', __( 'WP-PostViews', 'post-views-counter' ), array( $this, 'wp_postviews' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
222
  add_settings_field( 'pvc_deactivation_delete', __( 'Deactivation', 'post-views-counter' ), array( $this, 'deactivation_delete' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
223
 
224
  // display options
@@ -238,12 +244,12 @@ class Post_Views_Counter_Settings {
238
  */
239
  public function post_views_label() {
240
  echo '
241
- <div id="pvc_post_views_label">
242
- <fieldset>
243
- <input type="text" class="large-text" name="post_views_counter_settings_display[label]" value="' . esc_attr( Post_Views_Counter()->options['display']['label'] ) . '" />
244
- <p class="description">' . esc_html__( 'Enter the label for the post views counter field.', 'post-views-counter' ) . '</p>
245
- </fieldset>
246
- </div>';
247
  }
248
 
249
  /**
@@ -251,16 +257,16 @@ class Post_Views_Counter_Settings {
251
  */
252
  public function post_types_count() {
253
  echo '
254
- <div id="pvc_post_types_count">';
255
 
256
  foreach ( $this->post_types as $post_type => $post_type_name ) {
257
  echo '
258
- <label class="cb-checkbox"><input id="pvc_post_types_count-' . esc_attr( $post_type ) . '" type="checkbox" name="post_views_counter_settings_general[post_types_count][' . esc_attr( $post_type ) . ']" value="1" ' . checked( in_array( $post_type, Post_Views_Counter()->options['general']['post_types_count'], true ), true, false ) . ' />' . esc_html( $post_type_name ) . ' </label>';
259
  }
260
 
261
  echo '
262
- <p class="description">' . esc_html__( 'Select post types for which post views will be counted.', 'post-views-counter' ) . '</p>
263
- </div>';
264
  }
265
 
266
  /**
@@ -268,16 +274,16 @@ class Post_Views_Counter_Settings {
268
  */
269
  public function post_types_display() {
270
  echo '
271
- <div id="pvc_post_types_display">';
272
-
273
  foreach ( $this->post_types as $post_type => $post_type_name ) {
274
  echo '
275
- <label class="cb-checkbox"><input id="pvc_post_types_display-' . esc_attr( $post_type ) . '" type="checkbox" name="post_views_counter_settings_display[post_types_display][' . esc_attr( $post_type ) . ']" value="1" ' . checked( in_array( $post_type, Post_Views_Counter()->options['display']['post_types_display'], true ), true, false ) . ' />' . esc_html( $post_type_name ) . '</label>';
276
  }
277
 
278
  echo '
279
- <p class="description">' . esc_html__( 'Select post types for which the views count will be displayed.', 'post-views-counter' ) . '</p>
280
- </div>';
281
  }
282
 
283
  /**
@@ -285,18 +291,18 @@ class Post_Views_Counter_Settings {
285
  */
286
  public function counter_mode() {
287
  echo '
288
- <div id="pvc_counter_mode">';
289
 
290
  foreach ( $this->modes as $key => $value ) {
291
  $key = esc_attr( $key );
292
 
293
  echo '
294
- <label class="cb-radio"><input type="radio" name="post_views_counter_settings_general[counter_mode]" value="' . $key . '" ' . checked( $key, Post_Views_Counter()->options['general']['counter_mode'], false ) . ' />' . esc_html( $value ) . '</label>';
295
  }
296
 
297
  echo '
298
- <p class="description">' . esc_html__( 'Select the method of collecting post views data. If you are using any of the caching plugins select Javascript.', 'post-views-counter' ) . '</p>
299
- </div>';
300
  }
301
 
302
  /**
@@ -304,9 +310,9 @@ class Post_Views_Counter_Settings {
304
  */
305
  public function post_views_column() {
306
  echo '
307
- <div id="pvc_post_views_column">
308
- <label class="cb-checkbox"><input id="pvc-post-views-column-enable" type="checkbox" name="post_views_counter_settings_general[post_views_column]" value="1" ' . checked( true, Post_Views_Counter()->options['general']['post_views_column'], false ) . ' />' . esc_html__( 'Enable to display post views count column for each of the selected post types.', 'post-views-counter' ) . '</label>
309
- </div>';
310
  }
311
 
312
  /**
@@ -314,19 +320,19 @@ class Post_Views_Counter_Settings {
314
  */
315
  public function time_between_counts() {
316
  echo '
317
- <div id="pvc_time_between_counts">
318
- <input size="4" type="text" name="post_views_counter_settings_general[time_between_counts][number]" value="' . esc_attr( Post_Views_Counter()->options['general']['time_between_counts']['number'] ) . '" />
319
- <select class="pvc-chosen-short" name="post_views_counter_settings_general[time_between_counts][type]">';
320
 
321
  foreach ( $this->time_types as $type => $type_name ) {
322
  echo '
323
- <option value="' . esc_attr( $type ) . '" ' . selected( $type, Post_Views_Counter()->options['general']['time_between_counts']['type'], false ) . '>' . esc_html( $type_name ) . '</option>';
324
  }
325
 
326
  echo '
327
- </select>
328
- <p class="description">' . esc_html__( 'Enter the time between single user visit count.', 'post-views-counter' ) . '</p>
329
- </div>';
330
  }
331
 
332
  /**
@@ -334,19 +340,19 @@ class Post_Views_Counter_Settings {
334
  */
335
  public function reset_counts() {
336
  echo '
337
- <div id="pvc_reset_counts">
338
- <input size="4" type="text" name="post_views_counter_settings_general[reset_counts][number]" value="' . esc_attr( Post_Views_Counter()->options['general']['reset_counts']['number'] ) . '" />
339
- <select class="pvc-chosen-short" name="post_views_counter_settings_general[reset_counts][type]">';
340
 
341
  foreach ( $this->time_types as $type => $type_name ) {
342
  echo '
343
- <option value="' . esc_attr( $type ) . '" ' . selected( $type, Post_Views_Counter()->options['general']['reset_counts']['type'], false ) . '>' . esc_html( $type_name ) . '</option>';
344
  }
345
 
346
  echo '
347
- </select>
348
- <p class="description">' . esc_html__( 'Delete single day post views data older than specified above. Enter 0 (number zero) if you want to preserve your data regardless of its age.', 'post-views-counter' ) . '</p>
349
- </div>';
350
  }
351
 
352
  /**
@@ -354,19 +360,19 @@ class Post_Views_Counter_Settings {
354
  */
355
  public function flush_interval() {
356
  echo '
357
- <div id="pvc_flush_interval">
358
- <input size="4" type="text" name="post_views_counter_settings_general[flush_interval][number]" value="' . esc_attr( Post_Views_Counter()->options['general']['flush_interval']['number'] ) . '" />
359
- <select class="pvc-chosen-short" name="post_views_counter_settings_general[flush_interval][type]">';
360
 
361
  foreach ( $this->time_types as $type => $type_name ) {
362
  echo '
363
- <option value="' . esc_attr( $type ) . '" ' . selected( $type, Post_Views_Counter()->options['general']['flush_interval']['type'], false ) . '>' . esc_html( $type_name ) . '</option>';
364
  }
365
 
366
  echo '
367
- </select>
368
- <p class="description">' . __( 'How often to flush cached view counts from the object cache into the database. This feature is used only if a persistent object cache is detected and the interval is greater than 0 (number zero)). When used, view counts will be collected and stored in the object cache instead of the database and will then be asynchronously flushed to the database according to the specified interval.<br /><strong>Notice:</strong> Potential data loss may occur if the object cache is cleared/unavailable for the duration of the interval.', 'post-views-counter' ) . '</p>
369
- </div>';
370
  }
371
 
372
  /**
@@ -374,25 +380,27 @@ class Post_Views_Counter_Settings {
374
  */
375
  public function exclude() {
376
  echo '
377
- <div id="pvc_exclude">
378
- <fieldset>';
379
 
380
  foreach ( $this->groups as $type => $type_name ) {
381
  echo '
382
- <label class="cb-checkbox"><input id="pvc_exclude-' . $type . '" type="checkbox" name="post_views_counter_settings_general[exclude][groups][' . $type . ']" value="1" ' . checked( in_array( $type, Post_Views_Counter()->options['general']['exclude']['groups'], true ), true, false ) . ' />' . esc_html( $type_name ) . '</label>';
383
  }
384
 
385
- echo ' <p class="description">' . esc_html__( 'Use it to hide the post views counter from selected type of visitors.', 'post-views-counter' ) . '</p>
386
- <div class="pvc_user_roles"' . (in_array( 'roles', Post_Views_Counter()->options['general']['exclude']['groups'], true ) ? '' : ' style="display: none;"') . '>';
 
387
 
388
  foreach ( $this->user_roles as $role => $role_name ) {
389
- echo ' <label class="cb-checkbox"><input type="checkbox" name="post_views_counter_settings_general[exclude][roles][' . $role . ']" value="1" ' . checked( in_array( $role, Post_Views_Counter()->options['general']['exclude']['roles'], true ), true, false ) . '>' . esc_html( $role_name ) . '</label>';
 
390
  }
391
 
392
- echo ' <p class="description">' . esc_html__( 'Use it to hide the post views counter from selected user roles.', 'post-views-counter' ) . '</p>
393
- </div>
394
- </fieldset>
395
- </div>';
396
  }
397
 
398
  /**
@@ -401,28 +409,28 @@ class Post_Views_Counter_Settings {
401
  public function exclude_ips() {
402
  // lovely php 5.2 limitations
403
  $ips = Post_Views_Counter()->options['general']['exclude_ips'];
404
-
405
  echo '
406
- <div id="pvc_exclude_ips">';
407
 
408
  if ( ! empty( $ips ) ) {
409
  foreach ( $ips as $key => $ip ) {
410
  echo '
411
- <div class="ip-box">
412
- <input type="text" name="post_views_counter_settings_general[exclude_ips][]" value="' . esc_attr( $ip ) . '" /> <a href="#" class="remove-exclude-ip" title="' . esc_attr__( 'Remove', 'post-views-counter' ) . '">' . esc_attr__( 'Remove', 'post-views-counter' ) . '</a>
413
- </div>';
414
  }
415
  } else {
416
  echo '
417
- <div class="ip-box">
418
- <input type="text" name="post_views_counter_settings_general[exclude_ips][]" value="" /> <a href="#" class="remove-exclude-ip" title="' . esc_attr__( 'Remove', 'post-views-counter' ) . '">' . esc_attr__( 'Remove', 'post-views-counter' ) . '</a>
419
- </div>';
420
  }
421
 
422
  echo '
423
- <p><input type="button" class="button button-secondary add-exclude-ip" value="' . esc_attr__( 'Add new', 'post-views-counter' ) . '" /> <input type="button" class="button button-secondary add-current-ip" value="' . esc_attr__( 'Add my current IP', 'post-views-counter' ) . '" data-rel="' . esc_attr( $_SERVER['REMOTE_ADDR'] ) . '" /></p>
424
- <p class="description">' . esc_html__( 'Enter the IP addresses to be excluded from post views count.', 'post-views-counter' ) . '</p>
425
- </div>';
426
  }
427
 
428
  /**
@@ -430,23 +438,23 @@ class Post_Views_Counter_Settings {
430
  */
431
  public function wp_postviews() {
432
  echo '
433
- <div id="pvc_wp_postviews">
434
- <fieldset>
435
- <input type="submit" class="button button-secondary" name="post_views_counter_import_wp_postviews" value="' . __( 'Import', 'post-views-counter' ) . '"/>
436
- <p class="description">' . esc_html__( 'Import post views data from WP-PostViews plugin.', 'post-views-counter' ) . '</p>
437
- <label class="cb-checkbox"><input id="pvc-wp-postviews" type="checkbox" name="post_views_counter_import_wp_postviews_override" value="1" />' . esc_html__( 'Override existing Post Views Counter data.', 'post-views-counter' ) . '</label>
438
- </fieldset>
439
- </div>';
440
  }
441
-
442
  /**
443
  * Limit views edit to admins.
444
  */
445
  public function restrict_edit_views() {
446
  echo '
447
- <div id="pvc_restrict_edit_views">
448
- <label class="cb-checkbox"><input type="checkbox" name="post_views_counter_settings_general[restrict_edit_views]" value="1" ' . checked( true, Post_Views_Counter()->options['general']['restrict_edit_views'], false ) . ' />' . esc_html__( 'Enable to restrict post views editing to admins only.', 'post-views-counter' ) . '</label>
449
- </div>';
450
  }
451
 
452
  /**
@@ -454,26 +462,26 @@ class Post_Views_Counter_Settings {
454
  */
455
  public function deactivation_delete() {
456
  echo '
457
- <div id="pvc_deactivation_delete">
458
- <label class="cb-checkbox"><input type="checkbox" name="post_views_counter_settings_general[deactivation_delete]" value="1" ' . checked( true, Post_Views_Counter()->options['general']['deactivation_delete'], false ) . ' />' . esc_html__( 'Enable to delete all plugin data on deactivation.', 'post-views-counter' ) . '</label>
459
- </div>';
460
  }
461
-
462
  /**
463
  * Visibility option.
464
  */
465
  public function page_types_display() {
466
  echo '
467
- <div id="pvc_post_types_display">';
468
-
469
  foreach ( $this->page_types as $key => $label ) {
470
  echo '
471
- <label class="cb-checkbox"><input id="pvc_page_types_display-' . esc_attr( $key ) . '" type="checkbox" name="post_views_counter_settings_display[page_types_display][' . esc_attr( $key ) . ']" value="1" ' . checked( in_array( $key, Post_Views_Counter()->options['display']['page_types_display'], true ), true, false ) . ' />' . esc_html( $label ) . '</label>';
472
  }
473
 
474
  echo '
475
- <p class="description">' . esc_html__( 'Select page types where the views count will be displayed.', 'post-views-counter' ) . '</p>
476
- </div>';
477
  }
478
 
479
  /**
@@ -481,18 +489,18 @@ class Post_Views_Counter_Settings {
481
  */
482
  public function position() {
483
  echo '
484
- <div id="pvc_position">
485
- <select class="pvc-chosen-short" name="post_views_counter_settings_display[position]">';
486
 
487
  foreach ( $this->positions as $position => $position_name ) {
488
  echo '
489
- <option value="' . esc_attr( $position ) . '" ' . selected( $position, Post_Views_Counter()->options['display']['position'], false ) . '>' . esc_html( $position_name ) . '</option>';
490
  }
491
 
492
  echo '
493
- </select>
494
- <p class="description">' . esc_html__( 'Select where would you like to display the post views counter. Use [post-views] shortcode for manual display.', 'post-views-counter' ) . '</p>
495
- </div>';
496
  }
497
 
498
  /**
@@ -500,18 +508,18 @@ class Post_Views_Counter_Settings {
500
  */
501
  public function display_style() {
502
  echo '
503
- <div id="pvc_display_style">';
504
 
505
  foreach ( $this->display_styles as $display => $style ) {
506
  $display = esc_attr( $display );
507
 
508
  echo '
509
- <label class="cb-checkbox"><input type="checkbox" name="post_views_counter_settings_display[display_style][' . $display . ']" value="1" ' . checked( true, Post_Views_Counter()->options['display']['display_style'][$display], false ) . ' />' . esc_html( $style ) . '</label>';
510
  }
511
 
512
  echo '
513
- <p class="description">' . esc_html__( 'Choose how to display the post views counter.', 'post-views-counter' ) . '</p>
514
- </div>';
515
  }
516
 
517
  /**
@@ -519,10 +527,10 @@ class Post_Views_Counter_Settings {
519
  */
520
  public function icon_class() {
521
  echo '
522
- <div id="pvc_icon_class">
523
- <input type="text" name="post_views_counter_settings_display[icon_class]" class="large-text" value="' . esc_attr( Post_Views_Counter()->options['display']['icon_class'] ) . '" />
524
- <p class="description">' . sprintf( __( 'Enter the post views icon class. Any of the <a href="%s" target="_blank">Dashicons</a> classes are available.', 'post-views-counter' ), 'https://developer.wordpress.org/resource/dashicons/' ) . '</p>
525
- </div>';
526
  }
527
 
528
  /**
@@ -530,8 +538,8 @@ class Post_Views_Counter_Settings {
530
  */
531
  public function restrict_display() {
532
  echo '
533
- <div id="pvc_restrict_display">
534
- <fieldset>';
535
 
536
  foreach ( $this->groups as $type => $type_name ) {
537
 
@@ -539,20 +547,23 @@ class Post_Views_Counter_Settings {
539
  continue;
540
 
541
  echo '
542
- <label class="cb-checkbox"><input id="pvc_restrict_display-' . $type . '" type="checkbox" name="post_views_counter_settings_display[restrict_display][groups][' . esc_html( $type ) . ']" value="1" ' . checked( in_array( $type, Post_Views_Counter()->options['display']['restrict_display']['groups'], true ), true, false ) . ' />' . esc_html( $type_name ) . '</label>';
543
  }
544
 
545
- echo ' <p class="description">' . esc_html__( 'Use it to hide the post views counter from selected type of visitors.', 'post-views-counter' ) . '</p>
546
- <div class="pvc_user_roles"' . (in_array( 'roles', Post_Views_Counter()->options['display']['restrict_display']['groups'], true ) ? '' : ' style="display: none;"') . '>';
 
547
 
548
  foreach ( $this->user_roles as $role => $role_name ) {
549
- echo ' <label class="cb-checkbox"><input type="checkbox" name="post_views_counter_settings_display[restrict_display][roles][' . $role . ']" value="1" ' . checked( in_array( $role, Post_Views_Counter()->options['display']['restrict_display']['roles'], true ), true, false ) . ' />' . esc_html( $role_name ) . '</label>';
 
550
  }
551
 
552
- echo ' <p class="description">' . esc_html__( 'Use it to hide the post views counter from selected user roles.', 'post-views-counter' ) . '</p>
553
- </div>
554
- </fieldset>
555
- </div>';
 
556
  }
557
 
558
  /**
@@ -561,11 +572,11 @@ class Post_Views_Counter_Settings {
561
  public function validate_settings( $input ) {
562
  if ( isset( $_POST['post_views_counter_import_wp_postviews'] ) ) {
563
  global $wpdb;
564
-
565
  $meta_key = esc_attr( apply_filters( 'pvc_import_meta_key', 'views' ) );
566
 
567
  $views = $wpdb->get_results(
568
- "SELECT post_id, meta_value FROM " . $wpdb->postmeta . " WHERE meta_key = '" . $meta_key . "'", ARRAY_A, 0
569
  );
570
 
571
  if ( ! empty( $views ) ) {
@@ -605,7 +616,7 @@ class Post_Views_Counter_Settings {
605
  $input['post_views_column'] = $input['post_views_column'];
606
 
607
  // time between counts
608
- $input['time_between_counts']['number'] = (int)( isset( $input['time_between_counts']['number'] ) ? $input['time_between_counts']['number'] : Post_Views_Counter()->defaults['general']['time_between_counts']['number'] );
609
  $input['time_between_counts']['type'] = isset( $input['time_between_counts']['type'], $this->time_types[$input['time_between_counts']['type']] ) ? $input['time_between_counts']['type'] : Post_Views_Counter()->defaults['general']['time_between_counts']['type'];
610
 
611
  // flush interval
@@ -639,9 +650,8 @@ class Post_Views_Counter_Settings {
639
  if ( isset( $this->groups[$group] ) )
640
  $groups[] = $group;
641
  }
642
-
643
  $input['exclude']['groups'] = array_unique( $groups );
644
-
645
  } else {
646
  $input['exclude']['groups'] = array();
647
  }
@@ -674,7 +684,7 @@ class Post_Views_Counter_Settings {
674
 
675
  $input['exclude_ips'] = array_unique( $ips );
676
  }
677
-
678
  // restrict edit viewa
679
  $input['restrict_edit_views'] = isset( $input['restrict_edit_views'] ) ? $input['restrict_edit_views'] : Post_Views_Counter()->defaults['general']['restrict_edit_views'];
680
 
@@ -713,7 +723,7 @@ class Post_Views_Counter_Settings {
713
  $input['post_types_display'] = array_unique( $post_types );
714
  } else
715
  $input['post_types_display'] = array();
716
-
717
  // page types display
718
  if ( isset( $input['page_types_display'] ) ) {
719
  $page_types = array();
@@ -766,4 +776,5 @@ class Post_Views_Counter_Settings {
766
 
767
  return $input;
768
  }
 
769
  }
5
 
6
  /**
7
  * Post_Views_Counter_Settings class.
8
+ *
9
+ * @class Post_Views_Counter_Settings
10
  */
11
  class Post_Views_Counter_Settings {
12
 
33
  * Load default settings.
34
  */
35
  public function load_defaults() {
36
+
37
  if ( ! is_admin() )
38
  return;
39
+
40
  $this->modes = array(
41
  'php' => __( 'PHP', 'post-views-counter' ),
42
  'js' => __( 'JavaScript', 'post-views-counter' )
85
  );
86
 
87
  $this->user_roles = $this->get_user_roles();
88
+
89
  $this->page_types = apply_filters( 'pvc_page_types_display_options', array(
90
  'home' => __( 'Home', 'post-views-counter' ),
91
  'archive' => __( 'Archives', 'post-views-counter' ),
98
  * Get post types avaiable for counting.
99
  */
100
  public function load_post_types() {
101
+
102
  if ( ! is_admin() )
103
  return;
104
+
105
  $post_types = array();
106
 
107
  // built in public post types
123
 
124
  /**
125
  * Get all user roles.
126
+ *
127
+ * @global object $wp_roles
128
  */
129
  public function get_user_roles() {
130
  global $wp_roles;
145
  */
146
  public function admin_menu_options() {
147
  add_options_page(
148
+ __( 'Post Views Counter', 'post-views-counter' ), __( 'Post Views Counter', 'post-views-counter' ), 'manage_options', 'post-views-counter', array( $this, 'options_page' )
149
  );
150
  }
151
 
152
  /**
153
  * Options page callback.
154
+ *
155
+ * @return mixed
156
  */
157
  public function options_page() {
158
  $tab_key = (isset( $_GET['tab'] ) ? $_GET['tab'] : 'general');
159
 
160
  echo '
161
+ <div class="wrap">' . screen_icon() . '
162
+ <h2>' . __( 'Post Views Counter', 'post-views-counter' ) . '</h2>
163
+ <h2 class="nav-tab-wrapper">';
164
 
165
  foreach ( $this->tabs as $key => $name ) {
166
  echo '
167
+ <a class="nav-tab ' . ($tab_key == $key ? 'nav-tab-active' : '') . '" href="' . esc_url( admin_url( 'options-general.php?page=post-views-counter&tab=' . $key ) ) . '">' . $name['name'] . '</a>';
168
  }
169
 
170
  echo '
171
+ </h2>
172
+ <div class="post-views-counter-settings">
173
+ <div class="df-credits">
174
+ <h3 class="hndle">' . __( 'Post Views Counter', 'post-views-counter' ) . ' ' . Post_Views_Counter()->defaults['version'] . '</h3>
175
+ <div class="inside">
176
+ <h4 class="inner">' . __( 'Need support?', 'post-views-counter' ) . '</h4>
177
+ <p class="inner">' . __( 'If you are having problems with this plugin, please talk about them in the', 'post-views-counter' ) . ' <a href="http://www.dfactory.eu/support/?utm_source=post-views-counter-settings&utm_medium=link&utm_campaign=support" target="_blank" title="' . __( 'Support forum', 'post-views-counter' ) . '">' . __( 'Support forum', 'post-views-counter' ) . '</a></p>
178
+ <hr />
179
+ <h4 class="inner">' . __( 'Do you like this plugin?', 'post-views-counter' ) . '</h4>
180
+ <p class="inner"><a href="http://wordpress.org/support/view/plugin-reviews/post-views-counter" target="_blank" title="' . __( 'Rate it 5', 'post-views-counter' ) . '">' . __( 'Rate it 5', 'post-views-counter' ) . '</a> ' . __( 'on WordPress.org', 'post-views-counter' ) . '<br />' .
181
  __( 'Blog about it & link to the', 'post-views-counter' ) . ' <a href="http://www.dfactory.eu/plugins/post-views-counter/?utm_source=post-views-counter-settings&utm_medium=link&utm_campaign=blog-about" target="_blank" title="' . __( 'plugin page', 'post-views-counter' ) . '">' . __( 'plugin page', 'post-views-counter' ) . '</a><br/>' .
182
  __( 'Check out our other', 'post-views-counter' ) . ' <a href="http://www.dfactory.eu/plugins/?utm_source=post-views-counter-settings&utm_medium=link&utm_campaign=other-plugins" target="_blank" title="' . __( 'WordPress plugins', 'post-views-counter' ) . '">' . __( 'WordPress plugins', 'post-views-counter' ) . '</a>
183
+ </p>
184
+ <hr />
185
+ <p class="df-link inner">' . __( 'Created by', 'post-views-counter' ) . ' <a href="http://www.dfactory.eu/?utm_source=post-views-counter-settings&utm_medium=link&utm_campaign=created-by" target="_blank" title="dFactory - Quality plugins for WordPress"><img src="' . POST_VIEWS_COUNTER_URL . '/images/logo-dfactory.png' . '" title="dFactory - Quality plugins for WordPress" alt="dFactory - Quality plugins for WordPress" /></a></p>
186
+ </div>
187
+ </div>
188
+ <form action="options.php" method="post">';
189
 
190
  wp_nonce_field( 'update-options' );
191
  settings_fields( $this->tabs[$tab_key]['key'] );
192
  do_settings_sections( $this->tabs[$tab_key]['key'] );
193
 
194
  echo '
195
+ <p class="submit">';
196
 
197
  submit_button( '', 'primary', $this->tabs[$tab_key]['submit'], false );
198
 
201
  submit_button( __( 'Reset to defaults', 'post-views-counter' ), 'secondary reset_pvc_settings', $this->tabs[$tab_key]['reset'], false );
202
 
203
  echo '
204
+ </p>
205
+ </form>
206
+ </div>
207
+ <div class="clear"></div>
208
+ </div>';
209
  }
210
 
211
  /**
219
  add_settings_field( 'pvc_counter_mode', __( 'Counter Mode', 'post-views-counter' ), array( $this, 'counter_mode' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
220
  add_settings_field( 'pvc_post_views_column', __( 'Post Views Column', 'post-views-counter' ), array( $this, 'post_views_column' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
221
  add_settings_field( 'pvc_restrict_edit_views', __( 'Restrict Edit', 'post-views-counter' ), array( $this, 'restrict_edit_views' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
222
+ add_settings_field( 'pvc_time_between_counts', __( 'Count Interval', 'post-views-counter' ), array( $this, 'time_between_counts' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
223
  add_settings_field( 'pvc_reset_counts', __( 'Reset Data Interval', 'post-views-counter' ), array( $this, 'reset_counts' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
224
  add_settings_field( 'pvc_flush_interval', __( 'Flush Object Cache Interval', 'post-views-counter' ), array( $this, 'flush_interval' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
225
  add_settings_field( 'pvc_exclude', __( 'Exclude Visitors', 'post-views-counter' ), array( $this, 'exclude' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
226
  add_settings_field( 'pvc_exclude_ips', __( 'Exclude IPs', 'post-views-counter' ), array( $this, 'exclude_ips' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
227
+ add_settings_field( 'pvc_wp_postviews', __( 'WP-PostViews', 'post-views-counter' ), array( $this, 'wp_postviews' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
228
  add_settings_field( 'pvc_deactivation_delete', __( 'Deactivation', 'post-views-counter' ), array( $this, 'deactivation_delete' ), 'post_views_counter_settings_general', 'post_views_counter_settings_general' );
229
 
230
  // display options
244
  */
245
  public function post_views_label() {
246
  echo '
247
+ <div id="pvc_post_views_label">
248
+ <fieldset>
249
+ <input type="text" class="large-text" name="post_views_counter_settings_display[label]" value="' . esc_attr( Post_Views_Counter()->options['display']['label'] ) . '" />
250
+ <p class="description">' . esc_html__( 'Enter the label for the post views counter field.', 'post-views-counter' ) . '</p>
251
+ </fieldset>
252
+ </div>';
253
  }
254
 
255
  /**
257
  */
258
  public function post_types_count() {
259
  echo '
260
+ <div id="pvc_post_types_count">';
261
 
262
  foreach ( $this->post_types as $post_type => $post_type_name ) {
263
  echo '
264
+ <label class="cb-checkbox"><input id="pvc_post_types_count-' . esc_attr( $post_type ) . '" type="checkbox" name="post_views_counter_settings_general[post_types_count][' . esc_attr( $post_type ) . ']" value="1" ' . checked( in_array( $post_type, Post_Views_Counter()->options['general']['post_types_count'], true ), true, false ) . ' />' . esc_html( $post_type_name ) . ' </label>';
265
  }
266
 
267
  echo '
268
+ <p class="description">' . esc_html__( 'Select post types for which post views will be counted.', 'post-views-counter' ) . '</p>
269
+ </div>';
270
  }
271
 
272
  /**
274
  */
275
  public function post_types_display() {
276
  echo '
277
+ <div id="pvc_post_types_display">';
278
+
279
  foreach ( $this->post_types as $post_type => $post_type_name ) {
280
  echo '
281
+ <label class="cb-checkbox"><input id="pvc_post_types_display-' . esc_attr( $post_type ) . '" type="checkbox" name="post_views_counter_settings_display[post_types_display][' . esc_attr( $post_type ) . ']" value="1" ' . checked( in_array( $post_type, Post_Views_Counter()->options['display']['post_types_display'], true ), true, false ) . ' />' . esc_html( $post_type_name ) . '</label>';
282
  }
283
 
284
  echo '
285
+ <p class="description">' . esc_html__( 'Select post types for which the views count will be displayed.', 'post-views-counter' ) . '</p>
286
+ </div>';
287
  }
288
 
289
  /**
291
  */
292
  public function counter_mode() {
293
  echo '
294
+ <div id="pvc_counter_mode">';
295
 
296
  foreach ( $this->modes as $key => $value ) {
297
  $key = esc_attr( $key );
298
 
299
  echo '
300
+ <label class="cb-radio"><input type="radio" name="post_views_counter_settings_general[counter_mode]" value="' . $key . '" ' . checked( $key, Post_Views_Counter()->options['general']['counter_mode'], false ) . ' />' . esc_html( $value ) . '</label>';
301
  }
302
 
303
  echo '
304
+ <p class="description">' . esc_html__( 'Select the method of collecting post views data. If you are using any of the caching plugins select Javascript.', 'post-views-counter' ) . '</p>
305
+ </div>';
306
  }
307
 
308
  /**
310
  */
311
  public function post_views_column() {
312
  echo '
313
+ <div id="pvc_post_views_column">
314
+ <label class="cb-checkbox"><input id="pvc-post-views-column-enable" type="checkbox" name="post_views_counter_settings_general[post_views_column]" value="1" ' . checked( true, Post_Views_Counter()->options['general']['post_views_column'], false ) . ' />' . esc_html__( 'Enable to display post views count column for each of the selected post types.', 'post-views-counter' ) . '</label>
315
+ </div>';
316
  }
317
 
318
  /**
320
  */
321
  public function time_between_counts() {
322
  echo '
323
+ <div id="pvc_time_between_counts">
324
+ <input size="4" type="text" name="post_views_counter_settings_general[time_between_counts][number]" value="' . esc_attr( Post_Views_Counter()->options['general']['time_between_counts']['number'] ) . '" />
325
+ <select class="pvc-chosen-short" name="post_views_counter_settings_general[time_between_counts][type]">';
326
 
327
  foreach ( $this->time_types as $type => $type_name ) {
328
  echo '
329
+ <option value="' . esc_attr( $type ) . '" ' . selected( $type, Post_Views_Counter()->options['general']['time_between_counts']['type'], false ) . '>' . esc_html( $type_name ) . '</option>';
330
  }
331
 
332
  echo '
333
+ </select>
334
+ <p class="description">' . esc_html__( 'Enter the time between single user visit count.', 'post-views-counter' ) . '</p>
335
+ </div>';
336
  }
337
 
338
  /**
340
  */
341
  public function reset_counts() {
342
  echo '
343
+ <div id="pvc_reset_counts">
344
+ <input size="4" type="text" name="post_views_counter_settings_general[reset_counts][number]" value="' . esc_attr( Post_Views_Counter()->options['general']['reset_counts']['number'] ) . '" />
345
+ <select class="pvc-chosen-short" name="post_views_counter_settings_general[reset_counts][type]">';
346
 
347
  foreach ( $this->time_types as $type => $type_name ) {
348
  echo '
349
+ <option value="' . esc_attr( $type ) . '" ' . selected( $type, Post_Views_Counter()->options['general']['reset_counts']['type'], false ) . '>' . esc_html( $type_name ) . '</option>';
350
  }
351
 
352
  echo '
353
+ </select>
354
+ <p class="description">' . esc_html__( 'Delete single day post views data older than specified above. Enter 0 (number zero) if you want to preserve your data regardless of its age.', 'post-views-counter' ) . '</p>
355
+ </div>';
356
  }
357
 
358
  /**
360
  */
361
  public function flush_interval() {
362
  echo '
363
+ <div id="pvc_flush_interval">
364
+ <input size="4" type="text" name="post_views_counter_settings_general[flush_interval][number]" value="' . esc_attr( Post_Views_Counter()->options['general']['flush_interval']['number'] ) . '" />
365
+ <select class="pvc-chosen-short" name="post_views_counter_settings_general[flush_interval][type]">';
366
 
367
  foreach ( $this->time_types as $type => $type_name ) {
368
  echo '
369
+ <option value="' . esc_attr( $type ) . '" ' . selected( $type, Post_Views_Counter()->options['general']['flush_interval']['type'], false ) . '>' . esc_html( $type_name ) . '</option>';
370
  }
371
 
372
  echo '
373
+ </select>
374
+ <p class="description">' . __( 'How often to flush cached view counts from the object cache into the database. This feature is used only if a persistent object cache is detected and the interval is greater than 0 (number zero)). When used, view counts will be collected and stored in the object cache instead of the database and will then be asynchronously flushed to the database according to the specified interval.<br /><strong>Notice:</strong> Potential data loss may occur if the object cache is cleared/unavailable for the duration of the interval.', 'post-views-counter' ) . '</p>
375
+ </div>';
376
  }
377
 
378
  /**
380
  */
381
  public function exclude() {
382
  echo '
383
+ <div id="pvc_exclude">
384
+ <fieldset>';
385
 
386
  foreach ( $this->groups as $type => $type_name ) {
387
  echo '
388
+ <label class="cb-checkbox"><input id="pvc_exclude-' . $type . '" type="checkbox" name="post_views_counter_settings_general[exclude][groups][' . $type . ']" value="1" ' . checked( in_array( $type, Post_Views_Counter()->options['general']['exclude']['groups'], true ), true, false ) . ' />' . esc_html( $type_name ) . '</label>';
389
  }
390
 
391
+ echo '
392
+ <p class="description">' . esc_html__( 'Use it to hide the post views counter from selected type of visitors.', 'post-views-counter' ) . '</p>
393
+ <div class="pvc_user_roles"' . (in_array( 'roles', Post_Views_Counter()->options['general']['exclude']['groups'], true ) ? '' : ' style="display: none;"') . '>';
394
 
395
  foreach ( $this->user_roles as $role => $role_name ) {
396
+ echo '
397
+ <label class="cb-checkbox"><input type="checkbox" name="post_views_counter_settings_general[exclude][roles][' . $role . ']" value="1" ' . checked( in_array( $role, Post_Views_Counter()->options['general']['exclude']['roles'], true ), true, false ) . '>' . esc_html( $role_name ) . '</label>';
398
  }
399
 
400
+ echo ' <p class="description">' . esc_html__( 'Use it to hide the post views counter from selected user roles.', 'post-views-counter' ) . '</p>
401
+ </div>
402
+ </fieldset>
403
+ </div>';
404
  }
405
 
406
  /**
409
  public function exclude_ips() {
410
  // lovely php 5.2 limitations
411
  $ips = Post_Views_Counter()->options['general']['exclude_ips'];
412
+
413
  echo '
414
+ <div id="pvc_exclude_ips">';
415
 
416
  if ( ! empty( $ips ) ) {
417
  foreach ( $ips as $key => $ip ) {
418
  echo '
419
+ <div class="ip-box">
420
+ <input type="text" name="post_views_counter_settings_general[exclude_ips][]" value="' . esc_attr( $ip ) . '" /> <a href="#" class="remove-exclude-ip" title="' . esc_attr__( 'Remove', 'post-views-counter' ) . '">' . esc_attr__( 'Remove', 'post-views-counter' ) . '</a>
421
+ </div>';
422
  }
423
  } else {
424
  echo '
425
+ <div class="ip-box">
426
+ <input type="text" name="post_views_counter_settings_general[exclude_ips][]" value="" /> <a href="#" class="remove-exclude-ip" title="' . esc_attr__( 'Remove', 'post-views-counter' ) . '">' . esc_attr__( 'Remove', 'post-views-counter' ) . '</a>
427
+ </div>';
428
  }
429
 
430
  echo '
431
+ <p><input type="button" class="button button-secondary add-exclude-ip" value="' . esc_attr__( 'Add new', 'post-views-counter' ) . '" /> <input type="button" class="button button-secondary add-current-ip" value="' . esc_attr__( 'Add my current IP', 'post-views-counter' ) . '" data-rel="' . esc_attr( $_SERVER['REMOTE_ADDR'] ) . '" /></p>
432
+ <p class="description">' . esc_html__( 'Enter the IP addresses to be excluded from post views count.', 'post-views-counter' ) . '</p>
433
+ </div>';
434
  }
435
 
436
  /**
438
  */
439
  public function wp_postviews() {
440
  echo '
441
+ <div id="pvc_wp_postviews">
442
+ <fieldset>
443
+ <input type="submit" class="button button-secondary" name="post_views_counter_import_wp_postviews" value="' . __( 'Import', 'post-views-counter' ) . '"/>
444
+ <p class="description">' . esc_html__( 'Import post views data from WP-PostViews plugin.', 'post-views-counter' ) . '</p>
445
+ <label class="cb-checkbox"><input id="pvc-wp-postviews" type="checkbox" name="post_views_counter_import_wp_postviews_override" value="1" />' . esc_html__( 'Override existing Post Views Counter data.', 'post-views-counter' ) . '</label>
446
+ </fieldset>
447
+ </div>';
448
  }
449
+
450
  /**
451
  * Limit views edit to admins.
452
  */
453
  public function restrict_edit_views() {
454
  echo '
455
+ <div id="pvc_restrict_edit_views">
456
+ <label class="cb-checkbox"><input type="checkbox" name="post_views_counter_settings_general[restrict_edit_views]" value="1" ' . checked( true, Post_Views_Counter()->options['general']['restrict_edit_views'], false ) . ' />' . esc_html__( 'Enable to restrict post views editing to admins only.', 'post-views-counter' ) . '</label>
457
+ </div>';
458
  }
459
 
460
  /**
462
  */
463
  public function deactivation_delete() {
464
  echo '
465
+ <div id="pvc_deactivation_delete">
466
+ <label class="cb-checkbox"><input type="checkbox" name="post_views_counter_settings_general[deactivation_delete]" value="1" ' . checked( true, Post_Views_Counter()->options['general']['deactivation_delete'], false ) . ' />' . esc_html__( 'Enable to delete all plugin data on deactivation.', 'post-views-counter' ) . '</label>
467
+ </div>';
468
  }
469
+
470
  /**
471
  * Visibility option.
472
  */
473
  public function page_types_display() {
474
  echo '
475
+ <div id="pvc_post_types_display">';
476
+
477
  foreach ( $this->page_types as $key => $label ) {
478
  echo '
479
+ <label class="cb-checkbox"><input id="pvc_page_types_display-' . esc_attr( $key ) . '" type="checkbox" name="post_views_counter_settings_display[page_types_display][' . esc_attr( $key ) . ']" value="1" ' . checked( in_array( $key, Post_Views_Counter()->options['display']['page_types_display'], true ), true, false ) . ' />' . esc_html( $label ) . '</label>';
480
  }
481
 
482
  echo '
483
+ <p class="description">' . esc_html__( 'Select page types where the views count will be displayed.', 'post-views-counter' ) . '</p>
484
+ </div>';
485
  }
486
 
487
  /**
489
  */
490
  public function position() {
491
  echo '
492
+ <div id="pvc_position">
493
+ <select class="pvc-chosen-short" name="post_views_counter_settings_display[position]">';
494
 
495
  foreach ( $this->positions as $position => $position_name ) {
496
  echo '
497
+ <option value="' . esc_attr( $position ) . '" ' . selected( $position, Post_Views_Counter()->options['display']['position'], false ) . '>' . esc_html( $position_name ) . '</option>';
498
  }
499
 
500
  echo '
501
+ </select>
502
+ <p class="description">' . esc_html__( 'Select where would you like to display the post views counter. Use [post-views] shortcode for manual display.', 'post-views-counter' ) . '</p>
503
+ </div>';
504
  }
505
 
506
  /**
508
  */
509
  public function display_style() {
510
  echo '
511
+ <div id="pvc_display_style">';
512
 
513
  foreach ( $this->display_styles as $display => $style ) {
514
  $display = esc_attr( $display );
515
 
516
  echo '
517
+ <label class="cb-checkbox"><input type="checkbox" name="post_views_counter_settings_display[display_style][' . $display . ']" value="1" ' . checked( true, Post_Views_Counter()->options['display']['display_style'][$display], false ) . ' />' . esc_html( $style ) . '</label>';
518
  }
519
 
520
  echo '
521
+ <p class="description">' . esc_html__( 'Choose how to display the post views counter.', 'post-views-counter' ) . '</p>
522
+ </div>';
523
  }
524
 
525
  /**
527
  */
528
  public function icon_class() {
529
  echo '
530
+ <div id="pvc_icon_class">
531
+ <input type="text" name="post_views_counter_settings_display[icon_class]" class="large-text" value="' . esc_attr( Post_Views_Counter()->options['display']['icon_class'] ) . '" />
532
+ <p class="description">' . sprintf( __( 'Enter the post views icon class. Any of the <a href="%s" target="_blank">Dashicons</a> classes are available.', 'post-views-counter' ), 'https://developer.wordpress.org/resource/dashicons/' ) . '</p>
533
+ </div>';
534
  }
535
 
536
  /**
538
  */
539
  public function restrict_display() {
540
  echo '
541
+ <div id="pvc_restrict_display">
542
+ <fieldset>';
543
 
544
  foreach ( $this->groups as $type => $type_name ) {
545
 
547
  continue;
548
 
549
  echo '
550
+ <label class="cb-checkbox"><input id="pvc_restrict_display-' . $type . '" type="checkbox" name="post_views_counter_settings_display[restrict_display][groups][' . esc_html( $type ) . ']" value="1" ' . checked( in_array( $type, Post_Views_Counter()->options['display']['restrict_display']['groups'], true ), true, false ) . ' />' . esc_html( $type_name ) . '</label>';
551
  }
552
 
553
+ echo '
554
+ <p class="description">' . esc_html__( 'Use it to hide the post views counter from selected type of visitors.', 'post-views-counter' ) . '</p>
555
+ <div class="pvc_user_roles"' . (in_array( 'roles', Post_Views_Counter()->options['display']['restrict_display']['groups'], true ) ? '' : ' style="display: none;"') . '>';
556
 
557
  foreach ( $this->user_roles as $role => $role_name ) {
558
+ echo '
559
+ <label class="cb-checkbox"><input type="checkbox" name="post_views_counter_settings_display[restrict_display][roles][' . $role . ']" value="1" ' . checked( in_array( $role, Post_Views_Counter()->options['display']['restrict_display']['roles'], true ), true, false ) . ' />' . esc_html( $role_name ) . '</label>';
560
  }
561
 
562
+ echo '
563
+ <p class="description">' . esc_html__( 'Use it to hide the post views counter from selected user roles.', 'post-views-counter' ) . '</p>
564
+ </div>
565
+ </fieldset>
566
+ </div>';
567
  }
568
 
569
  /**
572
  public function validate_settings( $input ) {
573
  if ( isset( $_POST['post_views_counter_import_wp_postviews'] ) ) {
574
  global $wpdb;
575
+
576
  $meta_key = esc_attr( apply_filters( 'pvc_import_meta_key', 'views' ) );
577
 
578
  $views = $wpdb->get_results(
579
+ "SELECT post_id, meta_value FROM " . $wpdb->postmeta . " WHERE meta_key = '" . $meta_key . "'", ARRAY_A, 0
580
  );
581
 
582
  if ( ! empty( $views ) ) {
616
  $input['post_views_column'] = $input['post_views_column'];
617
 
618
  // time between counts
619
+ $input['time_between_counts']['number'] = (int) ( isset( $input['time_between_counts']['number'] ) ? $input['time_between_counts']['number'] : Post_Views_Counter()->defaults['general']['time_between_counts']['number'] );
620
  $input['time_between_counts']['type'] = isset( $input['time_between_counts']['type'], $this->time_types[$input['time_between_counts']['type']] ) ? $input['time_between_counts']['type'] : Post_Views_Counter()->defaults['general']['time_between_counts']['type'];
621
 
622
  // flush interval
650
  if ( isset( $this->groups[$group] ) )
651
  $groups[] = $group;
652
  }
653
+
654
  $input['exclude']['groups'] = array_unique( $groups );
 
655
  } else {
656
  $input['exclude']['groups'] = array();
657
  }
684
 
685
  $input['exclude_ips'] = array_unique( $ips );
686
  }
687
+
688
  // restrict edit viewa
689
  $input['restrict_edit_views'] = isset( $input['restrict_edit_views'] ) ? $input['restrict_edit_views'] : Post_Views_Counter()->defaults['general']['restrict_edit_views'];
690
 
723
  $input['post_types_display'] = array_unique( $post_types );
724
  } else
725
  $input['post_types_display'] = array();
726
+
727
  // page types display
728
  if ( isset( $input['page_types_display'] ) ) {
729
  $page_types = array();
776
 
777
  return $input;
778
  }
779
+
780
  }
includes/update.php CHANGED
@@ -5,6 +5,8 @@ if ( ! defined( 'ABSPATH' ) )
5
 
6
  /**
7
  * Post_Views_Counter_Update class.
 
 
8
  */
9
  class Post_Views_Counter_Update {
10
 
@@ -26,7 +28,7 @@ class Post_Views_Counter_Update {
26
  // new version?
27
  if ( version_compare( $current_db_version, Post_Views_Counter()->defaults['version'], '<' ) ) {
28
  // update plugin version
29
- update_option( 'post_views_counter_version', Post_Views_Counter()->defaults['version'] );
30
  }
31
  }
32
 
5
 
6
  /**
7
  * Post_Views_Counter_Update class.
8
+ *
9
+ * @class Post_Views_Counter_Update
10
  */
11
  class Post_Views_Counter_Update {
12
 
28
  // new version?
29
  if ( version_compare( $current_db_version, Post_Views_Counter()->defaults['version'], '<' ) ) {
30
  // update plugin version
31
+ update_option( 'post_views_counter_version', Post_Views_Counter()->defaults['version'], false );
32
  }
33
  }
34
 
includes/widgets.php CHANGED
@@ -5,6 +5,8 @@ if ( ! defined( 'ABSPATH' ) )
5
 
6
  /**
7
  * Post_Views_Counter_Widgets class.
 
 
8
  */
9
  class Post_Views_Counter_Widgets {
10
 
@@ -24,10 +26,11 @@ class Post_Views_Counter_Widgets {
24
 
25
  /**
26
  * Post_Views_Counter_List_Widget class.
 
 
27
  */
28
  class Post_Views_Counter_List_Widget extends WP_Widget {
29
 
30
- private $pvc_options;
31
  private $pvc_defaults;
32
  private $pvc_post_types;
33
  private $pvc_order_types;
@@ -35,25 +38,21 @@ class Post_Views_Counter_List_Widget extends WP_Widget {
35
 
36
  public function __construct() {
37
  parent::__construct(
38
- 'Post_Views_Counter_List_Widget', __( 'Most Viewed Posts', 'post-views-counter' ), array(
39
  'description' => __( 'Displays a list of the most viewed posts', 'post-views-counter' )
40
- )
41
- );
42
-
43
- $this->pvc_options = array_merge(
44
- array( 'general' => get_option( 'events_maker_general' ) )
45
  );
46
 
47
  $this->pvc_defaults = array(
48
- 'title' => __( 'Most Viewed Posts', 'post-views-counter' ),
49
- 'number_of_posts' => 5,
50
- 'thumbnail_size' => 'thumbnail',
51
- 'post_type' => array(),
52
- 'order' => 'desc',
53
- 'show_post_views' => true,
54
- 'show_post_thumbnail' => false,
55
- 'show_post_excerpt' => false,
56
- 'no_posts_message' => __( 'No Posts found', 'post-views-counter' )
57
  );
58
 
59
  $this->pvc_order_types = array(
@@ -73,15 +72,18 @@ class Post_Views_Counter_List_Widget extends WP_Widget {
73
  * Get selected post types.
74
  */
75
  public function load_post_types() {
76
-
77
  if ( ! is_admin() )
78
  return;
79
-
80
  $this->pvc_post_types = Post_Views_Counter()->settings->post_types;
81
  }
82
 
83
  /**
84
- * Display widget function.
 
 
 
85
  */
86
  public function widget( $args, $instance ) {
87
  $instance['title'] = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
@@ -93,75 +95,80 @@ class Post_Views_Counter_List_Widget extends WP_Widget {
93
  echo $html;
94
  }
95
 
96
- /**
97
- * Admin widget function.
 
 
98
  */
99
  public function form( $instance ) {
100
  $html = '
101
- <p>
102
- <label for="' . $this->get_field_id( 'title' ) . '">' . __( 'Title', 'post-views-counter' ) . ':</label>
103
- <input id="' . $this->get_field_id( 'title' ) . '" class="widefat" name="' . $this->get_field_name( 'title' ) . '" type="text" value="' . esc_attr( isset( $instance['title'] ) ? $instance['title'] : $this->pvc_defaults['title'] ) . '" />
104
- </p>
105
- <p>
106
- <label>' . __( 'Post Types', 'post-views-counter' ) . ':</label><br />';
107
 
108
  foreach ( $this->pvc_post_types as $post_type => $post_type_name ) {
109
  $html .= '
110
- <input id="' . $this->get_field_id( 'post_type' ) . '-' . $post_type . '" type="checkbox" name="' . $this->get_field_name( 'post_type' ) . '[]" value="' . $post_type . '" ' . checked( ( ! isset( $instance['post_type'] ) ? true : in_array( $post_type, $instance['post_type'], true ) ), true, false ) . '><label for="' . $this->get_field_id( 'post_type' ) . '-' . $post_type . '">' . esc_html( $post_type_name ) . '</label>';
111
  }
112
 
113
  $show_post_thumbnail = isset( $instance['show_post_thumbnail'] ) ? $instance['show_post_thumbnail'] : $this->pvc_defaults['show_post_thumbnail'];
114
 
115
  $html .= '
116
- </select>
117
- </p>
118
- <p>
119
- <label for="' . $this->get_field_id( 'number_of_posts' ) . '">' . __( 'Number of posts to show', 'post-views-counter' ) . ':</label>
120
- <input id="' . $this->get_field_id( 'number_of_posts' ) . '" name="' . $this->get_field_name( 'number_of_posts' ) . '" type="text" size="3" value="' . esc_attr( isset( $instance['number_of_posts'] ) ? $instance['number_of_posts'] : $this->pvc_defaults['number_of_posts'] ) . '" />
121
- </p>
122
- <p>
123
- <label for="' . $this->get_field_id( 'no_posts_message' ) . '">' . __( 'No posts message', 'post-views-counter' ) . ':</label>
124
- <input id="' . $this->get_field_id( 'no_posts_message' ) . '" class="widefat" type="text" name="' . $this->get_field_name( 'no_posts_message' ) . '" value="' . esc_attr( isset( $instance['no_posts_message'] ) ? $instance['no_posts_message'] : $this->pvc_defaults['no_posts_message'] ) . '" />
125
- </p>
126
- <p>
127
- <label for="' . $this->get_field_id( 'order' ) . '">' . __( 'Order', 'post-views-counter' ) . ':</label>
128
- <select id="' . $this->get_field_id( 'order' ) . '" name="' . $this->get_field_name( 'order' ) . '">';
129
 
130
  foreach ( $this->pvc_order_types as $id => $order ) {
131
  $html .= '
132
- <option value="' . esc_attr( $id ) . '" ' . selected( $id, ( isset( $instance['order'] ) ? $instance['order'] : $this->pvc_defaults['order'] ), false ) . '>' . $order . '</option>';
133
  }
134
 
135
  $html .= '
136
- </select>
137
- </p>
138
- <p>
139
- <input id="' . $this->get_field_id( 'show_post_views' ) . '" type="checkbox" name="' . $this->get_field_name( 'show_post_views' ) . '" ' . checked( true, (isset( $instance['show_post_views'] ) ? $instance['show_post_views'] : $this->pvc_defaults['show_post_views'] ), false ) . ' /> <label for="' . $this->get_field_id( 'show_post_views' ) . '">' . __( 'Display post views?', 'post-views-counter' ) . '</label>
140
- <br />
141
- <input id="' . $this->get_field_id( 'show_post_excerpt' ) . '" type="checkbox" name="' . $this->get_field_name( 'show_post_excerpt' ) . '" ' . checked( true, (isset( $instance['show_post_excerpt'] ) ? $instance['show_post_excerpt'] : $this->pvc_defaults['show_post_excerpt'] ), false ) . ' /> <label for="' . $this->get_field_id( 'show_post_excerpt' ) . '">' . __( 'Display post excerpt?', 'post-views-counter' ) . '</label>
142
- <br />
143
- <input id="' . $this->get_field_id( 'show_post_thumbnail' ) . '" class="em-show-event-thumbnail" type="checkbox" name="' . $this->get_field_name( 'show_post_thumbnail' ) . '" ' . checked( true, $show_post_thumbnail, false ) . ' /> <label for="' . $this->get_field_id( 'show_post_thumbnail' ) . '">' . __( 'Display post thumbnail?', 'post-views-counter' ) . '</label>
144
- </p>
145
- <p class="em-event-thumbnail-size"' . ($show_post_thumbnail ? '' : ' style="display: none;"') . '>
146
- <label for="' . $this->get_field_id( 'thumbnail_size' ) . '">' . __( 'Thumbnail size', 'post-views-counter' ) . ':</label>
147
- <select id="' . $this->get_field_id( 'thumbnail_size' ) . '" name="' . $this->get_field_name( 'thumbnail_size' ) . '">';
148
 
149
  $size_type = isset( $instance['thumbnail_size'] ) ? $instance['thumbnail_size'] : $this->pvc_defaults['thumbnail_size'];
150
 
151
  foreach ( $this->pvc_image_sizes as $size ) {
152
  $html .= '
153
- <option value="' . esc_attr( $size ) . '" ' . selected( $size, $size_type, false ) . '>' . $size . '</option>';
154
  }
155
 
156
  $html .= '
157
- </select>
158
- </p>';
159
 
160
  echo $html;
161
  }
162
 
163
  /**
164
- * Save widget function.
 
 
 
 
165
  */
166
  public function update( $new_instance, $old_instance ) {
167
  // number of posts
@@ -179,8 +186,8 @@ class Post_Views_Counter_List_Widget extends WP_Widget {
179
  $old_instance['show_post_excerpt'] = isset( $new_instance['show_post_excerpt'] );
180
 
181
  // texts
182
- $old_instance['title'] = sanitize_text_field( isset( $new_instance['title'] ) ? $new_instance['title'] : $this->pvc_defaults['title'] );
183
- $old_instance['no_posts_message'] = sanitize_text_field( isset( $new_instance['no_posts_message'] ) ? $new_instance['no_posts_message'] : $this->pvc_defaults['no_posts_message'] );
184
 
185
  // post types
186
  if ( isset( $new_instance['post_type'] ) ) {
5
 
6
  /**
7
  * Post_Views_Counter_Widgets class.
8
+ *
9
+ * @class Post_Views_Counter_Widgets
10
  */
11
  class Post_Views_Counter_Widgets {
12
 
26
 
27
  /**
28
  * Post_Views_Counter_List_Widget class.
29
+ *
30
+ * @class Post_Views_Counter_List_Widget
31
  */
32
  class Post_Views_Counter_List_Widget extends WP_Widget {
33
 
 
34
  private $pvc_defaults;
35
  private $pvc_post_types;
36
  private $pvc_order_types;
38
 
39
  public function __construct() {
40
  parent::__construct(
41
+ 'Post_Views_Counter_List_Widget', __( 'Most Viewed Posts', 'post-views-counter' ), array(
42
  'description' => __( 'Displays a list of the most viewed posts', 'post-views-counter' )
43
+ )
 
 
 
 
44
  );
45
 
46
  $this->pvc_defaults = array(
47
+ 'title' => __( 'Most Viewed Posts', 'post-views-counter' ),
48
+ 'number_of_posts' => 5,
49
+ 'thumbnail_size' => 'thumbnail',
50
+ 'post_type' => array(),
51
+ 'order' => 'desc',
52
+ 'show_post_views' => true,
53
+ 'show_post_thumbnail' => false,
54
+ 'show_post_excerpt' => false,
55
+ 'no_posts_message' => __( 'No Posts found', 'post-views-counter' )
56
  );
57
 
58
  $this->pvc_order_types = array(
72
  * Get selected post types.
73
  */
74
  public function load_post_types() {
75
+
76
  if ( ! is_admin() )
77
  return;
78
+
79
  $this->pvc_post_types = Post_Views_Counter()->settings->post_types;
80
  }
81
 
82
  /**
83
+ * Display widget.
84
+ *
85
+ * @param array $args
86
+ * @param object $instance
87
  */
88
  public function widget( $args, $instance ) {
89
  $instance['title'] = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
95
  echo $html;
96
  }
97
 
98
+ /** Render widget form.
99
+ *
100
+ * @param object $instance
101
+ * @return mixed
102
  */
103
  public function form( $instance ) {
104
  $html = '
105
+ <p>
106
+ <label for="' . $this->get_field_id( 'title' ) . '">' . __( 'Title', 'post-views-counter' ) . ':</label>
107
+ <input id="' . $this->get_field_id( 'title' ) . '" class="widefat" name="' . $this->get_field_name( 'title' ) . '" type="text" value="' . esc_attr( isset( $instance['title'] ) ? $instance['title'] : $this->pvc_defaults['title'] ) . '" />
108
+ </p>
109
+ <p>
110
+ <label>' . __( 'Post Types', 'post-views-counter' ) . ':</label><br />';
111
 
112
  foreach ( $this->pvc_post_types as $post_type => $post_type_name ) {
113
  $html .= '
114
+ <input id="' . $this->get_field_id( 'post_type' ) . '-' . $post_type . '" type="checkbox" name="' . $this->get_field_name( 'post_type' ) . '[]" value="' . $post_type . '" ' . checked( ( ! isset( $instance['post_type'] ) ? true : in_array( $post_type, $instance['post_type'], true ) ), true, false ) . '><label for="' . $this->get_field_id( 'post_type' ) . '-' . $post_type . '">' . esc_html( $post_type_name ) . '</label>';
115
  }
116
 
117
  $show_post_thumbnail = isset( $instance['show_post_thumbnail'] ) ? $instance['show_post_thumbnail'] : $this->pvc_defaults['show_post_thumbnail'];
118
 
119
  $html .= '
120
+ </p>
121
+ <p>
122
+ <label for="' . $this->get_field_id( 'number_of_posts' ) . '">' . __( 'Number of posts to show', 'post-views-counter' ) . ':</label>
123
+ <input id="' . $this->get_field_id( 'number_of_posts' ) . '" name="' . $this->get_field_name( 'number_of_posts' ) . '" type="text" size="3" value="' . esc_attr( isset( $instance['number_of_posts'] ) ? $instance['number_of_posts'] : $this->pvc_defaults['number_of_posts'] ) . '" />
124
+ </p>
125
+ <p>
126
+ <label for="' . $this->get_field_id( 'no_posts_message' ) . '">' . __( 'No posts message', 'post-views-counter' ) . ':</label>
127
+ <input id="' . $this->get_field_id( 'no_posts_message' ) . '" class="widefat" type="text" name="' . $this->get_field_name( 'no_posts_message' ) . '" value="' . esc_attr( isset( $instance['no_posts_message'] ) ? $instance['no_posts_message'] : $this->pvc_defaults['no_posts_message'] ) . '" />
128
+ </p>
129
+ <p>
130
+ <label for="' . $this->get_field_id( 'order' ) . '">' . __( 'Order', 'post-views-counter' ) . ':</label>
131
+ <select id="' . $this->get_field_id( 'order' ) . '" name="' . $this->get_field_name( 'order' ) . '">';
 
132
 
133
  foreach ( $this->pvc_order_types as $id => $order ) {
134
  $html .= '
135
+ <option value="' . esc_attr( $id ) . '" ' . selected( $id, ( isset( $instance['order'] ) ? $instance['order'] : $this->pvc_defaults['order'] ), false ) . '>' . $order . '</option>';
136
  }
137
 
138
  $html .= '
139
+ </select>
140
+ </p>
141
+ <p>
142
+ <input id="' . $this->get_field_id( 'show_post_views' ) . '" type="checkbox" name="' . $this->get_field_name( 'show_post_views' ) . '" ' . checked( true, (isset( $instance['show_post_views'] ) ? $instance['show_post_views'] : $this->pvc_defaults['show_post_views'] ), false ) . ' /> <label for="' . $this->get_field_id( 'show_post_views' ) . '">' . __( 'Display post views?', 'post-views-counter' ) . '</label>
143
+ <br />
144
+ <input id="' . $this->get_field_id( 'show_post_excerpt' ) . '" type="checkbox" name="' . $this->get_field_name( 'show_post_excerpt' ) . '" ' . checked( true, (isset( $instance['show_post_excerpt'] ) ? $instance['show_post_excerpt'] : $this->pvc_defaults['show_post_excerpt'] ), false ) . ' /> <label for="' . $this->get_field_id( 'show_post_excerpt' ) . '">' . __( 'Display post excerpt?', 'post-views-counter' ) . '</label>
145
+ <br />
146
+ <input id="' . $this->get_field_id( 'show_post_thumbnail' ) . '" class="em-show-event-thumbnail" type="checkbox" name="' . $this->get_field_name( 'show_post_thumbnail' ) . '" ' . checked( true, $show_post_thumbnail, false ) . ' /> <label for="' . $this->get_field_id( 'show_post_thumbnail' ) . '">' . __( 'Display post thumbnail?', 'post-views-counter' ) . '</label>
147
+ </p>
148
+ <p class="em-event-thumbnail-size"' . ($show_post_thumbnail ? '' : ' style="display: none;"') . '>
149
+ <label for="' . $this->get_field_id( 'thumbnail_size' ) . '">' . __( 'Thumbnail size', 'post-views-counter' ) . ':</label>
150
+ <select id="' . $this->get_field_id( 'thumbnail_size' ) . '" name="' . $this->get_field_name( 'thumbnail_size' ) . '">';
151
 
152
  $size_type = isset( $instance['thumbnail_size'] ) ? $instance['thumbnail_size'] : $this->pvc_defaults['thumbnail_size'];
153
 
154
  foreach ( $this->pvc_image_sizes as $size ) {
155
  $html .= '
156
+ <option value="' . esc_attr( $size ) . '" ' . selected( $size, $size_type, false ) . '>' . $size . '</option>';
157
  }
158
 
159
  $html .= '
160
+ </select>
161
+ </p>';
162
 
163
  echo $html;
164
  }
165
 
166
  /**
167
+ * Save widget form.
168
+ *
169
+ * @param array $new_instance
170
+ * @param array $old_instance
171
+ * @return array
172
  */
173
  public function update( $new_instance, $old_instance ) {
174
  // number of posts
186
  $old_instance['show_post_excerpt'] = isset( $new_instance['show_post_excerpt'] );
187
 
188
  // texts
189
+ $old_instance['title'] = sanitize_text_field( isset( $new_instance['title'] ) ? $new_instance['title'] : $this->pvc_defaults['title'] );
190
+ $old_instance['no_posts_message'] = sanitize_text_field( isset( $new_instance['no_posts_message'] ) ? $new_instance['no_posts_message'] : $this->pvc_defaults['no_posts_message'] );
191
 
192
  // post types
193
  if ( isset( $new_instance['post_type'] ) ) {
js/admin-dashboard.js CHANGED
@@ -1,98 +1,99 @@
1
  ( function ( $ ) {
2
 
3
- // set global options
4
- // Chart.defaults.global.tooltips.titleMarginBottom = 0;
5
- // Chart.defaults.global.tooltips.footerMarginTop = 4;
6
 
7
- window.onload = function() {
8
- updateChart( 'this_month' );
9
- };
10
-
11
- function updateChart( period ) {
12
-
13
- var container = document.getElementById( 'pvc_dashboard_container' );
14
-
15
- if ( $( container ).length > 0 ) {
16
 
17
- $( container ).addClass( 'loading' ).append( '<span class="spinner is-active"></span>' );
18
-
19
- $.ajax( {
20
- url: pvcArgs.ajaxURL,
21
- type: 'POST',
22
- dataType: 'json',
23
- data: ( {
24
- action : 'pvc_dashboard_chart',
25
- nonce : pvcArgs.nonce,
26
- period : period
27
- } ),
28
- success: function ( args ) {
29
-
30
- $( container ).removeClass( 'loading' );
31
- $( container ).find( '.spinner' ).removeClass( 'is-active' );
32
-
33
- var config = {
34
- type: 'line',
35
- data: args.data,
36
- options: {
37
- responsive: true,
38
- legend: {
39
- display: false,
40
- position: 'bottom',
41
- },
42
- scales: {
43
- xAxes: [{
44
- display: true,
45
- scaleLabel: {
46
- display: true,
47
- labelString: args.text.xAxes
48
- }
49
- }],
50
- yAxes: [{
51
- display: true,
52
- scaleLabel: {
53
- display: false,
54
- labelString: args.text.yAxes
55
- }
56
- }]
57
- },
58
- hover: {
59
- mode: 'label'
60
- },
61
- tooltips: {
62
- custom: function( tooltip ) {
63
- // console.log( tooltip );
64
- },
65
- callbacks: {
66
- title: function( tooltip ) {
67
- return args.data.dates[tooltip[0].index];
68
- }
69
- }
70
- }
71
- }
72
- };
73
-
74
- $.each( config.data.datasets, function ( i, dataset ) {
75
- dataset.fill = args.design.fill;
76
- dataset.borderColor = args.design.borderColor;
77
- dataset.backgroundColor = args.design.backgroundColor;
78
- dataset.borderWidth = args.design.borderWidth;
79
- dataset.borderDash = args.design.borderDash;
80
- dataset.pointBorderColor = args.design.pointBorderColor;
81
- dataset.pointBackgroundColor = args.design.pointBackgroundColor;
82
- dataset.pointBorderWidth = args.design.pointBorderWidth;
83
- } );
84
-
85
- window.chartPVC = new Chart( document.getElementById( 'pvc_chart' ).getContext( '2d' ), config );
86
  }
87
- } );
88
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  }
90
- }
91
 
92
- function updateLegend() {
93
- $legendContainer = $( '#legendContainer' );
94
- $legendContainer.empty();
95
- $legendContainer.append( window.chartPVC.generateLegend() );
96
  }
 
 
 
 
 
 
 
97
 
98
  } )( jQuery );
1
  ( function ( $ ) {
2
 
3
+ // set global options
4
+ // Chart.defaults.global.tooltips.titleMarginBottom = 0;
5
+ // Chart.defaults.global.tooltips.footerMarginTop = 4;
6
 
7
+ window.onload = function () {
8
+ updateChart( 'this_month' );
9
+ };
 
 
 
 
 
 
10
 
11
+ function updateChart( period ) {
12
+
13
+ var container = document.getElementById( 'pvc_dashboard_container' );
14
+
15
+ if ( $( container ).length > 0 ) {
16
+
17
+ $( container ).addClass( 'loading' ).append( '<span class="spinner is-active"></span>' );
18
+
19
+ $.ajax( {
20
+ url: pvcArgs.ajaxURL,
21
+ type: 'POST',
22
+ dataType: 'json',
23
+ data: ( {
24
+ action: 'pvc_dashboard_chart',
25
+ nonce: pvcArgs.nonce,
26
+ period: period
27
+ } ),
28
+ success: function ( args ) {
29
+ $( container ).removeClass( 'loading' );
30
+ $( container ).find( '.spinner' ).removeClass( 'is-active' );
31
+
32
+ var config = {
33
+ type: 'line',
34
+ data: args.data,
35
+ options: {
36
+ responsive: true,
37
+ legend: {
38
+ display: false,
39
+ position: 'bottom',
40
+ },
41
+ scales: {
42
+ xAxes: [ {
43
+ display: true,
44
+ scaleLabel: {
45
+ display: true,
46
+ labelString: args.text.xAxes,
47
+ fontSize: 14,
48
+ fontFamily: '-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif'
49
+ }
50
+ } ],
51
+ yAxes: [ {
52
+ display: true,
53
+ scaleLabel: {
54
+ display: false,
55
+ labelString: args.text.yAxes
56
+ }
57
+ } ]
58
+ },
59
+ hover: {
60
+ mode: 'label'
61
+ },
62
+ tooltips: {
63
+ custom: function ( tooltip ) {
64
+ // console.log( tooltip );
65
+ },
66
+ callbacks: {
67
+ title: function ( tooltip ) {
68
+ return args.data.dates[tooltip[0].index];
69
+ }
 
 
 
 
 
 
 
 
 
 
70
  }
71
+ }
72
+ }
73
+ };
74
+
75
+ $.each( config.data.datasets, function ( i, dataset ) {
76
+ dataset.fill = args.design.fill;
77
+ dataset.borderColor = args.design.borderColor;
78
+ dataset.backgroundColor = args.design.backgroundColor;
79
+ dataset.borderWidth = args.design.borderWidth;
80
+ dataset.borderDash = args.design.borderDash;
81
+ dataset.pointBorderColor = args.design.pointBorderColor;
82
+ dataset.pointBackgroundColor = args.design.pointBackgroundColor;
83
+ dataset.pointBorderWidth = args.design.pointBorderWidth;
84
+ } );
85
+
86
+ window.chartPVC = new Chart( document.getElementById( 'pvc_chart' ).getContext( '2d' ), config );
87
  }
88
+ } );
89
 
 
 
 
 
90
  }
91
+ }
92
+
93
+ function updateLegend() {
94
+ $legendContainer = $( '#legendContainer' );
95
+ $legendContainer.empty();
96
+ $legendContainer.append( window.chartPVC.generateLegend() );
97
+ }
98
 
99
  } )( jQuery );
js/admin-post.js CHANGED
@@ -1,49 +1,49 @@
1
  ( function ( $ ) {
2
 
3
- $( document ).ready( function () {
4
-
5
- // post views input
6
- $( '#post-views .edit-post-views' ).click( function () {
7
- if ( $( '#post-views-input-container' ).is( ":hidden" ) ) {
8
- $( '#post-views-input-container' ).slideDown( 'fast' );
9
- $( this ).hide();
10
- }
11
- return false;
12
- } );
13
-
14
- // save post views
15
- $( '#post-views .save-post-views' ).click( function () {
16
 
17
- var views = $.trim( $( '#post-views-display b' ).text() );
 
18
 
19
- $( '#post-views-input-container' ).slideUp( 'fast' );
20
- $( '#post-views .edit-post-views' ).show();
21
 
22
- views = parseInt( $( '#post-views-input' ).val() );
23
- // reassign value as integer
24
- $( '#post-views-input' ).val( views );
25
 
26
- $( '#post-views-display b' ).text( views );
 
 
27
 
28
- return false;
29
- } );
30
 
31
- // cancel post views
32
- $( '#post-views .cancel-post-views' ).click( function () {
33
 
34
- var views = $.trim( $( '#post-views-display b' ).text() );
 
35
 
36
- $( '#post-views-input-container' ).slideUp( 'fast' );
37
- $( '#post-views .edit-post-views' ).show();
38
 
39
- views = parseInt( $( '#post-views-current' ).val() );
 
40
 
41
- $( '#post-views-display b' ).text( views );
42
- $( '#post-views-input' ).val( views );
43
 
44
- return false;
45
- } );
46
 
 
47
  } );
48
 
 
 
49
  } )( jQuery );
1
  ( function ( $ ) {
2
 
3
+ $( document ).ready( function () {
4
+
5
+ // post views input
6
+ $( '#post-views .edit-post-views' ).click( function () {
7
+ if ( $( '#post-views-input-container' ).is( ":hidden" ) ) {
8
+ $( '#post-views-input-container' ).slideDown( 'fast' );
9
+ $( this ).hide();
10
+ }
11
+ return false;
12
+ } );
 
 
 
13
 
14
+ // save post views
15
+ $( '#post-views .save-post-views' ).click( function () {
16
 
17
+ var views = $.trim( $( '#post-views-display b' ).text() );
 
18
 
19
+ $( '#post-views-input-container' ).slideUp( 'fast' );
20
+ $( '#post-views .edit-post-views' ).show();
 
21
 
22
+ views = parseInt( $( '#post-views-input' ).val() );
23
+ // reassign value as integer
24
+ $( '#post-views-input' ).val( views );
25
 
26
+ $( '#post-views-display b' ).text( views );
 
27
 
28
+ return false;
29
+ } );
30
 
31
+ // cancel post views
32
+ $( '#post-views .cancel-post-views' ).click( function () {
33
 
34
+ var views = $.trim( $( '#post-views-display b' ).text() );
 
35
 
36
+ $( '#post-views-input-container' ).slideUp( 'fast' );
37
+ $( '#post-views .edit-post-views' ).show();
38
 
39
+ views = parseInt( $( '#post-views-current' ).val() );
 
40
 
41
+ $( '#post-views-display b' ).text( views );
42
+ $( '#post-views-input' ).val( views );
43
 
44
+ return false;
45
  } );
46
 
47
+ } );
48
+
49
  } )( jQuery );
js/admin-quick-edit.js CHANGED
@@ -1,57 +1,57 @@
1
  ( function ( $ ) {
2
- // we create a copy of the WP inline edit post function
3
- var $wp_inline_edit = inlineEditPost.edit;
4
- // and then we overwrite the function with our own code
5
- inlineEditPost.edit = function ( id ) {
6
- // call the original WP edit function
7
- // we don't want to leave WordPress hanging
8
- $wp_inline_edit.apply( this, arguments );
9
-
10
- // get the post ID
11
- var $post_id = 0;
12
-
13
- if ( typeof ( id ) == 'object' )
14
- $post_id = parseInt( this.getId( id ) );
15
-
16
- if ( $post_id > 0 ) {
17
- // define the edit row
18
- var $edit_row = $( '#edit-' + $post_id );
19
- var $post_row = $( '#post-' + $post_id );
20
-
21
- // get the data
22
- var $post_views = $( '.column-post_views', $post_row ).text();
23
-
24
- // populate the data
25
- $( ':input[name="post_views"]', $edit_row ).val( $post_views );
26
- }
27
-
28
- return false;
29
- };
30
-
31
- $( document ).on( 'click', '#bulk_edit', function () {
32
- // define the bulk edit row
33
- var $bulk_row = $( '#bulk-edit' );
34
-
35
- // get the selected post ids that are being edited
36
- var $post_ids = new Array();
37
- $bulk_row.find( '#bulk-titles' ).children().each( function () {
38
- $post_ids.push( $( this ).attr( 'id' ).replace( /^(ttle)/i, '' ) );
39
- } );
40
-
41
- // get the data
42
- var $post_views = $bulk_row.find( 'input[name="post_views"]' ).val();
43
-
44
- // save the data
45
- $.ajax( {
46
- url: ajaxurl, // this is a variable that WordPress has already defined for us
47
- type: 'post',
48
- async: false,
49
- cache: false,
50
- data: {
51
- action: 'save_bulk_post_views', // this is the name of our WP AJAX function that we'll set up next
52
- post_ids: $post_ids, // and these are the 2 parameters we're passing to our function
53
- post_views: $post_views,
54
- }
55
- } );
56
  } );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  } )( jQuery );
1
  ( function ( $ ) {
2
+ // we create a copy of the WP inline edit post function
3
+ var $wp_inline_edit = inlineEditPost.edit;
4
+ // and then we overwrite the function with our own code
5
+ inlineEditPost.edit = function ( id ) {
6
+ // call the original WP edit function
7
+ // we don't want to leave WordPress hanging
8
+ $wp_inline_edit.apply( this, arguments );
9
+
10
+ // get the post ID
11
+ var $post_id = 0;
12
+
13
+ if ( typeof ( id ) == 'object' )
14
+ $post_id = parseInt( this.getId( id ) );
15
+
16
+ if ( $post_id > 0 ) {
17
+ // define the edit row
18
+ var $edit_row = $( '#edit-' + $post_id );
19
+ var $post_row = $( '#post-' + $post_id );
20
+
21
+ // get the data
22
+ var $post_views = $( '.column-post_views', $post_row ).text();
23
+
24
+ // populate the data
25
+ $( ':input[name="post_views"]', $edit_row ).val( $post_views );
26
+ }
27
+
28
+ return false;
29
+ };
30
+
31
+ $( document ).on( 'click', '#bulk_edit', function () {
32
+ // define the bulk edit row
33
+ var $bulk_row = $( '#bulk-edit' );
34
+
35
+ // get the selected post ids that are being edited
36
+ var $post_ids = new Array();
37
+ $bulk_row.find( '#bulk-titles' ).children().each( function () {
38
+ $post_ids.push( $( this ).attr( 'id' ).replace( /^(ttle)/i, '' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  } );
40
+
41
+ // get the data
42
+ var $post_views = $bulk_row.find( 'input[name="post_views"]' ).val();
43
+
44
+ // save the data
45
+ $.ajax( {
46
+ url: ajaxurl, // this is a variable that WordPress has already defined for us
47
+ type: 'post',
48
+ async: false,
49
+ cache: false,
50
+ data: {
51
+ action: 'save_bulk_post_views', // this is the name of our WP AJAX function that we'll set up next
52
+ post_ids: $post_ids, // and these are the 2 parameters we're passing to our function
53
+ post_views: $post_views,
54
+ }
55
+ } );
56
+ } );
57
  } )( jQuery );
js/admin-settings.js CHANGED
@@ -1,67 +1,67 @@
1
  ( function ( $ ) {
2
 
3
- $( document ).ready( function () {
4
-
5
- $( '.post-views-counter-settings' ).checkBo();
6
-
7
- var ip_boxes = $( '#pvc_exclude_ips' ).find( '.ip-box' ).length;
8
-
9
- $( '#pvc_exclude_ips .ip-box:first' ).find( '.remove-exclude-ip' ).hide();
10
-
11
- // ask whether to reset options to defaults
12
- $( document ).on( 'click', '.reset_pvc_settings', function () {
13
- return confirm( pvcArgsSettings.resetToDefaults );
14
- } );
15
-
16
- // remove ip box
17
- $( document ).on( 'click', '.remove-exclude-ip', function ( e ) {
18
- e.preventDefault();
19
-
20
- ip_boxes--;
21
-
22
- var parent = $( this ).parent();
23
-
24
- // remove ip box
25
- parent.slideUp( 'fast', function() {
26
- $( this ).remove();
27
- } );
28
- } );
29
-
30
- // add ip box
31
- $( document ).on( 'click', '.add-exclude-ip', function () {
32
- ip_boxes++;
33
-
34
- var parent = $( this ).parents( '#pvc_exclude_ips' ),
35
- new_ip_box = parent.find( '.ip-box:last' ).clone().hide();
36
-
37
- // clear value
38
- new_ip_box.find( 'input' ).val( '' );
39
-
40
- if ( ip_boxes > 1 ) {
41
- new_ip_box.find( '.remove-exclude-ip' ).show();
42
- }
43
-
44
- // add and display new ip box
45
- parent.find( '.ip-box:last' ).after( new_ip_box ).next().slideDown( 'fast' );
46
- } );
47
-
48
- // add current ip
49
- $( document ).on( 'click', '.add-current-ip', function () {
50
- // fill input with user's current ip
51
- $( this ).parents( '#pvc_exclude_ips' ).find( '.ip-box' ).last().find( 'input' ).val( $( this ).attr( 'data-rel' ) );
52
- } );
53
-
54
- // toggle user roles
55
- $( '#pvc_exclude-roles, #pvc_restrict_display-roles' ).change( function () {
56
- if ( $( this ).is(':checked') ) {
57
- $( '.pvc_user_roles' ).slideDown( 'fast' );
58
- } else {
59
- $( '.pvc_user_roles' ).slideUp( 'fast' );
60
- }
61
- } );
62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  } );
64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  } )( jQuery );
66
 
67
  /*
@@ -71,4 +71,58 @@
71
  * Custom checkbox and radio
72
  * Author URL: elmahdim.com
73
  */
74
- !function(e){e.fn.checkBo=function(c){return c=e.extend({},{checkAllButton:null,checkAllTarget:null,checkAllTextDefault:null,checkAllTextToggle:null},c),this.each(function(){function t(e){this.input=e}function n(){var c=e(this).is(":checked");e(this).closest("label").toggleClass("checked",c)}function i(e,c,t){e.text(e.parent(a).hasClass("checked")?t:c)}function h(c){var t=c.attr("data-show");c=c.attr("data-hide"),e(t).removeClass("is-hidden"),e(c).addClass("is-hidden")}var l=e(this),a=l.find(".cb-checkbox"),d=l.find(".cb-radio"),o=l.find(".cb-switcher"),s=a.find("input:checkbox"),f=d.find("input:radio");s.wrap('<span class="cb-inner"><i></i></span>'),f.wrap('<span class="cb-inner"><i></i></span>');var k=new t("input:checkbox"),r=new t("input:radio");if(t.prototype.checkbox=function(e){var c=e.find(this.input).is(":checked");e.find(this.input).prop("checked",!c).trigger("change")},t.prototype.radiobtn=function(c,t){var n=e('input:radio[name="'+t+'"]');n.prop("checked",!1),n.closest(n.closest(d)).removeClass("checked"),c.addClass("checked"),c.find(this.input).get(0).checked=c.hasClass("checked"),c.find(this.input).change()},s.on("change",n),f.on("change",n),a.find("a").on("click",function(e){e.stopPropagation()}),a.on("click",function(c){c.preventDefault(),k.checkbox(e(this)),c=e(this).attr("data-toggle"),e(c).toggleClass("is-hidden"),h(e(this))}),d.on("click",function(c){c.preventDefault(),r.radiobtn(e(this),e(this).find("input:radio").attr("name")),h(e(this))}),e.fn.toggleCheckbox=function(){this.prop("checked",!this.is(":checked"))},e.fn.switcherChecker=function(){var c=e(this),t=c.find("input"),n=c.find(".cb-state");t.is(":checked")?(c.addClass("checked"),n.html(t.attr("data-state-on"))):(c.removeClass("checked"),n.html(t.attr("data-state-off")))},o.on("click",function(c){c.preventDefault(),c=e(this),c.find("input").toggleCheckbox(),c.switcherChecker(),e(c.attr("data-toggle")).toggleClass("is-hidden")}),o.each(function(){e(this).switcherChecker()}),c.checkAllButton&&c.checkAllTarget){var u=e(this);u.find(e(c.checkAllButton)).on("click",function(){u.find(c.checkAllTarget).find("input:checkbox").each(function(){u.find(e(c.checkAllButton)).hasClass("checked")?u.find(c.checkAllTarget).find("input:checkbox").prop("checked",!0).change():u.find(c.checkAllTarget).find("input:checkbox").prop("checked",!1).change()}),i(u.find(e(c.checkAllButton)).find(".toggle-text"),c.checkAllTextDefault,c.checkAllTextToggle)}),u.find(c.checkAllTarget).find(a).on("click",function(){u.find(c.checkAllButton).find("input:checkbox").prop("checked",!1).change().removeClass("checked"),i(u.find(e(c.checkAllButton)).find(".toggle-text"),c.checkAllTextDefault,c.checkAllTextToggle)})}l.find('[checked="checked"]').closest("label").addClass("checked"),l.find("input").is("input:disabled")&&l.find("input:disabled").closest("label").off().addClass("disabled")})}}(jQuery,window,document);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ( function ( $ ) {
2
 
3
+ $( document ).ready( function () {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
+ $( '.post-views-counter-settings' ).checkBo();
6
+
7
+ var ip_boxes = $( '#pvc_exclude_ips' ).find( '.ip-box' ).length;
8
+
9
+ $( '#pvc_exclude_ips .ip-box:first' ).find( '.remove-exclude-ip' ).hide();
10
+
11
+ // ask whether to reset options to defaults
12
+ $( document ).on( 'click', '.reset_pvc_settings', function () {
13
+ return confirm( pvcArgsSettings.resetToDefaults );
14
+ } );
15
+
16
+ // remove ip box
17
+ $( document ).on( 'click', '.remove-exclude-ip', function ( e ) {
18
+ e.preventDefault();
19
+
20
+ ip_boxes--;
21
+
22
+ var parent = $( this ).parent();
23
+
24
+ // remove ip box
25
+ parent.slideUp( 'fast', function () {
26
+ $( this ).remove();
27
+ } );
28
  } );
29
 
30
+ // add ip box
31
+ $( document ).on( 'click', '.add-exclude-ip', function () {
32
+ ip_boxes++;
33
+
34
+ var parent = $( this ).parents( '#pvc_exclude_ips' ),
35
+ new_ip_box = parent.find( '.ip-box:last' ).clone().hide();
36
+
37
+ // clear value
38
+ new_ip_box.find( 'input' ).val( '' );
39
+
40
+ if ( ip_boxes > 1 ) {
41
+ new_ip_box.find( '.remove-exclude-ip' ).show();
42
+ }
43
+
44
+ // add and display new ip box
45
+ parent.find( '.ip-box:last' ).after( new_ip_box ).next().slideDown( 'fast' );
46
+ } );
47
+
48
+ // add current ip
49
+ $( document ).on( 'click', '.add-current-ip', function () {
50
+ // fill input with user's current ip
51
+ $( this ).parents( '#pvc_exclude_ips' ).find( '.ip-box' ).last().find( 'input' ).val( $( this ).attr( 'data-rel' ) );
52
+ } );
53
+
54
+ // toggle user roles
55
+ $( '#pvc_exclude-roles, #pvc_restrict_display-roles' ).change( function () {
56
+ if ( $( this ).is( ':checked' ) ) {
57
+ $( '.pvc_user_roles' ).slideDown( 'fast' );
58
+ } else {
59
+ $( '.pvc_user_roles' ).slideUp( 'fast' );
60
+ }
61
+ } );
62
+
63
+ } );
64
+
65
  } )( jQuery );
66
 
67
  /*
71
  * Custom checkbox and radio
72
  * Author URL: elmahdim.com
73
  */
74
+ !function ( e ) {
75
+ e.fn.checkBo = function ( c ) {
76
+ return c = e.extend( { }, { checkAllButton: null, checkAllTarget: null, checkAllTextDefault: null, checkAllTextToggle: null }, c ), this.each( function () {
77
+ function t( e ) {
78
+ this.input = e
79
+ }
80
+ function n() {
81
+ var c = e( this ).is( ":checked" );
82
+ e( this ).closest( "label" ).toggleClass( "checked", c )
83
+ }
84
+ function i( e, c, t ) {
85
+ e.text( e.parent( a ).hasClass( "checked" ) ? t : c )
86
+ }
87
+ function h( c ) {
88
+ var t = c.attr( "data-show" );
89
+ c = c.attr( "data-hide" ), e( t ).removeClass( "is-hidden" ), e( c ).addClass( "is-hidden" )
90
+ }
91
+ var l = e( this ), a = l.find( ".cb-checkbox" ), d = l.find( ".cb-radio" ), o = l.find( ".cb-switcher" ), s = a.find( "input:checkbox" ), f = d.find( "input:radio" );
92
+ s.wrap( '<span class="cb-inner"><i></i></span>' ), f.wrap( '<span class="cb-inner"><i></i></span>' );
93
+ var k = new t( "input:checkbox" ), r = new t( "input:radio" );
94
+ if ( t.prototype.checkbox = function ( e ) {
95
+ var c = e.find( this.input ).is( ":checked" );
96
+ e.find( this.input ).prop( "checked", !c ).trigger( "change" )
97
+ }, t.prototype.radiobtn = function ( c, t ) {
98
+ var n = e( 'input:radio[name="' + t + '"]' );
99
+ n.prop( "checked", !1 ), n.closest( n.closest( d ) ).removeClass( "checked" ), c.addClass( "checked" ), c.find( this.input ).get( 0 ).checked = c.hasClass( "checked" ), c.find( this.input ).change()
100
+ }, s.on( "change", n ), f.on( "change", n ), a.find( "a" ).on( "click", function ( e ) {
101
+ e.stopPropagation()
102
+ } ), a.on( "click", function ( c ) {
103
+ c.preventDefault(), k.checkbox( e( this ) ), c = e( this ).attr( "data-toggle" ), e( c ).toggleClass( "is-hidden" ), h( e( this ) )
104
+ } ), d.on( "click", function ( c ) {
105
+ c.preventDefault(), r.radiobtn( e( this ), e( this ).find( "input:radio" ).attr( "name" ) ), h( e( this ) )
106
+ } ), e.fn.toggleCheckbox = function () {
107
+ this.prop( "checked", !this.is( ":checked" ) )
108
+ }, e.fn.switcherChecker = function () {
109
+ var c = e( this ), t = c.find( "input" ), n = c.find( ".cb-state" );
110
+ t.is( ":checked" ) ? ( c.addClass( "checked" ), n.html( t.attr( "data-state-on" ) ) ) : ( c.removeClass( "checked" ), n.html( t.attr( "data-state-off" ) ) )
111
+ }, o.on( "click", function ( c ) {
112
+ c.preventDefault(), c = e( this ), c.find( "input" ).toggleCheckbox(), c.switcherChecker(), e( c.attr( "data-toggle" ) ).toggleClass( "is-hidden" )
113
+ } ), o.each( function () {
114
+ e( this ).switcherChecker()
115
+ } ), c.checkAllButton && c.checkAllTarget ) {
116
+ var u = e( this );
117
+ u.find( e( c.checkAllButton ) ).on( "click", function () {
118
+ u.find( c.checkAllTarget ).find( "input:checkbox" ).each( function () {
119
+ u.find( e( c.checkAllButton ) ).hasClass( "checked" ) ? u.find( c.checkAllTarget ).find( "input:checkbox" ).prop( "checked", !0 ).change() : u.find( c.checkAllTarget ).find( "input:checkbox" ).prop( "checked", !1 ).change()
120
+ } ), i( u.find( e( c.checkAllButton ) ).find( ".toggle-text" ), c.checkAllTextDefault, c.checkAllTextToggle )
121
+ } ), u.find( c.checkAllTarget ).find( a ).on( "click", function () {
122
+ u.find( c.checkAllButton ).find( "input:checkbox" ).prop( "checked", !1 ).change().removeClass( "checked" ), i( u.find( e( c.checkAllButton ) ).find( ".toggle-text" ), c.checkAllTextDefault, c.checkAllTextToggle )
123
+ } )
124
+ }
125
+ l.find( '[checked="checked"]' ).closest( "label" ).addClass( "checked" ), l.find( "input" ).is( "input:disabled" ) && l.find( "input:disabled" ).closest( "label" ).off().addClass( "disabled" )
126
+ } )
127
+ }
128
+ }( jQuery, window, document );
js/chart.min.js CHANGED
@@ -1,41 +1,14 @@
1
- !function(t,e){"function"==typeof define&&define.amd?define(["moment"],e):"object"==typeof exports?module.exports=e.call(t,require("moment")):t.Chart=e.call(t,t.moment)}(this||window,function(t){/*!
2
- * Chart.js
3
- * http://chartjs.org/
4
- * Version: 2.0.0-beta2
5
- *
6
- * Copyright 2015 Nick Downie
7
- * Released under the MIT license
8
- * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md
9
- */
10
- /*!
11
- * Chart.js
12
- * http://chartjs.org/
13
- * Version: 2.0.0-beta2
14
- *
15
- * Copyright 2015 Nick Downie
16
- * Released under the MIT license
17
- * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md
18
- */
19
- /*!
20
- * Chart.js
21
- * http://chartjs.org/
22
- * Version: 2.0.0-beta2
23
- *
24
- * Copyright 2015 Nick Downie
25
- * Released under the MIT license
26
- * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md
27
- */
28
  /*!
29
  * Chart.js
30
  * http://chartjs.org/
31
- * Version: 2.0.0-beta2
32
  *
33
- * Copyright 2015 Nick Downie
34
  * Released under the MIT license
35
- * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md
36
  */
37
- return!function e(t,i,s){function a(n,r){if(!i[n]){if(!t[n]){var h="function"==typeof require&&require;if(!r&&h)return h(n,!0);if(o)return o(n,!0);var l=new Error("Cannot find module '"+n+"'");throw l.code="MODULE_NOT_FOUND",l}var c=i[n]={exports:{}};t[n][0].call(c.exports,function(e){var i=t[n][1][e];return a(i?i:e)},c,c.exports,e,t,i,s)}return i[n].exports}for(var o="function"==typeof require&&require,n=0;n<s.length;n++)a(s[n]);return a}({1:[function(t,e,i){!function(){var i=t("color-convert"),s=t("color-string"),a=function(t){if(t instanceof a)return t;if(!(this instanceof a))return new a(t);if(this.values={rgb:[0,0,0],hsl:[0,0,0],hsv:[0,0,0],hwb:[0,0,0],cmyk:[0,0,0,0],alpha:1},"string"==typeof t){var e=s.getRgba(t);if(e)this.setValues("rgb",e);else if(e=s.getHsla(t))this.setValues("hsl",e);else{if(!(e=s.getHwb(t)))throw new Error('Unable to parse color from string "'+t+'"');this.setValues("hwb",e)}}else if("object"==typeof t){var e=t;if(void 0!==e.r||void 0!==e.red)this.setValues("rgb",e);else if(void 0!==e.l||void 0!==e.lightness)this.setValues("hsl",e);else if(void 0!==e.v||void 0!==e.value)this.setValues("hsv",e);else if(void 0!==e.w||void 0!==e.whiteness)this.setValues("hwb",e);else{if(void 0===e.c&&void 0===e.cyan)throw new Error("Unable to parse color from object "+JSON.stringify(t));this.setValues("cmyk",e)}}};a.prototype={rgb:function(t){return this.setSpace("rgb",arguments)},hsl:function(t){return this.setSpace("hsl",arguments)},hsv:function(t){return this.setSpace("hsv",arguments)},hwb:function(t){return this.setSpace("hwb",arguments)},cmyk:function(t){return this.setSpace("cmyk",arguments)},rgbArray:function(){return this.values.rgb},hslArray:function(){return this.values.hsl},hsvArray:function(){return this.values.hsv},hwbArray:function(){return 1!==this.values.alpha?this.values.hwb.concat([this.values.alpha]):this.values.hwb},cmykArray:function(){return this.values.cmyk},rgbaArray:function(){var t=this.values.rgb;return t.concat([this.values.alpha])},hslaArray:function(){var t=this.values.hsl;return t.concat([this.values.alpha])},alpha:function(t){return void 0===t?this.values.alpha:(this.setValues("alpha",t),this)},red:function(t){return this.setChannel("rgb",0,t)},green:function(t){return this.setChannel("rgb",1,t)},blue:function(t){return this.setChannel("rgb",2,t)},hue:function(t){return this.setChannel("hsl",0,t)},saturation:function(t){return this.setChannel("hsl",1,t)},lightness:function(t){return this.setChannel("hsl",2,t)},saturationv:function(t){return this.setChannel("hsv",1,t)},whiteness:function(t){return this.setChannel("hwb",1,t)},blackness:function(t){return this.setChannel("hwb",2,t)},value:function(t){return this.setChannel("hsv",2,t)},cyan:function(t){return this.setChannel("cmyk",0,t)},magenta:function(t){return this.setChannel("cmyk",1,t)},yellow:function(t){return this.setChannel("cmyk",2,t)},black:function(t){return this.setChannel("cmyk",3,t)},hexString:function(){return s.hexString(this.values.rgb)},rgbString:function(){return s.rgbString(this.values.rgb,this.values.alpha)},rgbaString:function(){return s.rgbaString(this.values.rgb,this.values.alpha)},percentString:function(){return s.percentString(this.values.rgb,this.values.alpha)},hslString:function(){return s.hslString(this.values.hsl,this.values.alpha)},hslaString:function(){return s.hslaString(this.values.hsl,this.values.alpha)},hwbString:function(){return s.hwbString(this.values.hwb,this.values.alpha)},keyword:function(){return s.keyword(this.values.rgb,this.values.alpha)},rgbNumber:function(){return this.values.rgb[0]<<16|this.values.rgb[1]<<8|this.values.rgb[2]},luminosity:function(){for(var t=this.values.rgb,e=[],i=0;i<t.length;i++){var s=t[i]/255;e[i]=.03928>=s?s/12.92:Math.pow((s+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),i=t.luminosity();return e>i?(e+.05)/(i+.05):(i+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){return this.values.hsl[2]+=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},darken:function(t){return this.values.hsl[2]-=this.values.hsl[2]*t,this.setValues("hsl",this.values.hsl),this},saturate:function(t){return this.values.hsl[1]+=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},desaturate:function(t){return this.values.hsl[1]-=this.values.hsl[1]*t,this.setValues("hsl",this.values.hsl),this},whiten:function(t){return this.values.hwb[1]+=this.values.hwb[1]*t,this.setValues("hwb",this.values.hwb),this},blacken:function(t){return this.values.hwb[2]+=this.values.hwb[2]*t,this.setValues("hwb",this.values.hwb),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){return this.setValues("alpha",this.values.alpha-this.values.alpha*t),this},opaquer:function(t){return this.setValues("alpha",this.values.alpha+this.values.alpha*t),this},rotate:function(t){var e=this.values.hsl[0];return e=(e+t)%360,e=0>e?360+e:e,this.values.hsl[0]=e,this.setValues("hsl",this.values.hsl),this},mix:function(t,e){e=1-(null==e?.5:e);for(var i=2*e-1,s=this.alpha()-t.alpha(),a=((i*s==-1?i:(i+s)/(1+i*s))+1)/2,o=1-a,n=this.rgbArray(),r=t.rgbArray(),h=0;h<n.length;h++)n[h]=n[h]*a+r[h]*o;this.setValues("rgb",n);var l=this.alpha()*e+t.alpha()*(1-e);return this.setValues("alpha",l),this},toJSON:function(){return this.rgb()},clone:function(){return new a(this.rgb())}},a.prototype.getValues=function(t){for(var e={},i=0;i<t.length;i++)e[t.charAt(i)]=this.values[t][i];return 1!=this.values.alpha&&(e.a=this.values.alpha),e},a.prototype.setValues=function(t,e){var s={rgb:["red","green","blue"],hsl:["hue","saturation","lightness"],hsv:["hue","saturation","value"],hwb:["hue","whiteness","blackness"],cmyk:["cyan","magenta","yellow","black"]},a={rgb:[255,255,255],hsl:[360,100,100],hsv:[360,100,100],hwb:[360,100,100],cmyk:[100,100,100,100]},o=1;if("alpha"==t)o=e;else if(e.length)this.values[t]=e.slice(0,t.length),o=e[t.length];else if(void 0!==e[t.charAt(0)]){for(var n=0;n<t.length;n++)this.values[t][n]=e[t.charAt(n)];o=e.a}else if(void 0!==e[s[t][0]]){for(var r=s[t],n=0;n<t.length;n++)this.values[t][n]=e[r[n]];o=e.alpha}if(this.values.alpha=Math.max(0,Math.min(1,void 0!==o?o:this.values.alpha)),"alpha"!=t){for(var n=0;n<t.length;n++){var h=Math.max(0,Math.min(a[t][n],this.values[t][n]));this.values[t][n]=Math.round(h)}for(var l in s){l!=t&&(this.values[l]=i[t][l](this.values[t]));for(var n=0;n<l.length;n++){var h=Math.max(0,Math.min(a[l][n],this.values[l][n]));this.values[l][n]=Math.round(h)}}return!0}},a.prototype.setSpace=function(t,e){var i=e[0];return void 0===i?this.getValues(t):("number"==typeof i&&(i=Array.prototype.slice.call(e)),this.setValues(t,i),this)},a.prototype.setChannel=function(t,e,i){return void 0===i?this.values[t][e]:(this.values[t][e]=i,this.setValues(t,this.values[t]),this)},window.Color=e.exports=a}()},{"color-convert":3,"color-string":4}],2:[function(t,e,i){function s(t){var e,i,s,a=t[0]/255,o=t[1]/255,n=t[2]/255,r=Math.min(a,o,n),h=Math.max(a,o,n),l=h-r;return h==r?e=0:a==h?e=(o-n)/l:o==h?e=2+(n-a)/l:n==h&&(e=4+(a-o)/l),e=Math.min(60*e,360),0>e&&(e+=360),s=(r+h)/2,i=h==r?0:.5>=s?l/(h+r):l/(2-h-r),[e,100*i,100*s]}function a(t){var e,i,s,a=t[0],o=t[1],n=t[2],r=Math.min(a,o,n),h=Math.max(a,o,n),l=h-r;return i=0==h?0:l/h*1e3/10,h==r?e=0:a==h?e=(o-n)/l:o==h?e=2+(n-a)/l:n==h&&(e=4+(a-o)/l),e=Math.min(60*e,360),0>e&&(e+=360),s=h/255*1e3/10,[e,i,s]}function o(t){var e=t[0],i=t[1],a=t[2],o=s(t)[0],n=1/255*Math.min(e,Math.min(i,a)),a=1-1/255*Math.max(e,Math.max(i,a));return[o,100*n,100*a]}function n(t){var e,i,s,a,o=t[0]/255,n=t[1]/255,r=t[2]/255;return a=Math.min(1-o,1-n,1-r),e=(1-o-a)/(1-a)||0,i=(1-n-a)/(1-a)||0,s=(1-r-a)/(1-a)||0,[100*e,100*i,100*s,100*a]}function h(t){return G[JSON.stringify(t)]}function l(t){var e=t[0]/255,i=t[1]/255,s=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,s=s>.04045?Math.pow((s+.055)/1.055,2.4):s/12.92;var a=.4124*e+.3576*i+.1805*s,o=.2126*e+.7152*i+.0722*s,n=.0193*e+.1192*i+.9505*s;return[100*a,100*o,100*n]}function c(t){var e,i,s,a=l(t),o=a[0],n=a[1],r=a[2];return o/=95.047,n/=100,r/=108.883,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*n-16,i=500*(o-n),s=200*(n-r),[e,i,s]}function d(t){return B(c(t))}function u(t){var e,i,s,a,o,n=t[0]/360,r=t[1]/100,h=t[2]/100;if(0==r)return o=255*h,[o,o,o];i=.5>h?h*(1+r):h+r-h*r,e=2*h-i,a=[0,0,0];for(var l=0;3>l;l++)s=n+1/3*-(l-1),0>s&&s++,s>1&&s--,o=1>6*s?e+6*(i-e)*s:1>2*s?i:2>3*s?e+(i-e)*(2/3-s)*6:e,a[l]=255*o;return a}function m(t){var e,i,s=t[0],a=t[1]/100,o=t[2]/100;return o*=2,a*=1>=o?o:2-o,i=(o+a)/2,e=2*a/(o+a),[s,100*e,100*i]}function p(t){return o(u(t))}function f(t){return n(u(t))}function x(t){return h(u(t))}function v(t){var e=t[0]/60,i=t[1]/100,s=t[2]/100,a=Math.floor(e)%6,o=e-Math.floor(e),n=255*s*(1-i),r=255*s*(1-i*o),h=255*s*(1-i*(1-o)),s=255*s;switch(a){case 0:return[s,h,n];case 1:return[r,s,n];case 2:return[n,s,h];case 3:return[n,r,s];case 4:return[h,n,s];case 5:return[s,n,r]}}function y(t){var e,i,s=t[0],a=t[1]/100,o=t[2]/100;return i=(2-a)*o,e=a*o,e/=1>=i?i:2-i,e=e||0,i/=2,[s,100*e,100*i]}function k(t){return o(v(t))}function S(t){return n(v(t))}function D(t){return h(v(t))}function C(t){var e,i,s,a,o=t[0]/360,n=t[1]/100,h=t[2]/100,l=n+h;switch(l>1&&(n/=l,h/=l),e=Math.floor(6*o),i=1-h,s=6*o-e,0!=(1&e)&&(s=1-s),a=n+s*(i-n),e){default:case 6:case 0:r=i,g=a,b=n;break;case 1:r=a,g=i,b=n;break;case 2:r=n,g=i,b=a;break;case 3:r=n,g=a,b=i;break;case 4:r=a,g=n,b=i;break;case 5:r=i,g=n,b=a}return[255*r,255*g,255*b]}function w(t){return s(C(t))}function _(t){return a(C(t))}function A(t){return n(C(t))}function M(t){return h(C(t))}function I(t){var e,i,s,a=t[0]/100,o=t[1]/100,n=t[2]/100,r=t[3]/100;return e=1-Math.min(1,a*(1-r)+r),i=1-Math.min(1,o*(1-r)+r),s=1-Math.min(1,n*(1-r)+r),[255*e,255*i,255*s]}function P(t){return s(I(t))}function T(t){return a(I(t))}function F(t){return o(I(t))}function R(t){return h(I(t))}function L(t){var e,i,s,a=t[0]/100,o=t[1]/100,n=t[2]/100;return e=3.2406*a+-1.5372*o+n*-.4986,i=a*-.9689+1.8758*o+.0415*n,s=.0557*a+o*-.204+1.057*n,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,s=s>.0031308?1.055*Math.pow(s,1/2.4)-.055:s=12.92*s,e=Math.min(Math.max(0,e),1),i=Math.min(Math.max(0,i),1),s=Math.min(Math.max(0,s),1),[255*e,255*i,255*s]}function W(t){var e,i,s,a=t[0],o=t[1],n=t[2];return a/=95.047,o/=100,n/=108.883,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,e=116*o-16,i=500*(a-o),s=200*(o-n),[e,i,s]}function z(t){return B(W(t))}function V(t){var e,i,s,a,o=t[0],n=t[1],r=t[2];return 8>=o?(i=100*o/903.3,a=7.787*(i/100)+16/116):(i=100*Math.pow((o+16)/116,3),a=Math.pow(i/100,1/3)),e=.008856>=e/95.047?e=95.047*(n/500+a-16/116)/7.787:95.047*Math.pow(n/500+a,3),s=.008859>=s/108.883?s=108.883*(a-r/200-16/116)/7.787:108.883*Math.pow(a-r/200,3),[e,i,s]}function B(t){var e,i,s,a=t[0],o=t[1],n=t[2];return e=Math.atan2(n,o),i=360*e/2/Math.PI,0>i&&(i+=360),s=Math.sqrt(o*o+n*n),[a,s,i]}function O(t){return L(V(t))}function N(t){var e,i,s,a=t[0],o=t[1],n=t[2];return s=n/360*2*Math.PI,e=o*Math.cos(s),i=o*Math.sin(s),[a,e,i]}function H(t){return V(N(t))}function E(t){return O(N(t))}function j(t){return X[t]}function q(t){return s(j(t))}function U(t){return a(j(t))}function Y(t){return o(j(t))}function Q(t){return n(j(t))}function J(t){return c(j(t))}function Z(t){return l(j(t))}e.exports={rgb2hsl:s,rgb2hsv:a,rgb2hwb:o,rgb2cmyk:n,rgb2keyword:h,rgb2xyz:l,rgb2lab:c,rgb2lch:d,hsl2rgb:u,hsl2hsv:m,hsl2hwb:p,hsl2cmyk:f,hsl2keyword:x,hsv2rgb:v,hsv2hsl:y,hsv2hwb:k,hsv2cmyk:S,hsv2keyword:D,hwb2rgb:C,hwb2hsl:w,hwb2hsv:_,hwb2cmyk:A,hwb2keyword:M,cmyk2rgb:I,cmyk2hsl:P,cmyk2hsv:T,cmyk2hwb:F,cmyk2keyword:R,keyword2rgb:j,keyword2hsl:q,keyword2hsv:U,keyword2hwb:Y,keyword2cmyk:Q,keyword2lab:J,keyword2xyz:Z,xyz2rgb:L,xyz2lab:W,xyz2lch:z,lab2xyz:V,lab2rgb:O,lab2lch:B,lch2lab:N,lch2xyz:H,lch2rgb:E};var X={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},G={};for(var $ in X)G[JSON.stringify(X[$])]=$},{}],3:[function(t,e,i){var s=t("./conversions"),a=function(){return new l};for(var o in s){a[o+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),s[t](e)}}(o);var n=/(\w+)2(\w+)/.exec(o),r=n[1],h=n[2];a[r]=a[r]||{},a[r][h]=a[o]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var i=s[t](e);if("string"==typeof i||void 0===i)return i;for(var a=0;a<i.length;a++)i[a]=Math.round(i[a]);return i}}(o)}var l=function(){this.convs={}};l.prototype.routeSpace=function(t,e){var i=e[0];return void 0===i?this.getValues(t):("number"==typeof i&&(i=Array.prototype.slice.call(e)),this.setValues(t,i))},l.prototype.setValues=function(t,e){return this.space=t,this.convs={},this.convs[t]=e,this},l.prototype.getValues=function(t){var e=this.convs[t];if(!e){var i=this.space,s=this.convs[i];e=a[i][t](s),this.convs[t]=e}return e},["rgb","hsl","hsv","cmyk","keyword"].forEach(function(t){l.prototype[t]=function(e){return this.routeSpace(t,arguments)}}),e.exports=a},{"./conversions":2}],4:[function(t,e,i){function s(t){if(t){var e=/^#([a-fA-F0-9]{3})$/,i=/^#([a-fA-F0-9]{6})$/,s=/^rgba?\(\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/,a=/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/,o=/(\w+)/,n=[0,0,0],r=1,h=t.match(e);if(h){h=h[1];for(var l=0;l<n.length;l++)n[l]=parseInt(h[l]+h[l],16)}else if(h=t.match(i)){h=h[1];for(var l=0;l<n.length;l++)n[l]=parseInt(h.slice(2*l,2*l+2),16)}else if(h=t.match(s)){for(var l=0;l<n.length;l++)n[l]=parseInt(h[l+1]);r=parseFloat(h[4])}else if(h=t.match(a)){for(var l=0;l<n.length;l++)n[l]=Math.round(2.55*parseFloat(h[l+1]));r=parseFloat(h[4])}else if(h=t.match(o)){if("transparent"==h[1])return[0,0,0,0];if(n=y[h[1]],!n)return}for(var l=0;l<n.length;l++)n[l]=x(n[l],0,255);return r=r||0==r?x(r,0,1):1,n[3]=r,n}}function a(t){if(t){var e=/^hsla?\(\s*([+-]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)/,i=t.match(e);if(i){var s=parseFloat(i[4]),a=x(parseInt(i[1]),0,360),o=x(parseFloat(i[2]),0,100),n=x(parseFloat(i[3]),0,100),r=x(isNaN(s)?1:s,0,1);return[a,o,n,r]}}}function o(t){if(t){var e=/^hwb\(\s*([+-]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)/,i=t.match(e);if(i){var s=parseFloat(i[4]),a=x(parseInt(i[1]),0,360),o=x(parseFloat(i[2]),0,100),n=x(parseFloat(i[3]),0,100),r=x(isNaN(s)?1:s,0,1);return[a,o,n,r]}}}function n(t){var e=s(t);return e&&e.slice(0,3)}function r(t){var e=a(t);return e&&e.slice(0,3)}function h(t){var e=s(t);return e?e[3]:(e=a(t))?e[3]:(e=o(t))?e[3]:void 0}function l(t){return"#"+v(t[0])+v(t[1])+v(t[2])}function c(t,e){return 1>e||t[3]&&t[3]<1?d(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function d(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function u(t,e){if(1>e||t[3]&&t[3]<1)return g(t,e);var i=Math.round(t[0]/255*100),s=Math.round(t[1]/255*100),a=Math.round(t[2]/255*100);return"rgb("+i+"%, "+s+"%, "+a+"%)"}function g(t,e){var i=Math.round(t[0]/255*100),s=Math.round(t[1]/255*100),a=Math.round(t[2]/255*100);return"rgba("+i+"%, "+s+"%, "+a+"%, "+(e||t[3]||1)+")"}function m(t,e){return 1>e||t[3]&&t[3]<1?p(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function p(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function f(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function b(t){return k[t.slice(0,3)]}function x(t,e,i){return Math.min(Math.max(e,t),i)}function v(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var y=t("color-name");e.exports={getRgba:s,getHsla:a,getRgb:n,getHsl:r,getHwb:o,getAlpha:h,hexString:l,rgbString:c,rgbaString:d,percentString:u,percentaString:g,hslString:m,hslaString:p,hwbString:f,keyword:b};var k={};for(var S in y)k[y[S]]=S},{"color-name":5}],5:[function(t,e,i){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}]},{},[1]),function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.ctx=t,this.canvas=t.canvas,this.width=t.canvas.width||parseInt(i.helpers.getStyle(t.canvas,"width"))||i.helpers.getMaximumWidth(t.canvas),this.height=t.canvas.height||parseInt(i.helpers.getStyle(t.canvas,"height"))||i.helpers.getMaximumHeight(t.canvas),this.aspectRatio=this.width/this.height,(isNaN(this.aspectRatio)||isFinite(this.aspectRatio)===!1)&&(this.aspectRatio=void 0!==e.aspectRatio?e.aspectRatio:2),this.originalCanvasStyleWidth=t.canvas.style.width,this.originalCanvasStyleHeight=t.canvas.style.height,i.helpers.retinaScale(this),e&&(this.controller=new i.Controller(this));var s=this;return i.helpers.addResizeListener(t.canvas.parentNode,function(){s.controller&&s.controller.config.options.responsive&&s.controller.resize()}),this.controller?this.controller:this};i.defaults={global:{responsive:!0,responsiveAnimationDuration:0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{},legendCallback:function(t){var e=[];e.push('<ul class="'+t.id+'-legend">');for(var i=0;i<t.data.datasets.length;i++)e.push('<li><span style="background-color:'+t.data.datasets[i].backgroundColor+'">'),t.data.datasets[i].label&&e.push(t.data.datasets[i].label),e.push("</span></li>");return e.push("</ul>"),e.join("")}}},t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers={};i.each=function(t,e,s,a){var o,n;if(i.isArray(t))if(n=t.length,a)for(o=n-1;o>=0;o--)e.call(s,t[o],o);else for(o=0;n>o;o++)e.call(s,t[o],o);else if("object"==typeof t){var r=Object.keys(t);for(n=r.length,o=0;n>o;o++)e.call(s,t[r[o]],r[o])}},i.clone=function(t){var e={};return i.each(t,function(s,a){t.hasOwnProperty(a)&&(i.isArray(s)?e[a]=s.slice(0):"object"==typeof s&&null!==s?e[a]=i.clone(s):e[a]=s)}),e},i.extend=function(t){for(var e=arguments.length,s=[],a=1;e>a;a++)s.push(arguments[a]);return i.each(s,function(e){i.each(e,function(i,s){e.hasOwnProperty(s)&&(t[s]=i)})}),t},i.configMerge=function(t){var s=i.clone(t);return i.each(Array.prototype.slice.call(arguments,1),function(t){i.each(t,function(a,o){if(t.hasOwnProperty(o))if("scales"===o)s[o]=i.scaleMerge(s.hasOwnProperty(o)?s[o]:{},a);else if("scale"===o)s[o]=i.configMerge(s.hasOwnProperty(o)?s[o]:{},e.scaleService.getScaleDefaults(a.type),a);else if(s.hasOwnProperty(o)&&i.isArray(s[o])&&i.isArray(a)){var n=s[o];i.each(a,function(t,e){e<n.length?"object"==typeof n[e]&&null!==n[e]&&"object"==typeof t&&null!==t?n[e]=i.configMerge(n[e],t):n[e]=t:n.push(t)})}else s.hasOwnProperty(o)&&"object"==typeof s[o]&&null!==s[o]&&"object"==typeof a?s[o]=i.configMerge(s[o],a):s[o]=a})}),s},i.extendDeep=function(t){function e(t){return i.each(arguments,function(s){s!==t&&i.each(s,function(i,s){t[s]&&t[s].constructor&&t[s].constructor===Object?e(t[s],i):t[s]=i})}),t}return e.apply(this,arguments)},i.scaleMerge=function(t,s){var a=i.clone(t);return i.each(s,function(t,o){s.hasOwnProperty(o)&&("xAxes"===o||"yAxes"===o?a.hasOwnProperty(o)?i.each(t,function(t,s){s>=a[o].length||!a[o][s].type?a[o].push(i.configMerge(t.type?e.scaleService.getScaleDefaults(t.type):{},t)):t.type!==a[o][s].type?a[o][s]=i.configMerge(a[o][s],t.type?e.scaleService.getScaleDefaults(t.type):{},t):a[o][s]=i.configMerge(a[o][s],t)}):(a[o]=[],i.each(t,function(t){a[o].push(i.configMerge(t.type?e.scaleService.getScaleDefaults(t.type):{},t))})):a.hasOwnProperty(o)&&"object"==typeof a[o]&&null!==a[o]&&"object"==typeof t?a[o]=i.configMerge(a[o],t):a[o]=t)}),a},i.getValueAtIndexOrDefault=function(t,e,s){return void 0===t||null===t?s:i.isArray(t)?e<t.length?t[e]:s:t},i.getValueOrDefault=function(t,e){return void 0===t?e:t},i.indexOf=function(t,e){if(Array.prototype.indexOf)return t.indexOf(e);for(var i=0;i<t.length;i++)if(t[i]===e)return i;return-1},i.where=function(t,e){var s=[];return i.each(t,function(t){e(t)&&s.push(t)}),s},i.findNextWhere=function(t,e,i){(void 0===i||null===i)&&(i=-1);for(var s=i+1;s<t.length;s++){var a=t[s];if(e(a))return a}},i.findPreviousWhere=function(t,e,i){(void 0===i||null===i)&&(i=t.length);for(var s=i-1;s>=0;s--){var a=t[s];if(e(a))return a}},i.inherits=function(t){var e=this,s=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},a=function(){this.constructor=s};return a.prototype=e.prototype,s.prototype=new a,s.extend=i.inherits,t&&i.extend(s.prototype,t),s.__super__=e.prototype,s},i.noop=function(){},i.uid=function(){var t=0;return function(){return"chart-"+t++}}(),i.warn=function(t){console&&"function"==typeof console.warn&&console.warn(t)},i.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},i.max=function(t){return t.reduce(function(t,e){return isNaN(e)?t:Math.max(t,e)},Number.NEGATIVE_INFINITY)},i.min=function(t){return t.reduce(function(t,e){return isNaN(e)?t:Math.min(t,e)},Number.POSITIVE_INFINITY)},i.sign=function(t){return Math.sign?Math.sign(t):(t=+t,0===t||isNaN(t)?t:t>0?1:-1)},i.log10=function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10},i.toRadians=function(t){return t*(Math.PI/180)},i.toDegrees=function(t){return t*(180/Math.PI)},i.getAngleFromPoint=function(t,e){var i=e.x-t.x,s=e.y-t.y,a=Math.sqrt(i*i+s*s),o=Math.atan2(s,i);return o<-.5*Math.PI&&(o+=2*Math.PI),{angle:o,distance:a}},i.aliasPixel=function(t){return t%2===0?0:.5},i.splineCurve=function(t,e,i,s){var a=t.skip?e:t,o=e,n=i.skip?e:i,r=Math.sqrt(Math.pow(o.x-a.x,2)+Math.pow(o.y-a.y,2)),h=Math.sqrt(Math.pow(n.x-o.x,2)+Math.pow(n.y-o.y,2)),l=r/(r+h),c=h/(r+h);l=isNaN(l)?0:l,c=isNaN(c)?0:c;var d=s*l,u=s*c;return{previous:{x:o.x-d*(n.x-a.x),y:o.y-d*(n.y-a.y)},next:{x:o.x+u*(n.x-a.x),y:o.y+u*(n.y-a.y)}}},i.nextItem=function(t,e,i){return i?e>=t.length-1?t[0]:t[e+1]:e>=t.length-1?t[t.length-1]:t[e+1]},i.previousItem=function(t,e,i){return i?0>=e?t[t.length-1]:t[e-1]:0>=e?t[0]:t[e-1]},i.niceNum=function(t,e){var s,a=Math.floor(i.log10(t)),o=t/Math.pow(10,a);return s=e?1.5>o?1:3>o?2:7>o?5:10:1>=o?1:2>=o?2:5>=o?5:10,s*Math.pow(10,a)};var s=i.easingEffects={linear:function(t){return t},easeInQuad:function(t){return t*t},easeOutQuad:function(t){return-1*t*(t-2)},easeInOutQuad:function(t){return(t/=.5)<1?.5*t*t:-0.5*(--t*(t-2)-1)},easeInCubic:function(t){return t*t*t},easeOutCubic:function(t){return 1*((t=t/1-1)*t*t+1)},easeInOutCubic:function(t){return(t/=.5)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},easeInQuart:function(t){return t*t*t*t},easeOutQuart:function(t){return-1*((t=t/1-1)*t*t*t-1)},easeInOutQuart:function(t){return(t/=.5)<1?.5*t*t*t*t:-0.5*((t-=2)*t*t*t-2)},easeInQuint:function(t){return 1*(t/=1)*t*t*t*t},easeOutQuint:function(t){return 1*((t=t/1-1)*t*t*t*t+1)},easeInOutQuint:function(t){return(t/=.5)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)},easeInSine:function(t){return-1*Math.cos(t/1*(Math.PI/2))+1},easeOutSine:function(t){return 1*Math.sin(t/1*(Math.PI/2))},easeInOutSine:function(t){return-0.5*(Math.cos(Math.PI*t/1)-1)},easeInExpo:function(t){return 0===t?1:1*Math.pow(2,10*(t/1-1))},easeOutExpo:function(t){return 1===t?1:1*(-Math.pow(2,-10*t/1)+1)},easeInOutExpo:function(t){return 0===t?0:1===t?1:(t/=.5)<1?.5*Math.pow(2,10*(t-1)):.5*(-Math.pow(2,-10*--t)+2)},easeInCirc:function(t){return t>=1?t:-1*(Math.sqrt(1-(t/=1)*t)-1)},easeOutCirc:function(t){return 1*Math.sqrt(1-(t=t/1-1)*t)},easeInOutCirc:function(t){return(t/=.5)<1?-0.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},easeInElastic:function(t){var e=1.70158,i=0,s=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),s<Math.abs(1)?(s=1,e=i/4):e=i/(2*Math.PI)*Math.asin(1/s),-(s*Math.pow(2,10*(t-=1))*Math.sin((1*t-e)*(2*Math.PI)/i)))},easeOutElastic:function(t){var e=1.70158,i=0,s=1;return 0===t?0:1==(t/=1)?1:(i||(i=.3),s<Math.abs(1)?(s=1,e=i/4):e=i/(2*Math.PI)*Math.asin(1/s),s*Math.pow(2,-10*t)*Math.sin((1*t-e)*(2*Math.PI)/i)+1)},easeInOutElastic:function(t){var e=1.70158,i=0,s=1;return 0===t?0:2==(t/=.5)?1:(i||(i=1*(.3*1.5)),s<Math.abs(1)?(s=1,e=i/4):e=i/(2*Math.PI)*Math.asin(1/s),1>t?-.5*(s*Math.pow(2,10*(t-=1))*Math.sin((1*t-e)*(2*Math.PI)/i)):s*Math.pow(2,-10*(t-=1))*Math.sin((1*t-e)*(2*Math.PI)/i)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*(t*t*(((e*=1.525)+1)*t-e)):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-s.easeOutBounce(1-t)},easeOutBounce:function(t){return(t/=1)<1/2.75?1*(7.5625*t*t):2/2.75>t?1*(7.5625*(t-=1.5/2.75)*t+.75):2.5/2.75>t?1*(7.5625*(t-=2.25/2.75)*t+.9375):1*(7.5625*(t-=2.625/2.75)*t+.984375);
38
- },easeInOutBounce:function(t){return.5>t?.5*s.easeInBounce(2*t):.5*s.easeOutBounce(2*t-1)+.5}};i.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),i.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),i.getRelativePosition=function(t,e){var i,s,a=t.originalEvent||t,o=t.currentTarget||t.srcElement,n=o.getBoundingClientRect();return a.touches&&a.touches.length>0?(i=a.touches[0].clientX,s=a.touches[0].clientY):(i=a.clientX,s=a.clientY),i=Math.round((i-n.left)/(n.right-n.left)*o.width/e.currentDevicePixelRatio),s=Math.round((s-n.top)/(n.bottom-n.top)*o.height/e.currentDevicePixelRatio),{x:i,y:s}},i.addEvent=function(t,e,i){t.addEventListener?t.addEventListener(e,i):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i},i.removeEvent=function(t,e,s){t.removeEventListener?t.removeEventListener(e,s,!1):t.detachEvent?t.detachEvent("on"+e,s):t["on"+e]=i.noop},i.bindEvents=function(t,e,s){t.events||(t.events={}),i.each(e,function(e){t.events[e]=function(){s.apply(t,arguments)},i.addEvent(t.chart.canvas,e,t.events[e])})},i.unbindEvents=function(t,e){i.each(e,function(e,s){i.removeEvent(t.chart.canvas,s,e)})},i.getConstraintWidth=function(t){var e,i=document.defaultView.getComputedStyle(t)["max-width"],s=document.defaultView.getComputedStyle(t.parentNode)["max-width"],a=null!==i&&"none"!==i,o=null!==s&&"none"!==s;return(a||o)&&(e=Math.min(a?parseInt(i,10):Number.POSITIVE_INFINITY,o?parseInt(s,10):Number.POSITIVE_INFINITY)),e},i.getConstraintHeight=function(t){var e,i=document.defaultView.getComputedStyle(t)["max-height"],s=document.defaultView.getComputedStyle(t.parentNode)["max-height"],a=null!==i&&"none"!==i,o=null!==s&&"none"!==s;return(i||s)&&(e=Math.min(a?parseInt(i,10):Number.POSITIVE_INFINITY,o?parseInt(s,10):Number.POSITIVE_INFINITY)),e},i.getMaximumWidth=function(t){var e=t.parentNode,s=parseInt(i.getStyle(e,"padding-left"))+parseInt(i.getStyle(e,"padding-right")),a=e.clientWidth-s,o=i.getConstraintWidth(t);return void 0!==o&&(a=Math.min(a,o)),a},i.getMaximumHeight=function(t){var e=t.parentNode,s=parseInt(i.getStyle(e,"padding-top"))+parseInt(i.getStyle(e,"padding-bottom")),a=e.clientHeight-s,o=i.getConstraintHeight(t);return void 0!==o&&(a=Math.min(a,o)),a},i.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)},i.retinaScale=function(t){var e=t.ctx,i=t.canvas.width,s=t.canvas.height,a=t.currentDevicePixelRatio=window.devicePixelRatio||1;1!==a&&(e.canvas.height=s*a,e.canvas.width=i*a,e.scale(a,a),e.canvas.style.width=i+"px",e.canvas.style.height=s+"px",t.originalDevicePixelRatio=t.originalDevicePixelRatio||a)},i.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},i.fontString=function(t,e,i){return e+" "+t+"px "+i},i.longestText=function(t,e,s,a){a=a||{},a.data=a.data||{},a.garbageCollect=a.garbageCollect||[],a.font!==e&&(a.data={},a.garbageCollect=[],a.font=e),t.font=e;var o=0;i.each(s,function(e){var i=a.data[e];i||(i=a.data[e]=t.measureText(e).width,a.garbageCollect.push(e)),i>o&&(o=i)});var n=a.garbageCollect.length/2;if(n>s.length)for(var r=0;n>r;r++){var h=a.garbageCollect.shift();delete a.data[h]}return o},i.drawRoundedRectangle=function(t,e,i,s,a,o){t.beginPath(),t.moveTo(e+o,i),t.lineTo(e+s-o,i),t.quadraticCurveTo(e+s,i,e+s,i+o),t.lineTo(e+s,i+a-o),t.quadraticCurveTo(e+s,i+a,e+s-o,i+a),t.lineTo(e+o,i+a),t.quadraticCurveTo(e,i+a,e,i+a-o),t.lineTo(e,i+o),t.quadraticCurveTo(e,i,e+o,i),t.closePath()},i.color=function(e){return t.Color?t.Color(e):(console.log("Color.js not found!"),e)},i.addResizeListener=function(t,e){var i=document.createElement("iframe"),s="chartjs-hidden-iframe";i.classlist?i.classlist.add(s):i.setAttribute("class",s),i.style.width="100%",i.style.display="block",i.style.border=0,i.style.height=0,i.style.margin=0,i.style.position="absolute",i.style.left=0,i.style.right=0,i.style.top=0,i.style.bottom=0,t.insertBefore(i,t.firstChild);(i.contentWindow||i).onresize=function(){e&&e()}},i.removeResizeListener=function(t){var e=t.querySelector(".chartjs-hidden-iframe");e&&e.parentNode.removeChild(e)},i.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(arg)},i.isDatasetVisible=function(t){return!t.hidden},i.callCallback=function(t,e,i){t&&"function"==typeof t.call&&t.apply(i,e)}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.elements={},e.Element=function(t){i.extend(this,t),this.initialize.apply(this,arguments)},i.extend(e.Element.prototype,{initialize:function(){},pivot:function(){return this._view||(this._view=i.clone(this._model)),this._start=i.clone(this._view),this},transition:function(t){return this._view||(this._view=i.clone(this._model)),1===t?(this._view=this._model,this._start=null,this):(this._start||this.pivot(),i.each(this._model,function(e,s){if("_"!==s[0]&&this._model.hasOwnProperty(s))if(this._view.hasOwnProperty(s))if(e===this._view[s]);else if("string"==typeof e)try{var a=i.color(this._start[s]).mix(i.color(this._model[s]),t);this._view[s]=a.rgbString()}catch(o){this._view[s]=e}else if("number"==typeof e){var n=void 0!==this._start[s]&&isNaN(this._start[s])===!1?this._start[s]:0;this._view[s]=(this._model[s]-n)*t+n}else this._view[s]=e;else"number"!=typeof e||isNaN(this._view[s])?this._view[s]=e:this._view[s]=e*t;else;},this),this)},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return i.isNumber(this._model.x)&&i.isNumber(this._model.y)}}),e.Element.extend=i.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:i.noop,onComplete:i.noop},e.Animation=e.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),e.animationService={frameDuration:17,animations:[],dropFrames:0,addAnimation:function(t,e,s,a){a||(t.animating=!0);for(var o=0;o<this.animations.length;++o)if(this.animations[o].chartInstance===t)return void(this.animations[o].animationObject=e);this.animations.push({chartInstance:t,animationObject:e}),1==this.animations.length&&i.requestAnimFrame.call(window,this.digestWrapper)},cancelAnimation:function(t){var e=i.findNextWhere(this.animations,function(e){return e.chartInstance===t});e&&(this.animations.splice(e,1),t.animating=!1)},digestWrapper:function(){e.animationService.startDigest.call(e.animationService)},startDigest:function(){var t=Date.now(),e=0;this.dropFrames>1&&(e=Math.floor(this.dropFrames),this.dropFrames=this.dropFrames%1);for(var s=0;s<this.animations.length;s++)null===this.animations[s].animationObject.currentStep&&(this.animations[s].animationObject.currentStep=0),this.animations[s].animationObject.currentStep+=1+e,this.animations[s].animationObject.currentStep>this.animations[s].animationObject.numSteps&&(this.animations[s].animationObject.currentStep=this.animations[s].animationObject.numSteps),this.animations[s].animationObject.render(this.animations[s].chartInstance,this.animations[s].animationObject),this.animations[s].animationObject.onAnimationProgress&&this.animations[s].animationObject.onAnimationProgress.call&&this.animations[s].animationObject.onAnimationProgress.call(this.animations[s].chartInstance,this.animations[s]),this.animations[s].animationObject.currentStep==this.animations[s].animationObject.numSteps&&(this.animations[s].animationObject.onAnimationComplete&&this.animations[s].animationObject.onAnimationComplete.call&&this.animations[s].animationObject.onAnimationComplete.call(this.animations[s].chartInstance,this.animations[s]),this.animations[s].chartInstance.animating=!1,this.animations.splice(s,1),s--);var a=Date.now(),o=(a-t)/this.frameDuration;this.dropFrames+=o,this.animations.length>0&&i.requestAnimFrame.call(window,this.digestWrapper)}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.types={},e.instances={},e.controllers={},e.Controller=function(t){return this.chart=t,this.config=t.config,this.options=this.config.options=i.configMerge(e.defaults.global,e.defaults[this.config.type],this.config.options||{}),this.id=i.uid(),Object.defineProperty(this,"data",{get:function(){return this.config.data}}),e.instances[this.id]=this,this.options.responsive&&this.resize(!0),this.initialize.call(this),this},i.extend(e.Controller.prototype,{initialize:function(){return this.bindEvents(),this.ensureScalesHaveIDs(),this.buildOrUpdateControllers(),this.buildScales(),this.buildSurroundingItems(),this.updateLayout(),this.resetElements(),this.initToolTip(),this.draw(),this.update(),this},clear:function(){return i.clear(this.chart),this},stop:function(){return e.animationService.cancelAnimation(this),this},resize:function(t){var e=this.chart.canvas,s=i.getMaximumWidth(this.chart.canvas),a=this.options.maintainAspectRatio&&isNaN(this.chart.aspectRatio)===!1&&isFinite(this.chart.aspectRatio)&&0!==this.chart.aspectRatio?s/this.chart.aspectRatio:i.getMaximumHeight(this.chart.canvas),o=this.chart.width!==s||this.chart.height!==a;return o?(e.width=this.chart.width=s,e.height=this.chart.height=a,i.retinaScale(this.chart),t||(this.stop(),this.update(this.options.responsiveAnimationDuration)),this):this},ensureScalesHaveIDs:function(){var t="x-axis-",e="y-axis-";this.options.scales&&(this.options.scales.xAxes&&this.options.scales.xAxes.length&&i.each(this.options.scales.xAxes,function(e,i){e.id=e.id||t+i}),this.options.scales.yAxes&&this.options.scales.yAxes.length&&i.each(this.options.scales.yAxes,function(t,i){t.id=t.id||e+i}))},buildScales:function(){if(this.scales={},this.options.scales&&(this.options.scales.xAxes&&this.options.scales.xAxes.length&&i.each(this.options.scales.xAxes,function(t,i){var s=e.scaleService.getScaleConstructor(t.type);if(s){var a=new s({ctx:this.chart.ctx,options:t,chart:this,id:t.id});this.scales[a.id]=a}},this),this.options.scales.yAxes&&this.options.scales.yAxes.length&&i.each(this.options.scales.yAxes,function(t,i){var s=e.scaleService.getScaleConstructor(t.type);if(s){var a=new s({ctx:this.chart.ctx,options:t,chart:this,id:t.id});this.scales[a.id]=a}},this)),this.options.scale){var t=e.scaleService.getScaleConstructor(this.options.scale.type);if(t){var s=new t({ctx:this.chart.ctx,options:this.options.scale,chart:this});this.scale=s,this.scales.radialScale=s}}e.scaleService.addScalesToLayout(this)},buildSurroundingItems:function(){this.options.title&&(this.titleBlock=new e.Title({ctx:this.chart.ctx,options:this.options.title,chart:this}),e.layoutService.addBox(this,this.titleBlock)),this.options.legend&&(this.legend=new e.Legend({ctx:this.chart.ctx,options:this.options.legend,chart:this}),e.layoutService.addBox(this,this.legend))},updateLayout:function(){e.layoutService.update(this,this.chart.width,this.chart.height)},buildOrUpdateControllers:function(){var t=[],s=[];if(i.each(this.data.datasets,function(i,a){i.type||(i.type=this.config.type);var o=i.type;t.push(o),i.controller?i.controller.updateIndex(a):(i.controller=new e.controllers[o](this,a),s.push(i.controller))},this),t.length>1)for(var a=1;a<t.length;a++)if(t[a]!=t[a-1]){this.isCombo=!0;break}return s},resetElements:function(){i.each(this.data.datasets,function(t,e){t.controller.reset()})},update:function(t,s){this.tooltip._data=this.data;var a=this.buildOrUpdateControllers();e.layoutService.update(this,this.chart.width,this.chart.height),i.each(a,function(t){t.reset()}),i.each(this.data.datasets,function(t,e){t.controller.buildOrUpdateElements()}),i.each(this.data.datasets,function(t,e){t.controller.update()}),this.render(t,s)},render:function(t,s){if(this.options.animation&&("undefined"!=typeof t&&0!==t||"undefined"==typeof t&&0!==this.options.animation.duration)){var a=new e.Animation;a.numSteps=(t||this.options.animation.duration)/16.66,a.easing=this.options.animation.easing,a.render=function(t,e){var s=i.easingEffects[e.easing],a=e.currentStep/e.numSteps,o=s(a);t.draw(o,a,e.currentStep)},a.onAnimationProgress=this.options.animation.onProgress,a.onAnimationComplete=this.options.animation.onComplete,e.animationService.addAnimation(this,a,t,s)}else this.draw(),this.options.animation&&this.options.animation.onComplete&&this.options.animation.onComplete.call&&this.options.animation.onComplete.call(this);return this},draw:function(t){var e=t||1;this.clear(),i.each(this.boxes,function(t){t.draw(this.chartArea)},this),this.scale&&this.scale.draw(),i.each(this.data.datasets,function(e,s){i.isDatasetVisible(e)&&e.controller.draw(t)}),this.tooltip.transition(e).draw()},getElementAtEvent:function(t){var e=i.getRelativePosition(t,this.chart),s=[];return i.each(this.data.datasets,function(t,a){i.isDatasetVisible(t)&&i.each(t.metaData,function(t,i){return t.inRange(e.x,e.y)?(s.push(t),s):void 0})}),s},getElementsAtEvent:function(t){var e=i.getRelativePosition(t,this.chart),s=[],a=function(){for(var t=0;t<this.data.datasets.length;t++)if(i.isDatasetVisible(this.data.datasets[t]))for(var s=0;s<this.data.datasets[t].metaData.length;s++)if(this.data.datasets[t].metaData[s].inRange(e.x,e.y))return this.data.datasets[t].metaData[s]}.call(this);return a?(i.each(this.data.datasets,function(t,e){i.isDatasetVisible(t)&&s.push(t.metaData[a._index])}),s):s},getDatasetAtEvent:function(t){var e=this.getElementAtEvent(t);return e.length>0&&(e=this.data.datasets[e[0]._datasetIndex].metaData),e},generateLegend:function(){return this.options.legendCallback(this)},destroy:function(){this.clear(),i.unbindEvents(this,this.events),i.removeResizeListener(this.chart.canvas.parentNode);var t=this.chart.canvas;t.width=this.chart.width,t.height=this.chart.height,void 0!==this.chart.originalDevicePixelRatio&&this.chart.ctx.scale(1/this.chart.originalDevicePixelRatio,1/this.chart.originalDevicePixelRatio),t.style.width=this.chart.originalCanvasStyleWidth,t.style.height=this.chart.originalCanvasStyleHeight,delete e.instances[this.id]},toBase64Image:function(){return this.chart.canvas.toDataURL.apply(this.chart.canvas,arguments)},initToolTip:function(){this.tooltip=new e.Tooltip({_chart:this.chart,_chartInstance:this,_data:this.data,_options:this.options},this)},bindEvents:function(){i.bindEvents(this,this.options.events,function(t){this.eventHandler(t)})},eventHandler:function(t){if(this.lastActive=this.lastActive||[],this.lastTooltipActive=this.lastTooltipActive||[],"mouseout"==t.type)this.active=[],this.tooltipActive=[];else{var e=this,s=function(i){switch(i){case"single":return e.getElementAtEvent(t);case"label":return e.getElementsAtEvent(t);case"dataset":return e.getDatasetAtEvent(t);default:return t}};this.active=s(this.options.hover.mode),this.tooltipActive=s(this.options.tooltips.mode)}this.options.hover.onHover&&this.options.hover.onHover.call(this,this.active),("mouseup"==t.type||"click"==t.type)&&(this.options.onClick&&this.options.onClick.call(this,t,this.active),this.legend&&this.legend.handleEvent&&this.legend.handleEvent(t));if(this.lastActive.length)switch(this.options.hover.mode){case"single":this.data.datasets[this.lastActive[0]._datasetIndex].controller.removeHoverStyle(this.lastActive[0],this.lastActive[0]._datasetIndex,this.lastActive[0]._index);break;case"label":case"dataset":for(var a=0;a<this.lastActive.length;a++)this.lastActive[a]&&this.data.datasets[this.lastActive[a]._datasetIndex].controller.removeHoverStyle(this.lastActive[a],this.lastActive[a]._datasetIndex,this.lastActive[a]._index)}if(this.active.length&&this.options.hover.mode)switch(this.options.hover.mode){case"single":this.data.datasets[this.active[0]._datasetIndex].controller.setHoverStyle(this.active[0]);break;case"label":case"dataset":for(var o=0;o<this.active.length;o++)this.active[o]&&this.data.datasets[this.active[o]._datasetIndex].controller.setHoverStyle(this.active[o])}if((this.options.tooltips.enabled||this.options.tooltips.custom)&&(this.tooltip.initialize(),this.tooltip._active=this.tooltipActive,this.tooltip.update()),this.tooltip.pivot(),!this.animating){var n;i.each(this.active,function(t,e){t!==this.lastActive[e]&&(n=!0)},this),i.each(this.tooltipActive,function(t,e){t!==this.lastTooltipActive[e]&&(n=!0)},this),(this.lastActive.length!==this.active.length||this.lastTooltipActive.length!==this.tooltipActive.length||n)&&(this.stop(),(this.options.tooltips.enabled||this.options.tooltips.custom)&&this.tooltip.update(!0),this.render(this.options.hover.animationDuration,!0))}return this.lastActive=this.active,this.lastTooltipActive=this.tooltipActive,this}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.DatasetController=function(t,e){this.initialize.call(this,t,e)},i.extend(e.DatasetController.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},reset:function(){this.update(!0)},buildOrUpdateElements:function(){var t=this.getDataset().data.length,e=this.getDataset().metaData.length;if(e>t)this.getDataset().metaData.splice(t,e-t);else if(t>e)for(var i=e;t>i;++i)this.addElementAndReset(i)},addElements:i.noop,addElementAndReset:i.noop,draw:i.noop,removeHoverStyle:i.noop,setHoverStyle:i.noop,update:i.noop}),e.DatasetController.extend=i.inherits}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.layoutService={defaults:{},addBox:function(t,e){t.boxes||(t.boxes=[]),t.boxes.push(e)},removeBox:function(t,e){t.boxes&&t.boxes.splice(t.boxes.indexOf(e),1)},update:function(t,e,s){function a(t){var e,i=t.isHorizontal();i?(e=t.update(t.options.fullWidth?p:k,y),S-=e.height):(e=t.update(v,x),k-=e.width),D.push({horizontal:i,minSize:e,box:t})}function o(t){var e=i.findNextWhere(D,function(e){return e.box===t});if(e)if(t.isHorizontal()){var s={left:C,right:w,top:0,bottom:0};t.update(t.options.fullWidth?p:k,f/2,s)}else t.update(e.minSize.width,S)}function n(t){var e=i.findNextWhere(D,function(e){return e.box===t}),s={left:0,right:0,top:_,bottom:A};e&&t.update(e.minSize.width,S,s)}function r(t){t.isHorizontal()?(t.left=t.options.fullWidth?h:C,t.right=t.options.fullWidth?e-h:C+k,t.top=T,t.bottom=T+t.height,T=t.bottom):(t.left=P,t.right=P+t.width,t.top=_,t.bottom=_+S,P=t.right)}if(t){var h=e>30?5:2,l=s>30?5:2,c=i.where(t.boxes,function(t){return"left"==t.options.position}),d=i.where(t.boxes,function(t){return"right"==t.options.position}),u=i.where(t.boxes,function(t){return"top"==t.options.position}),g=i.where(t.boxes,function(t){return"bottom"==t.options.position}),m=i.where(t.boxes,function(t){return"chartArea"==t.options.position});u.sort(function(t,e){return(e.options.fullWidth?1:0)-(t.options.fullWidth?1:0)}),g.sort(function(t,e){return(t.options.fullWidth?1:0)-(e.options.fullWidth?1:0)});var p=e-2*h,f=s-2*l,b=p/2,x=f/2,v=(e-b)/(c.length+d.length),y=(s-x)/(u.length+g.length),k=p,S=f,D=[];i.each(c.concat(d,u,g),a);var C=h,w=h,_=l,A=l;i.each(c.concat(d),o),i.each(c,function(t){C+=t.width}),i.each(d,function(t){w+=t.width}),i.each(u.concat(g),o),i.each(u,function(t){_+=t.height}),i.each(g,function(t){A+=t.height}),i.each(c.concat(d),n),C=h,w=h,_=l,A=l,i.each(c,function(t){C+=t.width}),i.each(d,function(t){w+=t.width}),i.each(u,function(t){_+=t.height}),i.each(g,function(t){A+=t.height});var M=s-_-A,I=e-C-w;(I!==k||M!==S)&&(i.each(c,function(t){t.height=M}),i.each(d,function(t){t.height=M}),i.each(u,function(t){t.width=I}),i.each(g,function(t){t.width=I}),S=M,k=I);var P=h,T=l;i.each(c.concat(u),r),P+=k,T+=S,i.each(d,r),i.each(g,r),t.chartArea={left:C,top:_,right:C+k,bottom:_+S},i.each(m,function(e){e.left=t.chartArea.left,e.top=t.chartArea.top,e.right=t.chartArea.right,e.bottom=t.chartArea.bottom,e.update(k,S)})}}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.legend={display:!0,position:"top",fullWidth:!0,onClick:function(t,e){var i=this.chart.data.datasets[e.datasetIndex];i.hidden=!i.hidden,this.chart.update()},labels:{boxWidth:40,fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",padding:10,generateLabels:function(t){return t.datasets.map(function(t,e){return{text:t.label,fillStyle:t.backgroundColor,hidden:t.hidden,lineCap:t.borderCapStyle,lineDash:t.borderDash,lineDashOffset:t.borderDashOffset,lineJoin:t.borderJoinStyle,lineWidth:t.borderWidth,strokeStyle:t.borderColor,datasetIndex:e}},this)}}},e.Legend=e.Element.extend({initialize:function(t){i.extend(this,t),this.legendHitBoxes=[],this.doughnutMode=!1},beforeUpdate:i.noop,update:function(t,e,i){return this.beforeUpdate(),this.maxWidth=t,this.maxHeight=e,this.margins=i,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this.beforeBuildLabels(),this.buildLabels(),this.afterBuildLabels(),this.beforeFit(),this.fit(),this.afterFit(),this.afterUpdate(),this.minSize},afterUpdate:i.noop,beforeSetDimensions:i.noop,setDimensions:function(){this.isHorizontal()?(this.width=this.maxWidth,this.left=0,this.right=this.width):(this.height=this.maxHeight,this.top=0,this.bottom=this.height),this.paddingLeft=0,this.paddingTop=0,this.paddingRight=0,this.paddingBottom=0,this.minSize={width:0,height:0}},afterSetDimensions:i.noop,beforeBuildLabels:i.noop,buildLabels:function(){this.legendItems=this.options.labels.generateLabels.call(this,this.chart.data)},afterBuildLabels:i.noop,beforeFit:i.noop,fit:function(){var t=this.ctx,e=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);if(this.legendHitBoxes=[],this.isHorizontal()?this.minSize.width=this.maxWidth:this.minSize.width=this.options.display?10:0,this.isHorizontal()?this.minSize.height=this.options.display?10:0:this.minSize.height=this.maxHeight,this.options.display&&this.isHorizontal()){this.lineWidths=[0];var s=this.legendItems.length?this.options.labels.fontSize+this.options.labels.padding:0;t.textAlign="left",t.textBaseline="top",t.font=e,i.each(this.legendItems,function(e,i){var a=this.options.labels.boxWidth+this.options.labels.fontSize/2+t.measureText(e.text).width;this.lineWidths[this.lineWidths.length-1]+a>=this.width&&(s+=this.options.labels.fontSize+this.options.labels.padding,this.lineWidths[this.lineWidths.length]=this.left),this.legendHitBoxes[i]={left:0,top:0,width:a,height:this.options.labels.fontSize},this.lineWidths[this.lineWidths.length-1]+=a+this.options.labels.padding},this),this.minSize.height+=s}this.width=this.minSize.width,this.height=this.minSize.height},afterFit:i.noop,isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},draw:function(){if(this.options.display){var t=this.ctx,s={x:this.left+(this.width-this.lineWidths[0])/2,y:this.top+this.options.labels.padding,line:0},a=i.fontString(this.options.labels.fontSize,this.options.labels.fontStyle,this.options.labels.fontFamily);this.isHorizontal()&&(t.textAlign="left",t.textBaseline="top",t.lineWidth=.5,t.strokeStyle=this.options.labels.fontColor,t.fillStyle=this.options.labels.fontColor,t.font=a,i.each(this.legendItems,function(i,a){var o=t.measureText(i.text).width,n=this.options.labels.boxWidth+this.options.labels.fontSize/2+o;s.x+n>=this.width&&(s.y+=this.options.labels.fontSize+this.options.labels.padding,s.line++,s.x=this.left+(this.width-this.lineWidths[s.line])/2),t.save();var r=function(t,e){return void 0!==t?t:e};t.fillStyle=r(i.fillStyle,e.defaults.global.defaultColor),t.lineCap=r(i.lineCap,e.defaults.global.elements.line.borderCapStyle),t.lineDashOffset=r(i.lineDashOffset,e.defaults.global.elements.line.borderDashOffset),t.lineJoin=r(i.lineJoin,e.defaults.global.elements.line.borderJoinStyle),t.lineWidth=r(i.lineWidth,e.defaults.global.elements.line.borderWidth),t.strokeStyle=r(i.strokeStyle,e.defaults.global.defaultColor),t.setLineDash&&t.setLineDash(r(i.lineDash,e.defaults.global.elements.line.borderDash)),t.strokeRect(s.x,s.y,this.options.labels.boxWidth,this.options.labels.fontSize),t.fillRect(s.x,s.y,this.options.labels.boxWidth,this.options.labels.fontSize),t.restore(),this.legendHitBoxes[a].left=s.x,this.legendHitBoxes[a].top=s.y,t.fillText(i.text,this.options.labels.boxWidth+this.options.labels.fontSize/2+s.x,s.y),i.hidden&&(t.beginPath(),t.lineWidth=2,t.moveTo(this.options.labels.boxWidth+this.options.labels.fontSize/2+s.x,s.y+this.options.labels.fontSize/2),t.lineTo(this.options.labels.boxWidth+this.options.labels.fontSize/2+s.x+o,s.y+this.options.labels.fontSize/2),t.stroke()),s.x+=n+this.options.labels.padding},this))}},handleEvent:function(t){var e=i.getRelativePosition(t,this.chart.chart);if(e.x>=this.left&&e.x<=this.right&&e.y>=this.top&&e.y<=this.bottom)for(var s=0;s<this.legendHitBoxes.length;++s){var a=this.legendHitBoxes[s];if(e.x>=a.left&&e.x<=a.left+a.width&&e.y>=a.top&&e.y<=a.top+a.height){this.options.onClick&&this.options.onClick.call(this,t,this.legendItems[s]);break}}}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.scale={display:!0,gridLines:{display:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawOnChartArea:!0,drawTicks:!0,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)",offsetGridLines:!1},scaleLabel:{fontColor:"#666",fontFamily:"Helvetica Neue",fontSize:12,fontStyle:"normal",labelString:"",display:!1},ticks:{beginAtZero:!1,fontSize:12,fontStyle:"normal",fontColor:"#666",fontFamily:"Helvetica Neue",maxRotation:90,mirror:!1,padding:10,reverse:!1,display:!0,autoSkip:!0,autoSkipPadding:20,callback:function(t){return""+t}}},e.Scale=e.Element.extend({beforeUpdate:function(){i.callCallback(this.options.beforeUpdate,[this])},update:function(t,e,s){return this.beforeUpdate(),this.maxWidth=t,this.maxHeight=e,this.margins=i.extend({left:0,right:0,top:0,bottom:0},s),this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this.beforeBuildTicks(),this.buildTicks(),this.afterBuildTicks(),this.beforeTickToLabelConversion(),this.convertTicksToLabels(),this.afterTickToLabelConversion(),this.beforeCalculateTickRotation(),this.calculateTickRotation(),this.afterCalculateTickRotation(),this.beforeFit(),this.fit(),this.afterFit(),this.afterUpdate(),this.minSize},afterUpdate:function(){i.callCallback(this.options.afterUpdate,[this])},beforeSetDimensions:function(){i.callCallback(this.options.beforeSetDimensions,[this])},setDimensions:function(){this.isHorizontal()?(this.width=this.maxWidth,this.left=0,this.right=this.width):(this.height=this.maxHeight,this.top=0,this.bottom=this.height),this.paddingLeft=0,this.paddingTop=0,this.paddingRight=0,this.paddingBottom=0},afterSetDimensions:function(){i.callCallback(this.options.afterSetDimensions,[this])},beforeDataLimits:function(){i.callCallback(this.options.beforeDataLimits,[this])},determineDataLimits:i.noop,afterDataLimits:function(){i.callCallback(this.options.afterDataLimits,[this])},beforeBuildTicks:function(){i.callCallback(this.options.beforeBuildTicks,[this])},buildTicks:i.noop,afterBuildTicks:function(){i.callCallback(this.options.afterBuildTicks,[this])},beforeTickToLabelConversion:function(){i.callCallback(this.options.beforeTickToLabelConversion,[this])},convertTicksToLabels:function(){this.ticks=this.ticks.map(function(t,e,i){return this.options.ticks.userCallback?this.options.ticks.userCallback(t,e,i):this.options.ticks.callback(t,e,i)},this)},afterTickToLabelConversion:function(){i.callCallback(this.options.afterTickToLabelConversion,[this])},beforeCalculateTickRotation:function(){i.callCallback(this.options.beforeCalculateTickRotation,[this])},calculateTickRotation:function(){var t=i.fontString(this.options.ticks.fontSize,this.options.ticks.fontStyle,this.options.ticks.fontFamily);this.ctx.font=t;var e,s=this.ctx.measureText(this.ticks[0]).width,a=this.ctx.measureText(this.ticks[this.ticks.length-1]).width;if(this.labelRotation=0,this.paddingRight=0,this.paddingLeft=0,this.options.display&&this.isHorizontal()){this.paddingRight=a/2+3,this.paddingLeft=s/2+3,this.longestTextCache||(this.longestTextCache={});for(var o,n,r=i.longestText(this.ctx,t,this.ticks,this.longestTextCache),h=r,l=this.getPixelForTick(1)-this.getPixelForTick(0)-6;h>l&&this.labelRotation<this.options.ticks.maxRotation;){if(o=Math.cos(i.toRadians(this.labelRotation)),n=Math.sin(i.toRadians(this.labelRotation)),e=o*s,e+this.options.ticks.fontSize/2>this.yLabelWidth&&(this.paddingLeft=e+this.options.ticks.fontSize/2),this.paddingRight=this.options.ticks.fontSize/2,n*r>this.maxHeight){this.labelRotation--;break}this.labelRotation++,h=o*r}}this.margins&&(this.paddingLeft=Math.max(this.paddingLeft-this.margins.left,0),this.paddingRight=Math.max(this.paddingRight-this.margins.right,0))},afterCalculateTickRotation:function(){i.callCallback(this.options.afterCalculateTickRotation,[this])},beforeFit:function(){i.callCallback(this.options.beforeFit,[this])},fit:function(){if(this.minSize={width:0,height:0},this.isHorizontal()?this.minSize.width=this.isFullWidth()?this.maxWidth-this.margins.left-this.margins.right:this.maxWidth:this.minSize.width=this.options.gridLines.display&&this.options.display?10:0,this.isHorizontal()?this.minSize.height=this.options.gridLines.display&&this.options.display?10:0:this.minSize.height=this.maxHeight,this.options.scaleLabel.display&&(this.isHorizontal()?this.minSize.height+=1.5*this.options.scaleLabel.fontSize:this.minSize.width+=1.5*this.options.scaleLabel.fontSize),this.options.ticks.display&&this.options.display){var t=i.fontString(this.options.ticks.fontSize,this.options.ticks.fontStyle,this.options.ticks.fontFamily);this.longestTextCache||(this.longestTextCache={});var e=i.longestText(this.ctx,t,this.ticks,this.longestTextCache);if(this.isHorizontal()){this.longestLabelWidth=e;var s=Math.sin(i.toRadians(this.labelRotation))*this.longestLabelWidth+1.5*this.options.ticks.fontSize;this.minSize.height=Math.min(this.maxHeight,this.minSize.height+s),t=i.fontString(this.options.ticks.fontSize,this.options.ticks.fontStyle,this.options.ticks.fontFamily),this.ctx.font=t;var a=this.ctx.measureText(this.ticks[0]).width,o=this.ctx.measureText(this.ticks[this.ticks.length-1]).width,n=Math.cos(i.toRadians(this.labelRotation)),r=Math.sin(i.toRadians(this.labelRotation));this.paddingLeft=0!==this.labelRotation?n*a+3:a/2+3,this.paddingRight=0!==this.labelRotation?r*(this.options.ticks.fontSize/2)+3:o/2+3}else{var h=this.maxWidth-this.minSize.width;this.options.ticks.mirror||(e+=this.options.ticks.padding),h>e?this.minSize.width+=e:this.minSize.width=this.maxWidth,this.paddingTop=this.options.ticks.fontSize/2,this.paddingBottom=this.options.ticks.fontSize/2}}this.margins&&(this.paddingLeft=Math.max(this.paddingLeft-this.margins.left,0),this.paddingTop=Math.max(this.paddingTop-this.margins.top,0),this.paddingRight=Math.max(this.paddingRight-this.margins.right,0),this.paddingBottom=Math.max(this.paddingBottom-this.margins.bottom,0)),this.width=this.minSize.width,this.height=this.minSize.height},afterFit:function(){i.callCallback(this.options.afterFit,[this])},isHorizontal:function(){return"top"===this.options.position||"bottom"===this.options.position},isFullWidth:function(){return this.options.fullWidth},getRightValue:function s(t){return null===t||"undefined"==typeof t?NaN:"number"==typeof t&&isNaN(t)?NaN:"object"==typeof t?t instanceof Date?t:s(this.isHorizontal()?t.x:t.y):t},getLabelForIndex:i.noop,getPixelForValue:i.noop,getPixelForTick:function(t,e){if(this.isHorizontal()){
39
- var i=this.width-(this.paddingLeft+this.paddingRight),s=i/Math.max(this.ticks.length-(this.options.gridLines.offsetGridLines?0:1),1),a=s*t+this.paddingLeft;e&&(a+=s/2);var o=this.left+Math.round(a);return o+=this.isFullWidth()?this.margins.left:0}var n=this.height-(this.paddingTop+this.paddingBottom);return this.top+t*(n/(this.ticks.length-1))},getPixelForDecimal:function(t){if(this.isHorizontal()){var e=this.width-(this.paddingLeft+this.paddingRight),i=e*t+this.paddingLeft,s=this.left+Math.round(i);return s+=this.isFullWidth()?this.margins.left:0}return this.top+t*this.height},draw:function(t){if(this.options.display){var e,s,a,o,n,r=0!==this.labelRotation,h=this.options.ticks.autoSkip;this.options.ticks.maxTicksLimit&&(n=this.options.ticks.maxTicksLimit),this.ctx.fillStyle=this.options.ticks.fontColor;var l=i.fontString(this.options.ticks.fontSize,this.options.ticks.fontStyle,this.options.ticks.fontFamily),c=Math.cos(i.toRadians(this.labelRotation)),d=Math.sin(i.toRadians(this.labelRotation)),u=this.longestLabelWidth*c;this.options.ticks.fontSize*d;if(this.isHorizontal()){e=!0;var g="bottom"===this.options.position?this.top:this.bottom-10,m="bottom"===this.options.position?this.top+10:this.bottom;if(s=!1,(u/2+this.options.ticks.autoSkipPadding)*this.ticks.length>this.width-(this.paddingLeft+this.paddingRight)&&(s=1+Math.floor((u/2+this.options.ticks.autoSkipPadding)*this.ticks.length/(this.width-(this.paddingLeft+this.paddingRight)))),h||(s=!1),n&&this.ticks.length>n)for(;!s||this.ticks.length/(s||1)>n;)s||(s=1),s+=1;i.each(this.ticks,function(a,o){var n=this.ticks.length==o+1,h=s>1&&o%s>0;if((!h||n)&&void 0!==a&&null!==a){var c=this.getPixelForTick(o),d=this.getPixelForTick(o,this.options.gridLines.offsetGridLines);this.options.gridLines.display&&(o===("undefined"!=typeof this.zeroLineIndex?this.zeroLineIndex:0)?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),c+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(c,g),this.ctx.lineTo(c,m)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(c,t.top),this.ctx.lineTo(c,t.bottom)),this.ctx.stroke()),this.options.ticks.display&&(this.ctx.save(),this.ctx.translate(d,r?this.top+12:"top"===this.options.position?this.bottom-10:this.top+10),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=l,this.ctx.textAlign=r?"right":"center",this.ctx.textBaseline=r?"middle":"top"===this.options.position?"bottom":"top",this.ctx.fillText(a,0,0),this.ctx.restore())}},this),this.options.scaleLabel.display&&(this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillStyle=this.options.scaleLabel.fontColor,this.ctx.font=i.fontString(this.options.scaleLabel.fontSize,this.options.scaleLabel.fontStyle,this.options.scaleLabel.fontFamily),a=this.left+(this.right-this.left)/2,o="bottom"===this.options.position?this.bottom-this.options.scaleLabel.fontSize/2:this.top+this.options.scaleLabel.fontSize/2,this.ctx.fillText(this.options.scaleLabel.labelString,a,o))}else{e=!0;var p="right"===this.options.position?this.left:this.right-5,f="right"===this.options.position?this.left+5:this.right;if(i.each(this.ticks,function(s,a){if(void 0!==s&&null!==s){var o=this.getPixelForTick(a);if(this.options.gridLines.display&&(a===("undefined"!=typeof this.zeroLineIndex?this.zeroLineIndex:0)?(this.ctx.lineWidth=this.options.gridLines.zeroLineWidth,this.ctx.strokeStyle=this.options.gridLines.zeroLineColor,e=!0):e&&(this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color,e=!1),o+=i.aliasPixel(this.ctx.lineWidth),this.ctx.beginPath(),this.options.gridLines.drawTicks&&(this.ctx.moveTo(p,o),this.ctx.lineTo(f,o)),this.options.gridLines.drawOnChartArea&&(this.ctx.moveTo(t.left,o),this.ctx.lineTo(t.right,o)),this.ctx.stroke()),this.options.ticks.display){var n,r=this.getPixelForTick(a,this.options.gridLines.offsetGridLines);this.ctx.save(),"left"===this.options.position?this.options.ticks.mirror?(n=this.right+this.options.ticks.padding,this.ctx.textAlign="left"):(n=this.right-this.options.ticks.padding,this.ctx.textAlign="right"):this.options.ticks.mirror?(n=this.left-this.options.ticks.padding,this.ctx.textAlign="right"):(n=this.left+this.options.ticks.padding,this.ctx.textAlign="left"),this.ctx.translate(n,r),this.ctx.rotate(-1*i.toRadians(this.labelRotation)),this.ctx.font=l,this.ctx.textBaseline="middle",this.ctx.fillText(s,0,0),this.ctx.restore()}}},this),this.options.scaleLabel.display){a="left"===this.options.position?this.left+this.options.scaleLabel.fontSize/2:this.right-this.options.scaleLabel.fontSize/2,o=this.top+(this.bottom-this.top)/2;var b="left"===this.options.position?-.5*Math.PI:.5*Math.PI;this.ctx.save(),this.ctx.translate(a,o),this.ctx.rotate(b),this.ctx.textAlign="center",this.ctx.fillStyle=this.options.scaleLabel.fontColor,this.ctx.font=i.fontString(this.options.scaleLabel.fontSize,this.options.scaleLabel.fontStyle,this.options.scaleLabel.fontFamily),this.ctx.textBaseline="middle",this.ctx.fillText(this.options.scaleLabel.labelString,0,0),this.ctx.restore()}}this.ctx.lineWidth=this.options.gridLines.lineWidth,this.ctx.strokeStyle=this.options.gridLines.color;var x=this.left,v=this.right,y=this.top,k=this.bottom;this.isHorizontal()?(y=k="top"===this.options.position?this.bottom:this.top,y+=i.aliasPixel(this.ctx.lineWidth),k+=i.aliasPixel(this.ctx.lineWidth)):(x=v="left"===this.options.position?this.right:this.left,x+=i.aliasPixel(this.ctx.lineWidth),v+=i.aliasPixel(this.ctx.lineWidth)),this.ctx.beginPath(),this.ctx.moveTo(x,y),this.ctx.lineTo(v,k),this.ctx.stroke()}}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.scaleService={constructors:{},defaults:{},registerScaleType:function(t,e,s){this.constructors[t]=e,this.defaults[t]=i.clone(s)},getScaleConstructor:function(t){return this.constructors.hasOwnProperty(t)?this.constructors[t]:void 0},getScaleDefaults:function(t){return this.defaults.hasOwnProperty(t)?i.scaleMerge(e.defaults.scale,this.defaults[t]):{}},addScalesToLayout:function(t){i.each(t.scales,function(i){e.layoutService.addBox(t,i)})}}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.title={display:!1,position:"top",fullWidth:!0,fontColor:"#666",fontFamily:"Helvetica Neue",fontSize:12,fontStyle:"bold",padding:10,text:""},e.Title=e.Element.extend({initialize:function(t){i.extend(this,t),this.options=i.configMerge(e.defaults.global.title,t.options),this.legendHitBoxes=[]},beforeUpdate:i.noop,update:function(t,e,i){return this.beforeUpdate(),this.maxWidth=t,this.maxHeight=e,this.margins=i,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this.beforeBuildLabels(),this.buildLabels(),this.afterBuildLabels(),this.beforeFit(),this.fit(),this.afterFit(),this.afterUpdate(),this.minSize},afterUpdate:i.noop,beforeSetDimensions:i.noop,setDimensions:function(){this.isHorizontal()?(this.width=this.maxWidth,this.left=0,this.right=this.width):(this.height=this.maxHeight,this.top=0,this.bottom=this.height),this.paddingLeft=0,this.paddingTop=0,this.paddingRight=0,this.paddingBottom=0,this.minSize={width:0,height:0}},afterSetDimensions:i.noop,beforeBuildLabels:i.noop,buildLabels:i.noop,afterBuildLabels:i.noop,beforeFit:i.noop,fit:function(){this.ctx,i.fontString(this.options.fontSize,this.options.fontStyle,this.options.fontFamily);this.isHorizontal()?this.minSize.width=this.maxWidth:this.minSize.width=0,this.isHorizontal()?this.minSize.height=0:this.minSize.height=this.maxHeight,this.isHorizontal()&&this.options.display&&(this.minSize.height+=this.options.fontSize+2*this.options.padding),this.width=this.minSize.width,this.height=this.minSize.height},afterFit:i.noop,isHorizontal:function(){return"top"==this.options.position||"bottom"==this.options.position},draw:function(){if(this.options.display){var t,e,s=this.ctx;if(this.isHorizontal())this.options.display&&(s.textAlign="center",s.textBaseline="middle",s.fillStyle=this.options.fontColor,s.font=i.fontString(this.options.fontSize,this.options.fontStyle,this.options.fontFamily),t=this.left+(this.right-this.left)/2,e=this.top+(this.bottom-this.top)/2,s.fillText(this.options.text,t,e));else if(this.options.display){t="left"==this.options.position?this.left+this.options.fontSize/2:this.right-this.options.fontSize/2,e=this.top+(this.bottom-this.top)/2;var a="left"==this.options.position?-.5*Math.PI:.5*Math.PI;s.save(),s.translate(t,e),s.rotate(a),s.textAlign="center",s.fillStyle=this.options.fontColor,s.font=i.fontString(this.options.fontSize,this.options.fontStyle,this.options.fontFamily),s.textBaseline="middle",s.fillText(this.options.text,0,0),s.restore()}}}})}.call(this),function(){"use strict";function t(t,e){return e&&(s.isArray(e)?t=t.concat(e):t.push(e)),t}var e=this,i=e.Chart,s=i.helpers;i.defaults.global.tooltips={enabled:!0,custom:null,mode:"single",backgroundColor:"rgba(0,0,0,0.8)",titleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",titleFontSize:12,titleFontStyle:"bold",titleSpacing:2,titleMarginBottom:6,titleColor:"#fff",titleAlign:"left",bodyFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",bodyFontSize:12,bodyFontStyle:"normal",bodySpacing:2,bodyColor:"#fff",bodyAlign:"left",footerFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",footerFontSize:12,footerFontStyle:"bold",footerSpacing:2,footerMarginTop:6,footerColor:"#fff",footerAlign:"left",yPadding:6,xPadding:6,caretSize:5,cornerRadius:6,multiKeyBackground:"#fff",callbacks:{beforeTitle:s.noop,title:function(t,e){var i="";return t.length>0&&(t[0].xLabel?i=t[0].xLabel:e.labels.length>0&&t[0].index<e.labels.length&&(i=e.labels[t[0].index])),i},afterTitle:s.noop,beforeBody:s.noop,beforeLabel:s.noop,label:function(t,e){var i=e.datasets[t.datasetIndex].label||"";return i+": "+t.yLabel},afterLabel:s.noop,afterBody:s.noop,beforeFooter:s.noop,footer:s.noop,afterFooter:s.noop}},i.Tooltip=i.Element.extend({initialize:function(){var t=this._options;s.extend(this,{_model:{xPadding:t.tooltips.xPadding,yPadding:t.tooltips.yPadding,bodyColor:t.tooltips.bodyColor,_bodyFontFamily:t.tooltips.bodyFontFamily,_bodyFontStyle:t.tooltips.bodyFontStyle,_bodyAlign:t.tooltips.bodyAlign,bodyFontSize:t.tooltips.bodyFontSize,bodySpacing:t.tooltips.bodySpacing,titleColor:t.tooltips.titleColor,_titleFontFamily:t.tooltips.titleFontFamily,_titleFontStyle:t.tooltips.titleFontStyle,titleFontSize:t.tooltips.titleFontSize,_titleAlign:t.tooltips.titleAlign,titleSpacing:t.tooltips.titleSpacing,titleMarginBottom:t.tooltips.titleMarginBottom,footerColor:t.tooltips.footerColor,_footerFontFamily:t.tooltips.footerFontFamily,_footerFontStyle:t.tooltips.footerFontStyle,footerFontSize:t.tooltips.footerFontSize,_footerAlign:t.tooltips.footerAlign,footerSpacing:t.tooltips.footerSpacing,footerMarginTop:t.tooltips.footerMarginTop,caretSize:t.tooltips.caretSize,cornerRadius:t.tooltips.cornerRadius,backgroundColor:t.tooltips.backgroundColor,opacity:0,legendColorBackground:t.tooltips.multiKeyBackground}})},getTitle:function(){var e=this._options.tooltips.callbacks.beforeTitle.apply(this,arguments),i=this._options.tooltips.callbacks.title.apply(this,arguments),s=this._options.tooltips.callbacks.afterTitle.apply(this,arguments),a=[];return a=t(a,e),a=t(a,i),a=t(a,s)},getBeforeBody:function(){var t=this._options.tooltips.callbacks.beforeBody.apply(this,arguments);return s.isArray(t)?t:void 0!==t?[t]:[]},getBody:function(t,e){var i=[];return s.each(t,function(t){var s=this._options.tooltips.callbacks.beforeLabel.call(this,t,e)||"",a=this._options.tooltips.callbacks.label.call(this,t,e)||"",o=this._options.tooltips.callbacks.afterLabel.call(this,t,e)||"";i.push(s+a+o)},this),i},getAfterBody:function(){var t=this._options.tooltips.callbacks.afterBody.apply(this,arguments);return s.isArray(t)?t:void 0!==t?[t]:[]},getFooter:function(){var e=this._options.tooltips.callbacks.beforeFooter.apply(this,arguments),i=this._options.tooltips.callbacks.footer.apply(this,arguments),s=this._options.tooltips.callbacks.afterFooter.apply(this,arguments),a=[];return a=t(a,e),a=t(a,i),a=t(a,s)},getAveragePosition:function(t){if(!t.length)return!1;var e=[],i=[];s.each(t,function(t){if(t){var s=t.tooltipPosition();e.push(s.x),i.push(s.y)}});for(var a=0,o=0,n=0;n<e.length;n++)a+=e[n],o+=i[n];return{x:Math.round(a/e.length),y:Math.round(o/e.length)}},update:function(t){if(this._active.length){this._model.opacity=1;var e,i=this._active[0],a=[],o=[];if("single"===this._options.tooltips.mode){var n=i._yScale||i._scale;o.push({xLabel:i._xScale?i._xScale.getLabelForIndex(i._index,i._datasetIndex):"",yLabel:n?n.getLabelForIndex(i._index,i._datasetIndex):"",index:i._index,datasetIndex:i._datasetIndex}),e=this.getAveragePosition(this._active)}else s.each(this._data.datasets,function(t,e){if(s.isDatasetVisible(t)){var a=t.metaData[i._index];if(a){var n=i._yScale||i._scale;o.push({xLabel:a._xScale?a._xScale.getLabelForIndex(a._index,a._datasetIndex):"",yLabel:n?n.getLabelForIndex(a._index,a._datasetIndex):"",index:i._index,datasetIndex:e})}}}),s.each(this._active,function(t){t&&a.push({borderColor:t._view.borderColor,backgroundColor:t._view.backgroundColor})}),e=this.getAveragePosition(this._active),e.y=this._active[0]._yScale.getPixelForDecimal(.5);s.extend(this._model,{title:this.getTitle(o,this._data),beforeBody:this.getBeforeBody(o,this._data),body:this.getBody(o,this._data),afterBody:this.getAfterBody(o,this._data),footer:this.getFooter(o,this._data)}),s.extend(this._model,{x:Math.round(e.x),y:Math.round(e.y),caretPadding:s.getValueOrDefault(e.padding,2),labelColors:a});var r=this.getTooltipSize(this._model);this.determineAlignment(r),s.extend(this._model,this.getBackgroundPoint(this._model,r))}else this._model.opacity=0;return t&&this._options.tooltips.custom&&this._options.tooltips.custom.call(this,this._model),this},getTooltipSize:function(t){var e=this._chart.ctx,i={height:2*t.yPadding,width:0},a=t.body.length+t.beforeBody.length+t.afterBody.length;return i.height+=t.title.length*t.titleFontSize,i.height+=(t.title.length-1)*t.titleSpacing,i.height+=t.title.length?t.titleMarginBottom:0,i.height+=a*t.bodyFontSize,i.height+=a?(a-1)*t.bodySpacing:0,i.height+=t.footer.length?t.footerMarginTop:0,i.height+=t.footer.length*t.footerFontSize,i.height+=t.footer.length?(t.footer.length-1)*t.footerSpacing:0,e.font=s.fontString(t.titleFontSize,t._titleFontStyle,t._titleFontFamily),s.each(t.title,function(t){i.width=Math.max(i.width,e.measureText(t).width)}),e.font=s.fontString(t.bodyFontSize,t._bodyFontStyle,t._bodyFontFamily),s.each(t.beforeBody.concat(t.afterBody),function(t){i.width=Math.max(i.width,e.measureText(t).width)}),s.each(t.body,function(s){i.width=Math.max(i.width,e.measureText(s).width+("single"!==this._options.tooltips.mode?t.bodyFontSize+2:0))},this),e.font=s.fontString(t.footerFontSize,t._footerFontStyle,t._footerFontFamily),s.each(t.footer,function(t){i.width=Math.max(i.width,e.measureText(t).width)}),i.width+=2*t.xPadding,i},determineAlignment:function(t){this._model.xAlign=this._model.yAlign="center",this._model.y<t.height?this._model.yAlign="top":this._model.y>this._chart.height-t.height&&(this._model.yAlign="bottom");var e,i,s,a,o,n=this,r=(this._chartInstance.chartArea.left+this._chartInstance.chartArea.right)/2,h=(this._chartInstance.chartArea.top+this._chartInstance.chartArea.bottom)/2;"center"===this._model.yAlign?(e=function(t){return r>=t},i=function(t){return t>r}):(e=function(e){return e<=t.width/2},i=function(e){return e>=n._chart.width-t.width/2}),s=function(e){return e+t.width>n._chart.width},a=function(e){return e-t.width<0},o=function(t){return h>=t?"top":"bottom"},e(this._model.x)?(this._model.xAlign="left",s(this._model.x)&&(this._model.xAlign="center",this._model.yAlign=o(this._model.y))):i(this._model.x)&&(this._model.xAlign="right",a(this._model.x)&&(this._model.xAlign="center",this._model.yAlign=o(this._model.y)))},getBackgroundPoint:function(t,e){var i={x:t.x,y:t.y};return"right"===t.xAlign?i.x-=e.width:"center"===t.xAlign&&(i.x-=e.width/2),"top"===t.yAlign?i.y+=t.caretPadding+t.caretSize:"bottom"===t.yAlign?i.y-=e.height+t.caretPadding+t.caretSize:i.y-=e.height/2,"center"==t.yAlign?"left"===t.xAlign?i.x+=t.caretPadding+t.caretSize:"right"===t.xAlign&&(i.x-=t.caretPadding+t.caretSize):"left"===t.xAlign?i.x-=t.cornerRadius+t.caretPadding:"right"===t.xAlign&&(i.x+=t.cornerRadius+t.caretPadding),i},drawCaret:function(t,e,i,a){var o,n,r,h,l,c,d=this._view,u=this._chart.ctx;"center"===d.yAlign?("left"===d.xAlign?(o=t.x,n=o-d.caretSize,r=o):(o=t.x+e.width,n=o+d.caretSize,r=o),l=t.y+e.height/2,h=l-d.caretSize,c=l+d.caretSize):("left"===d.xAlign?(o=t.x+d.cornerRadius,n=o+d.caretSize,r=n+d.caretSize):"right"===d.xAlign?(o=t.x+e.width-d.cornerRadius,n=o-d.caretSize,r=n-d.caretSize):(n=t.x+e.width/2,o=n-d.caretSize,r=n+d.caretSize),"top"===d.yAlign?(h=t.y,l=h-d.caretSize,c=h):(h=t.y+e.height,l=h+d.caretSize,c=h)),u.fillStyle=s.color(d.backgroundColor).alpha(i).rgbString(),u.beginPath(),u.moveTo(o,h),u.lineTo(n,l),u.lineTo(r,c),u.closePath(),u.fill()},drawTitle:function(t,e,i,a){e.title.length&&(i.textAlign=e._titleAlign,i.textBaseline="top",i.fillStyle=s.color(e.titleColor).alpha(a).rgbString(),i.font=s.fontString(e.titleFontSize,e._titleFontStyle,e._titleFontFamily),s.each(e.title,function(s,a){i.fillText(s,t.x,t.y),t.y+=e.titleFontSize+e.titleSpacing,a+1===e.title.length&&(t.y+=e.titleMarginBottom-e.titleSpacing)}))},drawBody:function(t,e,i,a){i.textAlign=e._bodyAlign,i.textBaseline="top",i.fillStyle=s.color(e.bodyColor).alpha(a).rgbString(),i.font=s.fontString(e.bodyFontSize,e._bodyFontStyle,e._bodyFontFamily),s.each(e.beforeBody,function(s){i.fillText(s,t.x,t.y),t.y+=e.bodyFontSize+e.bodySpacing}),s.each(e.body,function(o,n){"single"!==this._options.tooltips.mode&&(i.fillStyle=s.color(e.legendColorBackground).alpha(a).rgbaString(),i.fillRect(t.x,t.y,e.bodyFontSize,e.bodyFontSize),i.strokeStyle=s.color(e.labelColors[n].borderColor).alpha(a).rgbaString(),i.strokeRect(t.x,t.y,e.bodyFontSize,e.bodyFontSize),i.fillStyle=s.color(e.labelColors[n].backgroundColor).alpha(a).rgbaString(),i.fillRect(t.x+1,t.y+1,e.bodyFontSize-2,e.bodyFontSize-2),i.fillStyle=s.color(e.bodyColor).alpha(a).rgbaString()),i.fillText(o,t.x+("single"!==this._options.tooltips.mode?e.bodyFontSize+2:0),t.y),t.y+=e.bodyFontSize+e.bodySpacing},this),s.each(e.afterBody,function(s){i.fillText(s,t.x,t.y),t.y+=e.bodyFontSize}),t.y-=e.bodySpacing},drawFooter:function(t,e,i,a){e.footer.length&&(t.y+=e.footerMarginTop,i.textAlign=e._footerAlign,i.textBaseline="top",i.fillStyle=s.color(e.footerColor).alpha(a).rgbString(),i.font=s.fontString(e.footerFontSize,e._footerFontStyle,e._footerFontFamily),s.each(e.footer,function(s){i.fillText(s,t.x,t.y),t.y+=e.footerFontSize+e.footerSpacing}))},draw:function(){var t=this._chart.ctx,e=this._view;if(0!==e.opacity){var i=e.caretPadding,a=this.getTooltipSize(e),o={x:e.x,y:e.y},n=Math.abs(e.opacity<.001)?0:e.opacity;this._options.tooltips.enabled&&(t.fillStyle=s.color(e.backgroundColor).alpha(n).rgbString(),s.drawRoundedRectangle(t,o.x,o.y,a.width,a.height,e.cornerRadius),t.fill(),this.drawCaret(o,a,n,i),o.x+=e.xPadding,o.y+=e.yPadding,this.drawTitle(o,e,t,n),this.drawBody(o,e,t,n),this.drawFooter(o,e,t,n))}}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categoryPercentage:.8,barPercentage:.9,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},e.controllers.bar=e.DatasetController.extend({initialize:function(t,i){e.DatasetController.prototype.initialize.call(this,t,i),this.getDataset().bar=!0},getBarCount:function(){var t=0;return i.each(this.chart.data.datasets,function(e){i.isDatasetVisible(e)&&e.bar&&++t}),t},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Rectangle({_chart:this.chart.chart,_datasetIndex:this.index,_index:t}),s=this.getBarCount();this.updateElement(i,t,!0,s),this.getDataset().metaData.splice(t,0,i)},update:function(t){var e=this.getBarCount();i.each(this.getDataset().metaData,function(i,s){this.updateElement(i,s,t,e)},this)},updateElement:function(t,e,s,a){var o,n=this.getScaleForId(this.getDataset().xAxisID),r=this.getScaleForId(this.getDataset().yAxisID);o=r.min<0&&r.max<0?r.getPixelForValue(r.max):r.min>0&&r.max>0?r.getPixelForValue(r.min):r.getPixelForValue(0),i.extend(t,{_chart:this.chart.chart,_xScale:n,_yScale:r,_datasetIndex:this.index,_index:e,_model:{x:this.calculateBarX(e,this.index),y:s?o:this.calculateBarY(e,this.index),label:this.chart.data.labels[e],datasetLabel:this.getDataset().label,base:this.calculateBarBase(this.index,e),width:this.calculateBarWidth(a),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}}),t.pivot()},calculateBarBase:function(t,e){var s=(this.getScaleForId(this.getDataset().xAxisID),this.getScaleForId(this.getDataset().yAxisID)),a=0;if(s.options.stacked){var o=this.chart.data.datasets[t].data[e];if(0>o)for(var n=0;t>n;n++){var r=this.chart.data.datasets[n];i.isDatasetVisible(r)&&r.yAxisID===s.id&&r.bar&&(a+=r.data[e]<0?r.data[e]:0)}else for(var h=0;t>h;h++){var l=this.chart.data.datasets[h];i.isDatasetVisible(l)&&l.yAxisID===s.id&&l.bar&&(a+=l.data[e]>0?l.data[e]:0)}return s.getPixelForValue(a)}return a=s.getPixelForValue(s.min),s.beginAtZero||s.min<=0&&s.max>=0||s.min>=0&&s.max<=0?a=s.getPixelForValue(0,0):s.min<0&&s.max<0&&(a=s.getPixelForValue(s.max)),a},getRuler:function(){var t=this.getScaleForId(this.getDataset().xAxisID),e=(this.getScaleForId(this.getDataset().yAxisID),this.getBarCount()),i=function(){for(var e=t.getPixelForTick(1)-t.getPixelForTick(0),i=2;i<this.getDataset().data.length;i++)e=Math.min(t.getPixelForTick(i)-t.getPixelForTick(i-1),e);return e}.call(this),s=i*t.options.categoryPercentage,a=(i-i*t.options.categoryPercentage)/2,o=s/e,n=o*t.options.barPercentage,r=o-o*t.options.barPercentage;return{datasetCount:e,tickWidth:i,categoryWidth:s,categorySpacing:a,fullBarWidth:o,barWidth:n,barSpacing:r}},calculateBarWidth:function(){var t=this.getScaleForId(this.getDataset().xAxisID),e=this.getRuler();return t.options.stacked?e.categoryWidth:e.barWidth},getBarIndex:function(t){for(var e=0,s=0;t>s;++s)i.isDatasetVisible(this.chart.data.datasets[s])&&this.chart.data.datasets[s].bar&&++e;return e},calculateBarX:function(t,e){var i=(this.getScaleForId(this.getDataset().yAxisID),this.getScaleForId(this.getDataset().xAxisID)),s=this.getBarIndex(e),a=this.getRuler(),o=i.getPixelForValue(null,t,e,this.chart.isCombo);return o-=this.chart.isCombo?a.tickWidth/2:0,i.options.stacked?o+a.categoryWidth/2+a.categorySpacing:o+a.barWidth/2+a.categorySpacing+a.barWidth*s+a.barSpacing/2+a.barSpacing*s},calculateBarY:function(t,e){var s=(this.getScaleForId(this.getDataset().xAxisID),this.getScaleForId(this.getDataset().yAxisID)),a=this.getDataset().data[t];if(s.options.stacked){for(var o=0,n=0,r=0;e>r;r++){var h=this.chart.data.datasets[r];i.isDatasetVisible(h)&&h.bar&&h.yAxisID===s.id&&(h.data[t]<0?n+=h.data[t]||0:o+=h.data[t]||0)}return 0>a?s.getPixelForValue(n+a):s.getPixelForValue(o+a)}return s.getPixelForValue(a)},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t,i){var s=this.getDataset().data[i];null===s||void 0===s||isNaN(s)||t.transition(e).draw()},this)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],s=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,s,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,s,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.hoverBorderWidth,s,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.rectangle.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.rectangle.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.rectangle.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.bubble={hover:{mode:"single"},scales:{xAxes:[{type:"linear",position:"bottom",id:"x-axis-0"}],yAxes:[{type:"linear",position:"left",id:"y-axis-0"}]},tooltips:{callbacks:{title:function(t,e){return""},label:function(t,e){var i=e.datasets[t.datasetIndex].label||"",s=e.datasets[t.datasetIndex].data[t.index];return i+": ("+s.x+", "+s.y+", "+s.r+")"}}}},e.controllers.bubble=e.DatasetController.extend({addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i)},update:function(t){var e,s=this.getDataset().metaData,a=this.getScaleForId(this.getDataset().yAxisID);this.getScaleForId(this.getDataset().xAxisID);e=a.min<0&&a.max<0?a.getPixelForValue(a.max):a.min>0&&a.max>0?a.getPixelForValue(a.min):a.getPixelForValue(0),i.each(s,function(e,i){this.updateElement(e,i,t)},this)},updateElement:function(t,e,s){var a,o=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);a=o.min<0&&o.max<0?o.getPixelForValue(o.max):o.min>0&&o.max>0?o.getPixelForValue(o.min):o.getPixelForValue(0),i.extend(t,{_chart:this.chart.chart,_xScale:n,_yScale:o,_datasetIndex:this.index,_index:e,_model:{x:s?n.getPixelForDecimal(.5):n.getPixelForValue(this.getDataset().data[e],e,this.index,this.chart.isCombo),y:s?a:o.getPixelForValue(this.getDataset().data[e],e,this.index),radius:s?0:t.custom&&t.custom.radius?t.custom.radius:this.getRadius(this.getDataset().data[e]),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.point.borderWidth),hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}}),t._model.skip=t.custom&&t.custom.skip?t.custom.skip:isNaN(t._model.x)||isNaN(t._model.y),t.pivot()},getRadius:function(t){return t.r||this.chart.options.elements.point.radius},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t,i){t.transition(e),t.draw()})},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],s=t._index;t._model.radius=t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(e.hoverRadius,s,this.chart.options.elements.point.hoverRadius)+this.getRadius(this.getDataset().data[t._index]),t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,s,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,s,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.hoverBorderWidth,s,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.radius=t.custom&&t.custom.radius?t.custom.radius:this.getRadius(this.getDataset().data[t._index]),t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.point.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.point.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.point.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.doughnut={animation:{animateRotate:!0,animateScale:!1},aspectRatio:1,hover:{mode:"single"},legendCallback:function(t){var e=[];if(e.push('<ul class="'+t.id+'-legend">'),t.data.datasets.length)for(var i=0;i<t.data.datasets[0].data.length;++i)e.push('<li><span style="background-color:'+t.data.datasets[0].backgroundColor[i]+'">'),t.data.labels[i]&&e.push(t.data.labels[i]),e.push("</span></li>");return e.push("</ul>"),e.join("")},legend:{labels:{generateLabels:function(t){return t.labels.map(function(e,i){return{text:e,fillStyle:t.datasets[0].backgroundColor[i],hidden:isNaN(t.datasets[0].data[i]),index:i}})}},onClick:function(t,e){i.each(this.chart.data.datasets,function(t){t.metaHiddenData=t.metaHiddenData||[];var i=e.index;isNaN(t.data[i])?isNaN(t.metaHiddenData[i])||(t.data[i]=t.metaHiddenData[i]):(t.metaHiddenData[i]=t.data[i],t.data[i]=NaN)}),this.chart.update()}},cutoutPercentage:50,tooltips:{callbacks:{title:function(){return""},label:function(t,e){return e.labels[t.index]+": "+e.datasets[t.datasetIndex].data[t.index]}}}},e.defaults.pie=i.clone(e.defaults.doughnut),i.extend(e.defaults.pie,{cutoutPercentage:0}),e.controllers.doughnut=e.controllers.pie=e.DatasetController.extend({linkScales:function(){},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t,s){this.getDataset().metaData=this.getDataset().metaData||[];var a=new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});s&&i.isArray(this.getDataset().backgroundColor)&&this.getDataset().backgroundColor.splice(t,0,s),this.updateElement(a,t,!0),
40
- this.getDataset().metaData.splice(t,0,a)},getVisibleDatasetCount:function(){return i.where(this.chart.data.datasets,function(t){return i.isDatasetVisible(t)}).length},getRingIndex:function(t){for(var e=0,s=0;t>s;++s)i.isDatasetVisible(this.chart.data.datasets[s])&&++e;return e},update:function(t){var e=Math.min(this.chart.chartArea.right-this.chart.chartArea.left,this.chart.chartArea.bottom-this.chart.chartArea.top);this.chart.outerRadius=Math.max(e/2-this.chart.options.elements.arc.borderWidth/2,0),this.chart.innerRadius=Math.max(this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,0),this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.getVisibleDatasetCount(),this.getDataset().total=0,i.each(this.getDataset().data,function(t){isNaN(t)||(this.getDataset().total+=Math.abs(t))},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.getRingIndex(this.index),this.innerRadius=this.outerRadius-this.chart.radiusLength,i.each(this.getDataset().metaData,function(e,i){this.updateElement(e,i,t)},this)},updateElement:function(t,e,s){var a=(this.chart.chartArea.left+this.chart.chartArea.right)/2,o=(this.chart.chartArea.top+this.chart.chartArea.bottom)/2,n={x:a,y:o,startAngle:Math.PI*-.5,endAngle:Math.PI*-.5,circumference:this.chart.options.animation.animateRotate?0:this.calculateCircumference(this.getDataset().data[e]),outerRadius:this.chart.options.animation.animateScale?0:this.outerRadius,innerRadius:this.chart.options.animation.animateScale?0:this.innerRadius};i.extend(t,{_chart:this.chart.chart,_datasetIndex:this.index,_index:e,_model:s?n:{x:a,y:o,circumference:this.calculateCircumference(this.getDataset().data[e]),outerRadius:this.outerRadius,innerRadius:this.innerRadius,backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.arc.backgroundColor),hoverBackgroundColor:t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(this.getDataset().hoverBackgroundColor,e,this.chart.options.elements.arc.hoverBackgroundColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.arc.borderWidth),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.getDataset().label,e,this.chart.data.labels[e])}}),s||(0===e?t._model.startAngle=Math.PI*-.5:t._model.startAngle=this.getDataset().metaData[e-1]._model.endAngle,t._model.endAngle=t._model.startAngle+t._model.circumference,e<this.getDataset().data.length-1&&(this.getDataset().metaData[e+1]._model.startAngle=t._model.endAngle)),t.pivot()},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t,i){t.transition(e).draw()})},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],s=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,s,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,s,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.hoverBorderWidth,s,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.arc.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.arc.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.arc.borderWidth)},calculateCircumference:function(t){return this.getDataset().total>0&&!isNaN(t)?1.999999*Math.PI*(t/this.getDataset().total):0}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={showLines:!0,hover:{mode:"label"},scales:{xAxes:[{type:"category",id:"x-axis-0"}],yAxes:[{type:"linear",id:"y-axis-0"}]}},e.controllers.line=e.DatasetController.extend({addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i),this.chart.options.showLines&&0!==this.chart.options.elements.line.tension&&this.updateBezierControlPoints()},update:function(t){var e,s=this.getDataset().metaDataset,a=this.getDataset().metaData,o=this.getScaleForId(this.getDataset().yAxisID);this.getScaleForId(this.getDataset().xAxisID);e=o.min<0&&o.max<0?o.getPixelForValue(o.max):o.min>0&&o.max>0?o.getPixelForValue(o.min):o.getPixelForValue(0),this.chart.options.showLines&&(s._scale=o,s._datasetIndex=this.index,s._children=a,s._model={tension:s.custom&&s.custom.tension?s.custom.tension:i.getValueOrDefault(this.getDataset().tension,this.chart.options.elements.line.tension),backgroundColor:s.custom&&s.custom.backgroundColor?s.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:s.custom&&s.custom.borderWidth?s.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:s.custom&&s.custom.borderColor?s.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,borderCapStyle:s.custom&&s.custom.borderCapStyle?s.custom.borderCapStyle:this.getDataset().borderCapStyle||this.chart.options.elements.line.borderCapStyle,borderDash:s.custom&&s.custom.borderDash?s.custom.borderDash:this.getDataset().borderDash||this.chart.options.elements.line.borderDash,borderDashOffset:s.custom&&s.custom.borderDashOffset?s.custom.borderDashOffset:this.getDataset().borderDashOffset||this.chart.options.elements.line.borderDashOffset,borderJoinStyle:s.custom&&s.custom.borderJoinStyle?s.custom.borderJoinStyle:this.getDataset().borderJoinStyle||this.chart.options.elements.line.borderJoinStyle,fill:s.custom&&s.custom.fill?s.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e},s.pivot()),i.each(a,function(e,i){this.updateElement(e,i,t)},this),this.chart.options.showLines&&0!==this.chart.options.elements.line.tension&&this.updateBezierControlPoints()},getPointBackgroundColor:function(t,e){var s=this.chart.options.elements.point.backgroundColor,a=this.getDataset();return t.custom&&t.custom.backgroundColor?s=t.custom.backgroundColor:a.pointBackgroundColor?s=i.getValueAtIndexOrDefault(a.pointBackgroundColor,e,s):a.backgroundColor&&(s=a.backgroundColor),s},getPointBorderColor:function(t,e){var s=this.chart.options.elements.point.borderColor,a=this.getDataset();return t.custom&&t.custom.borderColor?s=t.custom.borderColor:a.pointBorderColor?s=i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,s):a.borderColor&&(s=a.borderColor),s},getPointBorderWidth:function(t,e){var s=this.chart.options.elements.point.borderWidth,a=this.getDataset();return t.custom&&void 0!==t.custom.borderWidth?s=t.custom.borderWidth:void 0!==a.pointBorderWidth?s=i.getValueAtIndexOrDefault(a.pointBorderWidth,e,s):void 0!==a.borderWidth&&(s=a.borderWidth),s},updateElement:function(t,e,s){var a,o=this.getScaleForId(this.getDataset().yAxisID),n=this.getScaleForId(this.getDataset().xAxisID);a=o.min<0&&o.max<0?o.getPixelForValue(o.max):o.min>0&&o.max>0?o.getPixelForValue(o.min):o.getPixelForValue(0),t._chart=this.chart.chart,t._xScale=n,t._yScale=o,t._datasetIndex=this.index,t._index=e,t._model={x:n.getPixelForValue(this.getDataset().data[e],e,this.index,this.chart.isCombo),y:s?a:this.calculatePointY(this.getDataset().data[e],e,this.index,this.chart.isCombo),tension:t.custom&&t.custom.tension?t.custom.tension:i.getValueOrDefault(this.getDataset().tension,this.chart.options.elements.line.tension),radius:t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,e,this.chart.options.elements.point.radius),pointStyle:t.custom&&t.custom.pointStyle?t.custom.pointStyle:i.getValueAtIndexOrDefault(this.getDataset().pointStyle,e,this.chart.options.elements.point.pointStyle),backgroundColor:this.getPointBackgroundColor(t,e),borderColor:this.getPointBorderColor(t,e),borderWidth:this.getPointBorderWidth(t,e),hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)},t._model.skip=t.custom&&t.custom.skip?t.custom.skip:isNaN(t._model.x)||isNaN(t._model.y)},calculatePointY:function(t,e,s,a){var o=(this.getScaleForId(this.getDataset().xAxisID),this.getScaleForId(this.getDataset().yAxisID));if(o.options.stacked){for(var n=0,r=0,h=this.chart.data.datasets.length-1;h>s;h--){var l=this.chart.data.datasets[h];"line"===l.type&&i.isDatasetVisible(l)&&(l.data[e]<0?r+=l.data[e]||0:n+=l.data[e]||0)}return 0>t?o.getPixelForValue(r+t):o.getPixelForValue(n+t)}return o.getPixelForValue(t)},updateBezierControlPoints:function(){i.each(this.getDataset().metaData,function(t,e){var s=i.splineCurve(i.previousItem(this.getDataset().metaData,e)._model,t._model,i.nextItem(this.getDataset().metaData,e)._model,t._model.tension);t._model.controlPointPreviousX=Math.max(Math.min(s.previous.x,this.chart.chartArea.right),this.chart.chartArea.left),t._model.controlPointPreviousY=Math.max(Math.min(s.previous.y,this.chart.chartArea.bottom),this.chart.chartArea.top),t._model.controlPointNextX=Math.max(Math.min(s.next.x,this.chart.chartArea.right),this.chart.chartArea.left),t._model.controlPointNextY=Math.max(Math.min(s.next.y,this.chart.chartArea.bottom),this.chart.chartArea.top),t.pivot()},this)},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t){t.transition(e)}),this.chart.options.showLines&&this.getDataset().metaDataset.transition(e).draw(),i.each(this.getDataset().metaData,function(t){t.draw()})},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],s=t._index;t._model.radius=t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(e.pointHoverRadius,s,this.chart.options.elements.point.hoverRadius),t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.pointHoverBackgroundColor,s,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.pointHoverBorderColor,s,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.pointHoverBorderWidth,s,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.radius=t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,e,this.chart.options.elements.point.radius),t._model.backgroundColor=this.getPointBackgroundColor(t,e),t._model.borderColor=this.getPointBorderColor(t,e),t._model.borderWidth=this.getPointBorderWidth(t,e)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.polarArea={scale:{type:"radialLinear",lineArc:!0},animateRotate:!0,animateScale:!0,aspectRatio:1,legendCallback:function(t){var e=[];if(e.push('<ul class="'+t.id+'-legend">'),t.data.datasets.length)for(var i=0;i<t.data.datasets[0].data.length;++i)e.push('<li><span style="background-color:'+t.data.datasets[0].backgroundColor[i]+'">'),t.data.labels[i]&&e.push(t.data.labels[i]),e.push("</span></li>");return e.push("</ul>"),e.join("")},legend:{labels:{generateLabels:function(t){return t.labels.map(function(e,i){return{text:e,fillStyle:t.datasets[0].backgroundColor[i],hidden:isNaN(t.datasets[0].data[i]),index:i}})}},onClick:function(t,e){i.each(this.chart.data.datasets,function(t){t.metaHiddenData=t.metaHiddenData||[];var i=e.index;isNaN(t.data[i])?isNaN(t.metaHiddenData[i])||(t.data[i]=t.metaHiddenData[i]):(t.metaHiddenData[i]=t.data[i],t.data[i]=NaN)}),this.chart.update()}},tooltips:{callbacks:{title:function(){return""},label:function(t,e){return e.labels[t.index]+": "+t.yLabel}}}},e.controllers.polarArea=e.DatasetController.extend({linkScales:function(){},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Arc({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i)},getVisibleDatasetCount:function(){return i.where(this.chart.data.datasets,function(t){return i.isDatasetVisible(t)}).length},update:function(t){var e=Math.min(this.chart.chartArea.right-this.chart.chartArea.left,this.chart.chartArea.bottom-this.chart.chartArea.top);this.chart.outerRadius=Math.max((e-this.chart.options.elements.arc.borderWidth/2)/2,0),this.chart.innerRadius=Math.max(this.chart.options.cutoutPercentage?this.chart.outerRadius/100*this.chart.options.cutoutPercentage:1,0),this.chart.radiusLength=(this.chart.outerRadius-this.chart.innerRadius)/this.getVisibleDatasetCount(),this.getDataset().total=0,i.each(this.getDataset().data,function(t){this.getDataset().total+=Math.abs(t)},this),this.outerRadius=this.chart.outerRadius-this.chart.radiusLength*this.index,this.innerRadius=this.outerRadius-this.chart.radiusLength,i.each(this.getDataset().metaData,function(e,i){this.updateElement(e,i,t)},this)},updateElement:function(t,e,s){for(var a=this.calculateCircumference(this.getDataset().data[e]),o=(this.chart.chartArea.left+this.chart.chartArea.right)/2,n=(this.chart.chartArea.top+this.chart.chartArea.bottom)/2,r=0,h=0;e>h;++h)isNaN(this.getDataset().data[h])||++r;var l=-.5*Math.PI+a*r,c=l+a,d={x:o,y:n,innerRadius:0,outerRadius:this.chart.options.animateScale?0:this.chart.scale.getDistanceFromCenterForValue(this.getDataset().data[e]),startAngle:this.chart.options.animateRotate?Math.PI*-.5:l,endAngle:this.chart.options.animateRotate?Math.PI*-.5:c,backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.arc.backgroundColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.arc.borderWidth),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.chart.data.labels,e,this.chart.data.labels[e])};i.extend(t,{_chart:this.chart.chart,_datasetIndex:this.index,_index:e,_scale:this.chart.scale,_model:s?d:{x:o,y:n,innerRadius:0,outerRadius:this.chart.scale.getDistanceFromCenterForValue(this.getDataset().data[e]),startAngle:l,endAngle:c,backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.arc.backgroundColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.arc.borderWidth),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.arc.borderColor),label:i.getValueAtIndexOrDefault(this.chart.data.labels,e,this.chart.data.labels[e])}}),t.pivot()},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t,i){t.transition(e).draw()})},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],s=t._index;t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,s,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,s,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.hoverBorderWidth,s,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().backgroundColor,e,this.chart.options.elements.arc.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().borderColor,e,this.chart.options.elements.arc.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().borderWidth,e,this.chart.options.elements.arc.borderWidth)},calculateCircumference:function(t){if(isNaN(t))return 0;var e=i.where(this.getDataset().data,function(t){return isNaN(t)}).length;return 2*Math.PI/(this.getDataset().data.length-e)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},e.controllers.radar=e.DatasetController.extend({linkScales:function(){},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData,_loop:!0}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i,_model:{x:0,y:0}})},this)},addElementAndReset:function(t){this.getDataset().metaData=this.getDataset().metaData||[];var i=new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:t});this.updateElement(i,t,!0),this.getDataset().metaData.splice(t,0,i),this.updateBezierControlPoints()},update:function(t){var e,s=this.getDataset().metaDataset,a=this.getDataset().metaData,o=this.chart.scale;e=o.min<0&&o.max<0?o.getPointPositionForValue(0,o.max):o.min>0&&o.max>0?o.getPointPositionForValue(0,o.min):o.getPointPositionForValue(0,0),i.extend(this.getDataset().metaDataset,{_datasetIndex:this.index,_children:this.getDataset().metaData,_model:{tension:s.custom&&s.custom.tension?s.custom.tension:i.getValueOrDefault(this.getDataset().tension,this.chart.options.elements.line.tension),backgroundColor:s.custom&&s.custom.backgroundColor?s.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:s.custom&&s.custom.borderWidth?s.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:s.custom&&s.custom.borderColor?s.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:s.custom&&s.custom.fill?s.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,borderCapStyle:s.custom&&s.custom.borderCapStyle?s.custom.borderCapStyle:this.getDataset().borderCapStyle||this.chart.options.elements.line.borderCapStyle,borderDash:s.custom&&s.custom.borderDash?s.custom.borderDash:this.getDataset().borderDash||this.chart.options.elements.line.borderDash,borderDashOffset:s.custom&&s.custom.borderDashOffset?s.custom.borderDashOffset:this.getDataset().borderDashOffset||this.chart.options.elements.line.borderDashOffset,borderJoinStyle:s.custom&&s.custom.borderJoinStyle?s.custom.borderJoinStyle:this.getDataset().borderJoinStyle||this.chart.options.elements.line.borderJoinStyle,scaleTop:o.top,scaleBottom:o.bottom,scaleZero:e}}),this.getDataset().metaDataset.pivot(),i.each(a,function(e,i){this.updateElement(e,i,t)},this),this.updateBezierControlPoints()},updateElement:function(t,e,s){var a=this.chart.scale.getPointPositionForValue(e,this.getDataset().data[e]);i.extend(t,{_datasetIndex:this.index,_index:e,_scale:this.chart.scale,_model:{x:s?this.chart.scale.xCenter:a.x,y:s?this.chart.scale.yCenter:a.y,tension:t.custom&&t.custom.tension?t.custom.tension:i.getValueOrDefault(this.getDataset().tension,this.chart.options.elements.line.tension),radius:t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().pointRadius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth),pointStyle:t.custom&&t.custom.pointStyle?t.custom.pointStyle:i.getValueAtIndexOrDefault(this.getDataset().pointStyle,e,this.chart.options.elements.point.pointStyle),hitRadius:t.custom&&t.custom.hitRadius?t.custom.hitRadius:i.getValueAtIndexOrDefault(this.getDataset().hitRadius,e,this.chart.options.elements.point.hitRadius)}}),t._model.skip=t.custom&&t.custom.skip?t.custom.skip:isNaN(t._model.x)||isNaN(t._model.y)},updateBezierControlPoints:function(){i.each(this.getDataset().metaData,function(t,e){var s=i.splineCurve(i.previousItem(this.getDataset().metaData,e,!0)._model,t._model,i.nextItem(this.getDataset().metaData,e,!0)._model,t._model.tension);t._model.controlPointPreviousX=Math.max(Math.min(s.previous.x,this.chart.chartArea.right),this.chart.chartArea.left),t._model.controlPointPreviousY=Math.max(Math.min(s.previous.y,this.chart.chartArea.bottom),this.chart.chartArea.top),t._model.controlPointNextX=Math.max(Math.min(s.next.x,this.chart.chartArea.right),this.chart.chartArea.left),t._model.controlPointNextY=Math.max(Math.min(s.next.y,this.chart.chartArea.bottom),this.chart.chartArea.top),t.pivot()},this)},draw:function(t){var e=t||1;i.each(this.getDataset().metaData,function(t,i){t.transition(e)}),this.getDataset().metaDataset.transition(e).draw(),i.each(this.getDataset().metaData,function(t){t.draw()})},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],s=t._index;t._model.radius=t.custom&&t.custom.hoverRadius?t.custom.hoverRadius:i.getValueAtIndexOrDefault(e.pointHoverRadius,s,this.chart.options.elements.point.hoverRadius),t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.pointHoverBackgroundColor,s,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.pointHoverBorderColor,s,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.pointHoverBorderWidth,s,t._model.borderWidth)},removeHoverStyle:function(t){var e=(this.chart.data.datasets[t._datasetIndex],t._index);t._model.radius=t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,e,this.chart.options.elements.point.radius),t._model.backgroundColor=t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),t._model.borderColor=t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),t._model.borderWidth=t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndexOrDefault(this.getDataset().pointBorderWidth,e,this.chart.options.elements.point.borderWidth)}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=(e.helpers,{position:"bottom"}),s=e.Scale.extend({buildTicks:function(t){this.ticks=this.chart.data.labels},getLabelForIndex:function(t,e){return this.ticks[t]},getPixelForValue:function(t,e,i,s){if(this.isHorizontal()){var a=this.width-(this.paddingLeft+this.paddingRight),o=a/Math.max(this.chart.data.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),n=o*e+this.paddingLeft;return this.options.gridLines.offsetGridLines&&s&&(n+=o/2),this.left+Math.round(n)}var r=this.height-(this.paddingTop+this.paddingBottom),h=r/Math.max(this.chart.data.labels.length-(this.options.gridLines.offsetGridLines?0:1),1),l=h*e+this.paddingTop;return this.options.gridLines.offsetGridLines&&s&&(l+=h/2),this.top+Math.round(l)}});e.scaleService.registerScaleType("category",s,i)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,s={position:"left",ticks:{callback:function(t,e,s){var a=s[1]-s[0];Math.abs(a)>1&&t!==Math.floor(t)&&(a=t-Math.floor(t));var o=i.log10(Math.abs(a)),n="";if(0!==t){var r=-1*Math.floor(o);r=Math.max(Math.min(r,20),0),n=t.toFixed(r)}else n="0";return n}}},a=e.Scale.extend({determineDataLimits:function(){if(this.min=null,this.max=null,this.options.stacked){var t={},e=!1,s=!1;i.each(this.chart.data.datasets,function(a){void 0===t[a.type]&&(t[a.type]={positiveValues:[],negativeValues:[]});var o=t[a.type].positiveValues,n=t[a.type].negativeValues;i.isDatasetVisible(a)&&(this.isHorizontal()?a.xAxisID===this.id:a.yAxisID===this.id)&&i.each(a.data,function(t,i){var a=+this.getRightValue(t);isNaN(a)||(o[i]=o[i]||0,n[i]=n[i]||0,this.options.relativePoints?o[i]=100:0>a?(s=!0,n[i]+=a):(e=!0,o[i]+=a))},this)},this),i.each(t,function(t){var e=t.positiveValues.concat(t.negativeValues),s=i.min(e),a=i.max(e);this.min=null===this.min?s:Math.min(this.min,s),this.max=null===this.max?a:Math.max(this.max,a)},this)}else i.each(this.chart.data.datasets,function(t){i.isDatasetVisible(t)&&(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t,e){var i=+this.getRightValue(t);isNaN(i)||(null===this.min?this.min=i:i<this.min&&(this.min=i),null===this.max?this.max=i:i>this.max&&(this.max=i))},this)},this);if(this.options.ticks.beginAtZero){var a=i.sign(this.min),o=i.sign(this.max);0>a&&0>o?this.max=0:a>0&&o>0&&(this.min=0)}void 0!==this.options.ticks.min?this.min=this.options.ticks.min:void 0!==this.options.ticks.suggestedMin&&(this.min=Math.min(this.min,this.options.ticks.suggestedMin)),void 0!==this.options.ticks.max?this.max=this.options.ticks.max:void 0!==this.options.ticks.suggestedMax&&(this.max=Math.max(this.max,this.options.ticks.suggestedMax)),this.min===this.max&&(this.min--,this.max++)},buildTicks:function(){this.ticks=[];var t;t=this.isHorizontal()?Math.min(this.options.ticks.maxTicksLimit?this.options.ticks.maxTicksLimit:11,Math.ceil(this.width/50)):Math.min(this.options.ticks.maxTicksLimit?this.options.ticks.maxTicksLimit:11,Math.ceil(this.height/(2*this.options.ticks.fontSize))),t=Math.max(2,t);var e=i.niceNum(this.max-this.min,!1),s=i.niceNum(e/(t-1),!0),a=Math.floor(this.min/s)*s,o=Math.ceil(this.max/s)*s,n=Math.ceil((o-a)/s);this.ticks.push(void 0!==this.options.ticks.min?this.options.ticks.min:a);for(var r=1;n>r;++r)this.ticks.push(a+r*s);this.ticks.push(void 0!==this.options.ticks.max?this.options.ticks.max:o),("left"==this.options.position||"right"==this.options.position)&&this.ticks.reverse(),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.ticks.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),this.ticksAsNumbers=this.ticks.slice(),this.zeroLineIndex=this.ticks.indexOf(0)},getLabelForIndex:function(t,e){return+this.getRightValue(this.chart.data.datasets[e].data[t])},getPixelForValue:function(t,e,i,s){var a,o=+this.getRightValue(t),n=this.end-this.start;if(this.isHorizontal()){var r=this.width-(this.paddingLeft+this.paddingRight);return a=this.left+r/n*(o-this.start),Math.round(a+this.paddingLeft)}var h=this.height-(this.paddingTop+this.paddingBottom);return a=this.bottom-this.paddingBottom-h/n*(o-this.start),Math.round(a)},getPixelForTick:function(t,e){return this.getPixelForValue(this.ticksAsNumbers[t],null,null,e)}});e.scaleService.registerScaleType("linear",a,s)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,s={position:"left",ticks:{callback:function(t,i,s){var a=t/Math.pow(10,Math.floor(e.helpers.log10(t)));return 1===a||2===a||5===a||0===i||i===s.length-1?t.toExponential():""}}},a=e.Scale.extend({determineDataLimits:function(){if(this.min=null,this.max=null,this.options.stacked){var t={};i.each(this.chart.data.datasets,function(e){i.isDatasetVisible(e)&&(this.isHorizontal()?e.xAxisID===this.id:e.yAxisID===this.id)&&(void 0===t[e.type]&&(t[e.type]=[]),i.each(e.data,function(i,s){var a=t[e.type],o=+this.getRightValue(i);isNaN(o)||(a[s]=a[s]||0,this.options.relativePoints?a[s]=100:a[s]+=o)},this))},this),i.each(t,function(t){var e=i.min(t),s=i.max(t);this.min=null===this.min?e:Math.min(this.min,e),this.max=null===this.max?s:Math.max(this.max,s)},this)}else i.each(this.chart.data.datasets,function(t){i.isDatasetVisible(t)&&(this.isHorizontal()?t.xAxisID===this.id:t.yAxisID===this.id)&&i.each(t.data,function(t,e){var i=+this.getRightValue(t);isNaN(i)||(null===this.min?this.min=i:i<this.min&&(this.min=i),null===this.max?this.max=i:i>this.max&&(this.max=i))},this)},this);this.min=void 0!==this.options.ticks.min?this.options.ticks.min:this.min,this.max=void 0!==this.options.ticks.max?this.options.ticks.max:this.max,this.min===this.max&&(0!==this.min&&null!==this.min?(this.min=Math.pow(10,Math.floor(i.log10(this.min))-1),this.max=Math.pow(10,Math.floor(i.log10(this.max))+1)):(this.min=1,this.max=10))},buildTicks:function(){this.tickValues=[];for(var t=void 0!==this.options.ticks.min?this.options.ticks.min:Math.pow(10,Math.floor(i.log10(this.min)));t<this.max;){this.tickValues.push(t);var e=Math.floor(i.log10(t)),s=Math.floor(t/Math.pow(10,e))+1;10===s&&(s=1,++e),t=s*Math.pow(10,e)}var a=void 0!==this.options.ticks.max?this.options.ticks.max:t;this.tickValues.push(a),("left"==this.options.position||"right"==this.options.position)&&this.tickValues.reverse(),this.max=i.max(this.tickValues),this.min=i.min(this.tickValues),this.options.ticks.reverse?(this.tickValues.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),this.ticks=this.tickValues.slice()},getLabelForIndex:function(t,e){return+this.getRightValue(this.chart.data.datasets[e].data[t])},getPixelForTick:function(t,e){return this.getPixelForValue(this.tickValues[t],null,null,e);
41
- },getPixelForValue:function(t,e,s,a){var o,n=+this.getRightValue(t),r=i.log10(this.end)-i.log10(this.start);if(this.isHorizontal())if(0===n)o=this.left+this.paddingLeft;else{var h=this.width-(this.paddingLeft+this.paddingRight);o=this.left+h/r*(i.log10(n)-i.log10(this.start)),o+=this.paddingLeft}else if(0===n)o=this.top+this.paddingTop;else{var l=this.height-(this.paddingTop+this.paddingBottom);o=this.bottom-this.paddingBottom-l/r*(i.log10(n)-i.log10(this.start))}return o}});e.scaleService.registerScaleType("logarithmic",a,s)}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,s={display:!0,animate:!0,lineArc:!1,position:"chartArea",angleLines:{display:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},ticks:{showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2},pointLabels:{fontFamily:"'Arial'",fontStyle:"normal",fontSize:10,fontColor:"#666",callback:function(t){return t}}},a=e.Scale.extend({getValueCount:function(){return this.chart.data.labels.length},setDimensions:function(){this.width=this.maxWidth,this.height=this.maxHeight,this.xCenter=Math.round(this.width/2),this.yCenter=Math.round(this.height/2);var t=i.min([this.height,this.width]);this.drawingArea=this.options.display?t/2-(this.options.ticks.fontSize/2+this.options.ticks.backdropPaddingY):t/2},determineDataLimits:function(){if(this.min=null,this.max=null,i.each(this.chart.data.datasets,function(t){i.isDatasetVisible(t)&&i.each(t.data,function(t,e){var i=+this.getRightValue(t);isNaN(i)||(null===this.min?this.min=i:i<this.min&&(this.min=i),null===this.max?this.max=i:i>this.max&&(this.max=i))},this)},this),this.options.ticks.beginAtZero){var t=i.sign(this.min),e=i.sign(this.max);0>t&&0>e?this.max=0:t>0&&e>0&&(this.min=0)}void 0!==this.options.ticks.min?this.min=this.options.ticks.min:void 0!==this.options.ticks.suggestedMin&&(this.min=Math.min(this.min,this.options.ticks.suggestedMin)),void 0!==this.options.ticks.max?this.max=this.options.ticks.max:void 0!==this.options.ticks.suggestedMax&&(this.max=Math.max(this.max,this.options.ticks.suggestedMax)),this.min===this.max&&(this.min--,this.max++)},buildTicks:function(){this.ticks=[];var t=Math.min(this.options.ticks.maxTicksLimit?this.options.ticks.maxTicksLimit:11,Math.ceil(this.drawingArea/(1.5*this.options.ticks.fontSize)));t=Math.max(2,t);var e=i.niceNum(this.max-this.min,!1),s=i.niceNum(e/(t-1),!0),a=Math.floor(this.min/s)*s,o=Math.ceil(this.max/s)*s,n=Math.ceil((o-a)/s);this.ticks.push(void 0!==this.options.ticks.min?this.options.ticks.min:a);for(var r=1;n>r;++r)this.ticks.push(a+r*s);this.ticks.push(void 0!==this.options.ticks.max?this.options.ticks.max:o),this.max=i.max(this.ticks),this.min=i.min(this.ticks),this.options.ticks.reverse?(this.ticks.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),this.zeroLineIndex=this.ticks.indexOf(0)},convertTicksToLabels:function(){e.Scale.prototype.convertTicksToLabels.call(this),this.pointLabels=this.chart.data.labels.map(this.options.pointLabels.callback,this)},getLabelForIndex:function(t,e){return+this.getRightValue(this.chart.data.datasets[e].data[t])},fit:function(){var t,e,s,a,o,n,r,h,l,c,d,u,g=i.min([this.height/2-this.options.pointLabels.fontSize-5,this.width/2]),m=this.width,p=0;for(this.ctx.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),e=0;e<this.getValueCount();e++)t=this.getPointPosition(e,g),s=this.ctx.measureText(this.pointLabels[e]?this.pointLabels[e]:"").width+5,0===e||e===this.getValueCount()/2?(a=s/2,t.x+a>m&&(m=t.x+a,o=e),t.x-a<p&&(p=t.x-a,r=e)):e<this.getValueCount()/2?t.x+s>m&&(m=t.x+s,o=e):e>this.getValueCount()/2&&t.x-s<p&&(p=t.x-s,r=e);l=p,c=Math.ceil(m-this.width),n=this.getIndexAngle(o),h=this.getIndexAngle(r),d=c/Math.sin(n+Math.PI/2),u=l/Math.sin(h+Math.PI/2),d=i.isNumber(d)?d:0,u=i.isNumber(u)?u:0,this.drawingArea=Math.round(g-(u+d)/2),this.setCenterPoint(u,d)},setCenterPoint:function(t,e){var i=this.width-e-this.drawingArea,s=t+this.drawingArea;this.xCenter=Math.round((s+i)/2+this.left),this.yCenter=Math.round(this.height/2+this.top)},getIndexAngle:function(t){var e=2*Math.PI/this.getValueCount();return t*e-Math.PI/2},getDistanceFromCenterForValue:function(t){if(null===t)return 0;var e=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-t)*e:(t-this.min)*e},getPointPosition:function(t,e){var i=this.getIndexAngle(t);return{x:Math.round(Math.cos(i)*e)+this.xCenter,y:Math.round(Math.sin(i)*e)+this.yCenter}},getPointPositionForValue:function(t,e){return this.getPointPosition(t,this.getDistanceFromCenterForValue(e))},draw:function(){if(this.options.display){var t=this.ctx;if(i.each(this.ticks,function(e,s){if(s>0||this.options.reverse){var a=this.getDistanceFromCenterForValue(this.ticks[s]),o=this.yCenter-a;if(this.options.gridLines.display)if(t.strokeStyle=this.options.gridLines.color,t.lineWidth=this.options.gridLines.lineWidth,this.options.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,a,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var n=0;n<this.getValueCount();n++){var r=this.getPointPosition(n,this.getDistanceFromCenterForValue(this.ticks[s]));0===n?t.moveTo(r.x,r.y):t.lineTo(r.x,r.y)}t.closePath(),t.stroke()}if(this.options.ticks.display){if(t.font=i.fontString(this.options.ticks.fontSize,this.options.ticks.fontStyle,this.options.ticks.fontFamily),this.options.ticks.showLabelBackdrop){var h=t.measureText(e).width;t.fillStyle=this.options.ticks.backdropColor,t.fillRect(this.xCenter-h/2-this.options.ticks.backdropPaddingX,o-this.options.ticks.fontSize/2-this.options.ticks.backdropPaddingY,h+2*this.options.ticks.backdropPaddingX,this.options.ticks.fontSize+2*this.options.ticks.backdropPaddingY)}t.textAlign="center",t.textBaseline="middle",t.fillStyle=this.options.ticks.fontColor,t.fillText(e,this.xCenter,o)}}},this),!this.options.lineArc){t.lineWidth=this.options.angleLines.lineWidth,t.strokeStyle=this.options.angleLines.color;for(var e=this.getValueCount()-1;e>=0;e--){if(this.options.angleLines.display){var s=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.options.reverse?this.min:this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(s.x,s.y),t.stroke(),t.closePath()}var a=this.getPointPosition(e,this.getDistanceFromCenterForValue(this.options.reverse?this.min:this.max)+5);t.font=i.fontString(this.options.pointLabels.fontSize,this.options.pointLabels.fontStyle,this.options.pointLabels.fontFamily),t.fillStyle=this.options.pointLabels.fontColor;var o=this.pointLabels.length,n=this.pointLabels.length/2,r=n/2,h=r>e||e>o-r,l=e===r||e===o-r;0===e?t.textAlign="center":e===n?t.textAlign="center":n>e?t.textAlign="left":t.textAlign="right",l?t.textBaseline="middle":h?t.textBaseline="bottom":t.textBaseline="top",t.fillText(this.pointLabels[e]?this.pointLabels[e]:"",a.x,a.y)}}}}});e.scaleService.registerScaleType("radialLinear",a,s)}.call(this),function(t){"use strict";if(!t)return void console.warn("Chart.js - Moment.js could not be found! You must include it before Chart.js to use the time scale. Download at http://momentjs.com/");var e=this,i=e.Chart,s=i.helpers,a={units:[{name:"millisecond",steps:[1,2,5,10,20,50,100,250,500]},{name:"second",steps:[1,2,5,10,30]},{name:"minute",steps:[1,2,5,10,30]},{name:"hour",steps:[1,2,3,6,12]},{name:"day",steps:[1,2,5]},{name:"week",maxStep:4},{name:"month",maxStep:3},{name:"quarter",maxStep:4},{name:"year",maxStep:!1}]},o={position:"bottom",time:{format:!1,unit:!1,round:!1,displayFormat:!1,displayFormats:{millisecond:"h:mm:ss.SSS a",second:"h:mm:ss a",minute:"h:mm:ss a",hour:"MMM D, hA",day:"ll",week:"ll",month:"MMM YYYY",quarter:"[Q]Q - YYYY",year:"YYYY"}}},n=i.Scale.extend({getLabelMoment:function(t,e){return this.labelMoments[t][e]},determineDataLimits:function(){this.labelMoments=[];var e=[];this.chart.data.labels&&this.chart.data.labels.length>0?(s.each(this.chart.data.labels,function(t,i){var s=this.parseTime(t);this.options.time.round&&s.startOf(this.options.time.round),e.push(s)},this),this.firstTick=t.min.call(this,e),this.lastTick=t.max.call(this,e)):(this.firstTick=null,this.lastTick=null),s.each(this.chart.data.datasets,function(i,a){var o=[];"object"==typeof i.data[0]?s.each(i.data,function(e,i){var s=this.parseTime(this.getRightValue(e));this.options.time.round&&s.startOf(this.options.time.round),o.push(s),this.firstTick=null!==this.firstTick?t.min(this.firstTick,s):s,this.lastTick=null!==this.lastTick?t.max(this.lastTick,s):s},this):o=e,this.labelMoments.push(o)},this),this.options.time.min&&(this.firstTick=this.parseTime(this.options.time.min)),this.options.time.max&&(this.lastTick=this.parseTime(this.options.time.max)),this.firstTick=(this.firstTick||t()).clone(),this.lastTick=(this.lastTick||t()).clone()},buildTicks:function(t){if(this.ticks=[],this.unitScale=1,this.options.time.unit)this.tickUnit=this.options.time.unit||"day",this.displayFormat=this.options.time.displayFormats[this.tickUnit],this.tickRange=Math.ceil(this.lastTick.diff(this.firstTick,this.tickUnit,!0));else{var e=this.isHorizontal()?this.width-(this.paddingLeft+this.paddingRight):this.height-(this.paddingTop+this.paddingBottom),i=e/(this.options.ticks.fontSize+10),o=this.options.time.round?0:1;this.tickUnit="millisecond",this.tickRange=Math.ceil(this.lastTick.diff(this.firstTick,this.tickUnit,!0)+o),this.displayFormat=this.options.time.displayFormats[this.tickUnit];for(var n=0,r=a.units[n];n<a.units.length;){if(this.unitScale=1,s.isArray(r.steps)&&Math.ceil(this.tickRange/i)<s.max(r.steps)){for(var h=0;h<r.steps.length;++h)if(r.steps[h]>Math.ceil(this.tickRange/i)){this.unitScale=r.steps[h];break}break}if(r.maxStep===!1||Math.ceil(this.tickRange/i)<r.maxStep){this.unitScale=Math.ceil(this.tickRange/i);break}++n,r=a.units[n],this.tickUnit=r.name,this.tickRange=Math.ceil(this.lastTick.diff(this.firstTick,this.tickUnit)+o),this.displayFormat=this.options.time.displayFormats[r.name]}}var l;this.options.time.min?l=this.firstTick.clone().startOf(this.tickUnit):(this.firstTick.startOf(this.tickUnit),l=this.firstTick),this.options.time.max||this.lastTick.endOf(this.tickUnit),this.smallestLabelSeparation=this.width,s.each(this.chart.data.datasets,function(t,e){for(var i=1;i<this.labelMoments[e].length;i++)this.smallestLabelSeparation=Math.min(this.smallestLabelSeparation,this.labelMoments[e][i].diff(this.labelMoments[e][i-1],this.tickUnit,!0))},this),this.options.time.displayFormat&&(this.displayFormat=this.options.time.displayFormat),this.ticks.push(this.firstTick.clone());for(var c=1;c<this.tickRange;++c){var d=l.clone().add(c,this.tickUnit);if(this.options.time.max&&d.diff(this.lastTick,this.tickUnit,!0)>=0)break;c%this.unitScale===0&&this.ticks.push(d)}this.options.time.max?this.ticks.push(this.lastTick.clone()):0!==this.ticks[this.ticks.length-1].diff(this.lastTick,this.tickUnit,!0)&&(this.tickRange=Math.ceil(this.tickRange/this.unitScale)*this.unitScale,this.ticks.push(this.firstTick.clone().add(this.tickRange,this.tickUnit)),this.lastTick=this.ticks[this.ticks.length-1].clone())},getLabelForIndex:function(t,e){var i=this.chart.data.labels&&t<this.chart.data.labels.length?this.chart.data.labels[t]:"";return"object"==typeof this.chart.data.datasets[e].data[0]&&(i=this.getRightValue(this.chart.data.datasets[e].data[t])),this.options.time.tooltipFormat&&(i=this.parseTime(i).format(this.options.time.tooltipFormat)),i},convertTicksToLabels:function(){this.ticks=this.ticks.map(function(t,e,i){var s=t.format(this.displayFormat);return this.options.ticks.userCallback?this.options.ticks.userCallback(s,e,i):s},this)},getPixelForValue:function(t,e,i,s){var a=this.getLabelMoment(i,e),o=a.diff(this.firstTick,this.tickUnit,!0),n=o/this.tickRange;if(this.isHorizontal()){var r=this.width-(this.paddingLeft+this.paddingRight),h=(r/Math.max(this.ticks.length-1,1),r*n+this.paddingLeft);return this.left+Math.round(h)}var l=this.height-(this.paddingTop+this.paddingBottom),c=(l/Math.max(this.ticks.length-1,1),l*n+this.paddingTop);return this.top+Math.round(c)},parseTime:function(e){return"function"==typeof e.getMonth||"number"==typeof e?t(e):e.isValid&&e.isValid()?e:"string"!=typeof this.options.time.format&&this.options.time.format.call?this.options.time.format(e):t(e,this.options.time.format)}});i.scaleService.registerScaleType("time",n,o)}.call(this,t),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.elements.arc={backgroundColor:e.defaults.global.defaultColor,borderColor:"#fff",borderWidth:2},e.elements.Arc=e.Element.extend({inLabelRange:function(t){var e=this._view;return e?Math.pow(t-e.x,2)<Math.pow(e.radius+e.hoverRadius,2):!1},inRange:function(t,e){var s=this._view;if(s){var a=i.getAngleFromPoint(s,{x:t,y:e}),o=s.startAngle<-.5*Math.PI?s.startAngle+2*Math.PI:s.startAngle>1.5*Math.PI?s.startAngle-2*Math.PI:s.startAngle,n=s.endAngle<-.5*Math.PI?s.endAngle+2*Math.PI:s.endAngle>1.5*Math.PI?s.endAngle-2*Math.PI:s.endAngle,r=a.angle>=o&&a.angle<=n,h=a.distance>=s.innerRadius&&a.distance<=s.outerRadius;return r&&h}return!1},tooltipPosition:function(){var t=this._view,e=t.startAngle+(t.endAngle-t.startAngle)/2,i=(t.outerRadius-t.innerRadius)/2+t.innerRadius;return{x:t.x+Math.cos(e)*i,y:t.y+Math.sin(e)*i}},draw:function(){var t=this._chart.ctx,e=this._view;t.beginPath(),t.arc(e.x,e.y,e.outerRadius,e.startAngle,e.endAngle),t.arc(e.x,e.y,e.innerRadius,e.endAngle,e.startAngle,!0),t.closePath(),t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.fillStyle=e.backgroundColor,t.fill(),t.lineJoin="bevel",e.borderWidth&&t.stroke()}})}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.elements.line={tension:.4,backgroundColor:e.defaults.global.defaultColor,borderWidth:3,borderColor:e.defaults.global.defaultColor,borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",fill:!0},e.elements.Line=e.Element.extend({lineToNextPoint:function(t,e,i,s,a){var o=this._chart.ctx;e._view.skip?s.call(this,t,e,i):t._view.skip?a.call(this,t,e,i):0===e._view.tension?o.lineTo(e._view.x,e._view.y):o.bezierCurveTo(t._view.controlPointNextX,t._view.controlPointNextY,e._view.controlPointPreviousX,e._view.controlPointPreviousY,e._view.x,e._view.y)},draw:function(){function t(t){n._view.skip||r._view.skip?t&&o.lineTo(s._view.scaleZero.x,s._view.scaleZero.y):o.bezierCurveTo(r._view.controlPointNextX,r._view.controlPointNextY,n._view.controlPointPreviousX,n._view.controlPointPreviousY,n._view.x,n._view.y)}var s=this,a=this._view,o=this._chart.ctx,n=this._children[0],r=this._children[this._children.length-1];o.save(),this._children.length>0&&a.fill&&(o.beginPath(),i.each(this._children,function(t,e){var s=i.previousItem(this._children,e),n=i.nextItem(this._children,e);0===e?(this._loop?o.moveTo(a.scaleZero.x,a.scaleZero.y):o.moveTo(t._view.x,a.scaleZero),t._view.skip?this._loop||o.moveTo(n._view.x,this._view.scaleZero):o.lineTo(t._view.x,t._view.y)):this.lineToNextPoint(s,t,n,function(t,e,i){this._loop?o.lineTo(this._view.scaleZero.x,this._view.scaleZero.y):(o.lineTo(t._view.x,this._view.scaleZero),o.moveTo(i._view.x,this._view.scaleZero))},function(t,e){o.lineTo(e._view.x,e._view.y)})},this),this._loop?t(!0):(o.lineTo(this._children[this._children.length-1]._view.x,a.scaleZero),o.lineTo(this._children[0]._view.x,a.scaleZero)),o.fillStyle=a.backgroundColor||e.defaults.global.defaultColor,o.closePath(),o.fill()),o.lineCap=a.borderCapStyle||e.defaults.global.elements.line.borderCapStyle,o.setLineDash&&o.setLineDash(a.borderDash||e.defaults.global.elements.line.borderDash),o.lineDashOffset=a.borderDashOffset||e.defaults.global.elements.line.borderDashOffset,o.lineJoin=a.borderJoinStyle||e.defaults.global.elements.line.borderJoinStyle,o.lineWidth=a.borderWidth||e.defaults.global.elements.line.borderWidth,o.strokeStyle=a.borderColor||e.defaults.global.defaultColor,o.beginPath(),i.each(this._children,function(t,e){var s=i.previousItem(this._children,e),a=i.nextItem(this._children,e);0===e?o.moveTo(t._view.x,t._view.y):this.lineToNextPoint(s,t,a,function(t,e,i){o.moveTo(i._view.x,i._view.y)},function(t,e){o.moveTo(e._view.x,e._view.y)})},this),this._loop&&this._children.length>0&&t(),o.stroke(),o.restore()}})}.call(this),function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.point={radius:3,pointStyle:"circle",backgroundColor:e.defaults.global.defaultColor,borderWidth:1,borderColor:e.defaults.global.defaultColor,hitRadius:1,hoverRadius:4,hoverBorderWidth:1},e.elements.Point=e.Element.extend({inRange:function(t,e){var i=this._view;if(i){var s=i.hitRadius+i.radius;return Math.pow(t-i.x,2)+Math.pow(e-i.y,2)<Math.pow(s,2)}return!1},inLabelRange:function(t){var e=this._view;return e?Math.pow(t-e.x,2)<Math.pow(e.radius+e.hitRadius,2):!1},tooltipPosition:function(){var t=this._view;return{x:t.x,y:t.y,padding:t.radius+t.borderWidth}},draw:function(){var t=this._view,i=this._chart.ctx;if(!t.skip&&(t.radius>0||t.borderWidth>0)){i.strokeStyle=t.borderColor||e.defaults.global.defaultColor,i.lineWidth=t.borderWidth||e.defaults.global.elements.point.borderWidth,i.fillStyle=t.backgroundColor||e.defaults.global.defaultColor;var s=t.radius||e.defaults.global.elements.point.radius;switch(t.pointStyle){case"circle":default:i.beginPath(),i.arc(t.x,t.y,s,0,2*Math.PI),i.closePath(),i.fill();break;case"triangle":i.beginPath();var a=3*s/Math.sqrt(3),o=a*Math.sqrt(3)/2;i.moveTo(t.x-a/2,t.y+o/3),i.lineTo(t.x+a/2,t.y+o/3),i.lineTo(t.x,t.y-2*o/3),i.closePath(),i.fill();break;case"rect":i.fillRect(t.x-1/Math.SQRT2*s,t.y-1/Math.SQRT2*s,2/Math.SQRT2*s,2/Math.SQRT2*s),i.strokeRect(t.x-1/Math.SQRT2*s,t.y-1/Math.SQRT2*s,2/Math.SQRT2*s,2/Math.SQRT2*s);break;case"rectRot":i.translate(t.x,t.y),i.rotate(Math.PI/4),i.fillRect(-1/Math.SQRT2*s,-1/Math.SQRT2*s,2/Math.SQRT2*s,2/Math.SQRT2*s),i.strokeRect(-1/Math.SQRT2*s,-1/Math.SQRT2*s,2/Math.SQRT2*s,2/Math.SQRT2*s),i.setTransform(1,0,0,1,0,0);break;case"cross":i.beginPath(),i.moveTo(t.x,t.y+s),i.lineTo(t.x,t.y-s),i.moveTo(t.x-s,t.y),i.lineTo(t.x+s,t.y),i.closePath();break;case"crossRot":i.beginPath();var n=Math.cos(Math.PI/4)*s,r=Math.sin(Math.PI/4)*s;i.moveTo(t.x-n,t.y-r),i.lineTo(t.x+n,t.y+r),i.moveTo(t.x-n,t.y+r),i.lineTo(t.x+n,t.y-r),i.closePath();break;case"star":i.beginPath(),i.moveTo(t.x,t.y+s),i.lineTo(t.x,t.y-s),i.moveTo(t.x-s,t.y),i.lineTo(t.x+s,t.y);var n=Math.cos(Math.PI/4)*s,r=Math.sin(Math.PI/4)*s;i.moveTo(t.x-n,t.y-r),i.lineTo(t.x+n,t.y+r),i.moveTo(t.x-n,t.y+r),i.lineTo(t.x+n,t.y-r),i.closePath();break;case"line":i.beginPath(),i.moveTo(t.x-s,t.y),i.lineTo(t.x+s,t.y),i.closePath();break;case"dash":i.beginPath(),i.moveTo(t.x,t.y),i.lineTo(t.x+s,t.y),i.closePath()}i.stroke()}}})}.call(this),function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.rectangle={backgroundColor:e.defaults.global.defaultColor,borderWidth:0,borderColor:e.defaults.global.defaultColor},e.elements.Rectangle=e.Element.extend({draw:function(){var t=this._chart.ctx,e=this._view,i=e.width/2,s=e.x-i,a=e.x+i,o=e.base-(e.base-e.y),n=e.borderWidth/2;e.borderWidth&&(s+=n,a-=n,o+=n),t.beginPath(),t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.moveTo(s,e.base),t.lineTo(s,o),t.lineTo(a,o),t.lineTo(a,e.base),t.fill(),e.borderWidth&&t.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=this._view,s=!1;return i&&(s=i.y<i.base?t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y),s},inLabelRange:function(t){var e=this._view;return e?t>=e.x-e.width/2&&t<=e.x+e.width/2:!1},tooltipPosition:function(){var t=this._view;return{x:t.x,y:t.y}}})}.call(this),function(){"use strict";var t=this,e=t.Chart;e.helpers;e.Bar=function(t,i){return i.type="bar",new e(t,i)}}.call(this),function(){"use strict";var t=this,e=t.Chart;e.helpers;e.Bubble=function(t,i){return i.type="bubble",new e(t,i)}}.call(this),function(){"use strict";var t=this,e=t.Chart;e.helpers;e.Doughnut=function(t,i){return i.type="doughnut",new e(t,i)}}.call(this),function(){"use strict";var t=this,e=t.Chart;e.helpers;e.Line=function(t,i){return i.type="line",new e(t,i)}}.call(this),function(){"use strict";var t=this,e=t.Chart;e.helpers;e.PolarArea=function(t,i){return i.type="polarArea",new e(t,i)}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers,s={aspectRatio:1};e.Radar=function(t,a){return a.options=i.configMerge(s,a.options),a.type="radar",new e(t,a)}}.call(this),function(){"use strict";var t=this,e=t.Chart,i=(e.helpers,{hover:{mode:"single"},scales:{xAxes:[{type:"linear",position:"bottom",id:"x-axis-1"}],yAxes:[{type:"linear",position:"left",id:"y-axis-1"}]},tooltips:{callbacks:{title:function(t,e){return""},label:function(t,e){return"("+t.xLabel+", "+t.yLabel+")"}}}});e.defaults.scatter=i,e.controllers.scatter=e.controllers.line,e.Scatter=function(t,i){return i.type="scatter",new e(t,i)}}.call(this),this.Chart});
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  /*!
2
  * Chart.js
3
  * http://chartjs.org/
4
+ * Version: 2.4.0
5
  *
6
+ * Copyright 2016 Nick Downie
7
  * Released under the MIT license
8
+ * https://github.com/chartjs/Chart.js/blob/master/LICENSE.md
9
  */
10
+ !function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.Chart=t()}}(function(){return function t(e,a,i){function n(r,l){if(!a[r]){if(!e[r]){var s="function"==typeof require&&require;if(!l&&s)return s(r,!0);if(o)return o(r,!0);var d=new Error("Cannot find module '"+r+"'");throw d.code="MODULE_NOT_FOUND",d}var u=a[r]={exports:{}};e[r][0].call(u.exports,function(t){var a=e[r][1][t];return n(a?a:t)},u,u.exports,t,e,a,i)}return a[r].exports}for(var o="function"==typeof require&&require,r=0;r<i.length;r++)n(i[r]);return n}({1:[function(t,e,a){},{}],2:[function(t,e,a){function i(t){if(t){var e=/^#([a-fA-F0-9]{3})$/,a=/^#([a-fA-F0-9]{6})$/,i=/^rgba?\(\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/,n=/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/,o=/(\w+)/,r=[0,0,0],l=1,s=t.match(e);if(s){s=s[1];for(var d=0;d<r.length;d++)r[d]=parseInt(s[d]+s[d],16)}else if(s=t.match(a)){s=s[1];for(var d=0;d<r.length;d++)r[d]=parseInt(s.slice(2*d,2*d+2),16)}else if(s=t.match(i)){for(var d=0;d<r.length;d++)r[d]=parseInt(s[d+1]);l=parseFloat(s[4])}else if(s=t.match(n)){for(var d=0;d<r.length;d++)r[d]=Math.round(2.55*parseFloat(s[d+1]));l=parseFloat(s[4])}else if(s=t.match(o)){if("transparent"==s[1])return[0,0,0,0];if(r=y[s[1]],!r)return}for(var d=0;d<r.length;d++)r[d]=v(r[d],0,255);return l=l||0==l?v(l,0,1):1,r[3]=l,r}}function n(t){if(t){var e=/^hsla?\(\s*([+-]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)/,a=t.match(e);if(a){var i=parseFloat(a[4]),n=v(parseInt(a[1]),0,360),o=v(parseFloat(a[2]),0,100),r=v(parseFloat(a[3]),0,100),l=v(isNaN(i)?1:i,0,1);return[n,o,r,l]}}}function o(t){if(t){var e=/^hwb\(\s*([+-]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)/,a=t.match(e);if(a){var i=parseFloat(a[4]),n=v(parseInt(a[1]),0,360),o=v(parseFloat(a[2]),0,100),r=v(parseFloat(a[3]),0,100),l=v(isNaN(i)?1:i,0,1);return[n,o,r,l]}}}function r(t){var e=i(t);return e&&e.slice(0,3)}function l(t){var e=n(t);return e&&e.slice(0,3)}function s(t){var e=i(t);return e?e[3]:(e=n(t))?e[3]:(e=o(t))?e[3]:void 0}function d(t){return"#"+x(t[0])+x(t[1])+x(t[2])}function u(t,e){return 1>e||t[3]&&t[3]<1?c(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function c(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function h(t,e){if(1>e||t[3]&&t[3]<1)return f(t,e);var a=Math.round(t[0]/255*100),i=Math.round(t[1]/255*100),n=Math.round(t[2]/255*100);return"rgb("+a+"%, "+i+"%, "+n+"%)"}function f(t,e){var a=Math.round(t[0]/255*100),i=Math.round(t[1]/255*100),n=Math.round(t[2]/255*100);return"rgba("+a+"%, "+i+"%, "+n+"%, "+(e||t[3]||1)+")"}function g(t,e){return 1>e||t[3]&&t[3]<1?p(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function p(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function m(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function b(t){return k[t.slice(0,3)]}function v(t,e,a){return Math.min(Math.max(e,t),a)}function x(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var y=t(6);e.exports={getRgba:i,getHsla:n,getRgb:r,getHsl:l,getHwb:o,getAlpha:s,hexString:d,rgbString:u,rgbaString:c,percentString:h,percentaString:f,hslString:g,hslaString:p,hwbString:m,keyword:b};var k={};for(var S in y)k[y[S]]=S},{6:6}],3:[function(t,e,a){var i=t(5),n=t(2),o=function(t){if(t instanceof o)return t;if(!(this instanceof o))return new o(t);this.values={rgb:[0,0,0],hsl:[0,0,0],hsv:[0,0,0],hwb:[0,0,0],cmyk:[0,0,0,0],alpha:1};var e;if("string"==typeof t)if(e=n.getRgba(t))this.setValues("rgb",e);else if(e=n.getHsla(t))this.setValues("hsl",e);else{if(!(e=n.getHwb(t)))throw new Error('Unable to parse color from string "'+t+'"');this.setValues("hwb",e)}else if("object"==typeof t)if(e=t,void 0!==e.r||void 0!==e.red)this.setValues("rgb",e);else if(void 0!==e.l||void 0!==e.lightness)this.setValues("hsl",e);else if(void 0!==e.v||void 0!==e.value)this.setValues("hsv",e);else if(void 0!==e.w||void 0!==e.whiteness)this.setValues("hwb",e);else{if(void 0===e.c&&void 0===e.cyan)throw new Error("Unable to parse color from object "+JSON.stringify(t));this.setValues("cmyk",e)}};o.prototype={rgb:function(){return this.setSpace("rgb",arguments)},hsl:function(){return this.setSpace("hsl",arguments)},hsv:function(){return this.setSpace("hsv",arguments)},hwb:function(){return this.setSpace("hwb",arguments)},cmyk:function(){return this.setSpace("cmyk",arguments)},rgbArray:function(){return this.values.rgb},hslArray:function(){return this.values.hsl},hsvArray:function(){return this.values.hsv},hwbArray:function(){var t=this.values;return 1!==t.alpha?t.hwb.concat([t.alpha]):t.hwb},cmykArray:function(){return this.values.cmyk},rgbaArray:function(){var t=this.values;return t.rgb.concat([t.alpha])},hslaArray:function(){var t=this.values;return t.hsl.concat([t.alpha])},alpha:function(t){return void 0===t?this.values.alpha:(this.setValues("alpha",t),this)},red:function(t){return this.setChannel("rgb",0,t)},green:function(t){return this.setChannel("rgb",1,t)},blue:function(t){return this.setChannel("rgb",2,t)},hue:function(t){return t&&(t%=360,t=0>t?360+t:t),this.setChannel("hsl",0,t)},saturation:function(t){return this.setChannel("hsl",1,t)},lightness:function(t){return this.setChannel("hsl",2,t)},saturationv:function(t){return this.setChannel("hsv",1,t)},whiteness:function(t){return this.setChannel("hwb",1,t)},blackness:function(t){return this.setChannel("hwb",2,t)},value:function(t){return this.setChannel("hsv",2,t)},cyan:function(t){return this.setChannel("cmyk",0,t)},magenta:function(t){return this.setChannel("cmyk",1,t)},yellow:function(t){return this.setChannel("cmyk",2,t)},black:function(t){return this.setChannel("cmyk",3,t)},hexString:function(){return n.hexString(this.values.rgb)},rgbString:function(){return n.rgbString(this.values.rgb,this.values.alpha)},rgbaString:function(){return n.rgbaString(this.values.rgb,this.values.alpha)},percentString:function(){return n.percentString(this.values.rgb,this.values.alpha)},hslString:function(){return n.hslString(this.values.hsl,this.values.alpha)},hslaString:function(){return n.hslaString(this.values.hsl,this.values.alpha)},hwbString:function(){return n.hwbString(this.values.hwb,this.values.alpha)},keyword:function(){return n.keyword(this.values.rgb,this.values.alpha)},rgbNumber:function(){var t=this.values.rgb;return t[0]<<16|t[1]<<8|t[2]},luminosity:function(){for(var t=this.values.rgb,e=[],a=0;a<t.length;a++){var i=t[a]/255;e[a]=.03928>=i?i/12.92:Math.pow((i+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),a=t.luminosity();return e>a?(e+.05)/(a+.05):(a+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){var e=this.values.hsl;return e[2]+=e[2]*t,this.setValues("hsl",e),this},darken:function(t){var e=this.values.hsl;return e[2]-=e[2]*t,this.setValues("hsl",e),this},saturate:function(t){var e=this.values.hsl;return e[1]+=e[1]*t,this.setValues("hsl",e),this},desaturate:function(t){var e=this.values.hsl;return e[1]-=e[1]*t,this.setValues("hsl",e),this},whiten:function(t){var e=this.values.hwb;return e[1]+=e[1]*t,this.setValues("hwb",e),this},blacken:function(t){var e=this.values.hwb;return e[2]+=e[2]*t,this.setValues("hwb",e),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){var e=this.values.alpha;return this.setValues("alpha",e-e*t),this},opaquer:function(t){var e=this.values.alpha;return this.setValues("alpha",e+e*t),this},rotate:function(t){var e=this.values.hsl,a=(e[0]+t)%360;return e[0]=0>a?360+a:a,this.setValues("hsl",e),this},mix:function(t,e){var a=this,i=t,n=void 0===e?.5:e,o=2*n-1,r=a.alpha()-i.alpha(),l=((o*r===-1?o:(o+r)/(1+o*r))+1)/2,s=1-l;return this.rgb(l*a.red()+s*i.red(),l*a.green()+s*i.green(),l*a.blue()+s*i.blue()).alpha(a.alpha()*n+i.alpha()*(1-n))},toJSON:function(){return this.rgb()},clone:function(){var t,e,a=new o,i=this.values,n=a.values;for(var r in i)i.hasOwnProperty(r)&&(t=i[r],e={}.toString.call(t),"[object Array]"===e?n[r]=t.slice(0):"[object Number]"===e?n[r]=t:console.error("unexpected color value:",t));return a}},o.prototype.spaces={rgb:["red","green","blue"],hsl:["hue","saturation","lightness"],hsv:["hue","saturation","value"],hwb:["hue","whiteness","blackness"],cmyk:["cyan","magenta","yellow","black"]},o.prototype.maxes={rgb:[255,255,255],hsl:[360,100,100],hsv:[360,100,100],hwb:[360,100,100],cmyk:[100,100,100,100]},o.prototype.getValues=function(t){for(var e=this.values,a={},i=0;i<t.length;i++)a[t.charAt(i)]=e[t][i];return 1!==e.alpha&&(a.a=e.alpha),a},o.prototype.setValues=function(t,e){var a,n=this.values,o=this.spaces,r=this.maxes,l=1;if("alpha"===t)l=e;else if(e.length)n[t]=e.slice(0,t.length),l=e[t.length];else if(void 0!==e[t.charAt(0)]){for(a=0;a<t.length;a++)n[t][a]=e[t.charAt(a)];l=e.a}else if(void 0!==e[o[t][0]]){var s=o[t];for(a=0;a<t.length;a++)n[t][a]=e[s[a]];l=e.alpha}if(n.alpha=Math.max(0,Math.min(1,void 0===l?n.alpha:l)),"alpha"===t)return!1;var d;for(a=0;a<t.length;a++)d=Math.max(0,Math.min(r[t][a],n[t][a])),n[t][a]=Math.round(d);for(var u in o)u!==t&&(n[u]=i[t][u](n[t]));return!0},o.prototype.setSpace=function(t,e){var a=e[0];return void 0===a?this.getValues(t):("number"==typeof a&&(a=Array.prototype.slice.call(e)),this.setValues(t,a),this)},o.prototype.setChannel=function(t,e,a){var i=this.values[t];return void 0===a?i[e]:a===i[e]?this:(i[e]=a,this.setValues(t,i),this)},"undefined"!=typeof window&&(window.Color=o),e.exports=o},{2:2,5:5}],4:[function(t,e,a){function i(t){var e,a,i,n=t[0]/255,o=t[1]/255,r=t[2]/255,l=Math.min(n,o,r),s=Math.max(n,o,r),d=s-l;return s==l?e=0:n==s?e=(o-r)/d:o==s?e=2+(r-n)/d:r==s&&(e=4+(n-o)/d),e=Math.min(60*e,360),0>e&&(e+=360),i=(l+s)/2,a=s==l?0:.5>=i?d/(s+l):d/(2-s-l),[e,100*a,100*i]}function n(t){var e,a,i,n=t[0],o=t[1],r=t[2],l=Math.min(n,o,r),s=Math.max(n,o,r),d=s-l;return a=0==s?0:d/s*1e3/10,s==l?e=0:n==s?e=(o-r)/d:o==s?e=2+(r-n)/d:r==s&&(e=4+(n-o)/d),e=Math.min(60*e,360),0>e&&(e+=360),i=s/255*1e3/10,[e,a,i]}function o(t){var e=t[0],a=t[1],n=t[2],o=i(t)[0],r=1/255*Math.min(e,Math.min(a,n)),n=1-1/255*Math.max(e,Math.max(a,n));return[o,100*r,100*n]}function l(t){var e,a,i,n,o=t[0]/255,r=t[1]/255,l=t[2]/255;return n=Math.min(1-o,1-r,1-l),e=(1-o-n)/(1-n)||0,a=(1-r-n)/(1-n)||0,i=(1-l-n)/(1-n)||0,[100*e,100*a,100*i,100*n]}function s(t){return G[JSON.stringify(t)]}function d(t){var e=t[0]/255,a=t[1]/255,i=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,a=a>.04045?Math.pow((a+.055)/1.055,2.4):a/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92;var n=.4124*e+.3576*a+.1805*i,o=.2126*e+.7152*a+.0722*i,r=.0193*e+.1192*a+.9505*i;return[100*n,100*o,100*r]}function u(t){var e,a,i,n=d(t),o=n[0],r=n[1],l=n[2];return o/=95.047,r/=100,l/=108.883,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,l=l>.008856?Math.pow(l,1/3):7.787*l+16/116,e=116*r-16,a=500*(o-r),i=200*(r-l),[e,a,i]}function c(t){return W(u(t))}function h(t){var e,a,i,n,o,r=t[0]/360,l=t[1]/100,s=t[2]/100;if(0==l)return o=255*s,[o,o,o];a=.5>s?s*(1+l):s+l-s*l,e=2*s-a,n=[0,0,0];for(var d=0;3>d;d++)i=r+1/3*-(d-1),0>i&&i++,i>1&&i--,o=1>6*i?e+6*(a-e)*i:1>2*i?a:2>3*i?e+(a-e)*(2/3-i)*6:e,n[d]=255*o;return n}function f(t){var e,a,i=t[0],n=t[1]/100,o=t[2]/100;return 0===o?[0,0,0]:(o*=2,n*=1>=o?o:2-o,a=(o+n)/2,e=2*n/(o+n),[i,100*e,100*a])}function p(t){return o(h(t))}function m(t){return l(h(t))}function v(t){return s(h(t))}function x(t){var e=t[0]/60,a=t[1]/100,i=t[2]/100,n=Math.floor(e)%6,o=e-Math.floor(e),r=255*i*(1-a),l=255*i*(1-a*o),s=255*i*(1-a*(1-o)),i=255*i;switch(n){case 0:return[i,s,r];case 1:return[l,i,r];case 2:return[r,i,s];case 3:return[r,l,i];case 4:return[s,r,i];case 5:return[i,r,l]}}function y(t){var e,a,i=t[0],n=t[1]/100,o=t[2]/100;return a=(2-n)*o,e=n*o,e/=1>=a?a:2-a,e=e||0,a/=2,[i,100*e,100*a]}function k(t){return o(x(t))}function S(t){return l(x(t))}function w(t){return s(x(t))}function M(t){var e,a,i,n,o=t[0]/360,l=t[1]/100,s=t[2]/100,d=l+s;switch(d>1&&(l/=d,s/=d),e=Math.floor(6*o),a=1-s,i=6*o-e,0!=(1&e)&&(i=1-i),n=l+i*(a-l),e){default:case 6:case 0:r=a,g=n,b=l;break;case 1:r=n,g=a,b=l;break;case 2:r=l,g=a,b=n;break;case 3:r=l,g=n,b=a;break;case 4:r=n,g=l,b=a;break;case 5:r=a,g=l,b=n}return[255*r,255*g,255*b]}function C(t){return i(M(t))}function D(t){return n(M(t))}function I(t){return l(M(t))}function A(t){return s(M(t))}function T(t){var e,a,i,n=t[0]/100,o=t[1]/100,r=t[2]/100,l=t[3]/100;return e=1-Math.min(1,n*(1-l)+l),a=1-Math.min(1,o*(1-l)+l),i=1-Math.min(1,r*(1-l)+l),[255*e,255*a,255*i]}function P(t){return i(T(t))}function F(t){return n(T(t))}function _(t){return o(T(t))}function R(t){return s(T(t))}function V(t){var e,a,i,n=t[0]/100,o=t[1]/100,r=t[2]/100;return e=3.2406*n+-1.5372*o+r*-.4986,a=n*-.9689+1.8758*o+.0415*r,i=.0557*n+o*-.204+1.057*r,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,a=a>.0031308?1.055*Math.pow(a,1/2.4)-.055:a=12.92*a,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,e=Math.min(Math.max(0,e),1),a=Math.min(Math.max(0,a),1),i=Math.min(Math.max(0,i),1),[255*e,255*a,255*i]}function L(t){var e,a,i,n=t[0],o=t[1],r=t[2];return n/=95.047,o/=100,r/=108.883,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*o-16,a=500*(n-o),i=200*(o-r),[e,a,i]}function O(t){return W(L(t))}function B(t){var e,a,i,n,o=t[0],r=t[1],l=t[2];return 8>=o?(a=100*o/903.3,n=7.787*(a/100)+16/116):(a=100*Math.pow((o+16)/116,3),n=Math.pow(a/100,1/3)),e=.008856>=e/95.047?e=95.047*(r/500+n-16/116)/7.787:95.047*Math.pow(r/500+n,3),i=.008859>=i/108.883?i=108.883*(n-l/200-16/116)/7.787:108.883*Math.pow(n-l/200,3),[e,a,i]}function W(t){var e,a,i,n=t[0],o=t[1],r=t[2];return e=Math.atan2(r,o),a=360*e/2/Math.PI,0>a&&(a+=360),i=Math.sqrt(o*o+r*r),[n,i,a]}function z(t){return V(B(t))}function N(t){var e,a,i,n=t[0],o=t[1],r=t[2];return i=r/360*2*Math.PI,e=o*Math.cos(i),a=o*Math.sin(i),[n,e,a]}function E(t){return B(N(t))}function H(t){return z(N(t))}function U(t){return Z[t]}function j(t){return i(U(t))}function q(t){return n(U(t))}function Y(t){return o(U(t))}function X(t){return l(U(t))}function K(t){return u(U(t))}function J(t){return d(U(t))}e.exports={rgb2hsl:i,rgb2hsv:n,rgb2hwb:o,rgb2cmyk:l,rgb2keyword:s,rgb2xyz:d,rgb2lab:u,rgb2lch:c,hsl2rgb:h,hsl2hsv:f,hsl2hwb:p,hsl2cmyk:m,hsl2keyword:v,hsv2rgb:x,hsv2hsl:y,hsv2hwb:k,hsv2cmyk:S,hsv2keyword:w,hwb2rgb:M,hwb2hsl:C,hwb2hsv:D,hwb2cmyk:I,hwb2keyword:A,cmyk2rgb:T,cmyk2hsl:P,cmyk2hsv:F,cmyk2hwb:_,cmyk2keyword:R,keyword2rgb:U,keyword2hsl:j,keyword2hsv:q,keyword2hwb:Y,keyword2cmyk:X,keyword2lab:K,keyword2xyz:J,xyz2rgb:V,xyz2lab:L,xyz2lch:O,lab2xyz:B,lab2rgb:z,lab2lch:W,lch2lab:N,lch2xyz:E,lch2rgb:H};var Z={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},G={};for(var Q in Z)G[JSON.stringify(Z[Q])]=Q},{}],5:[function(t,e,a){var i=t(4),n=function(){return new d};for(var o in i){n[o+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),i[t](e)}}(o);var r=/(\w+)2(\w+)/.exec(o),l=r[1],s=r[2];n[l]=n[l]||{},n[l][s]=n[o]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var a=i[t](e);if("string"==typeof a||void 0===a)return a;for(var n=0;n<a.length;n++)a[n]=Math.round(a[n]);return a}}(o)}var d=function(){this.convs={}};d.prototype.routeSpace=function(t,e){var a=e[0];return void 0===a?this.getValues(t):("number"==typeof a&&(a=Array.prototype.slice.call(e)),this.setValues(t,a))},d.prototype.setValues=function(t,e){return this.space=t,this.convs={},this.convs[t]=e,this},d.prototype.getValues=function(t){var e=this.convs[t];if(!e){var a=this.space,i=this.convs[a];e=n[a][t](i),this.convs[t]=e}return e},["rgb","hsl","hsv","cmyk","keyword"].forEach(function(t){d.prototype[t]=function(e){return this.routeSpace(t,arguments)}}),e.exports=n},{4:4}],6:[function(t,e,a){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}],7:[function(t,e,a){var i=t(28)();t(26)(i),t(22)(i),t(25)(i),t(21)(i),t(23)(i),t(24)(i),t(29)(i),t(33)(i),t(31)(i),t(34)(i),t(32)(i),t(35)(i),t(30)(i),t(27)(i),t(36)(i),t(37)(i),t(38)(i),t(39)(i),t(40)(i),t(43)(i),t(41)(i),t(42)(i),t(44)(i),t(45)(i),t(46)(i),t(15)(i),t(16)(i),t(17)(i),t(18)(i),t(19)(i),t(20)(i),t(8)(i),t(9)(i),t(10)(i),t(11)(i),t(12)(i),t(13)(i),t(14)(i),window.Chart=e.exports=i},{10:10,11:11,12:12,13:13,14:14,15:15,16:16,17:17,18:18,19:19,20:20,21:21,22:22,23:23,24:24,25:25,26:26,27:27,28:28,29:29,30:30,31:31,32:32,33:33,34:34,35:35,36:36,37:37,38:38,39:39,40:40,41:41,42:42,43:43,44:44,45:45,46:46,8:8,9:9}],8:[function(t,e,a){"use strict";e.exports=function(t){t.Bar=function(e,a){return a.type="bar",new t(e,a)}}},{}],9:[function(t,e,a){"use strict";e.exports=function(t){t.Bubble=function(e,a){return a.type="bubble",new t(e,a)}}},{}],10:[function(t,e,a){"use strict";e.exports=function(t){t.Doughnut=function(e,a){return a.type="doughnut",new t(e,a)}}},{}],11:[function(t,e,a){"use strict";e.exports=function(t){t.Line=function(e,a){return a.type="line",new t(e,a)}}},{}],12:[function(t,e,a){"use strict";e.exports=function(t){t.PolarArea=function(e,a){return a.type="polarArea",new t(e,a)}}},{}],13:[function(t,e,a){"use strict";e.exports=function(t){t.Radar=function(e,a){return a.type="radar",new t(e,a)}}},{}],14:[function(t,e,a){"use strict";e.exports=function(t){var e={hover:{mode:"single"},scales:{xAxes:[{type:"linear",position:"bottom",id:"x-axis-1"}],yAxes:[{type:"linear",position:"left",id:"y-axis-1"}]},tooltips:{callbacks:{title:function(){return""},label:function(t){return"("+t.xLabel+", "+t.yLabel+")"}}}};t.defaults.scatter=e,t.controllers.scatter=t.controllers.line,t.Scatter=function(e,a){return a.type="scatter",new t(e,a)}}},{}],15:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers;t.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categoryPercentage:.8,barPercentage:.9,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},t.controllers.bar=t.DatasetController.extend({dataElementType:t.elements.Rectangle,initialize:function(e,a){t.DatasetController.prototype.initialize.call(this,e,a),this.getMeta().bar=!0},getBarCount:function(){var t=this,a=0;return e.each(t.chart.data.datasets,function(e,i){var n=t.chart.getDatasetMeta(i);n.bar&&t.chart.isDatasetVisible(i)&&++a},t),a},update:function(t){var a=this;e.each(a.getMeta().data,function(e,i){a.updateElement(e,i,t)},a)},updateElement:function(t,a,i){var n=this,o=n.getMeta(),r=n.getScaleForId(o.xAxisID),l=n.getScaleForId(o.yAxisID),s=l.getBasePixel(),d=n.chart.options.elements.rectangle,u=t.custom||{},c=n.getDataset();t._xScale=r,t._yScale=l,t._datasetIndex=n.index,t._index=a;var h=n.getRuler(a);t._model={x:n.calculateBarX(a,n.index,h),y:i?s:n.calculateBarY(a,n.index),label:n.chart.data.labels[a],datasetLabel:c.label,base:i?s:n.calculateBarBase(n.index,a),width:n.calculateBarWidth(h),backgroundColor:u.backgroundColor?u.backgroundColor:e.getValueAtIndexOrDefault(c.backgroundColor,a,d.backgroundColor),borderSkipped:u.borderSkipped?u.borderSkipped:d.borderSkipped,borderColor:u.borderColor?u.borderColor:e.getValueAtIndexOrDefault(c.borderColor,a,d.borderColor),borderWidth:u.borderWidth?u.borderWidth:e.getValueAtIndexOrDefault(c.borderWidth,a,d.borderWidth)},t.pivot()},calculateBarBase:function(t,e){var a=this,i=a.getMeta(),n=a.getScaleForId(i.yAxisID),o=0;if(n.options.stacked){for(var r=a.chart,l=r.data.datasets,s=Number(l[t].data[e]),d=0;t>d;d++){var u=l[d],c=r.getDatasetMeta(d);if(c.bar&&c.yAxisID===n.id&&r.isDatasetVisible(d)){var h=Number(u.data[e]);o+=0>s?Math.min(h,0):Math.max(h,0)}}return n.getPixelForValue(o)}return n.getBasePixel()},getRuler:function(t){var e,a=this,i=a.getMeta(),n=a.getScaleForId(i.xAxisID),o=a.getBarCount();e="category"===n.options.type?n.getPixelForTick(t+1)-n.getPixelForTick(t):n.width/n.ticks.length;var r=e*n.options.categoryPercentage,l=(e-e*n.options.categoryPercentage)/2,s=r/o;if(n.ticks.length!==a.chart.data.labels.length){var d=n.ticks.length/a.chart.data.labels.length;s*=d}var u=s*n.options.barPercentage,c=s-s*n.options.barPercentage;return{datasetCount:o,tickWidth:e,categoryWidth:r,categorySpacing:l,fullBarWidth:s,barWidth:u,barSpacing:c}},calculateBarWidth:function(t){var e=this.getScaleForId(this.getMeta().xAxisID);return e.options.barThickness?e.options.barThickness:e.options.stacked?t.categoryWidth:t.barWidth},getBarIndex:function(t){var e,a,i=0;for(a=0;t>a;++a)e=this.chart.getDatasetMeta(a),e.bar&&this.chart.isDatasetVisible(a)&&++i;return i},calculateBarX:function(t,e,a){var i=this,n=i.getMeta(),o=i.getScaleForId(n.xAxisID),r=i.getBarIndex(e),l=o.getPixelForValue(null,t,e,i.chart.isCombo);return l-=i.chart.isCombo?a.tickWidth/2:0,o.options.stacked?l+a.categoryWidth/2+a.categorySpacing:l+a.barWidth/2+a.categorySpacing+a.barWidth*r+a.barSpacing/2+a.barSpacing*r},calculateBarY:function(t,e){var a=this,i=a.getMeta(),n=a.getScaleForId(i.yAxisID),o=Number(a.getDataset().data[t]);if(n.options.stacked){for(var r=0,l=0,s=0;e>s;s++){var d=a.chart.data.datasets[s],u=a.chart.getDatasetMeta(s);if(u.bar&&u.yAxisID===n.id&&a.chart.isDatasetVisible(s)){var c=Number(d.data[t]);0>c?l+=c||0:r+=c||0}}return 0>o?n.getPixelForValue(l+o):n.getPixelForValue(r+o)}return n.getPixelForValue(o)},draw:function(t){var e,a,i=this,n=t||1,o=i.getMeta().data,r=i.getDataset();for(e=0,a=o.length;a>e;++e){var l=r.data[e];null===l||void 0===l||isNaN(l)||o[e].transition(n).draw()}},setHoverStyle:function(t){var a=this.chart.data.datasets[t._datasetIndex],i=t._index,n=t.custom||{},o=t._model;o.backgroundColor=n.hoverBackgroundColor?n.hoverBackgroundColor:e.getValueAtIndexOrDefault(a.hoverBackgroundColor,i,e.getHoverColor(o.backgroundColor)),o.borderColor=n.hoverBorderColor?n.hoverBorderColor:e.getValueAtIndexOrDefault(a.hoverBorderColor,i,e.getHoverColor(o.borderColor)),o.borderWidth=n.hoverBorderWidth?n.hoverBorderWidth:e.getValueAtIndexOrDefault(a.hoverBorderWidth,i,o.borderWidth)},removeHoverStyle:function(t){var a=this.chart.data.datasets[t._datasetIndex],i=t._index,n=t.custom||{},o=t._model,r=this.chart.options.elements.rectangle;o.backgroundColor=n.backgroundColor?n.backgroundColor:e.getValueAtIndexOrDefault(a.backgroundColor,i,r.backgroundColor),o.borderColor=n.borderColor?n.borderColor:e.getValueAtIndexOrDefault(a.borderColor,i,r.borderColor),o.borderWidth=n.borderWidth?n.borderWidth:e.getValueAtIndexOrDefault(a.borderWidth,i,r.borderWidth)}}),t.defaults.horizontalBar={hover:{mode:"label"},scales:{xAxes:[{type:"linear",position:"bottom"}],yAxes:[{position:"left",type:"category",categoryPercentage:.8,barPercentage:.9,gridLines:{offsetGridLines:!0}}]},elements:{rectangle:{borderSkipped:"left"}},tooltips:{callbacks:{title:function(t,e){var a="";return t.length>0&&(t[0].yLabel?a=t[0].yLabel:e.labels.length>0&&t[0].index<e.labels.length&&(a=e.labels[t[0].index])),a},label:function(t,e){var a=e.datasets[t.datasetIndex].label||"";return a+": "+t.xLabel}}}},t.controllers.horizontalBar=t.controllers.bar.extend({updateElement:function(t,a,i){var n=this,o=n.getMeta(),r=n.getScaleForId(o.xAxisID),l=n.getScaleForId(o.yAxisID),s=r.getBasePixel(),d=t.custom||{},u=n.getDataset(),c=n.chart.options.elements.rectangle;t._xScale=r,t._yScale=l,t._datasetIndex=n.index,t._index=a;var h=n.getRuler(a);t._model={x:i?s:n.calculateBarX(a,n.index),y:n.calculateBarY(a,n.index,h),label:n.chart.data.labels[a],datasetLabel:u.label,base:i?s:n.calculateBarBase(n.index,a),height:n.calculateBarHeight(h),backgroundColor:d.backgroundColor?d.backgroundColor:e.getValueAtIndexOrDefault(u.backgroundColor,a,c.backgroundColor),borderSkipped:d.borderSkipped?d.borderSkipped:c.borderSkipped,borderColor:d.borderColor?d.borderColor:e.getValueAtIndexOrDefault(u.borderColor,a,c.borderColor),borderWidth:d.borderWidth?d.borderWidth:e.getValueAtIndexOrDefault(u.borderWidth,a,c.borderWidth)},t.draw=function(){function t(t){return s[(u+t)%4]}var e=this._chart.ctx,a=this._view,i=a.height/2,n=a.y-i,o=a.y+i,r=a.base-(a.base-a.x),l=a.borderWidth/2;a.borderWidth&&(n+=l,o-=l,r+=l),e.beginPath(),e.fillStyle=a.backgroundColor,e.strokeStyle=a.borderColor,e.lineWidth=a.borderWidth;var s=[[a.base,o],[a.base,n],[r,n],[r,o]],d=["bottom","left","top","right"],u=d.indexOf(a.borderSkipped,0);-1===u&&(u=0),e.moveTo.apply(e,t(0));for(var c=1;4>c;c++)e.lineTo.apply(e,t(c));e.fill(),a.borderWidth&&e.stroke()},t.pivot()},calculateBarBase:function(t,e){var a=this,i=a.getMeta(),n=a.getScaleForId(i.xAxisID),o=0;if(n.options.stacked){for(var r=a.chart,l=r.data.datasets,s=Number(l[t].data[e]),d=0;t>d;d++){var u=l[d],c=r.getDatasetMeta(d);if(c.bar&&c.xAxisID===n.id&&r.isDatasetVisible(d)){
11
+ var h=Number(u.data[e]);o+=0>s?Math.min(h,0):Math.max(h,0)}}return n.getPixelForValue(o)}return n.getBasePixel()},getRuler:function(t){var e,a=this,i=a.getMeta(),n=a.getScaleForId(i.yAxisID),o=a.getBarCount();e="category"===n.options.type?n.getPixelForTick(t+1)-n.getPixelForTick(t):n.width/n.ticks.length;var r=e*n.options.categoryPercentage,l=(e-e*n.options.categoryPercentage)/2,s=r/o;if(n.ticks.length!==a.chart.data.labels.length){var d=n.ticks.length/a.chart.data.labels.length;s*=d}var u=s*n.options.barPercentage,c=s-s*n.options.barPercentage;return{datasetCount:o,tickHeight:e,categoryHeight:r,categorySpacing:l,fullBarHeight:s,barHeight:u,barSpacing:c}},calculateBarHeight:function(t){var e=this,a=e.getScaleForId(e.getMeta().yAxisID);return a.options.barThickness?a.options.barThickness:a.options.stacked?t.categoryHeight:t.barHeight},calculateBarX:function(t,e){var a=this,i=a.getMeta(),n=a.getScaleForId(i.xAxisID),o=Number(a.getDataset().data[t]);if(n.options.stacked){for(var r=0,l=0,s=0;e>s;s++){var d=a.chart.data.datasets[s],u=a.chart.getDatasetMeta(s);if(u.bar&&u.xAxisID===n.id&&a.chart.isDatasetVisible(s)){var c=Number(d.data[t]);0>c?l+=c||0:r+=c||0}}return 0>o?n.getPixelForValue(l+o):n.getPixelForValue(r+o)}return n.getPixelForValue(o)},calculateBarY:function(t,e,a){var i=this,n=i.getMeta(),o=i.getScaleForId(n.yAxisID),r=i.getBarIndex(e),l=o.getPixelForValue(null,t,e,i.chart.isCombo);return l-=i.chart.isCombo?a.tickHeight/2:0,o.options.stacked?l+a.categoryHeight/2+a.categorySpacing:l+a.barHeight/2+a.categorySpacing+a.barHeight*r+a.barSpacing/2+a.barSpacing*r}})}},{}],16:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers;t.defaults.bubble={hover:{mode:"single"},scales:{xAxes:[{type:"linear",position:"bottom",id:"x-axis-0"}],yAxes:[{type:"linear",position:"left",id:"y-axis-0"}]},tooltips:{callbacks:{title:function(){return""},label:function(t,e){var a=e.datasets[t.datasetIndex].label||"",i=e.datasets[t.datasetIndex].data[t.index];return a+": ("+t.xLabel+", "+t.yLabel+", "+i.r+")"}}}},t.controllers.bubble=t.DatasetController.extend({dataElementType:t.elements.Point,update:function(t){var a=this,i=a.getMeta(),n=i.data;e.each(n,function(e,i){a.updateElement(e,i,t)})},updateElement:function(a,i,n){var o=this,r=o.getMeta(),l=o.getScaleForId(r.xAxisID),s=o.getScaleForId(r.yAxisID),d=a.custom||{},u=o.getDataset(),c=u.data[i],h=o.chart.options.elements.point,f=o.index;e.extend(a,{_xScale:l,_yScale:s,_datasetIndex:f,_index:i,_model:{x:n?l.getPixelForDecimal(.5):l.getPixelForValue("object"==typeof c?c:NaN,i,f,o.chart.isCombo),y:n?s.getBasePixel():s.getPixelForValue(c,i,f),radius:n?0:d.radius?d.radius:o.getRadius(c),hitRadius:d.hitRadius?d.hitRadius:e.getValueAtIndexOrDefault(u.hitRadius,i,h.hitRadius)}}),t.DatasetController.prototype.removeHoverStyle.call(o,a,h);var g=a._model;g.skip=d.skip?d.skip:isNaN(g.x)||isNaN(g.y),a.pivot()},getRadius:function(t){return t.r||this.chart.options.elements.point.radius},setHoverStyle:function(a){var i=this;t.DatasetController.prototype.setHoverStyle.call(i,a);var n=i.chart.data.datasets[a._datasetIndex],o=a._index,r=a.custom||{},l=a._model;l.radius=r.hoverRadius?r.hoverRadius:e.getValueAtIndexOrDefault(n.hoverRadius,o,i.chart.options.elements.point.hoverRadius)+i.getRadius(n.data[o])},removeHoverStyle:function(e){var a=this;t.DatasetController.prototype.removeHoverStyle.call(a,e,a.chart.options.elements.point);var i=a.chart.data.datasets[e._datasetIndex].data[e._index],n=e.custom||{},o=e._model;o.radius=n.radius?n.radius:a.getRadius(i)}})}},{}],17:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers,a=t.defaults;a.doughnut={animation:{animateRotate:!0,animateScale:!1},aspectRatio:1,hover:{mode:"single"},legendCallback:function(t){var e=[];e.push('<ul class="'+t.id+'-legend">');var a=t.data,i=a.datasets,n=a.labels;if(i.length)for(var o=0;o<i[0].data.length;++o)e.push('<li><span style="background-color:'+i[0].backgroundColor[o]+'"></span>'),n[o]&&e.push(n[o]),e.push("</li>");return e.push("</ul>"),e.join("")},legend:{labels:{generateLabels:function(t){var a=t.data;return a.labels.length&&a.datasets.length?a.labels.map(function(i,n){var o=t.getDatasetMeta(0),r=a.datasets[0],l=o.data[n],s=l&&l.custom||{},d=e.getValueAtIndexOrDefault,u=t.options.elements.arc,c=s.backgroundColor?s.backgroundColor:d(r.backgroundColor,n,u.backgroundColor),h=s.borderColor?s.borderColor:d(r.borderColor,n,u.borderColor),f=s.borderWidth?s.borderWidth:d(r.borderWidth,n,u.borderWidth);return{text:i,fillStyle:c,strokeStyle:h,lineWidth:f,hidden:isNaN(r.data[n])||o.data[n].hidden,index:n}}):[]}},onClick:function(t,e){var a,i,n,o=e.index,r=this.chart;for(a=0,i=(r.data.datasets||[]).length;i>a;++a)n=r.getDatasetMeta(a),n.data[o]&&(n.data[o].hidden=!n.data[o].hidden);r.update()}},cutoutPercentage:50,rotation:Math.PI*-.5,circumference:2*Math.PI,tooltips:{callbacks:{title:function(){return""},label:function(t,a){var i=a.labels[t.index],n=": "+a.datasets[t.datasetIndex].data[t.index];return e.isArray(i)?(i=i.slice(),i[0]+=n):i+=n,i}}}},a.pie=e.clone(a.doughnut),e.extend(a.pie,{cutoutPercentage:0}),t.controllers.doughnut=t.controllers.pie=t.DatasetController.extend({dataElementType:t.elements.Arc,linkScales:e.noop,getRingIndex:function(t){for(var e=0,a=0;t>a;++a)this.chart.isDatasetVisible(a)&&++e;return e},update:function(t){var a=this,i=a.chart,n=i.chartArea,o=i.options,r=o.elements.arc,l=n.right-n.left-r.borderWidth,s=n.bottom-n.top-r.borderWidth,d=Math.min(l,s),u={x:0,y:0},c=a.getMeta(),h=o.cutoutPercentage,f=o.circumference;if(f<2*Math.PI){var g=o.rotation%(2*Math.PI);g+=2*Math.PI*(g>=Math.PI?-1:g<-Math.PI?1:0);var p=g+f,m={x:Math.cos(g),y:Math.sin(g)},b={x:Math.cos(p),y:Math.sin(p)},v=0>=g&&p>=0||g<=2*Math.PI&&2*Math.PI<=p,x=g<=.5*Math.PI&&.5*Math.PI<=p||g<=2.5*Math.PI&&2.5*Math.PI<=p,y=g<=-Math.PI&&-Math.PI<=p||g<=Math.PI&&Math.PI<=p,k=g<=.5*-Math.PI&&.5*-Math.PI<=p||g<=1.5*Math.PI&&1.5*Math.PI<=p,S=h/100,w={x:y?-1:Math.min(m.x*(m.x<0?1:S),b.x*(b.x<0?1:S)),y:k?-1:Math.min(m.y*(m.y<0?1:S),b.y*(b.y<0?1:S))},M={x:v?1:Math.max(m.x*(m.x>0?1:S),b.x*(b.x>0?1:S)),y:x?1:Math.max(m.y*(m.y>0?1:S),b.y*(b.y>0?1:S))},C={width:.5*(M.x-w.x),height:.5*(M.y-w.y)};d=Math.min(l/C.width,s/C.height),u={x:(M.x+w.x)*-.5,y:(M.y+w.y)*-.5}}i.borderWidth=a.getMaxBorderWidth(c.data),i.outerRadius=Math.max((d-i.borderWidth)/2,0),i.innerRadius=Math.max(h?i.outerRadius/100*h:1,0),i.radiusLength=(i.outerRadius-i.innerRadius)/i.getVisibleDatasetCount(),i.offsetX=u.x*i.outerRadius,i.offsetY=u.y*i.outerRadius,c.total=a.calculateTotal(),a.outerRadius=i.outerRadius-i.radiusLength*a.getRingIndex(a.index),a.innerRadius=a.outerRadius-i.radiusLength,e.each(c.data,function(e,i){a.updateElement(e,i,t)})},updateElement:function(t,a,i){var n=this,o=n.chart,r=o.chartArea,l=o.options,s=l.animation,d=(r.left+r.right)/2,u=(r.top+r.bottom)/2,c=l.rotation,h=l.rotation,f=n.getDataset(),g=i&&s.animateRotate?0:t.hidden?0:n.calculateCircumference(f.data[a])*(l.circumference/(2*Math.PI)),p=i&&s.animateScale?0:n.innerRadius,m=i&&s.animateScale?0:n.outerRadius,b=e.getValueAtIndexOrDefault;e.extend(t,{_datasetIndex:n.index,_index:a,_model:{x:d+o.offsetX,y:u+o.offsetY,startAngle:c,endAngle:h,circumference:g,outerRadius:m,innerRadius:p,label:b(f.label,a,o.data.labels[a])}});var v=t._model;this.removeHoverStyle(t),i&&s.animateRotate||(0===a?v.startAngle=l.rotation:v.startAngle=n.getMeta().data[a-1]._model.endAngle,v.endAngle=v.startAngle+v.circumference),t.pivot()},removeHoverStyle:function(e){t.DatasetController.prototype.removeHoverStyle.call(this,e,this.chart.options.elements.arc)},calculateTotal:function(){var t,a=this.getDataset(),i=this.getMeta(),n=0;return e.each(i.data,function(e,i){t=a.data[i],isNaN(t)||e.hidden||(n+=Math.abs(t))}),n},calculateCircumference:function(t){var e=this.getMeta().total;return e>0&&!isNaN(t)?2*Math.PI*(t/e):0},getMaxBorderWidth:function(t){for(var e,a,i=0,n=this.index,o=t.length,r=0;o>r;r++)e=t[r]._model?t[r]._model.borderWidth:0,a=t[r]._chart?t[r]._chart.config.data.datasets[n].hoverBorderWidth:0,i=e>i?e:i,i=a>i?a:i;return i}})}},{}],18:[function(t,e,a){"use strict";e.exports=function(t){function e(t,e){return a.getValueOrDefault(t.showLine,e.showLines)}var a=t.helpers;t.defaults.line={showLines:!0,spanGaps:!1,hover:{mode:"label"},scales:{xAxes:[{type:"category",id:"x-axis-0"}],yAxes:[{type:"linear",id:"y-axis-0"}]}},t.controllers.line=t.DatasetController.extend({datasetElementType:t.elements.Line,dataElementType:t.elements.Point,update:function(t){var i,n,o,r=this,l=r.getMeta(),s=l.dataset,d=l.data||[],u=r.chart.options,c=u.elements.line,h=r.getScaleForId(l.yAxisID),f=r.getDataset(),g=e(f,u);for(g&&(o=s.custom||{},void 0!==f.tension&&void 0===f.lineTension&&(f.lineTension=f.tension),s._scale=h,s._datasetIndex=r.index,s._children=d,s._model={spanGaps:f.spanGaps?f.spanGaps:u.spanGaps,tension:o.tension?o.tension:a.getValueOrDefault(f.lineTension,c.tension),backgroundColor:o.backgroundColor?o.backgroundColor:f.backgroundColor||c.backgroundColor,borderWidth:o.borderWidth?o.borderWidth:f.borderWidth||c.borderWidth,borderColor:o.borderColor?o.borderColor:f.borderColor||c.borderColor,borderCapStyle:o.borderCapStyle?o.borderCapStyle:f.borderCapStyle||c.borderCapStyle,borderDash:o.borderDash?o.borderDash:f.borderDash||c.borderDash,borderDashOffset:o.borderDashOffset?o.borderDashOffset:f.borderDashOffset||c.borderDashOffset,borderJoinStyle:o.borderJoinStyle?o.borderJoinStyle:f.borderJoinStyle||c.borderJoinStyle,fill:o.fill?o.fill:void 0!==f.fill?f.fill:c.fill,steppedLine:o.steppedLine?o.steppedLine:a.getValueOrDefault(f.steppedLine,c.stepped),cubicInterpolationMode:o.cubicInterpolationMode?o.cubicInterpolationMode:a.getValueOrDefault(f.cubicInterpolationMode,c.cubicInterpolationMode),scaleTop:h.top,scaleBottom:h.bottom,scaleZero:h.getBasePixel()},s.pivot()),i=0,n=d.length;n>i;++i)r.updateElement(d[i],i,t);for(g&&0!==s._model.tension&&r.updateBezierControlPoints(),i=0,n=d.length;n>i;++i)d[i].pivot()},getPointBackgroundColor:function(t,e){var i=this.chart.options.elements.point.backgroundColor,n=this.getDataset(),o=t.custom||{};return o.backgroundColor?i=o.backgroundColor:n.pointBackgroundColor?i=a.getValueAtIndexOrDefault(n.pointBackgroundColor,e,i):n.backgroundColor&&(i=n.backgroundColor),i},getPointBorderColor:function(t,e){var i=this.chart.options.elements.point.borderColor,n=this.getDataset(),o=t.custom||{};return o.borderColor?i=o.borderColor:n.pointBorderColor?i=a.getValueAtIndexOrDefault(n.pointBorderColor,e,i):n.borderColor&&(i=n.borderColor),i},getPointBorderWidth:function(t,e){var i=this.chart.options.elements.point.borderWidth,n=this.getDataset(),o=t.custom||{};return o.borderWidth?i=o.borderWidth:n.pointBorderWidth?i=a.getValueAtIndexOrDefault(n.pointBorderWidth,e,i):n.borderWidth&&(i=n.borderWidth),i},updateElement:function(t,e,i){var n,o,r=this,l=r.getMeta(),s=t.custom||{},d=r.getDataset(),u=r.index,c=d.data[e],h=r.getScaleForId(l.yAxisID),f=r.getScaleForId(l.xAxisID),g=r.chart.options.elements.point,p=r.chart.data.labels||[],m=1===p.length||1===d.data.length||r.chart.isCombo;void 0!==d.radius&&void 0===d.pointRadius&&(d.pointRadius=d.radius),void 0!==d.hitRadius&&void 0===d.pointHitRadius&&(d.pointHitRadius=d.hitRadius),n=f.getPixelForValue("object"==typeof c?c:NaN,e,u,m),o=i?h.getBasePixel():r.calculatePointY(c,e,u),t._xScale=f,t._yScale=h,t._datasetIndex=u,t._index=e,t._model={x:n,y:o,skip:s.skip||isNaN(n)||isNaN(o),radius:s.radius||a.getValueAtIndexOrDefault(d.pointRadius,e,g.radius),pointStyle:s.pointStyle||a.getValueAtIndexOrDefault(d.pointStyle,e,g.pointStyle),backgroundColor:r.getPointBackgroundColor(t,e),borderColor:r.getPointBorderColor(t,e),borderWidth:r.getPointBorderWidth(t,e),tension:l.dataset._model?l.dataset._model.tension:0,steppedLine:l.dataset._model?l.dataset._model.steppedLine:!1,hitRadius:s.hitRadius||a.getValueAtIndexOrDefault(d.pointHitRadius,e,g.hitRadius)}},calculatePointY:function(t,e,a){var i,n,o,r=this,l=r.chart,s=r.getMeta(),d=r.getScaleForId(s.yAxisID),u=0,c=0;if(d.options.stacked){for(i=0;a>i;i++)if(n=l.data.datasets[i],o=l.getDatasetMeta(i),"line"===o.type&&o.yAxisID===d.id&&l.isDatasetVisible(i)){var h=Number(d.getRightValue(n.data[e]));0>h?c+=h||0:u+=h||0}var f=Number(d.getRightValue(t));return 0>f?d.getPixelForValue(c+f):d.getPixelForValue(u+f)}return d.getPixelForValue(t)},updateBezierControlPoints:function(){function t(t,e,a){return Math.max(Math.min(t,a),e)}var e,i,n,o,r,l=this,s=l.getMeta(),d=l.chart.chartArea,u=s.data||[];if(s.dataset._model.spanGaps&&(u=u.filter(function(t){return!t._model.skip})),"monotone"===s.dataset._model.cubicInterpolationMode)a.splineCurveMonotone(u);else for(e=0,i=u.length;i>e;++e)n=u[e],o=n._model,r=a.splineCurve(a.previousItem(u,e)._model,o,a.nextItem(u,e)._model,s.dataset._model.tension),o.controlPointPreviousX=r.previous.x,o.controlPointPreviousY=r.previous.y,o.controlPointNextX=r.next.x,o.controlPointNextY=r.next.y;if(l.chart.options.elements.line.capBezierPoints)for(e=0,i=u.length;i>e;++e)o=u[e]._model,o.controlPointPreviousX=t(o.controlPointPreviousX,d.left,d.right),o.controlPointPreviousY=t(o.controlPointPreviousY,d.top,d.bottom),o.controlPointNextX=t(o.controlPointNextX,d.left,d.right),o.controlPointNextY=t(o.controlPointNextY,d.top,d.bottom)},draw:function(t){var a,i,n=this,o=n.getMeta(),r=o.data||[],l=t||1;for(a=0,i=r.length;i>a;++a)r[a].transition(l);for(e(n.getDataset(),n.chart.options)&&o.dataset.transition(l).draw(),a=0,i=r.length;i>a;++a)r[a].draw()},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],i=t._index,n=t.custom||{},o=t._model;o.radius=n.hoverRadius||a.getValueAtIndexOrDefault(e.pointHoverRadius,i,this.chart.options.elements.point.hoverRadius),o.backgroundColor=n.hoverBackgroundColor||a.getValueAtIndexOrDefault(e.pointHoverBackgroundColor,i,a.getHoverColor(o.backgroundColor)),o.borderColor=n.hoverBorderColor||a.getValueAtIndexOrDefault(e.pointHoverBorderColor,i,a.getHoverColor(o.borderColor)),o.borderWidth=n.hoverBorderWidth||a.getValueAtIndexOrDefault(e.pointHoverBorderWidth,i,o.borderWidth)},removeHoverStyle:function(t){var e=this,i=e.chart.data.datasets[t._datasetIndex],n=t._index,o=t.custom||{},r=t._model;void 0!==i.radius&&void 0===i.pointRadius&&(i.pointRadius=i.radius),r.radius=o.radius||a.getValueAtIndexOrDefault(i.pointRadius,n,e.chart.options.elements.point.radius),r.backgroundColor=e.getPointBackgroundColor(t,n),r.borderColor=e.getPointBorderColor(t,n),r.borderWidth=e.getPointBorderWidth(t,n)}})}},{}],19:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers;t.defaults.polarArea={scale:{type:"radialLinear",lineArc:!0,ticks:{beginAtZero:!0}},animation:{animateRotate:!0,animateScale:!0},startAngle:-.5*Math.PI,aspectRatio:1,legendCallback:function(t){var e=[];e.push('<ul class="'+t.id+'-legend">');var a=t.data,i=a.datasets,n=a.labels;if(i.length)for(var o=0;o<i[0].data.length;++o)e.push('<li><span style="background-color:'+i[0].backgroundColor[o]+'"></span>'),n[o]&&e.push(n[o]),e.push("</li>");return e.push("</ul>"),e.join("")},legend:{labels:{generateLabels:function(t){var a=t.data;return a.labels.length&&a.datasets.length?a.labels.map(function(i,n){var o=t.getDatasetMeta(0),r=a.datasets[0],l=o.data[n],s=l.custom||{},d=e.getValueAtIndexOrDefault,u=t.options.elements.arc,c=s.backgroundColor?s.backgroundColor:d(r.backgroundColor,n,u.backgroundColor),h=s.borderColor?s.borderColor:d(r.borderColor,n,u.borderColor),f=s.borderWidth?s.borderWidth:d(r.borderWidth,n,u.borderWidth);return{text:i,fillStyle:c,strokeStyle:h,lineWidth:f,hidden:isNaN(r.data[n])||o.data[n].hidden,index:n}}):[]}},onClick:function(t,e){var a,i,n,o=e.index,r=this.chart;for(a=0,i=(r.data.datasets||[]).length;i>a;++a)n=r.getDatasetMeta(a),n.data[o].hidden=!n.data[o].hidden;r.update()}},tooltips:{callbacks:{title:function(){return""},label:function(t,e){return e.labels[t.index]+": "+t.yLabel}}}},t.controllers.polarArea=t.DatasetController.extend({dataElementType:t.elements.Arc,linkScales:e.noop,update:function(t){var a=this,i=a.chart,n=i.chartArea,o=a.getMeta(),r=i.options,l=r.elements.arc,s=Math.min(n.right-n.left,n.bottom-n.top);i.outerRadius=Math.max((s-l.borderWidth/2)/2,0),i.innerRadius=Math.max(r.cutoutPercentage?i.outerRadius/100*r.cutoutPercentage:1,0),i.radiusLength=(i.outerRadius-i.innerRadius)/i.getVisibleDatasetCount(),a.outerRadius=i.outerRadius-i.radiusLength*a.index,a.innerRadius=a.outerRadius-i.radiusLength,o.count=a.countVisibleElements(),e.each(o.data,function(e,i){a.updateElement(e,i,t)})},updateElement:function(t,a,i){for(var n=this,o=n.chart,r=n.getDataset(),l=o.options,s=l.animation,d=o.scale,u=e.getValueAtIndexOrDefault,c=o.data.labels,h=n.calculateCircumference(r.data[a]),f=d.xCenter,g=d.yCenter,p=0,m=n.getMeta(),b=0;a>b;++b)isNaN(r.data[b])||m.data[b].hidden||++p;var v=l.startAngle,x=t.hidden?0:d.getDistanceFromCenterForValue(r.data[a]),y=v+h*p,k=y+(t.hidden?0:h),S=s.animateScale?0:d.getDistanceFromCenterForValue(r.data[a]);e.extend(t,{_datasetIndex:n.index,_index:a,_scale:d,_model:{x:f,y:g,innerRadius:0,outerRadius:i?S:x,startAngle:i&&s.animateRotate?v:y,endAngle:i&&s.animateRotate?v:k,label:u(c,a,c[a])}}),n.removeHoverStyle(t),t.pivot()},removeHoverStyle:function(e){t.DatasetController.prototype.removeHoverStyle.call(this,e,this.chart.options.elements.arc)},countVisibleElements:function(){var t=this.getDataset(),a=this.getMeta(),i=0;return e.each(a.data,function(e,a){isNaN(t.data[a])||e.hidden||i++}),i},calculateCircumference:function(t){var e=this.getMeta().count;return e>0&&!isNaN(t)?2*Math.PI/e:0}})}},{}],20:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers;t.defaults.radar={aspectRatio:1,scale:{type:"radialLinear"},elements:{line:{tension:0}}},t.controllers.radar=t.DatasetController.extend({datasetElementType:t.elements.Line,dataElementType:t.elements.Point,linkScales:e.noop,update:function(t){var a=this,i=a.getMeta(),n=i.dataset,o=i.data,r=n.custom||{},l=a.getDataset(),s=a.chart.options.elements.line,d=a.chart.scale;void 0!==l.tension&&void 0===l.lineTension&&(l.lineTension=l.tension),e.extend(i.dataset,{_datasetIndex:a.index,_children:o,_loop:!0,_model:{tension:r.tension?r.tension:e.getValueOrDefault(l.lineTension,s.tension),backgroundColor:r.backgroundColor?r.backgroundColor:l.backgroundColor||s.backgroundColor,borderWidth:r.borderWidth?r.borderWidth:l.borderWidth||s.borderWidth,borderColor:r.borderColor?r.borderColor:l.borderColor||s.borderColor,fill:r.fill?r.fill:void 0!==l.fill?l.fill:s.fill,borderCapStyle:r.borderCapStyle?r.borderCapStyle:l.borderCapStyle||s.borderCapStyle,borderDash:r.borderDash?r.borderDash:l.borderDash||s.borderDash,borderDashOffset:r.borderDashOffset?r.borderDashOffset:l.borderDashOffset||s.borderDashOffset,borderJoinStyle:r.borderJoinStyle?r.borderJoinStyle:l.borderJoinStyle||s.borderJoinStyle,scaleTop:d.top,scaleBottom:d.bottom,scaleZero:d.getBasePosition()}}),i.dataset.pivot(),e.each(o,function(e,i){a.updateElement(e,i,t)},a),a.updateBezierControlPoints()},updateElement:function(t,a,i){var n=this,o=t.custom||{},r=n.getDataset(),l=n.chart.scale,s=n.chart.options.elements.point,d=l.getPointPositionForValue(a,r.data[a]);e.extend(t,{_datasetIndex:n.index,_index:a,_scale:l,_model:{x:i?l.xCenter:d.x,y:i?l.yCenter:d.y,tension:o.tension?o.tension:e.getValueOrDefault(r.tension,n.chart.options.elements.line.tension),radius:o.radius?o.radius:e.getValueAtIndexOrDefault(r.pointRadius,a,s.radius),backgroundColor:o.backgroundColor?o.backgroundColor:e.getValueAtIndexOrDefault(r.pointBackgroundColor,a,s.backgroundColor),borderColor:o.borderColor?o.borderColor:e.getValueAtIndexOrDefault(r.pointBorderColor,a,s.borderColor),borderWidth:o.borderWidth?o.borderWidth:e.getValueAtIndexOrDefault(r.pointBorderWidth,a,s.borderWidth),pointStyle:o.pointStyle?o.pointStyle:e.getValueAtIndexOrDefault(r.pointStyle,a,s.pointStyle),hitRadius:o.hitRadius?o.hitRadius:e.getValueAtIndexOrDefault(r.hitRadius,a,s.hitRadius)}}),t._model.skip=o.skip?o.skip:isNaN(t._model.x)||isNaN(t._model.y)},updateBezierControlPoints:function(){var t=this.chart.chartArea,a=this.getMeta();e.each(a.data,function(i,n){var o=i._model,r=e.splineCurve(e.previousItem(a.data,n,!0)._model,o,e.nextItem(a.data,n,!0)._model,o.tension);o.controlPointPreviousX=Math.max(Math.min(r.previous.x,t.right),t.left),o.controlPointPreviousY=Math.max(Math.min(r.previous.y,t.bottom),t.top),o.controlPointNextX=Math.max(Math.min(r.next.x,t.right),t.left),o.controlPointNextY=Math.max(Math.min(r.next.y,t.bottom),t.top),i.pivot()})},draw:function(t){var a=this.getMeta(),i=t||1;e.each(a.data,function(t){t.transition(i)}),a.dataset.transition(i).draw(),e.each(a.data,function(t){t.draw()})},setHoverStyle:function(t){var a=this.chart.data.datasets[t._datasetIndex],i=t.custom||{},n=t._index,o=t._model;o.radius=i.hoverRadius?i.hoverRadius:e.getValueAtIndexOrDefault(a.pointHoverRadius,n,this.chart.options.elements.point.hoverRadius),o.backgroundColor=i.hoverBackgroundColor?i.hoverBackgroundColor:e.getValueAtIndexOrDefault(a.pointHoverBackgroundColor,n,e.getHoverColor(o.backgroundColor)),o.borderColor=i.hoverBorderColor?i.hoverBorderColor:e.getValueAtIndexOrDefault(a.pointHoverBorderColor,n,e.getHoverColor(o.borderColor)),o.borderWidth=i.hoverBorderWidth?i.hoverBorderWidth:e.getValueAtIndexOrDefault(a.pointHoverBorderWidth,n,o.borderWidth)},removeHoverStyle:function(t){var a=this.chart.data.datasets[t._datasetIndex],i=t.custom||{},n=t._index,o=t._model,r=this.chart.options.elements.point;o.radius=i.radius?i.radius:e.getValueAtIndexOrDefault(a.radius,n,r.radius),o.backgroundColor=i.backgroundColor?i.backgroundColor:e.getValueAtIndexOrDefault(a.pointBackgroundColor,n,r.backgroundColor),o.borderColor=i.borderColor?i.borderColor:e.getValueAtIndexOrDefault(a.pointBorderColor,n,r.borderColor),o.borderWidth=i.borderWidth?i.borderWidth:e.getValueAtIndexOrDefault(a.pointBorderWidth,n,r.borderWidth)}})}},{}],21:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers;t.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:e.noop,onComplete:e.noop},t.Animation=t.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),t.animationService={frameDuration:17,animations:[],dropFrames:0,request:null,addAnimation:function(t,e,a,i){var n=this;i||(t.animating=!0);for(var o=0;o<n.animations.length;++o)if(n.animations[o].chartInstance===t)return void(n.animations[o].animationObject=e);n.animations.push({chartInstance:t,animationObject:e}),1===n.animations.length&&n.requestAnimationFrame()},cancelAnimation:function(t){var a=e.findIndex(this.animations,function(e){return e.chartInstance===t});-1!==a&&(this.animations.splice(a,1),t.animating=!1)},requestAnimationFrame:function(){var t=this;null===t.request&&(t.request=e.requestAnimFrame.call(window,function(){t.request=null,t.startDigest()}))},startDigest:function(){var t=this,e=Date.now(),a=0;t.dropFrames>1&&(a=Math.floor(t.dropFrames),t.dropFrames=t.dropFrames%1);for(var i=0;i<t.animations.length;)null===t.animations[i].animationObject.currentStep&&(t.animations[i].animationObject.currentStep=0),t.animations[i].animationObject.currentStep+=1+a,t.animations[i].animationObject.currentStep>t.animations[i].animationObject.numSteps&&(t.animations[i].animationObject.currentStep=t.animations[i].animationObject.numSteps),t.animations[i].animationObject.render(t.animations[i].chartInstance,t.animations[i].animationObject),t.animations[i].animationObject.onAnimationProgress&&t.animations[i].animationObject.onAnimationProgress.call&&t.animations[i].animationObject.onAnimationProgress.call(t.animations[i].chartInstance,t.animations[i]),t.animations[i].animationObject.currentStep===t.animations[i].animationObject.numSteps?(t.animations[i].animationObject.onAnimationComplete&&t.animations[i].animationObject.onAnimationComplete.call&&t.animations[i].animationObject.onAnimationComplete.call(t.animations[i].chartInstance,t.animations[i]),t.animations[i].chartInstance.animating=!1,t.animations.splice(i,1)):++i;var n=Date.now(),o=(n-e)/t.frameDuration;t.dropFrames+=o,t.animations.length>0&&t.requestAnimationFrame()}}}},{}],22:[function(t,e,a){"use strict";e.exports=function(t){var e=t.canvasHelpers={};e.drawPoint=function(t,e,a,i,n){var o,r,l,s,d,u;if("object"==typeof e&&(o=e.toString(),"[object HTMLImageElement]"===o||"[object HTMLCanvasElement]"===o))return void t.drawImage(e,i-e.width/2,n-e.height/2);if(!(isNaN(a)||0>=a)){switch(e){default:t.beginPath(),t.arc(i,n,a,0,2*Math.PI),t.closePath(),t.fill();break;case"triangle":t.beginPath(),r=3*a/Math.sqrt(3),d=r*Math.sqrt(3)/2,t.moveTo(i-r/2,n+d/3),t.lineTo(i+r/2,n+d/3),t.lineTo(i,n-2*d/3),t.closePath(),t.fill();break;case"rect":u=1/Math.SQRT2*a,t.beginPath(),t.fillRect(i-u,n-u,2*u,2*u),t.strokeRect(i-u,n-u,2*u,2*u);break;case"rectRot":u=1/Math.SQRT2*a,t.beginPath(),t.moveTo(i-u,n),t.lineTo(i,n+u),t.lineTo(i+u,n),t.lineTo(i,n-u),t.closePath(),t.fill();break;case"cross":t.beginPath(),t.moveTo(i,n+a),t.lineTo(i,n-a),t.moveTo(i-a,n),t.lineTo(i+a,n),t.closePath();break;case"crossRot":t.beginPath(),l=Math.cos(Math.PI/4)*a,s=Math.sin(Math.PI/4)*a,t.moveTo(i-l,n-s),t.lineTo(i+l,n+s),t.moveTo(i-l,n+s),t.lineTo(i+l,n-s),t.closePath();break;case"star":t.beginPath(),t.moveTo(i,n+a),t.lineTo(i,n-a),t.moveTo(i-a,n),t.lineTo(i+a,n),l=Math.cos(Math.PI/4)*a,s=Math.sin(Math.PI/4)*a,t.moveTo(i-l,n-s),t.lineTo(i+l,n+s),t.moveTo(i-l,n+s),t.lineTo(i+l,n-s),t.closePath();break;case"line":t.beginPath(),t.moveTo(i-a,n),t.lineTo(i+a,n),t.closePath();break;case"dash":t.beginPath(),t.moveTo(i,n),t.lineTo(i+a,n),t.closePath()}t.stroke()}}}},{}],23:[function(t,e,a){"use strict";e.exports=function(t){function e(t,e){var a=r.getStyle(t,e),i=a&&a.match(/(\d+)px/);return i?Number(i[1]):void 0}function a(t,a){var i=t.style,n=t.getAttribute("height"),o=t.getAttribute("width");if(t._chartjs={initial:{height:n,width:o,style:{display:i.display,height:i.height,width:i.width}}},i.display=i.display||"block",null===o||""===o){var r=e(t,"width");void 0!==r&&(t.width=r)}if(null===n||""===n)if(""===t.style.height)t.height=t.width/(a.options.aspectRatio||2);else{var l=e(t,"height");void 0!==r&&(t.height=l)}return t}function i(t){if(t._chartjs){var e=t._chartjs.initial;["height","width"].forEach(function(a){var i=e[a];void 0===i||null===i?t.removeAttribute(a):t.setAttribute(a,i)}),r.each(e.style||{},function(e,a){t.style[a]=e}),t.width=t.width,delete t._chartjs}}function n(t,e){if("string"==typeof t?t=document.getElementById(t):t.length&&(t=t[0]),t&&t.canvas&&(t=t.canvas),t instanceof HTMLCanvasElement){var i=t.getContext&&t.getContext("2d");if(i instanceof CanvasRenderingContext2D)return a(t,e),i}return null}function o(e){e=e||{};var a=e.data=e.data||{};return a.datasets=a.datasets||[],a.labels=a.labels||[],e.options=r.configMerge(t.defaults.global,t.defaults[e.type],e.options||{}),e}var r=t.helpers;t.types={},t.instances={},t.controllers={},t.Controller=function(e,a,i){var l=this;a=o(a);var s=n(e,a),d=s&&s.canvas,u=d&&d.height,c=d&&d.width;return i.ctx=s,i.canvas=d,i.config=a,i.width=c,i.height=u,i.aspectRatio=u?c/u:null,l.id=r.uid(),l.chart=i,l.config=a,l.options=a.options,l._bufferedRender=!1,t.instances[l.id]=l,Object.defineProperty(l,"data",{get:function(){return l.config.data}}),s&&d?(r.retinaScale(i),l.options.responsive&&(r.addResizeListener(d.parentNode,function(){l.resize()}),l.resize(!0)),l.initialize(),l):(console.error("Failed to create chart: can't acquire context from the given item"),l)},r.extend(t.Controller.prototype,{initialize:function(){var e=this;return t.plugins.notify("beforeInit",[e]),e.bindEvents(),e.ensureScalesHaveIDs(),e.buildOrUpdateControllers(),e.buildScales(),e.updateLayout(),e.resetElements(),e.initToolTip(),e.update(),t.plugins.notify("afterInit",[e]),e},clear:function(){return r.clear(this.chart),this},stop:function(){return t.animationService.cancelAnimation(this),this},resize:function(e){var a=this,i=a.chart,n=a.options,o=i.canvas,l=n.maintainAspectRatio&&i.aspectRatio||null,s=Math.floor(r.getMaximumWidth(o)),d=Math.floor(l?s/l:r.getMaximumHeight(o));if(i.width!==s||i.height!==d){o.width=i.width=s,o.height=i.height=d,o.style.width=s+"px",o.style.height=d+"px",r.retinaScale(i);var u={width:s,height:d};t.plugins.notify("resize",[a,u]),a.options.onResize&&a.options.onResize(a,u),e||(a.stop(),a.update(a.options.responsiveAnimationDuration))}},ensureScalesHaveIDs:function(){var t=this.options,e=t.scales||{},a=t.scale;r.each(e.xAxes,function(t,e){t.id=t.id||"x-axis-"+e}),r.each(e.yAxes,function(t,e){t.id=t.id||"y-axis-"+e}),a&&(a.id=a.id||"scale")},buildScales:function(){var e=this,a=e.options,i=e.scales={},n=[];a.scales&&(n=n.concat((a.scales.xAxes||[]).map(function(t){return{options:t,dtype:"category"}}),(a.scales.yAxes||[]).map(function(t){return{options:t,dtype:"linear"}}))),a.scale&&n.push({options:a.scale,dtype:"radialLinear",isDefault:!0}),r.each(n,function(a){var n=a.options,o=r.getValueOrDefault(n.type,a.dtype),l=t.scaleService.getScaleConstructor(o);if(l){var s=new l({id:n.id,options:n,ctx:e.chart.ctx,chart:e});i[s.id]=s,a.isDefault&&(e.scale=s)}}),t.scaleService.addScalesToLayout(this)},updateLayout:function(){t.layoutService.update(this,this.chart.width,this.chart.height)},buildOrUpdateControllers:function(){var e=this,a=[],i=[];if(r.each(e.data.datasets,function(n,o){var r=e.getDatasetMeta(o);r.type||(r.type=n.type||e.config.type),a.push(r.type),r.controller?r.controller.updateIndex(o):(r.controller=new t.controllers[r.type](e,o),i.push(r.controller))},e),a.length>1)for(var n=1;n<a.length;n++)if(a[n]!==a[n-1]){e.isCombo=!0;break}return i},resetElements:function(){var t=this;r.each(t.data.datasets,function(e,a){t.getDatasetMeta(a).controller.reset()},t)},reset:function(){this.resetElements(),this.tooltip.initialize()},update:function(e,a){var i=this;t.plugins.notify("beforeUpdate",[i]),i.tooltip._data=i.data;var n=i.buildOrUpdateControllers();r.each(i.data.datasets,function(t,e){i.getDatasetMeta(e).controller.buildOrUpdateElements()},i),t.layoutService.update(i,i.chart.width,i.chart.height),t.plugins.notify("afterScaleUpdate",[i]),r.each(n,function(t){t.reset()}),i.updateDatasets(),t.plugins.notify("afterUpdate",[i]),i._bufferedRender?i._bufferedRequest={lazy:a,duration:e}:i.render(e,a)},updateDatasets:function(){var e,a,i=this;if(t.plugins.notify("beforeDatasetsUpdate",[i])){for(e=0,a=i.data.datasets.length;a>e;++e)i.getDatasetMeta(e).controller.update();t.plugins.notify("afterDatasetsUpdate",[i])}},render:function(e,a){var i=this;t.plugins.notify("beforeRender",[i]);var n=i.options.animation;if(n&&("undefined"!=typeof e&&0!==e||"undefined"==typeof e&&0!==n.duration)){var o=new t.Animation;o.numSteps=(e||n.duration)/16.66,o.easing=n.easing,o.render=function(t,e){var a=r.easingEffects[e.easing],i=e.currentStep/e.numSteps,n=a(i);t.draw(n,i,e.currentStep)},o.onAnimationProgress=n.onProgress,o.onAnimationComplete=n.onComplete,t.animationService.addAnimation(i,o,e,a)}else i.draw(),n&&n.onComplete&&n.onComplete.call&&n.onComplete.call(i);return i},draw:function(e){var a=this,i=e||1;a.clear(),t.plugins.notify("beforeDraw",[a,i]),r.each(a.boxes,function(t){t.draw(a.chartArea)},a),a.scale&&a.scale.draw(),t.plugins.notify("beforeDatasetsDraw",[a,i]),r.each(a.data.datasets,function(t,i){a.isDatasetVisible(i)&&a.getDatasetMeta(i).controller.draw(e)},a,!0),t.plugins.notify("afterDatasetsDraw",[a,i]),a.tooltip.transition(i).draw(),t.plugins.notify("afterDraw",[a,i])},getElementAtEvent:function(e){return t.Interaction.modes.single(this,e)},getElementsAtEvent:function(e){return t.Interaction.modes.label(this,e,{intersect:!0})},getElementsAtXAxis:function(e){return t.Interaction.modes["x-axis"](this,e,{intersect:!0})},getElementsAtEventForMode:function(e,a,i){var n=t.Interaction.modes[a];return"function"==typeof n?n(this,e,i):[]},getDatasetAtEvent:function(e){return t.Interaction.modes.dataset(this,e)},getDatasetMeta:function(t){var e=this,a=e.data.datasets[t];a._meta||(a._meta={});
12
+ var i=a._meta[e.id];return i||(i=a._meta[e.id]={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null}),i},getVisibleDatasetCount:function(){for(var t=0,e=0,a=this.data.datasets.length;a>e;++e)this.isDatasetVisible(e)&&t++;return t},isDatasetVisible:function(t){var e=this.getDatasetMeta(t);return"boolean"==typeof e.hidden?!e.hidden:!this.data.datasets[t].hidden},generateLegend:function(){return this.options.legendCallback(this)},destroy:function(){var e,a,n,o=this,l=o.chart.canvas;for(o.stop(),a=0,n=o.data.datasets.length;n>a;++a)e=o.getDatasetMeta(a),e.controller&&(e.controller.destroy(),e.controller=null);l&&(r.unbindEvents(o,o.events),r.removeResizeListener(l.parentNode),r.clear(o.chart),i(l),o.chart.canvas=null,o.chart.ctx=null),t.plugins.notify("destroy",[o]),delete t.instances[o.id]},toBase64Image:function(){return this.chart.canvas.toDataURL.apply(this.chart.canvas,arguments)},initToolTip:function(){var e=this;e.tooltip=new t.Tooltip({_chart:e.chart,_chartInstance:e,_data:e.data,_options:e.options.tooltips},e),e.tooltip.initialize()},bindEvents:function(){var t=this;r.bindEvents(t,t.options.events,function(e){t.eventHandler(e)})},updateHoverStyle:function(t,e,a){var i,n,o,r=a?"setHoverStyle":"removeHoverStyle";for(n=0,o=t.length;o>n;++n)i=t[n],i&&this.getDatasetMeta(i._datasetIndex).controller[r](i)},eventHandler:function(t){var e=this,a=e.legend,i=e.tooltip,n=e.options.hover;e._bufferedRender=!0,e._bufferedRequest=null;var o=e.handleEvent(t);o|=a&&a.handleEvent(t),o|=i&&i.handleEvent(t);var r=e._bufferedRequest;return r?e.render(r.duration,r.lazy):o&&!e.animating&&(e.stop(),e.render(n.animationDuration,!0)),e._bufferedRender=!1,e._bufferedRequest=null,e},handleEvent:function(t){var e=this,a=e.options||{},i=a.hover,n=!1;return e.lastActive=e.lastActive||[],"mouseout"===t.type?e.active=[]:e.active=e.getElementsAtEventForMode(t,i.mode,i),i.onHover&&i.onHover.call(e,e.active),("mouseup"===t.type||"click"===t.type)&&a.onClick&&a.onClick.call(e,t,e.active),e.lastActive.length&&e.updateHoverStyle(e.lastActive,i.mode,!1),e.active.length&&i.mode&&e.updateHoverStyle(e.active,i.mode,!0),n=!r.arrayEquals(e.active,e.lastActive),e.lastActive=e.active,n}})}},{}],24:[function(t,e,a){"use strict";e.exports=function(t){function e(t,e){return t._chartjs?void t._chartjs.listeners.push(e):(Object.defineProperty(t,"_chartjs",{configurable:!0,enumerable:!1,value:{listeners:[e]}}),void n.forEach(function(e){var a="onData"+e.charAt(0).toUpperCase()+e.slice(1),n=t[e];Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:function(){var e=Array.prototype.slice.call(arguments),o=n.apply(this,e);return i.each(t._chartjs.listeners,function(t){"function"==typeof t[a]&&t[a].apply(t,e)}),o}})}))}function a(t,e){var a=t._chartjs;if(a){var i=a.listeners,o=i.indexOf(e);-1!==o&&i.splice(o,1),i.length>0||(n.forEach(function(e){delete t[e]}),delete t._chartjs)}}var i=t.helpers,n=["push","pop","shift","splice","unshift"];t.DatasetController=function(t,e){this.initialize(t,e)},i.extend(t.DatasetController.prototype,{datasetElementType:null,dataElementType:null,initialize:function(t,e){var a=this;a.chart=t,a.index=e,a.linkScales(),a.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){var t=this,e=t.getMeta(),a=t.getDataset();null===e.xAxisID&&(e.xAxisID=a.xAxisID||t.chart.options.scales.xAxes[0].id),null===e.yAxisID&&(e.yAxisID=a.yAxisID||t.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getMeta:function(){return this.chart.getDatasetMeta(this.index)},getScaleForId:function(t){return this.chart.scales[t]},reset:function(){this.update(!0)},destroy:function(){this._data&&a(this._data,this)},createMetaDataset:function(){var t=this,e=t.datasetElementType;return e&&new e({_chart:t.chart.chart,_datasetIndex:t.index})},createMetaData:function(t){var e=this,a=e.dataElementType;return a&&new a({_chart:e.chart.chart,_datasetIndex:e.index,_index:t})},addElements:function(){var t,e,a=this,i=a.getMeta(),n=a.getDataset().data||[],o=i.data;for(t=0,e=n.length;e>t;++t)o[t]=o[t]||a.createMetaData(t);i.dataset=i.dataset||a.createMetaDataset()},addElementAndReset:function(t){var e=this.createMetaData(t);this.getMeta().data.splice(t,0,e),this.updateElement(e,t,!0)},buildOrUpdateElements:function(){var t=this,i=t.getDataset(),n=i.data||(i.data=[]);t._data!==n&&(t._data&&a(t._data,t),e(n,t),t._data=n),t.resyncElements()},update:i.noop,draw:function(t){var e,a,i=t||1,n=this.getMeta().data;for(e=0,a=n.length;a>e;++e)n[e].transition(i).draw()},removeHoverStyle:function(t,e){var a=this.chart.data.datasets[t._datasetIndex],n=t._index,o=t.custom||{},r=i.getValueAtIndexOrDefault,l=t._model;l.backgroundColor=o.backgroundColor?o.backgroundColor:r(a.backgroundColor,n,e.backgroundColor),l.borderColor=o.borderColor?o.borderColor:r(a.borderColor,n,e.borderColor),l.borderWidth=o.borderWidth?o.borderWidth:r(a.borderWidth,n,e.borderWidth)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index,n=t.custom||{},o=i.getValueAtIndexOrDefault,r=i.getHoverColor,l=t._model;l.backgroundColor=n.hoverBackgroundColor?n.hoverBackgroundColor:o(e.hoverBackgroundColor,a,r(l.backgroundColor)),l.borderColor=n.hoverBorderColor?n.hoverBorderColor:o(e.hoverBorderColor,a,r(l.borderColor)),l.borderWidth=n.hoverBorderWidth?n.hoverBorderWidth:o(e.hoverBorderWidth,a,l.borderWidth)},resyncElements:function(){var t=this,e=t.getMeta(),a=t.getDataset().data,i=e.data.length,n=a.length;i>n?e.data.splice(n,i-n):n>i&&t.insertElements(i,n-i)},insertElements:function(t,e){for(var a=0;e>a;++a)this.addElementAndReset(t+a)},onDataPush:function(){this.insertElements(this.getDataset().data.length-1,arguments.length)},onDataPop:function(){this.getMeta().data.pop()},onDataShift:function(){this.getMeta().data.shift()},onDataSplice:function(t,e){this.getMeta().data.splice(t,e),this.insertElements(t,arguments.length-2)},onDataUnshift:function(){this.insertElements(0,arguments.length)}}),t.DatasetController.extend=i.inherits}},{}],25:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers;t.elements={},t.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(t.Element.prototype,{initialize:function(){this.hidden=!1},pivot:function(){var t=this;return t._view||(t._view=e.clone(t._model)),t._start=e.clone(t._view),t},transition:function(t){var a=this;return a._view||(a._view=e.clone(a._model)),1===t?(a._view=a._model,a._start=null,a):(a._start||a.pivot(),e.each(a._model,function(i,n){if("_"===n[0]);else if(a._view.hasOwnProperty(n))if(i===a._view[n]);else if("string"==typeof i)try{var o=e.color(a._model[n]).mix(e.color(a._start[n]),t);a._view[n]=o.rgbString()}catch(r){a._view[n]=i}else if("number"==typeof i){var l=void 0!==a._start[n]&&isNaN(a._start[n])===!1?a._start[n]:0;a._view[n]=(a._model[n]-l)*t+l}else a._view[n]=i;else"number"!=typeof i||isNaN(a._view[n])?a._view[n]=i:a._view[n]=i*t},a),a)},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),t.Element.extend=e.inherits}},{}],26:[function(t,e,a){"use strict";var i=t(3);e.exports=function(t){function e(t,e,a){var i;return"string"==typeof t?(i=parseInt(t,10),-1!==t.indexOf("%")&&(i=i/100*e.parentNode[a])):i=t,i}function a(t){return void 0!==t&&null!==t&&"none"!==t}function n(t,i,n){var o=document.defaultView,r=t.parentNode,l=o.getComputedStyle(t)[i],s=o.getComputedStyle(r)[i],d=a(l),u=a(s),c=Number.POSITIVE_INFINITY;return d||u?Math.min(d?e(l,t,n):c,u?e(s,r,n):c):"none"}var o=t.helpers={};o.each=function(t,e,a,i){var n,r;if(o.isArray(t))if(r=t.length,i)for(n=r-1;n>=0;n--)e.call(a,t[n],n);else for(n=0;r>n;n++)e.call(a,t[n],n);else if("object"==typeof t){var l=Object.keys(t);for(r=l.length,n=0;r>n;n++)e.call(a,t[l[n]],l[n])}},o.clone=function(t){var e={};return o.each(t,function(t,a){o.isArray(t)?e[a]=t.slice(0):"object"==typeof t&&null!==t?e[a]=o.clone(t):e[a]=t}),e},o.extend=function(t){for(var e=function(e,a){t[a]=e},a=1,i=arguments.length;i>a;a++)o.each(arguments[a],e);return t},o.configMerge=function(e){var a=o.clone(e);return o.each(Array.prototype.slice.call(arguments,1),function(e){o.each(e,function(e,i){var n=a.hasOwnProperty(i),r=n?a[i]:{};"scales"===i?a[i]=o.scaleMerge(r,e):"scale"===i?a[i]=o.configMerge(r,t.scaleService.getScaleDefaults(e.type),e):!n||"object"!=typeof r||o.isArray(r)||null===r||"object"!=typeof e||o.isArray(e)?a[i]=e:a[i]=o.configMerge(r,e)})}),a},o.scaleMerge=function(e,a){var i=o.clone(e);return o.each(a,function(e,a){"xAxes"===a||"yAxes"===a?i.hasOwnProperty(a)?o.each(e,function(e,n){var r=o.getValueOrDefault(e.type,"xAxes"===a?"category":"linear"),l=t.scaleService.getScaleDefaults(r);n>=i[a].length||!i[a][n].type?i[a].push(o.configMerge(l,e)):e.type&&e.type!==i[a][n].type?i[a][n]=o.configMerge(i[a][n],l,e):i[a][n]=o.configMerge(i[a][n],e)}):(i[a]=[],o.each(e,function(e){var n=o.getValueOrDefault(e.type,"xAxes"===a?"category":"linear");i[a].push(o.configMerge(t.scaleService.getScaleDefaults(n),e))})):i.hasOwnProperty(a)&&"object"==typeof i[a]&&null!==i[a]&&"object"==typeof e?i[a]=o.configMerge(i[a],e):i[a]=e}),i},o.getValueAtIndexOrDefault=function(t,e,a){return void 0===t||null===t?a:o.isArray(t)?e<t.length?t[e]:a:t},o.getValueOrDefault=function(t,e){return void 0===t?e:t},o.indexOf=Array.prototype.indexOf?function(t,e){return t.indexOf(e)}:function(t,e){for(var a=0,i=t.length;i>a;++a)if(t[a]===e)return a;return-1},o.where=function(t,e){if(o.isArray(t)&&Array.prototype.filter)return t.filter(e);var a=[];return o.each(t,function(t){e(t)&&a.push(t)}),a},o.findIndex=Array.prototype.findIndex?function(t,e,a){return t.findIndex(e,a)}:function(t,e,a){a=void 0===a?t:a;for(var i=0,n=t.length;n>i;++i)if(e.call(a,t[i],i,t))return i;return-1},o.findNextWhere=function(t,e,a){(void 0===a||null===a)&&(a=-1);for(var i=a+1;i<t.length;i++){var n=t[i];if(e(n))return n}},o.findPreviousWhere=function(t,e,a){(void 0===a||null===a)&&(a=t.length);for(var i=a-1;i>=0;i--){var n=t[i];if(e(n))return n}},o.inherits=function(t){var e=this,a=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},i=function(){this.constructor=a};return i.prototype=e.prototype,a.prototype=new i,a.extend=o.inherits,t&&o.extend(a.prototype,t),a.__super__=e.prototype,a},o.noop=function(){},o.uid=function(){var t=0;return function(){return t++}}(),o.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},o.almostEquals=function(t,e,a){return Math.abs(t-e)<a},o.max=function(t){return t.reduce(function(t,e){return isNaN(e)?t:Math.max(t,e)},Number.NEGATIVE_INFINITY)},o.min=function(t){return t.reduce(function(t,e){return isNaN(e)?t:Math.min(t,e)},Number.POSITIVE_INFINITY)},o.sign=Math.sign?function(t){return Math.sign(t)}:function(t){return t=+t,0===t||isNaN(t)?t:t>0?1:-1},o.log10=Math.log10?function(t){return Math.log10(t)}:function(t){return Math.log(t)/Math.LN10},o.toRadians=function(t){return t*(Math.PI/180)},o.toDegrees=function(t){return t*(180/Math.PI)},o.getAngleFromPoint=function(t,e){var a=e.x-t.x,i=e.y-t.y,n=Math.sqrt(a*a+i*i),o=Math.atan2(i,a);return o<-.5*Math.PI&&(o+=2*Math.PI),{angle:o,distance:n}},o.distanceBetweenPoints=function(t,e){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))},o.aliasPixel=function(t){return t%2===0?0:.5},o.splineCurve=function(t,e,a,i){var n=t.skip?e:t,o=e,r=a.skip?e:a,l=Math.sqrt(Math.pow(o.x-n.x,2)+Math.pow(o.y-n.y,2)),s=Math.sqrt(Math.pow(r.x-o.x,2)+Math.pow(r.y-o.y,2)),d=l/(l+s),u=s/(l+s);d=isNaN(d)?0:d,u=isNaN(u)?0:u;var c=i*d,h=i*u;return{previous:{x:o.x-c*(r.x-n.x),y:o.y-c*(r.y-n.y)},next:{x:o.x+h*(r.x-n.x),y:o.y+h*(r.y-n.y)}}},o.EPSILON=Number.EPSILON||1e-14,o.splineCurveMonotone=function(t){var e,a,i,n,r=(t||[]).map(function(t){return{model:t._model,deltaK:0,mK:0}}),l=r.length;for(e=0;l>e;++e)i=r[e],i.model.skip||(a=e>0?r[e-1]:null,n=l-1>e?r[e+1]:null,n&&!n.model.skip&&(i.deltaK=(n.model.y-i.model.y)/(n.model.x-i.model.x)),!a||a.model.skip?i.mK=i.deltaK:!n||n.model.skip?i.mK=a.deltaK:this.sign(a.deltaK)!==this.sign(i.deltaK)?i.mK=0:i.mK=(a.deltaK+i.deltaK)/2);var s,d,u,c;for(e=0;l-1>e;++e)i=r[e],n=r[e+1],i.model.skip||n.model.skip||(o.almostEquals(i.deltaK,0,this.EPSILON)?i.mK=n.mK=0:(s=i.mK/i.deltaK,d=n.mK/i.deltaK,c=Math.pow(s,2)+Math.pow(d,2),9>=c||(u=3/Math.sqrt(c),i.mK=s*u*i.deltaK,n.mK=d*u*i.deltaK)));var h;for(e=0;l>e;++e)i=r[e],i.model.skip||(a=e>0?r[e-1]:null,n=l-1>e?r[e+1]:null,a&&!a.model.skip&&(h=(i.model.x-a.model.x)/3,i.model.controlPointPreviousX=i.model.x-h,i.model.controlPointPreviousY=i.model.y-h*i.mK),n&&!n.model.skip&&(h=(n.model.x-i.model.x)/3,i.model.controlPointNextX=i.model.x+h,i.model.controlPointNextY=i.model.y+h*i.mK))},o.nextItem=function(t,e,a){return a?e>=t.length-1?t[0]:t[e+1]:e>=t.length-1?t[t.length-1]:t[e+1]},o.previousItem=function(t,e,a){return a?0>=e?t[t.length-1]:t[e-1]:0>=e?t[0]:t[e-1]},o.niceNum=function(t,e){var a,i=Math.floor(o.log10(t)),n=t/Math.pow(10,i);return a=e?1.5>n?1:3>n?2:7>n?5:10:1>=n?1:2>=n?2:5>=n?5:10,a*Math.pow(10,i)};var r=o.easingEffects={linear:function(t){return t},easeInQuad:function(t){return t*t},easeOutQuad:function(t){return-1*t*(t-2)},easeInOutQuad:function(t){return(t/=.5)<1?.5*t*t:-0.5*(--t*(t-2)-1)},easeInCubic:function(t){return t*t*t},easeOutCubic:function(t){return 1*((t=t/1-1)*t*t+1)},easeInOutCubic:function(t){return(t/=.5)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},easeInQuart:function(t){return t*t*t*t},easeOutQuart:function(t){return-1*((t=t/1-1)*t*t*t-1)},easeInOutQuart:function(t){return(t/=.5)<1?.5*t*t*t*t:-0.5*((t-=2)*t*t*t-2)},easeInQuint:function(t){return 1*(t/=1)*t*t*t*t},easeOutQuint:function(t){return 1*((t=t/1-1)*t*t*t*t+1)},easeInOutQuint:function(t){return(t/=.5)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)},easeInSine:function(t){return-1*Math.cos(t/1*(Math.PI/2))+1},easeOutSine:function(t){return 1*Math.sin(t/1*(Math.PI/2))},easeInOutSine:function(t){return-0.5*(Math.cos(Math.PI*t/1)-1)},easeInExpo:function(t){return 0===t?1:1*Math.pow(2,10*(t/1-1))},easeOutExpo:function(t){return 1===t?1:1*(-Math.pow(2,-10*t/1)+1)},easeInOutExpo:function(t){return 0===t?0:1===t?1:(t/=.5)<1?.5*Math.pow(2,10*(t-1)):.5*(-Math.pow(2,-10*--t)+2)},easeInCirc:function(t){return t>=1?t:-1*(Math.sqrt(1-(t/=1)*t)-1)},easeOutCirc:function(t){return 1*Math.sqrt(1-(t=t/1-1)*t)},easeInOutCirc:function(t){return(t/=.5)<1?-0.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},easeInElastic:function(t){var e=1.70158,a=0,i=1;return 0===t?0:1===(t/=1)?1:(a||(a=.3),i<Math.abs(1)?(i=1,e=a/4):e=a/(2*Math.PI)*Math.asin(1/i),-(i*Math.pow(2,10*(t-=1))*Math.sin((1*t-e)*(2*Math.PI)/a)))},easeOutElastic:function(t){var e=1.70158,a=0,i=1;return 0===t?0:1===(t/=1)?1:(a||(a=.3),i<Math.abs(1)?(i=1,e=a/4):e=a/(2*Math.PI)*Math.asin(1/i),i*Math.pow(2,-10*t)*Math.sin((1*t-e)*(2*Math.PI)/a)+1)},easeInOutElastic:function(t){var e=1.70158,a=0,i=1;return 0===t?0:2===(t/=.5)?1:(a||(a=1*(.3*1.5)),i<Math.abs(1)?(i=1,e=a/4):e=a/(2*Math.PI)*Math.asin(1/i),1>t?-.5*(i*Math.pow(2,10*(t-=1))*Math.sin((1*t-e)*(2*Math.PI)/a)):i*Math.pow(2,-10*(t-=1))*Math.sin((1*t-e)*(2*Math.PI)/a)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*(t*t*(((e*=1.525)+1)*t-e)):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-r.easeOutBounce(1-t)},easeOutBounce:function(t){return(t/=1)<1/2.75?1*(7.5625*t*t):2/2.75>t?1*(7.5625*(t-=1.5/2.75)*t+.75):2.5/2.75>t?1*(7.5625*(t-=2.25/2.75)*t+.9375):1*(7.5625*(t-=2.625/2.75)*t+.984375)},easeInOutBounce:function(t){return.5>t?.5*r.easeInBounce(2*t):.5*r.easeOutBounce(2*t-1)+.5}};o.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),o.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),o.getRelativePosition=function(t,e){var a,i,n=t.originalEvent||t,r=t.currentTarget||t.srcElement,l=r.getBoundingClientRect(),s=n.touches;s&&s.length>0?(a=s[0].clientX,i=s[0].clientY):(a=n.clientX,i=n.clientY);var d=parseFloat(o.getStyle(r,"padding-left")),u=parseFloat(o.getStyle(r,"padding-top")),c=parseFloat(o.getStyle(r,"padding-right")),h=parseFloat(o.getStyle(r,"padding-bottom")),f=l.right-l.left-d-c,g=l.bottom-l.top-u-h;return a=Math.round((a-l.left-d)/f*r.width/e.currentDevicePixelRatio),i=Math.round((i-l.top-u)/g*r.height/e.currentDevicePixelRatio),{x:a,y:i}},o.addEvent=function(t,e,a){t.addEventListener?t.addEventListener(e,a):t.attachEvent?t.attachEvent("on"+e,a):t["on"+e]=a},o.removeEvent=function(t,e,a){t.removeEventListener?t.removeEventListener(e,a,!1):t.detachEvent?t.detachEvent("on"+e,a):t["on"+e]=o.noop},o.bindEvents=function(t,e,a){var i=t.events=t.events||{};o.each(e,function(e){i[e]=function(){a.apply(t,arguments)},o.addEvent(t.chart.canvas,e,i[e])})},o.unbindEvents=function(t,e){var a=t.chart.canvas;o.each(e,function(t,e){o.removeEvent(a,e,t)})},o.getConstraintWidth=function(t){return n(t,"max-width","clientWidth")},o.getConstraintHeight=function(t){return n(t,"max-height","clientHeight")},o.getMaximumWidth=function(t){var e=t.parentNode,a=parseInt(o.getStyle(e,"padding-left"),10),i=parseInt(o.getStyle(e,"padding-right"),10),n=e.clientWidth-a-i,r=o.getConstraintWidth(t);return isNaN(r)?n:Math.min(n,r)},o.getMaximumHeight=function(t){var e=t.parentNode,a=parseInt(o.getStyle(e,"padding-top"),10),i=parseInt(o.getStyle(e,"padding-bottom"),10),n=e.clientHeight-a-i,r=o.getConstraintHeight(t);return isNaN(r)?n:Math.min(n,r)},o.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)},o.retinaScale=function(t){var e=t.currentDevicePixelRatio=window.devicePixelRatio||1;if(1!==e){var a=t.canvas,i=t.height,n=t.width;a.height=i*e,a.width=n*e,t.ctx.scale(e,e),a.style.height=i+"px",a.style.width=n+"px"}},o.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},o.fontString=function(t,e,a){return e+" "+t+"px "+a},o.longestText=function(t,e,a,i){i=i||{};var n=i.data=i.data||{},r=i.garbageCollect=i.garbageCollect||[];i.font!==e&&(n=i.data={},r=i.garbageCollect=[],i.font=e),t.font=e;var l=0;o.each(a,function(e){void 0!==e&&null!==e&&o.isArray(e)!==!0?l=o.measureText(t,n,r,l,e):o.isArray(e)&&o.each(e,function(e){void 0===e||null===e||o.isArray(e)||(l=o.measureText(t,n,r,l,e))})});var s=r.length/2;if(s>a.length){for(var d=0;s>d;d++)delete n[r[d]];r.splice(0,s)}return l},o.measureText=function(t,e,a,i,n){var o=e[n];return o||(o=e[n]=t.measureText(n).width,a.push(n)),o>i&&(i=o),i},o.numberOfLabelLines=function(t){var e=1;return o.each(t,function(t){o.isArray(t)&&t.length>e&&(e=t.length)}),e},o.drawRoundedRectangle=function(t,e,a,i,n,o){t.beginPath(),t.moveTo(e+o,a),t.lineTo(e+i-o,a),t.quadraticCurveTo(e+i,a,e+i,a+o),t.lineTo(e+i,a+n-o),t.quadraticCurveTo(e+i,a+n,e+i-o,a+n),t.lineTo(e+o,a+n),t.quadraticCurveTo(e,a+n,e,a+n-o),t.lineTo(e,a+o),t.quadraticCurveTo(e,a,e+o,a),t.closePath()},o.color=function(e){return i?i(e instanceof CanvasGradient?t.defaults.global.defaultColor:e):(console.error("Color.js not found!"),e)},o.addResizeListener=function(t,e){var a=document.createElement("iframe");a.className="chartjs-hidden-iframe",a.style.cssText="display:block;overflow:hidden;border:0;margin:0;top:0;left:0;bottom:0;right:0;height:100%;width:100%;position:absolute;pointer-events:none;z-index:-1;",a.tabIndex=-1;var i=t._chartjs={resizer:a,ticking:!1},n=function(){i.ticking||(i.ticking=!0,o.requestAnimFrame.call(window,function(){return i.resizer?(i.ticking=!1,e()):void 0}))};o.addEvent(a,"load",function(){o.addEvent(a.contentWindow||a,"resize",n),n()}),t.insertBefore(a,t.firstChild)},o.removeResizeListener=function(t){if(t&&t._chartjs){var e=t._chartjs.resizer;e&&(e.parentNode.removeChild(e),t._chartjs.resizer=null),delete t._chartjs}},o.isArray=Array.isArray?function(t){return Array.isArray(t)}:function(t){return"[object Array]"===Object.prototype.toString.call(t)},o.arrayEquals=function(t,e){var a,i,n,r;if(!t||!e||t.length!==e.length)return!1;for(a=0,i=t.length;i>a;++a)if(n=t[a],r=e[a],n instanceof Array&&r instanceof Array){if(!o.arrayEquals(n,r))return!1}else if(n!==r)return!1;return!0},o.callCallback=function(t,e,a){t&&"function"==typeof t.call&&t.apply(a,e)},o.getHoverColor=function(t){return t instanceof CanvasPattern?t:o.color(t).saturate(.5).darken(.1).rgbString()}}},{3:3}],27:[function(t,e,a){"use strict";e.exports=function(t){function e(t,e){var a,i,n,o,r,l=t.data.datasets;for(i=0,o=l.length;o>i;++i)if(t.isDatasetVisible(i))for(a=t.getDatasetMeta(i),n=0,r=a.data.length;r>n;++n){var s=a.data[n];s._view.skip||e(s)}}function a(t,a){var i=[];return e(t,function(t){t.inRange(a.x,a.y)&&i.push(t)}),i}function i(t,a,i,n){var r=Number.POSITIVE_INFINITY,l=[];return n||(n=o.distanceBetweenPoints),e(t,function(t){if(!i||t.inRange(a.x,a.y)){var e=t.getCenterPoint(),o=n(a,e);r>o?(l=[t],r=o):o===r&&l.push(t)}}),l}function n(t,e,n){var r=o.getRelativePosition(e,t.chart),l=function(t,e){return Math.abs(t.x-e.x)},s=n.intersect?a(t,r):i(t,r,!1,l),d=[];return s.length?(t.data.datasets.forEach(function(e,a){if(t.isDatasetVisible(a)){var i=t.getDatasetMeta(a),n=i.data[s[0]._index];n&&!n._view.skip&&d.push(n)}}),d):[]}var o=t.helpers;t.Interaction={modes:{single:function(t,a){var i=o.getRelativePosition(a,t.chart),n=[];return e(t,function(t){return t.inRange(i.x,i.y)?(n.push(t),n):void 0}),n.slice(0,1)},label:n,index:n,dataset:function(t,e,n){var r=o.getRelativePosition(e,t.chart),l=n.intersect?a(t,r):i(t,r,!1);return l.length>0&&(l=t.getDatasetMeta(l[0]._datasetIndex).data),l},"x-axis":function(t,e){return n(t,e,!0)},point:function(t,e){var i=o.getRelativePosition(e,t.chart);return a(t,i)},nearest:function(t,e,a){var n=o.getRelativePosition(e,t.chart),r=i(t,n,a.intersect);return r.length>1&&r.sort(function(t,e){var a=t.getArea(),i=e.getArea(),n=a-i;return 0===n&&(n=t._datasetIndex-e._datasetIndex),n}),r.slice(0,1)},x:function(t,a,i){var n=o.getRelativePosition(a,t.chart),r=[],l=!1;return e(t,function(t){t.inXRange(n.x)&&r.push(t),t.inRange(n.x,n.y)&&(l=!0)}),i.intersect&&!l&&(r=[]),r},y:function(t,a,i){var n=o.getRelativePosition(a,t.chart),r=[],l=!1;return e(t,function(t){t.inYRange(n.y)&&r.push(t),t.inRange(n.x,n.y)&&(l=!0)}),i.intersect&&!l&&(r=[]),r}}}}},{}],28:[function(t,e,a){"use strict";e.exports=function(){var t=function(e,a){return this.controller=new t.Controller(e,a,this),this.controller};return t.defaults={global:{responsive:!0,responsiveAnimationDuration:0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove"],hover:{onHover:null,mode:"nearest",intersect:!0,animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",defaultFontColor:"#666",defaultFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",defaultFontSize:12,defaultFontStyle:"normal",showLines:!0,elements:{},legendCallback:function(t){var e=[];e.push('<ul class="'+t.id+'-legend">');for(var a=0;a<t.data.datasets.length;a++)e.push('<li><span style="background-color:'+t.data.datasets[a].backgroundColor+'"></span>'),t.data.datasets[a].label&&e.push(t.data.datasets[a].label),e.push("</li>");return e.push("</ul>"),e.join("")}}},t.Chart=t,t}},{}],29:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers;t.layoutService={defaults:{},addBox:function(t,e){t.boxes||(t.boxes=[]),t.boxes.push(e)},removeBox:function(t,e){t.boxes&&t.boxes.splice(t.boxes.indexOf(e),1)},update:function(t,a,i){function n(t){var e,a=t.isHorizontal();a?(e=t.update(t.options.fullWidth?x:C,M),D-=e.height):(e=t.update(w,S),C-=e.width),I.push({horizontal:a,minSize:e,box:t})}function o(t){var a=e.findNextWhere(I,function(e){return e.box===t});if(a)if(t.isHorizontal()){var i={left:A,right:T,top:0,bottom:0};t.update(t.options.fullWidth?x:C,y/2,i)}else t.update(a.minSize.width,D)}function r(t){var a=e.findNextWhere(I,function(e){return e.box===t}),i={left:0,right:0,top:P,bottom:F};a&&t.update(a.minSize.width,D,i)}function l(t){t.isHorizontal()?(t.left=t.options.fullWidth?u:A,t.right=t.options.fullWidth?a-c:A+C,t.top=L,t.bottom=L+t.height,L=t.bottom):(t.left=V,t.right=V+t.width,t.top=P,t.bottom=P+D,V=t.right)}if(t){var s=t.options.layout,d=s?s.padding:null,u=0,c=0,h=0,f=0;isNaN(d)?(u=d.left||0,c=d.right||0,h=d.top||0,f=d.bottom||0):(u=d,c=d,h=d,f=d);var g=e.where(t.boxes,function(t){return"left"===t.options.position}),p=e.where(t.boxes,function(t){return"right"===t.options.position}),m=e.where(t.boxes,function(t){return"top"===t.options.position}),b=e.where(t.boxes,function(t){return"bottom"===t.options.position}),v=e.where(t.boxes,function(t){return"chartArea"===t.options.position});m.sort(function(t,e){return(e.options.fullWidth?1:0)-(t.options.fullWidth?1:0)}),b.sort(function(t,e){return(t.options.fullWidth?1:0)-(e.options.fullWidth?1:0)});var x=a-u-c,y=i-h-f,k=x/2,S=y/2,w=(a-k)/(g.length+p.length),M=(i-S)/(m.length+b.length),C=x,D=y,I=[];e.each(g.concat(p,m,b),n);var A=u,T=c,P=h,F=f;e.each(g.concat(p),o),e.each(g,function(t){A+=t.width}),e.each(p,function(t){T+=t.width}),e.each(m.concat(b),o),e.each(m,function(t){P+=t.height}),e.each(b,function(t){F+=t.height}),e.each(g.concat(p),r),A=u,T=c,P=h,F=f,e.each(g,function(t){A+=t.width}),e.each(p,function(t){T+=t.width}),e.each(m,function(t){P+=t.height}),e.each(b,function(t){F+=t.height});var _=i-P-F,R=a-A-T;(R!==C||_!==D)&&(e.each(g,function(t){t.height=_}),e.each(p,function(t){t.height=_}),e.each(m,function(t){t.options.fullWidth||(t.width=R)}),e.each(b,function(t){t.options.fullWidth||(t.width=R)}),D=_,C=R);var V=u,L=h;e.each(g.concat(m),l),V+=C,L+=D,e.each(p,l),e.each(b,l),t.chartArea={left:A,top:P,right:A+C,bottom:P+D},e.each(v,function(e){e.left=t.chartArea.left,e.top=t.chartArea.top,e.right=t.chartArea.right,e.bottom=t.chartArea.bottom,e.update(C,D)})}}}}},{}],30:[function(t,e,a){"use strict";e.exports=function(t){function e(t,e){return t.usePointStyle?e*Math.SQRT2:t.boxWidth}var a=t.helpers,i=a.noop;t.defaults.global.legend={display:!0,position:"top",fullWidth:!0,reverse:!1,onClick:function(t,e){var a=e.datasetIndex,i=this.chart,n=i.getDatasetMeta(a);n.hidden=null===n.hidden?!i.data.datasets[a].hidden:null,i.update()},onHover:null,labels:{boxWidth:40,padding:10,generateLabels:function(t){var e=t.data;return a.isArray(e.datasets)?e.datasets.map(function(e,i){return{text:e.label,fillStyle:a.isArray(e.backgroundColor)?e.backgroundColor[0]:e.backgroundColor,hidden:!t.isDatasetVisible(i),lineCap:e.borderCapStyle,lineDash:e.borderDash,lineDashOffset:e.borderDashOffset,lineJoin:e.borderJoinStyle,lineWidth:e.borderWidth,strokeStyle:e.borderColor,pointStyle:e.pointStyle,datasetIndex:i}},this):[]}}},t.Legend=t.Element.extend({initialize:function(t){a.extend(this,t),this.legendHitBoxes=[],this.doughnutMode=!1},beforeUpdate:i,update:function(t,e,a){var i=this;return i.beforeUpdate(),i.maxWidth=t,i.maxHeight=e,i.margins=a,i.beforeSetDimensions(),i.setDimensions(),i.afterSetDimensions(),i.beforeBuildLabels(),i.buildLabels(),i.afterBuildLabels(),i.beforeFit(),i.fit(),i.afterFit(),i.afterUpdate(),i.minSize},afterUpdate:i,beforeSetDimensions:i,setDimensions:function(){var t=this;t.isHorizontal()?(t.width=t.maxWidth,t.left=0,t.right=t.width):(t.height=t.maxHeight,t.top=0,t.bottom=t.height),t.paddingLeft=0,t.paddingTop=0,t.paddingRight=0,t.paddingBottom=0,t.minSize={width:0,height:0}},afterSetDimensions:i,beforeBuildLabels:i,buildLabels:function(){var t=this;t.legendItems=t.options.labels.generateLabels.call(t,t.chart),t.options.reverse&&t.legendItems.reverse()},afterBuildLabels:i,beforeFit:i,fit:function(){var i=this,n=i.options,o=n.labels,r=n.display,l=i.ctx,s=t.defaults.global,d=a.getValueOrDefault,u=d(o.fontSize,s.defaultFontSize),c=d(o.fontStyle,s.defaultFontStyle),h=d(o.fontFamily,s.defaultFontFamily),f=a.fontString(u,c,h),g=i.legendHitBoxes=[],p=i.minSize,m=i.isHorizontal();if(m?(p.width=i.maxWidth,p.height=r?10:0):(p.width=r?10:0,p.height=i.maxHeight),r)if(l.font=f,m){var b=i.lineWidths=[0],v=i.legendItems.length?u+o.padding:0;l.textAlign="left",l.textBaseline="top",a.each(i.legendItems,function(t,a){var n=e(o,u),r=n+u/2+l.measureText(t.text).width;b[b.length-1]+r+o.padding>=i.width&&(v+=u+o.padding,b[b.length]=i.left),g[a]={left:0,top:0,width:r,height:u},b[b.length-1]+=r+o.padding}),p.height+=v}else{var x=o.padding,y=i.columnWidths=[],k=o.padding,S=0,w=0,M=u+x;a.each(i.legendItems,function(t,a){var i=e(o,u),n=i+u/2+l.measureText(t.text).width;w+M>p.height&&(k+=S+o.padding,y.push(S),S=0,w=0),S=Math.max(S,n),w+=M,g[a]={left:0,top:0,width:n,height:u}}),k+=S,y.push(S),p.width+=k}i.width=p.width,i.height=p.height},afterFit:i,isHorizontal:function(){return"top"===this.options.position||"bottom"===this.options.position},draw:function(){var i=this,n=i.options,o=n.labels,r=t.defaults.global,l=r.elements.line,s=i.width,d=i.lineWidths;if(n.display){var u,c=i.ctx,h=a.getValueOrDefault,f=h(o.fontColor,r.defaultFontColor),g=h(o.fontSize,r.defaultFontSize),p=h(o.fontStyle,r.defaultFontStyle),m=h(o.fontFamily,r.defaultFontFamily),b=a.fontString(g,p,m);c.textAlign="left",c.textBaseline="top",c.lineWidth=.5,c.strokeStyle=f,c.fillStyle=f,c.font=b;var v=e(o,g),x=i.legendHitBoxes,y=function(e,a,i){if(!(isNaN(v)||0>=v)){c.save(),c.fillStyle=h(i.fillStyle,r.defaultColor),c.lineCap=h(i.lineCap,l.borderCapStyle),c.lineDashOffset=h(i.lineDashOffset,l.borderDashOffset),c.lineJoin=h(i.lineJoin,l.borderJoinStyle),c.lineWidth=h(i.lineWidth,l.borderWidth),c.strokeStyle=h(i.strokeStyle,r.defaultColor);var o=0===h(i.lineWidth,l.borderWidth);if(c.setLineDash&&c.setLineDash(h(i.lineDash,l.borderDash)),n.labels&&n.labels.usePointStyle){var s=g*Math.SQRT2/2,d=s/Math.SQRT2,u=e+d,f=a+d;t.canvasHelpers.drawPoint(c,i.pointStyle,s,u,f)}else o||c.strokeRect(e,a,v,g),c.fillRect(e,a,v,g);c.restore()}},k=function(t,e,a,i){c.fillText(a.text,v+g/2+t,e),a.hidden&&(c.beginPath(),c.lineWidth=2,c.moveTo(v+g/2+t,e+g/2),c.lineTo(v+g/2+t+i,e+g/2),c.stroke())},S=i.isHorizontal();u=S?{x:i.left+(s-d[0])/2,y:i.top+o.padding,line:0}:{x:i.left+o.padding,y:i.top+o.padding,line:0};var w=g+o.padding;a.each(i.legendItems,function(t,e){var a=c.measureText(t.text).width,n=v+g/2+a,r=u.x,l=u.y;S?r+n>=s&&(l=u.y+=w,u.line++,r=u.x=i.left+(s-d[u.line])/2):l+w>i.bottom&&(r=u.x=r+i.columnWidths[u.line]+o.padding,l=u.y=i.top,u.line++),y(r,l,t),x[e].left=r,x[e].top=l,k(r,l,t,a),S?u.x+=n+o.padding:u.y+=w})}},handleEvent:function(t){var e=this,i=e.options,n="mouseup"===t.type?"click":t.type,o=!1;if("mousemove"===n){if(!i.onHover)return}else{if("click"!==n)return;if(!i.onClick)return}var r=a.getRelativePosition(t,e.chart.chart),l=r.x,s=r.y;if(l>=e.left&&l<=e.right&&s>=e.top&&s<=e.bottom)for(var d=e.legendHitBoxes,u=0;u<d.length;++u){var c=d[u];if(l>=c.left&&l<=c.left+c.width&&s>=c.top&&s<=c.top+c.height){if("click"===n){i.onClick.call(e,t,e.legendItems[u]),o=!0;break}if("mousemove"===n){i.onHover.call(e,t,e.legendItems[u]),o=!0;break}}}return o}}),t.plugins.register({beforeInit:function(e){var a=e.options,i=a.legend;i&&(e.legend=new t.Legend({ctx:e.chart.ctx,options:i,chart:e}),t.layoutService.addBox(e,e.legend))}})}},{}],31:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers.noop;t.plugins={_plugins:[],register:function(t){var e=this._plugins;[].concat(t).forEach(function(t){-1===e.indexOf(t)&&e.push(t)})},unregister:function(t){var e=this._plugins;[].concat(t).forEach(function(t){var a=e.indexOf(t);-1!==a&&e.splice(a,1)})},clear:function(){this._plugins=[]},count:function(){return this._plugins.length},getAll:function(){return this._plugins},notify:function(t,e){var a,i,n=this._plugins,o=n.length;
13
+ for(a=0;o>a;++a)if(i=n[a],"function"==typeof i[t]&&i[t].apply(i,e||[])===!1)return!1;return!0}},t.PluginBase=t.Element.extend({beforeInit:e,afterInit:e,beforeUpdate:e,afterUpdate:e,beforeDraw:e,afterDraw:e,destroy:e}),t.pluginService=t.plugins}},{}],32:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers;t.defaults.scale={display:!0,position:"left",gridLines:{display:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawBorder:!0,drawOnChartArea:!0,drawTicks:!0,tickMarkLength:10,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)",offsetGridLines:!1,borderDash:[],borderDashOffset:0},scaleLabel:{labelString:"",display:!1},ticks:{beginAtZero:!1,minRotation:0,maxRotation:50,mirror:!1,padding:10,reverse:!1,display:!0,autoSkip:!0,autoSkipPadding:0,labelOffset:0,callback:t.Ticks.formatters.values}},t.Scale=t.Element.extend({beforeUpdate:function(){e.callCallback(this.options.beforeUpdate,[this])},update:function(t,a,i){var n=this;return n.beforeUpdate(),n.maxWidth=t,n.maxHeight=a,n.margins=e.extend({left:0,right:0,top:0,bottom:0},i),n.beforeSetDimensions(),n.setDimensions(),n.afterSetDimensions(),n.beforeDataLimits(),n.determineDataLimits(),n.afterDataLimits(),n.beforeBuildTicks(),n.buildTicks(),n.afterBuildTicks(),n.beforeTickToLabelConversion(),n.convertTicksToLabels(),n.afterTickToLabelConversion(),n.beforeCalculateTickRotation(),n.calculateTickRotation(),n.afterCalculateTickRotation(),n.beforeFit(),n.fit(),n.afterFit(),n.afterUpdate(),n.minSize},afterUpdate:function(){e.callCallback(this.options.afterUpdate,[this])},beforeSetDimensions:function(){e.callCallback(this.options.beforeSetDimensions,[this])},setDimensions:function(){var t=this;t.isHorizontal()?(t.width=t.maxWidth,t.left=0,t.right=t.width):(t.height=t.maxHeight,t.top=0,t.bottom=t.height),t.paddingLeft=0,t.paddingTop=0,t.paddingRight=0,t.paddingBottom=0},afterSetDimensions:function(){e.callCallback(this.options.afterSetDimensions,[this])},beforeDataLimits:function(){e.callCallback(this.options.beforeDataLimits,[this])},determineDataLimits:e.noop,afterDataLimits:function(){e.callCallback(this.options.afterDataLimits,[this])},beforeBuildTicks:function(){e.callCallback(this.options.beforeBuildTicks,[this])},buildTicks:e.noop,afterBuildTicks:function(){e.callCallback(this.options.afterBuildTicks,[this])},beforeTickToLabelConversion:function(){e.callCallback(this.options.beforeTickToLabelConversion,[this])},convertTicksToLabels:function(){var t=this,e=t.options.ticks;t.ticks=t.ticks.map(e.userCallback||e.callback)},afterTickToLabelConversion:function(){e.callCallback(this.options.afterTickToLabelConversion,[this])},beforeCalculateTickRotation:function(){e.callCallback(this.options.beforeCalculateTickRotation,[this])},calculateTickRotation:function(){var a=this,i=a.ctx,n=t.defaults.global,o=a.options.ticks,r=e.getValueOrDefault(o.fontSize,n.defaultFontSize),l=e.getValueOrDefault(o.fontStyle,n.defaultFontStyle),s=e.getValueOrDefault(o.fontFamily,n.defaultFontFamily),d=e.fontString(r,l,s);i.font=d;var u,c=i.measureText(a.ticks[0]).width,h=i.measureText(a.ticks[a.ticks.length-1]).width;if(a.labelRotation=o.minRotation||0,a.paddingRight=0,a.paddingLeft=0,a.options.display&&a.isHorizontal()){a.paddingRight=h/2+3,a.paddingLeft=c/2+3,a.longestTextCache||(a.longestTextCache={});for(var f,g,p=e.longestText(i,d,a.ticks,a.longestTextCache),m=p,b=a.getPixelForTick(1)-a.getPixelForTick(0)-6;m>b&&a.labelRotation<o.maxRotation;){if(f=Math.cos(e.toRadians(a.labelRotation)),g=Math.sin(e.toRadians(a.labelRotation)),u=f*c,u+r/2>a.yLabelWidth&&(a.paddingLeft=u+r/2),a.paddingRight=r/2,g*p>a.maxHeight){a.labelRotation--;break}a.labelRotation++,m=f*p}}a.margins&&(a.paddingLeft=Math.max(a.paddingLeft-a.margins.left,0),a.paddingRight=Math.max(a.paddingRight-a.margins.right,0))},afterCalculateTickRotation:function(){e.callCallback(this.options.afterCalculateTickRotation,[this])},beforeFit:function(){e.callCallback(this.options.beforeFit,[this])},fit:function(){var a=this,i=a.minSize={width:0,height:0},n=a.options,o=t.defaults.global,r=n.ticks,l=n.scaleLabel,s=n.gridLines,d=n.display,u=a.isHorizontal(),c=e.getValueOrDefault(r.fontSize,o.defaultFontSize),h=e.getValueOrDefault(r.fontStyle,o.defaultFontStyle),f=e.getValueOrDefault(r.fontFamily,o.defaultFontFamily),g=e.fontString(c,h,f),p=e.getValueOrDefault(l.fontSize,o.defaultFontSize),m=n.gridLines.tickMarkLength;if(u?i.width=a.isFullWidth()?a.maxWidth-a.margins.left-a.margins.right:a.maxWidth:i.width=d&&s.drawTicks?m:0,u?i.height=d&&s.drawTicks?m:0:i.height=a.maxHeight,l.display&&d&&(u?i.height+=1.5*p:i.width+=1.5*p),r.display&&d){a.longestTextCache||(a.longestTextCache={});var b=e.longestText(a.ctx,g,a.ticks,a.longestTextCache),v=e.numberOfLabelLines(a.ticks),x=.5*c;if(u){a.longestLabelWidth=b;var y=Math.sin(e.toRadians(a.labelRotation))*a.longestLabelWidth+c*v+x*v;i.height=Math.min(a.maxHeight,i.height+y),a.ctx.font=g;var k=a.ctx.measureText(a.ticks[0]).width,S=a.ctx.measureText(a.ticks[a.ticks.length-1]).width,w=Math.cos(e.toRadians(a.labelRotation)),M=Math.sin(e.toRadians(a.labelRotation));a.paddingLeft=0!==a.labelRotation?w*k+3:k/2+3,a.paddingRight=0!==a.labelRotation?M*(c/2)+3:S/2+3}else{var C=a.maxWidth-i.width,D=r.mirror;D?b=0:b+=a.options.ticks.padding,C>b?i.width+=b:i.width=a.maxWidth,a.paddingTop=c/2,a.paddingBottom=c/2}}a.margins&&(a.paddingLeft=Math.max(a.paddingLeft-a.margins.left,0),a.paddingTop=Math.max(a.paddingTop-a.margins.top,0),a.paddingRight=Math.max(a.paddingRight-a.margins.right,0),a.paddingBottom=Math.max(a.paddingBottom-a.margins.bottom,0)),a.width=i.width,a.height=i.height},afterFit:function(){e.callCallback(this.options.afterFit,[this])},isHorizontal:function(){return"top"===this.options.position||"bottom"===this.options.position},isFullWidth:function(){return this.options.fullWidth},getRightValue:function(t){return null===t||"undefined"==typeof t?NaN:"number"!=typeof t||isFinite(t)?"object"==typeof t?t instanceof Date||t.isValid?t:this.getRightValue(this.isHorizontal()?t.x:t.y):t:NaN},getLabelForIndex:e.noop,getPixelForValue:e.noop,getValueForPixel:e.noop,getPixelForTick:function(t,e){var a=this;if(a.isHorizontal()){var i=a.width-(a.paddingLeft+a.paddingRight),n=i/Math.max(a.ticks.length-(a.options.gridLines.offsetGridLines?0:1),1),o=n*t+a.paddingLeft;e&&(o+=n/2);var r=a.left+Math.round(o);return r+=a.isFullWidth()?a.margins.left:0}var l=a.height-(a.paddingTop+a.paddingBottom);return a.top+t*(l/(a.ticks.length-1))},getPixelForDecimal:function(t){var e=this;if(e.isHorizontal()){var a=e.width-(e.paddingLeft+e.paddingRight),i=a*t+e.paddingLeft,n=e.left+Math.round(i);return n+=e.isFullWidth()?e.margins.left:0}return e.top+t*e.height},getBasePixel:function(){var t=this,e=t.min,a=t.max;return t.getPixelForValue(t.beginAtZero?0:0>e&&0>a?a:e>0&&a>0?e:0)},draw:function(a){var i=this,n=i.options;if(n.display){var o,r,l=i.ctx,s=t.defaults.global,d=n.ticks,u=n.gridLines,c=n.scaleLabel,h=0!==i.labelRotation,f=d.autoSkip,g=i.isHorizontal();d.maxTicksLimit&&(r=d.maxTicksLimit);var p=e.getValueOrDefault(d.fontColor,s.defaultFontColor),m=e.getValueOrDefault(d.fontSize,s.defaultFontSize),b=e.getValueOrDefault(d.fontStyle,s.defaultFontStyle),v=e.getValueOrDefault(d.fontFamily,s.defaultFontFamily),x=e.fontString(m,b,v),y=u.tickMarkLength,k=e.getValueOrDefault(u.borderDash,s.borderDash),S=e.getValueOrDefault(u.borderDashOffset,s.borderDashOffset),w=e.getValueOrDefault(c.fontColor,s.defaultFontColor),M=e.getValueOrDefault(c.fontSize,s.defaultFontSize),C=e.getValueOrDefault(c.fontStyle,s.defaultFontStyle),D=e.getValueOrDefault(c.fontFamily,s.defaultFontFamily),I=e.fontString(M,C,D),A=e.toRadians(i.labelRotation),T=Math.cos(A),P=i.longestLabelWidth*T;l.fillStyle=p;var F=[];if(g){if(o=!1,h&&(P/=2),(P+d.autoSkipPadding)*i.ticks.length>i.width-(i.paddingLeft+i.paddingRight)&&(o=1+Math.floor((P+d.autoSkipPadding)*i.ticks.length/(i.width-(i.paddingLeft+i.paddingRight)))),r&&i.ticks.length>r)for(;!o||i.ticks.length/(o||1)>r;)o||(o=1),o+=1;f||(o=!1)}var _="right"===n.position?i.left:i.right-y,R="right"===n.position?i.left+y:i.right,V="bottom"===n.position?i.top:i.bottom-y,L="bottom"===n.position?i.top+y:i.bottom;if(e.each(i.ticks,function(t,r){if(void 0!==t&&null!==t){var l=i.ticks.length===r+1,s=o>1&&r%o>0||r%o===0&&r+o>=i.ticks.length;if((!s||l)&&void 0!==t&&null!==t){var c,f;r===("undefined"!=typeof i.zeroLineIndex?i.zeroLineIndex:0)?(c=u.zeroLineWidth,f=u.zeroLineColor):(c=e.getValueAtIndexOrDefault(u.lineWidth,r),f=e.getValueAtIndexOrDefault(u.color,r));var p,m,b,v,x,w,M,C,D,I,T="middle",P="middle";if(g){h||(P="top"===n.position?"bottom":"top"),T=h?"right":"center";var O=i.getPixelForTick(r)+e.aliasPixel(c);D=i.getPixelForTick(r,u.offsetGridLines)+d.labelOffset,I=h?i.top+12:"top"===n.position?i.bottom-y:i.top+y,p=b=x=M=O,m=V,v=L,w=a.top,C=a.bottom}else{"left"===n.position?d.mirror?(D=i.right+d.padding,T="left"):(D=i.right-d.padding,T="right"):d.mirror?(D=i.left-d.padding,T="right"):(D=i.left+d.padding,T="left");var B=i.getPixelForTick(r);B+=e.aliasPixel(c),I=i.getPixelForTick(r,u.offsetGridLines),p=_,b=R,x=a.left,M=a.right,m=v=w=C=B}F.push({tx1:p,ty1:m,tx2:b,ty2:v,x1:x,y1:w,x2:M,y2:C,labelX:D,labelY:I,glWidth:c,glColor:f,glBorderDash:k,glBorderDashOffset:S,rotation:-1*A,label:t,textBaseline:P,textAlign:T})}}}),e.each(F,function(t){if(u.display&&(l.save(),l.lineWidth=t.glWidth,l.strokeStyle=t.glColor,l.setLineDash&&(l.setLineDash(t.glBorderDash),l.lineDashOffset=t.glBorderDashOffset),l.beginPath(),u.drawTicks&&(l.moveTo(t.tx1,t.ty1),l.lineTo(t.tx2,t.ty2)),u.drawOnChartArea&&(l.moveTo(t.x1,t.y1),l.lineTo(t.x2,t.y2)),l.stroke(),l.restore()),d.display){l.save(),l.translate(t.labelX,t.labelY),l.rotate(t.rotation),l.font=x,l.textBaseline=t.textBaseline,l.textAlign=t.textAlign;var a=t.label;if(e.isArray(a))for(var i=0,n=-(a.length-1)*m*.75;i<a.length;++i)l.fillText(""+a[i],0,n),n+=1.5*m;else l.fillText(a,0,0);l.restore()}}),c.display){var O,B,W=0;if(g)O=i.left+(i.right-i.left)/2,B="bottom"===n.position?i.bottom-M/2:i.top+M/2;else{var z="left"===n.position;O=z?i.left+M/2:i.right-M/2,B=i.top+(i.bottom-i.top)/2,W=z?-.5*Math.PI:.5*Math.PI}l.save(),l.translate(O,B),l.rotate(W),l.textAlign="center",l.textBaseline="middle",l.fillStyle=w,l.font=I,l.fillText(c.labelString,0,0),l.restore()}if(u.drawBorder){l.lineWidth=e.getValueAtIndexOrDefault(u.lineWidth,0),l.strokeStyle=e.getValueAtIndexOrDefault(u.color,0);var N=i.left,E=i.right,H=i.top,U=i.bottom,j=e.aliasPixel(l.lineWidth);g?(H=U="top"===n.position?i.bottom:i.top,H+=j,U+=j):(N=E="left"===n.position?i.right:i.left,N+=j,E+=j),l.beginPath(),l.moveTo(N,H),l.lineTo(E,U),l.stroke()}}}})}},{}],33:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers;t.scaleService={constructors:{},defaults:{},registerScaleType:function(t,a,i){this.constructors[t]=a,this.defaults[t]=e.clone(i)},getScaleConstructor:function(t){return this.constructors.hasOwnProperty(t)?this.constructors[t]:void 0},getScaleDefaults:function(a){return this.defaults.hasOwnProperty(a)?e.scaleMerge(t.defaults.scale,this.defaults[a]):{}},updateScaleDefaults:function(t,a){var i=this.defaults;i.hasOwnProperty(t)&&(i[t]=e.extend(i[t],a))},addScalesToLayout:function(a){e.each(a.scales,function(e){t.layoutService.addBox(a,e)})}}}},{}],34:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers;t.Ticks={generators:{linear:function(t,a){var i,n=[];if(t.stepSize&&t.stepSize>0)i=t.stepSize;else{var o=e.niceNum(a.max-a.min,!1);i=e.niceNum(o/(t.maxTicks-1),!0)}var r=Math.floor(a.min/i)*i,l=Math.ceil(a.max/i)*i;if(t.min&&t.max&&t.stepSize){var s=(t.max-t.min)%t.stepSize===0;s&&(r=t.min,l=t.max)}var d=(l-r)/i;d=e.almostEquals(d,Math.round(d),i/1e3)?Math.round(d):Math.ceil(d),n.push(void 0!==t.min?t.min:r);for(var u=1;d>u;++u)n.push(r+u*i);return n.push(void 0!==t.max?t.max:l),n},logarithmic:function(t,a){for(var i=[],n=e.getValueOrDefault,o=n(t.min,Math.pow(10,Math.floor(e.log10(a.min))));o<a.max;){i.push(o);var r,l;0===o?(r=Math.floor(e.log10(a.minNotZero)),l=Math.round(a.minNotZero/Math.pow(10,r))):(r=Math.floor(e.log10(o)),l=Math.floor(o/Math.pow(10,r))+1),10===l&&(l=1,++r),o=l*Math.pow(10,r)}var s=n(t.max,o);return i.push(s),i}},formatters:{values:function(t){return e.isArray(t)?t:""+t},linear:function(t,a,i){var n=i.length>3?i[2]-i[1]:i[1]-i[0];Math.abs(n)>1&&t!==Math.floor(t)&&(n=t-Math.floor(t));var o=e.log10(Math.abs(n)),r="";if(0!==t){var l=-1*Math.floor(o);l=Math.max(Math.min(l,20),0),r=t.toFixed(l)}else r="0";return r},logarithmic:function(t,a,i){var n=t/Math.pow(10,Math.floor(e.log10(t)));return 0===t?"0":1===n||2===n||5===n||0===a||a===i.length-1?t.toExponential():""}}}}},{}],35:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers;t.defaults.global.title={display:!1,position:"top",fullWidth:!0,fontStyle:"bold",padding:10,text:""};var a=e.noop;t.Title=t.Element.extend({initialize:function(a){var i=this;e.extend(i,a),i.options=e.configMerge(t.defaults.global.title,a.options),i.legendHitBoxes=[]},beforeUpdate:function(){var a=this.chart.options;a&&a.title&&(this.options=e.configMerge(t.defaults.global.title,a.title))},update:function(t,e,a){var i=this;return i.beforeUpdate(),i.maxWidth=t,i.maxHeight=e,i.margins=a,i.beforeSetDimensions(),i.setDimensions(),i.afterSetDimensions(),i.beforeBuildLabels(),i.buildLabels(),i.afterBuildLabels(),i.beforeFit(),i.fit(),i.afterFit(),i.afterUpdate(),i.minSize},afterUpdate:a,beforeSetDimensions:a,setDimensions:function(){var t=this;t.isHorizontal()?(t.width=t.maxWidth,t.left=0,t.right=t.width):(t.height=t.maxHeight,t.top=0,t.bottom=t.height),t.paddingLeft=0,t.paddingTop=0,t.paddingRight=0,t.paddingBottom=0,t.minSize={width:0,height:0}},afterSetDimensions:a,beforeBuildLabels:a,buildLabels:a,afterBuildLabels:a,beforeFit:a,fit:function(){var a=this,i=e.getValueOrDefault,n=a.options,o=t.defaults.global,r=n.display,l=i(n.fontSize,o.defaultFontSize),s=a.minSize;a.isHorizontal()?(s.width=a.maxWidth,s.height=r?l+2*n.padding:0):(s.width=r?l+2*n.padding:0,s.height=a.maxHeight),a.width=s.width,a.height=s.height},afterFit:a,isHorizontal:function(){var t=this.options.position;return"top"===t||"bottom"===t},draw:function(){var a=this,i=a.ctx,n=e.getValueOrDefault,o=a.options,r=t.defaults.global;if(o.display){var l,s,d,u=n(o.fontSize,r.defaultFontSize),c=n(o.fontStyle,r.defaultFontStyle),h=n(o.fontFamily,r.defaultFontFamily),f=e.fontString(u,c,h),g=0,p=a.top,m=a.left,b=a.bottom,v=a.right;i.fillStyle=n(o.fontColor,r.defaultFontColor),i.font=f,a.isHorizontal()?(l=m+(v-m)/2,s=p+(b-p)/2,d=v-m):(l="left"===o.position?m+u/2:v-u/2,s=p+(b-p)/2,d=b-p,g=Math.PI*("left"===o.position?-.5:.5)),i.save(),i.translate(l,s),i.rotate(g),i.textAlign="center",i.textBaseline="middle",i.fillText(o.text,0,0,d),i.restore()}}}),t.plugins.register({beforeInit:function(e){var a=e.options,i=a.title;i&&(e.titleBlock=new t.Title({ctx:e.chart.ctx,options:i,chart:e}),t.layoutService.addBox(e,e.titleBlock))}})}},{}],36:[function(t,e,a){"use strict";e.exports=function(t){function e(t,e){var a=s.color(t);return a.alpha(e*a.alpha()).rgbaString()}function a(t,e){return e&&(s.isArray(e)?Array.prototype.push.apply(t,e):t.push(e)),t}function i(t){var e=t._xScale,a=t._yScale||t._scale,i=t._index,n=t._datasetIndex;return{xLabel:e?e.getLabelForIndex(i,n):"",yLabel:a?a.getLabelForIndex(i,n):"",index:i,datasetIndex:n,x:t._model.x,y:t._model.y}}function n(e){var a=t.defaults.global,i=s.getValueOrDefault;return{xPadding:e.xPadding,yPadding:e.yPadding,xAlign:e.xAlign,yAlign:e.yAlign,bodyFontColor:e.bodyFontColor,_bodyFontFamily:i(e.bodyFontFamily,a.defaultFontFamily),_bodyFontStyle:i(e.bodyFontStyle,a.defaultFontStyle),_bodyAlign:e.bodyAlign,bodyFontSize:i(e.bodyFontSize,a.defaultFontSize),bodySpacing:e.bodySpacing,titleFontColor:e.titleFontColor,_titleFontFamily:i(e.titleFontFamily,a.defaultFontFamily),_titleFontStyle:i(e.titleFontStyle,a.defaultFontStyle),titleFontSize:i(e.titleFontSize,a.defaultFontSize),_titleAlign:e.titleAlign,titleSpacing:e.titleSpacing,titleMarginBottom:e.titleMarginBottom,footerFontColor:e.footerFontColor,_footerFontFamily:i(e.footerFontFamily,a.defaultFontFamily),_footerFontStyle:i(e.footerFontStyle,a.defaultFontStyle),footerFontSize:i(e.footerFontSize,a.defaultFontSize),_footerAlign:e.footerAlign,footerSpacing:e.footerSpacing,footerMarginTop:e.footerMarginTop,caretSize:e.caretSize,cornerRadius:e.cornerRadius,backgroundColor:e.backgroundColor,opacity:0,legendColorBackground:e.multiKeyBackground,displayColors:e.displayColors}}function o(t,e){var a=t._chart.ctx,i=2*e.yPadding,n=0,o=e.body,r=o.reduce(function(t,e){return t+e.before.length+e.lines.length+e.after.length},0);r+=e.beforeBody.length+e.afterBody.length;var l=e.title.length,d=e.footer.length,u=e.titleFontSize,c=e.bodyFontSize,h=e.footerFontSize;i+=l*u,i+=l?(l-1)*e.titleSpacing:0,i+=l?e.titleMarginBottom:0,i+=r*c,i+=r?(r-1)*e.bodySpacing:0,i+=d?e.footerMarginTop:0,i+=d*h,i+=d?(d-1)*e.footerSpacing:0;var f=0,g=function(t){n=Math.max(n,a.measureText(t).width+f)};return a.font=s.fontString(u,e._titleFontStyle,e._titleFontFamily),s.each(e.title,g),a.font=s.fontString(c,e._bodyFontStyle,e._bodyFontFamily),s.each(e.beforeBody.concat(e.afterBody),g),f=e.displayColors?c+2:0,s.each(o,function(t){s.each(t.before,g),s.each(t.lines,g),s.each(t.after,g)}),f=0,a.font=s.fontString(h,e._footerFontStyle,e._footerFontFamily),s.each(e.footer,g),n+=2*e.xPadding,{width:n,height:i}}function r(t,e){var a=t._model,i=t._chart,n=t._chartInstance.chartArea,o="center",r="center";a.y<e.height?r="top":a.y>i.height-e.height&&(r="bottom");var l,s,d,u,c,h=(n.left+n.right)/2,f=(n.top+n.bottom)/2;"center"===r?(l=function(t){return h>=t},s=function(t){return t>h}):(l=function(t){return t<=e.width/2},s=function(t){return t>=i.width-e.width/2}),d=function(t){return t+e.width>i.width},u=function(t){return t-e.width<0},c=function(t){return f>=t?"top":"bottom"},l(a.x)?(o="left",d(a.x)&&(o="center",r=c(a.y))):s(a.x)&&(o="right",u(a.x)&&(o="center",r=c(a.y)));var g=t._options;return{xAlign:g.xAlign?g.xAlign:o,yAlign:g.yAlign?g.yAlign:r}}function l(t,e,a){var i=t.x,n=t.y,o=t.caretSize,r=t.caretPadding,l=t.cornerRadius,s=a.xAlign,d=a.yAlign,u=o+r,c=l+r;return"right"===s?i-=e.width:"center"===s&&(i-=e.width/2),"top"===d?n+=u:n-="bottom"===d?e.height+u:e.height/2,"center"===d?"left"===s?i+=u:"right"===s&&(i-=u):"left"===s?i-=c:"right"===s&&(i+=c),{x:i,y:n}}var s=t.helpers;t.defaults.global.tooltips={enabled:!0,custom:null,mode:"nearest",position:"average",intersect:!0,backgroundColor:"rgba(0,0,0,0.8)",titleFontStyle:"bold",titleSpacing:2,titleMarginBottom:6,titleFontColor:"#fff",titleAlign:"left",bodySpacing:2,bodyFontColor:"#fff",bodyAlign:"left",footerFontStyle:"bold",footerSpacing:2,footerMarginTop:6,footerFontColor:"#fff",footerAlign:"left",yPadding:6,xPadding:6,caretSize:5,cornerRadius:6,multiKeyBackground:"#fff",displayColors:!0,callbacks:{beforeTitle:s.noop,title:function(t,e){var a="",i=e.labels,n=i?i.length:0;if(t.length>0){var o=t[0];o.xLabel?a=o.xLabel:n>0&&o.index<n&&(a=i[o.index])}return a},afterTitle:s.noop,beforeBody:s.noop,beforeLabel:s.noop,label:function(t,e){var a=e.datasets[t.datasetIndex].label||"";return a+": "+t.yLabel},labelColor:function(t,e){var a=e.getDatasetMeta(t.datasetIndex),i=a.data[t.index],n=i._view;return{borderColor:n.borderColor,backgroundColor:n.backgroundColor}},afterLabel:s.noop,afterBody:s.noop,beforeFooter:s.noop,footer:s.noop,afterFooter:s.noop}},t.Tooltip=t.Element.extend({initialize:function(){this._model=n(this._options)},getTitle:function(){var t=this,e=t._options,i=e.callbacks,n=i.beforeTitle.apply(t,arguments),o=i.title.apply(t,arguments),r=i.afterTitle.apply(t,arguments),l=[];return l=a(l,n),l=a(l,o),l=a(l,r)},getBeforeBody:function(){var t=this._options.callbacks.beforeBody.apply(this,arguments);return s.isArray(t)?t:void 0!==t?[t]:[]},getBody:function(t,e){var i=this,n=i._options.callbacks,o=[];return s.each(t,function(t){var r={before:[],lines:[],after:[]};a(r.before,n.beforeLabel.call(i,t,e)),a(r.lines,n.label.call(i,t,e)),a(r.after,n.afterLabel.call(i,t,e)),o.push(r)}),o},getAfterBody:function(){var t=this._options.callbacks.afterBody.apply(this,arguments);return s.isArray(t)?t:void 0!==t?[t]:[]},getFooter:function(){var t=this,e=t._options.callbacks,i=e.beforeFooter.apply(t,arguments),n=e.footer.apply(t,arguments),o=e.afterFooter.apply(t,arguments),r=[];return r=a(r,i),r=a(r,n),r=a(r,o)},update:function(e){var a,d,u=this,c=u._options,h=u._model,f=u._model=n(c),g=u._active,p=u._data,m=u._chartInstance,b={xAlign:h.xAlign,yAlign:h.yAlign},v={x:h.x,y:h.y},x={width:h.width,height:h.height},y={x:h.caretX,y:h.caretY};if(g.length){f.opacity=1;var k=[];y=t.Tooltip.positioners[c.position](g,u._eventPosition);var S=[];for(a=0,d=g.length;d>a;++a)S.push(i(g[a]));c.filter&&(S=S.filter(function(t){return c.filter(t,p)})),c.itemSort&&(S=S.sort(function(t,e){return c.itemSort(t,e,p)})),s.each(S,function(t){k.push(c.callbacks.labelColor.call(u,t,m))}),f.title=u.getTitle(S,p),f.beforeBody=u.getBeforeBody(S,p),f.body=u.getBody(S,p),f.afterBody=u.getAfterBody(S,p),f.footer=u.getFooter(S,p),f.x=Math.round(y.x),f.y=Math.round(y.y),f.caretPadding=s.getValueOrDefault(y.padding,2),f.labelColors=k,f.dataPoints=S,x=o(this,f),b=r(this,x),v=l(f,x,b)}else f.opacity=0;return f.xAlign=b.xAlign,f.yAlign=b.yAlign,f.x=v.x,f.y=v.y,f.width=x.width,f.height=x.height,f.caretX=y.x,f.caretY=y.y,u._model=f,e&&c.custom&&c.custom.call(u,f),u},drawCaret:function(t,a,i){var n,o,r,l,s,d,u=this._view,c=this._chart.ctx,h=u.caretSize,f=u.cornerRadius,g=u.xAlign,p=u.yAlign,m=t.x,b=t.y,v=a.width,x=a.height;"center"===p?("left"===g?(n=m,o=n-h,r=n):(n=m+v,o=n+h,r=n),s=b+x/2,l=s-h,d=s+h):("left"===g?(n=m+f,o=n+h,r=o+h):"right"===g?(n=m+v-f,o=n-h,r=o-h):(o=m+v/2,n=o-h,r=o+h),"top"===p?(l=b,s=l-h,d=l):(l=b+x,s=l+h,d=l)),c.fillStyle=e(u.backgroundColor,i),c.beginPath(),c.moveTo(n,l),c.lineTo(o,s),c.lineTo(r,d),c.closePath(),c.fill()},drawTitle:function(t,a,i,n){var o=a.title;if(o.length){i.textAlign=a._titleAlign,i.textBaseline="top";var r=a.titleFontSize,l=a.titleSpacing;i.fillStyle=e(a.titleFontColor,n),i.font=s.fontString(r,a._titleFontStyle,a._titleFontFamily);var d,u;for(d=0,u=o.length;u>d;++d)i.fillText(o[d],t.x,t.y),t.y+=r+l,d+1===o.length&&(t.y+=a.titleMarginBottom-l)}},drawBody:function(t,a,i,n){var o=a.bodyFontSize,r=a.bodySpacing,l=a.body;i.textAlign=a._bodyAlign,i.textBaseline="top";var d=e(a.bodyFontColor,n);i.fillStyle=d,i.font=s.fontString(o,a._bodyFontStyle,a._bodyFontFamily);var u=0,c=function(e){i.fillText(e,t.x+u,t.y),t.y+=o+r};s.each(a.beforeBody,c);var h=a.displayColors;u=h?o+2:0,s.each(l,function(r,l){s.each(r.before,c),s.each(r.lines,function(r){h&&(i.fillStyle=e(a.legendColorBackground,n),i.fillRect(t.x,t.y,o,o),i.strokeStyle=e(a.labelColors[l].borderColor,n),i.strokeRect(t.x,t.y,o,o),i.fillStyle=e(a.labelColors[l].backgroundColor,n),i.fillRect(t.x+1,t.y+1,o-2,o-2),i.fillStyle=d),c(r)}),s.each(r.after,c)}),u=0,s.each(a.afterBody,c),t.y-=r},drawFooter:function(t,a,i,n){var o=a.footer;o.length&&(t.y+=a.footerMarginTop,i.textAlign=a._footerAlign,i.textBaseline="top",i.fillStyle=e(a.footerFontColor,n),i.font=s.fontString(a.footerFontSize,a._footerFontStyle,a._footerFontFamily),s.each(o,function(e){i.fillText(e,t.x,t.y),t.y+=a.footerFontSize+a.footerSpacing}))},drawBackground:function(t,a,i,n,o){i.fillStyle=e(a.backgroundColor,o),s.drawRoundedRectangle(i,t.x,t.y,n.width,n.height,a.cornerRadius),i.fill()},draw:function(){var t=this._chart.ctx,e=this._view;if(0!==e.opacity){var a={width:e.width,height:e.height},i={x:e.x,y:e.y},n=Math.abs(e.opacity<.001)?0:e.opacity;this._options.enabled&&(this.drawBackground(i,e,t,a,n),this.drawCaret(i,a,n),i.x+=e.xPadding,i.y+=e.yPadding,this.drawTitle(i,e,t,n),this.drawBody(i,e,t,n),this.drawFooter(i,e,t,n))}},handleEvent:function(t){var e=this,a=e._options,i=!1;if(e._lastActive=e._lastActive||[],"mouseout"===t.type?e._active=[]:e._active=e._chartInstance.getElementsAtEventForMode(t,a.mode,a),i=!s.arrayEquals(e._active,e._lastActive),e._lastActive=e._active,a.enabled||a.custom){e._eventPosition=s.getRelativePosition(t,e._chart);var n=e._model;e.update(!0),e.pivot(),i|=n.x!==e._model.x||n.y!==e._model.y}return i}}),t.Tooltip.positioners={average:function(t){if(!t.length)return!1;var e,a,i=0,n=0,o=0;for(e=0,a=t.length;a>e;++e){var r=t[e];if(r&&r.hasValue()){var l=r.tooltipPosition();i+=l.x,n+=l.y,++o}}return{x:Math.round(i/o),y:Math.round(n/o)}},nearest:function(t,e){var a,i,n,o=e.x,r=e.y,l=Number.POSITIVE_INFINITY;for(i=0,n=t.length;n>i;++i){var d=t[i];if(d&&d.hasValue()){var u=d.getCenterPoint(),c=s.distanceBetweenPoints(e,u);l>c&&(l=c,a=d)}}if(a){var h=a.tooltipPosition();o=h.x,r=h.y}return{x:o,y:r}}}}},{}],37:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers,a=t.defaults.global;a.elements.arc={backgroundColor:a.defaultColor,borderColor:"#fff",borderWidth:2},t.elements.Arc=t.Element.extend({inLabelRange:function(t){var e=this._view;return e?Math.pow(t-e.x,2)<Math.pow(e.radius+e.hoverRadius,2):!1},inRange:function(t,a){var i=this._view;if(i){for(var n=e.getAngleFromPoint(i,{x:t,y:a}),o=n.angle,r=n.distance,l=i.startAngle,s=i.endAngle;l>s;)s+=2*Math.PI;for(;o>s;)o-=2*Math.PI;for(;l>o;)o+=2*Math.PI;var d=o>=l&&s>=o,u=r>=i.innerRadius&&r<=i.outerRadius;return d&&u}return!1},getCenterPoint:function(){var t=this._view,e=(t.startAngle+t.endAngle)/2,a=(t.innerRadius+t.outerRadius)/2;return{x:t.x+Math.cos(e)*a,y:t.y+Math.sin(e)*a}},getArea:function(){var t=this._view;return Math.PI*((t.endAngle-t.startAngle)/(2*Math.PI))*(Math.pow(t.outerRadius,2)-Math.pow(t.innerRadius,2))},tooltipPosition:function(){var t=this._view,e=t.startAngle+(t.endAngle-t.startAngle)/2,a=(t.outerRadius-t.innerRadius)/2+t.innerRadius;return{x:t.x+Math.cos(e)*a,y:t.y+Math.sin(e)*a}},draw:function(){var t=this._chart.ctx,e=this._view,a=e.startAngle,i=e.endAngle;t.beginPath(),t.arc(e.x,e.y,e.outerRadius,a,i),t.arc(e.x,e.y,e.innerRadius,i,a,!0),t.closePath(),t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.fillStyle=e.backgroundColor,t.fill(),t.lineJoin="bevel",e.borderWidth&&t.stroke()}})}},{}],38:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers,a=t.defaults.global;t.defaults.global.elements.line={tension:.4,backgroundColor:a.defaultColor,borderWidth:3,borderColor:a.defaultColor,borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",capBezierPoints:!0,fill:!0},t.elements.Line=t.Element.extend({draw:function(){function t(t,e){var a=e._view;e._view.steppedLine===!0?(s.lineTo(a.x,t._view.y),s.lineTo(a.x,a.y)):0===e._view.tension?s.lineTo(a.x,a.y):s.bezierCurveTo(t._view.controlPointNextX,t._view.controlPointNextY,a.controlPointPreviousX,a.controlPointPreviousY,a.x,a.y)}var i=this,n=i._view,o=n.spanGaps,r=n.scaleZero,l=i._loop;l||("top"===n.fill?r=n.scaleTop:"bottom"===n.fill&&(r=n.scaleBottom));var s=i._chart.ctx;s.save();var d=i._children.slice(),u=-1;l&&d.length&&d.push(d[0]);var c,h,f,g;if(d.length&&n.fill){for(s.beginPath(),c=0;c<d.length;++c)h=d[c],f=e.previousItem(d,c),g=h._view,0===c?(l?s.moveTo(r.x,r.y):s.moveTo(g.x,r),g.skip||(u=c,s.lineTo(g.x,g.y))):(f=-1===u?f:d[u],g.skip?o||u!==c-1||(l?s.lineTo(r.x,r.y):s.lineTo(f._view.x,r)):(u!==c-1?o&&-1!==u?t(f,h):l?s.lineTo(g.x,g.y):(s.lineTo(g.x,r),s.lineTo(g.x,g.y)):t(f,h),u=c));l||-1===u||s.lineTo(d[u]._view.x,r),s.fillStyle=n.backgroundColor||a.defaultColor,s.closePath(),s.fill()}var p=a.elements.line;for(s.lineCap=n.borderCapStyle||p.borderCapStyle,s.setLineDash&&s.setLineDash(n.borderDash||p.borderDash),s.lineDashOffset=n.borderDashOffset||p.borderDashOffset,s.lineJoin=n.borderJoinStyle||p.borderJoinStyle,s.lineWidth=n.borderWidth||p.borderWidth,s.strokeStyle=n.borderColor||a.defaultColor,s.beginPath(),u=-1,c=0;c<d.length;++c)h=d[c],f=e.previousItem(d,c),g=h._view,0===c?g.skip||(s.moveTo(g.x,g.y),u=c):(f=-1===u?f:d[u],g.skip||(u!==c-1&&!o||-1===u?s.moveTo(g.x,g.y):t(f,h),u=c));s.stroke(),s.restore()}})}},{}],39:[function(t,e,a){"use strict";e.exports=function(t){function e(t){var e=this._view;return e?Math.pow(t-e.x,2)<Math.pow(e.radius+e.hitRadius,2):!1}function a(t){var e=this._view;return e?Math.pow(t-e.y,2)<Math.pow(e.radius+e.hitRadius,2):!1}var i=t.helpers,n=t.defaults.global,o=n.defaultColor;n.elements.point={radius:3,pointStyle:"circle",backgroundColor:o,borderWidth:1,borderColor:o,hitRadius:1,hoverRadius:4,hoverBorderWidth:1},t.elements.Point=t.Element.extend({inRange:function(t,e){var a=this._view;return a?Math.pow(t-a.x,2)+Math.pow(e-a.y,2)<Math.pow(a.hitRadius+a.radius,2):!1},inLabelRange:e,inXRange:e,inYRange:a,getCenterPoint:function(){var t=this._view;return{x:t.x,y:t.y}},getArea:function(){return Math.PI*Math.pow(this._view.radius,2)},tooltipPosition:function(){var t=this._view;return{x:t.x,y:t.y,padding:t.radius+t.borderWidth}},draw:function(){var e=this._view,a=this._chart.ctx,r=e.pointStyle,l=e.radius,s=e.x,d=e.y;e.skip||(a.strokeStyle=e.borderColor||o,a.lineWidth=i.getValueOrDefault(e.borderWidth,n.elements.point.borderWidth),a.fillStyle=e.backgroundColor||o,t.canvasHelpers.drawPoint(a,r,l,s,d))}})}},{}],40:[function(t,e,a){"use strict";e.exports=function(t){function e(t){return void 0!==t._view.width}function a(t){var a,i,n,o,r=t._view;if(e(t)){var l=r.width/2;a=r.x-l,i=r.x+l,n=Math.min(r.y,r.base),o=Math.max(r.y,r.base)}else{var s=r.height/2;a=Math.min(r.x,r.base),i=Math.max(r.x,r.base),n=r.y-s,o=r.y+s}return{left:a,top:n,right:i,bottom:o}}var i=t.defaults.global;i.elements.rectangle={backgroundColor:i.defaultColor,borderWidth:0,borderColor:i.defaultColor,borderSkipped:"bottom"},t.elements.Rectangle=t.Element.extend({draw:function(){function t(t){return s[(u+t)%4]}var e=this._chart.ctx,a=this._view,i=a.width/2,n=a.x-i,o=a.x+i,r=a.base-(a.base-a.y),l=a.borderWidth/2;a.borderWidth&&(n+=l,o-=l,r+=l),e.beginPath(),e.fillStyle=a.backgroundColor,e.strokeStyle=a.borderColor,e.lineWidth=a.borderWidth;var s=[[n,a.base],[n,r],[o,r],[o,a.base]],d=["bottom","left","top","right"],u=d.indexOf(a.borderSkipped,0);-1===u&&(u=0);var c=t(0);e.moveTo(c[0],c[1]);for(var h=1;4>h;h++)c=t(h),e.lineTo(c[0],c[1]);e.fill(),a.borderWidth&&e.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=!1;if(this._view){var n=a(this);i=t>=n.left&&t<=n.right&&e>=n.top&&e<=n.bottom}return i},inLabelRange:function(t,i){var n=this;if(!n._view)return!1;var o=!1,r=a(n);return o=e(n)?t>=r.left&&t<=r.right:i>=r.top&&i<=r.bottom},inXRange:function(t){var e=a(this);return t>=e.left&&t<=e.right},inYRange:function(t){var e=a(this);return t>=e.top&&t<=e.bottom},getCenterPoint:function(){var t,a,i=this._view;return e(this)?(t=i.x,a=(i.y+i.base)/2):(t=(i.x+i.base)/2,a=i.y),{x:t,y:a}},getArea:function(){var t=this._view;return t.width*Math.abs(t.y-t.base)},tooltipPosition:function(){var t=this._view;return{x:t.x,y:t.y}}})}},{}],41:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers,a={position:"bottom"},i=t.Scale.extend({getLabels:function(){var t=this.chart.data;return(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels},determineDataLimits:function(){var t=this,a=t.getLabels();t.minIndex=0,t.maxIndex=a.length-1;var i;void 0!==t.options.ticks.min&&(i=e.indexOf(a,t.options.ticks.min),t.minIndex=-1!==i?i:t.minIndex),void 0!==t.options.ticks.max&&(i=e.indexOf(a,t.options.ticks.max),t.maxIndex=-1!==i?i:t.maxIndex),t.min=a[t.minIndex],t.max=a[t.maxIndex]},buildTicks:function(){var t=this,e=t.getLabels();t.ticks=0===t.minIndex&&t.maxIndex===e.length-1?e:e.slice(t.minIndex,t.maxIndex+1)},getLabelForIndex:function(t,e){var a=this,i=a.chart.data,n=a.isHorizontal();return i.xLabels&&n||i.yLabels&&!n?a.getRightValue(i.datasets[e].data[t]):a.ticks[t]},getPixelForValue:function(t,e,a,i){var n=this,o=Math.max(n.maxIndex+1-n.minIndex-(n.options.gridLines.offsetGridLines?0:1),1);if(void 0!==t&&isNaN(e)){var r=n.getLabels(),l=r.indexOf(t);e=-1!==l?l:e}if(n.isHorizontal()){var s=n.width-(n.paddingLeft+n.paddingRight),d=s/o,u=d*(e-n.minIndex)+n.paddingLeft;return(n.options.gridLines.offsetGridLines&&i||n.maxIndex===n.minIndex&&i)&&(u+=d/2),
14
+ n.left+Math.round(u)}var c=n.height-(n.paddingTop+n.paddingBottom),h=c/o,f=h*(e-n.minIndex)+n.paddingTop;return n.options.gridLines.offsetGridLines&&i&&(f+=h/2),n.top+Math.round(f)},getPixelForTick:function(t,e){return this.getPixelForValue(this.ticks[t],t+this.minIndex,null,e)},getValueForPixel:function(t){var e,a=this,i=Math.max(a.ticks.length-(a.options.gridLines.offsetGridLines?0:1),1),n=a.isHorizontal(),o=n?a.width-(a.paddingLeft+a.paddingRight):a.height-(a.paddingTop+a.paddingBottom),r=o/i;return t-=n?a.left:a.top,a.options.gridLines.offsetGridLines&&(t-=r/2),t-=n?a.paddingLeft:a.paddingTop,e=0>=t?0:Math.round(t/r)},getBasePixel:function(){return this.bottom}});t.scaleService.registerScaleType("category",i,a)}},{}],42:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers,a={position:"left",ticks:{callback:t.Ticks.formatters.linear}},i=t.LinearScaleBase.extend({determineDataLimits:function(){function t(t){return l?t.xAxisID===a.id:t.yAxisID===a.id}var a=this,i=a.options,n=a.chart,o=n.data,r=o.datasets,l=a.isHorizontal();if(a.min=null,a.max=null,i.stacked){var s={};e.each(r,function(o,r){var l=n.getDatasetMeta(r);void 0===s[l.type]&&(s[l.type]={positiveValues:[],negativeValues:[]});var d=s[l.type].positiveValues,u=s[l.type].negativeValues;n.isDatasetVisible(r)&&t(l)&&e.each(o.data,function(t,e){var n=+a.getRightValue(t);isNaN(n)||l.data[e].hidden||(d[e]=d[e]||0,u[e]=u[e]||0,i.relativePoints?d[e]=100:0>n?u[e]+=n:d[e]+=n)})}),e.each(s,function(t){var i=t.positiveValues.concat(t.negativeValues),n=e.min(i),o=e.max(i);a.min=null===a.min?n:Math.min(a.min,n),a.max=null===a.max?o:Math.max(a.max,o)})}else e.each(r,function(i,o){var r=n.getDatasetMeta(o);n.isDatasetVisible(o)&&t(r)&&e.each(i.data,function(t,e){var i=+a.getRightValue(t);isNaN(i)||r.data[e].hidden||(null===a.min?a.min=i:i<a.min&&(a.min=i),null===a.max?a.max=i:i>a.max&&(a.max=i))})});this.handleTickRangeOptions()},getTickLimit:function(){var a,i=this,n=i.options.ticks;if(i.isHorizontal())a=Math.min(n.maxTicksLimit?n.maxTicksLimit:11,Math.ceil(i.width/50));else{var o=e.getValueOrDefault(n.fontSize,t.defaults.global.defaultFontSize);a=Math.min(n.maxTicksLimit?n.maxTicksLimit:11,Math.ceil(i.height/(2*o)))}return a},handleDirectionalChanges:function(){this.isHorizontal()||this.ticks.reverse()},getLabelForIndex:function(t,e){return+this.getRightValue(this.chart.data.datasets[e].data[t])},getPixelForValue:function(t){var e,a,i=this,n=i.paddingLeft,o=i.paddingBottom,r=i.start,l=+i.getRightValue(t),s=i.end-r;return i.isHorizontal()?(a=i.width-(n+i.paddingRight),e=i.left+a/s*(l-r),Math.round(e+n)):(a=i.height-(i.paddingTop+o),e=i.bottom-o-a/s*(l-r),Math.round(e))},getValueForPixel:function(t){var e=this,a=e.isHorizontal(),i=e.paddingLeft,n=e.paddingBottom,o=a?e.width-(i+e.paddingRight):e.height-(e.paddingTop+n),r=(a?t-e.left-i:e.bottom-n-t)/o;return e.start+(e.end-e.start)*r},getPixelForTick:function(t){return this.getPixelForValue(this.ticksAsNumbers[t])}});t.scaleService.registerScaleType("linear",i,a)}},{}],43:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers,a=e.noop;t.LinearScaleBase=t.Scale.extend({handleTickRangeOptions:function(){var t=this,a=t.options,i=a.ticks;if(i.beginAtZero){var n=e.sign(t.min),o=e.sign(t.max);0>n&&0>o?t.max=0:n>0&&o>0&&(t.min=0)}void 0!==i.min?t.min=i.min:void 0!==i.suggestedMin&&(t.min=Math.min(t.min,i.suggestedMin)),void 0!==i.max?t.max=i.max:void 0!==i.suggestedMax&&(t.max=Math.max(t.max,i.suggestedMax)),t.min===t.max&&(t.max++,i.beginAtZero||t.min--)},getTickLimit:a,handleDirectionalChanges:a,buildTicks:function(){var a=this,i=a.options,n=i.ticks,o=a.getTickLimit();o=Math.max(2,o);var r={maxTicks:o,min:n.min,max:n.max,stepSize:e.getValueOrDefault(n.fixedStepSize,n.stepSize)},l=a.ticks=t.Ticks.generators.linear(r,a);a.handleDirectionalChanges(),a.max=e.max(l),a.min=e.min(l),n.reverse?(l.reverse(),a.start=a.max,a.end=a.min):(a.start=a.min,a.end=a.max)},convertTicksToLabels:function(){var e=this;e.ticksAsNumbers=e.ticks.slice(),e.zeroLineIndex=e.ticks.indexOf(0),t.Scale.prototype.convertTicksToLabels.call(e)}})}},{}],44:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers,a={position:"left",ticks:{callback:t.Ticks.formatters.logarithmic}},i=t.Scale.extend({determineDataLimits:function(){function t(t){return d?t.xAxisID===a.id:t.yAxisID===a.id}var a=this,i=a.options,n=i.ticks,o=a.chart,r=o.data,l=r.datasets,s=e.getValueOrDefault,d=a.isHorizontal();if(a.min=null,a.max=null,a.minNotZero=null,i.stacked){var u={};e.each(l,function(n,r){var l=o.getDatasetMeta(r);o.isDatasetVisible(r)&&t(l)&&(void 0===u[l.type]&&(u[l.type]=[]),e.each(n.data,function(t,e){var n=u[l.type],o=+a.getRightValue(t);isNaN(o)||l.data[e].hidden||(n[e]=n[e]||0,i.relativePoints?n[e]=100:n[e]+=o)}))}),e.each(u,function(t){var i=e.min(t),n=e.max(t);a.min=null===a.min?i:Math.min(a.min,i),a.max=null===a.max?n:Math.max(a.max,n)})}else e.each(l,function(i,n){var r=o.getDatasetMeta(n);o.isDatasetVisible(n)&&t(r)&&e.each(i.data,function(t,e){var i=+a.getRightValue(t);isNaN(i)||r.data[e].hidden||(null===a.min?a.min=i:i<a.min&&(a.min=i),null===a.max?a.max=i:i>a.max&&(a.max=i),0!==i&&(null===a.minNotZero||i<a.minNotZero)&&(a.minNotZero=i))})});a.min=s(n.min,a.min),a.max=s(n.max,a.max),a.min===a.max&&(0!==a.min&&null!==a.min?(a.min=Math.pow(10,Math.floor(e.log10(a.min))-1),a.max=Math.pow(10,Math.floor(e.log10(a.max))+1)):(a.min=1,a.max=10))},buildTicks:function(){var a=this,i=a.options,n=i.ticks,o={min:n.min,max:n.max},r=a.ticks=t.Ticks.generators.logarithmic(o,a);a.isHorizontal()||r.reverse(),a.max=e.max(r),a.min=e.min(r),n.reverse?(r.reverse(),a.start=a.max,a.end=a.min):(a.start=a.min,a.end=a.max)},convertTicksToLabels:function(){this.tickValues=this.ticks.slice(),t.Scale.prototype.convertTicksToLabels.call(this)},getLabelForIndex:function(t,e){return+this.getRightValue(this.chart.data.datasets[e].data[t])},getPixelForTick:function(t){return this.getPixelForValue(this.tickValues[t])},getPixelForValue:function(t){var a,i,n,o=this,r=o.start,l=+o.getRightValue(t),s=o.paddingTop,d=o.paddingBottom,u=o.paddingLeft,c=o.options,h=c.ticks;return o.isHorizontal()?(n=e.log10(o.end)-e.log10(r),0===l?i=o.left+u:(a=o.width-(u+o.paddingRight),i=o.left+a/n*(e.log10(l)-e.log10(r)),i+=u)):(a=o.height-(s+d),0!==r||h.reverse?0===o.end&&h.reverse?(n=e.log10(o.start)-e.log10(o.minNotZero),i=l===o.end?o.top+s:l===o.minNotZero?o.top+s+.02*a:o.top+s+.02*a+.98*a/n*(e.log10(l)-e.log10(o.minNotZero))):(n=e.log10(o.end)-e.log10(r),a=o.height-(s+d),i=o.bottom-d-a/n*(e.log10(l)-e.log10(r))):(n=e.log10(o.end)-e.log10(o.minNotZero),i=l===r?o.bottom-d:l===o.minNotZero?o.bottom-d-.02*a:o.bottom-d-.02*a-.98*a/n*(e.log10(l)-e.log10(o.minNotZero)))),i},getValueForPixel:function(t){var a,i,n=this,o=e.log10(n.end)-e.log10(n.start);return n.isHorizontal()?(i=n.width-(n.paddingLeft+n.paddingRight),a=n.start*Math.pow(10,(t-n.left-n.paddingLeft)*o/i)):(i=n.height-(n.paddingTop+n.paddingBottom),a=Math.pow(10,(n.bottom-n.paddingBottom-t)*o/i)/n.start),a}});t.scaleService.registerScaleType("logarithmic",i,a)}},{}],45:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers,a=t.defaults.global,i={display:!0,animate:!0,lineArc:!1,position:"chartArea",angleLines:{display:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},ticks:{showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2,callback:t.Ticks.formatters.linear},pointLabels:{fontSize:10,callback:function(t){return t}}},n=t.LinearScaleBase.extend({getValueCount:function(){return this.chart.data.labels.length},setDimensions:function(){var t=this,i=t.options,n=i.ticks;t.width=t.maxWidth,t.height=t.maxHeight,t.xCenter=Math.round(t.width/2),t.yCenter=Math.round(t.height/2);var o=e.min([t.height,t.width]),r=e.getValueOrDefault(n.fontSize,a.defaultFontSize);t.drawingArea=i.display?o/2-(r/2+n.backdropPaddingY):o/2},determineDataLimits:function(){var t=this,a=t.chart;t.min=null,t.max=null,e.each(a.data.datasets,function(i,n){if(a.isDatasetVisible(n)){var o=a.getDatasetMeta(n);e.each(i.data,function(e,a){var i=+t.getRightValue(e);isNaN(i)||o.data[a].hidden||(null===t.min?t.min=i:i<t.min&&(t.min=i),null===t.max?t.max=i:i>t.max&&(t.max=i))})}}),t.handleTickRangeOptions()},getTickLimit:function(){var t=this.options.ticks,i=e.getValueOrDefault(t.fontSize,a.defaultFontSize);return Math.min(t.maxTicksLimit?t.maxTicksLimit:11,Math.ceil(this.drawingArea/(1.5*i)))},convertTicksToLabels:function(){var e=this;t.LinearScaleBase.prototype.convertTicksToLabels.call(e),e.pointLabels=e.chart.data.labels.map(e.options.pointLabels.callback,e)},getLabelForIndex:function(t,e){return+this.getRightValue(this.chart.data.datasets[e].data[t])},fit:function(){var t,i,n,o,r,l,s,d,u,c,h,f,g=this.options.pointLabels,p=e.getValueOrDefault(g.fontSize,a.defaultFontSize),m=e.getValueOrDefault(g.fontStyle,a.defaultFontStyle),b=e.getValueOrDefault(g.fontFamily,a.defaultFontFamily),v=e.fontString(p,m,b),x=e.min([this.height/2-p-5,this.width/2]),y=this.width,k=0;for(this.ctx.font=v,i=0;i<this.getValueCount();i++){t=this.getPointPosition(i,x),n=this.ctx.measureText(this.pointLabels[i]?this.pointLabels[i]:"").width+5;var S=this.getIndexAngle(i)+Math.PI/2,w=360*S/(2*Math.PI)%360;0===w||180===w?(o=n/2,t.x+o>y&&(y=t.x+o,r=i),t.x-o<k&&(k=t.x-o,s=i)):180>w?t.x+n>y&&(y=t.x+n,r=i):t.x-n<k&&(k=t.x-n,s=i)}u=k,c=Math.ceil(y-this.width),l=this.getIndexAngle(r),d=this.getIndexAngle(s),h=c/Math.sin(l+Math.PI/2),f=u/Math.sin(d+Math.PI/2),h=e.isNumber(h)?h:0,f=e.isNumber(f)?f:0,this.drawingArea=Math.round(x-(f+h)/2),this.setCenterPoint(f,h)},setCenterPoint:function(t,e){var a=this,i=a.width-e-a.drawingArea,n=t+a.drawingArea;a.xCenter=Math.round((n+i)/2+a.left),a.yCenter=Math.round(a.height/2+a.top)},getIndexAngle:function(t){var e=2*Math.PI/this.getValueCount(),a=this.chart.options&&this.chart.options.startAngle?this.chart.options.startAngle:0,i=a*Math.PI*2/360;return t*e-Math.PI/2+i},getDistanceFromCenterForValue:function(t){var e=this;if(null===t)return 0;var a=e.drawingArea/(e.max-e.min);return e.options.reverse?(e.max-t)*a:(t-e.min)*a},getPointPosition:function(t,e){var a=this,i=a.getIndexAngle(t);return{x:Math.round(Math.cos(i)*e)+a.xCenter,y:Math.round(Math.sin(i)*e)+a.yCenter}},getPointPositionForValue:function(t,e){return this.getPointPosition(t,this.getDistanceFromCenterForValue(e))},getBasePosition:function(){var t=this,e=t.min,a=t.max;return t.getPointPositionForValue(0,t.beginAtZero?0:0>e&&0>a?a:e>0&&a>0?e:0)},draw:function(){var t=this,i=t.options,n=i.gridLines,o=i.ticks,r=i.angleLines,l=i.pointLabels,s=e.getValueOrDefault;if(i.display){var d=t.ctx,u=s(o.fontSize,a.defaultFontSize),c=s(o.fontStyle,a.defaultFontStyle),h=s(o.fontFamily,a.defaultFontFamily),f=e.fontString(u,c,h);if(e.each(t.ticks,function(r,l){if(l>0||i.reverse){var c=t.getDistanceFromCenterForValue(t.ticksAsNumbers[l]),h=t.yCenter-c;if(n.display&&0!==l)if(d.strokeStyle=e.getValueAtIndexOrDefault(n.color,l-1),d.lineWidth=e.getValueAtIndexOrDefault(n.lineWidth,l-1),i.lineArc)d.beginPath(),d.arc(t.xCenter,t.yCenter,c,0,2*Math.PI),d.closePath(),d.stroke();else{d.beginPath();for(var g=0;g<t.getValueCount();g++){var p=t.getPointPosition(g,c);0===g?d.moveTo(p.x,p.y):d.lineTo(p.x,p.y)}d.closePath(),d.stroke()}if(o.display){var m=s(o.fontColor,a.defaultFontColor);if(d.font=f,o.showLabelBackdrop){var b=d.measureText(r).width;d.fillStyle=o.backdropColor,d.fillRect(t.xCenter-b/2-o.backdropPaddingX,h-u/2-o.backdropPaddingY,b+2*o.backdropPaddingX,u+2*o.backdropPaddingY)}d.textAlign="center",d.textBaseline="middle",d.fillStyle=m,d.fillText(r,t.xCenter,h)}}}),!i.lineArc){d.lineWidth=r.lineWidth,d.strokeStyle=r.color;for(var g=t.getDistanceFromCenterForValue(i.reverse?t.min:t.max),p=s(l.fontSize,a.defaultFontSize),m=s(l.fontStyle,a.defaultFontStyle),b=s(l.fontFamily,a.defaultFontFamily),v=e.fontString(p,m,b),x=t.getValueCount()-1;x>=0;x--){if(r.display){var y=t.getPointPosition(x,g);d.beginPath(),d.moveTo(t.xCenter,t.yCenter),d.lineTo(y.x,y.y),d.stroke(),d.closePath()}var k=t.getPointPosition(x,g+5),S=s(l.fontColor,a.defaultFontColor);d.font=v,d.fillStyle=S;var w=t.pointLabels,M=this.getIndexAngle(x)+Math.PI/2,C=360*M/(2*Math.PI)%360;0===C||180===C?d.textAlign="center":180>C?d.textAlign="left":d.textAlign="right",90===C||270===C?d.textBaseline="middle":C>270||90>C?d.textBaseline="bottom":d.textBaseline="top",d.fillText(w[x]?w[x]:"",k.x,k.y)}}}}});t.scaleService.registerScaleType("radialLinear",n,i)}},{}],46:[function(t,e,a){"use strict";var i=t(1);i="function"==typeof i?i:window.moment,e.exports=function(t){var e=t.helpers,a={units:[{name:"millisecond",steps:[1,2,5,10,20,50,100,250,500]},{name:"second",steps:[1,2,5,10,30]},{name:"minute",steps:[1,2,5,10,30]},{name:"hour",steps:[1,2,3,6,12]},{name:"day",steps:[1,2,5]},{name:"week",maxStep:4},{name:"month",maxStep:3},{name:"quarter",maxStep:4},{name:"year",maxStep:!1}]},n={position:"bottom",time:{parser:!1,format:!1,unit:!1,round:!1,displayFormat:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{millisecond:"h:mm:ss.SSS a",second:"h:mm:ss a",minute:"h:mm:ss a",hour:"MMM D, hA",day:"ll",week:"ll",month:"MMM YYYY",quarter:"[Q]Q - YYYY",year:"YYYY"}},ticks:{autoSkip:!1}},o=t.Scale.extend({initialize:function(){if(!i)throw new Error("Chart.js - Moment.js could not be found! You must include it before Chart.js to use the time scale. Download at https://momentjs.com");t.Scale.prototype.initialize.call(this)},getLabelMoment:function(t,e){return null===t||null===e?null:"undefined"!=typeof this.labelMoments[t]?this.labelMoments[t][e]:null},getLabelDiff:function(t,e){var a=this;return null===t||null===e?null:(void 0===a.labelDiffs&&a.buildLabelDiffs(),"undefined"!=typeof a.labelDiffs[t]?a.labelDiffs[t][e]:null)},getMomentStartOf:function(t){var e=this;return"week"===e.options.time.unit&&e.options.time.isoWeekday!==!1?t.clone().startOf("isoWeek").isoWeekday(e.options.time.isoWeekday):t.clone().startOf(e.tickUnit)},determineDataLimits:function(){var t=this;t.labelMoments=[];var a=[];t.chart.data.labels&&t.chart.data.labels.length>0?(e.each(t.chart.data.labels,function(e){var i=t.parseTime(e);i.isValid()&&(t.options.time.round&&i.startOf(t.options.time.round),a.push(i))},t),t.firstTick=i.min.call(t,a),t.lastTick=i.max.call(t,a)):(t.firstTick=null,t.lastTick=null),e.each(t.chart.data.datasets,function(n,o){var r=[],l=t.chart.isDatasetVisible(o);"object"==typeof n.data[0]&&null!==n.data[0]?e.each(n.data,function(e){var a=t.parseTime(t.getRightValue(e));a.isValid()&&(t.options.time.round&&a.startOf(t.options.time.round),r.push(a),l&&(t.firstTick=null!==t.firstTick?i.min(t.firstTick,a):a,t.lastTick=null!==t.lastTick?i.max(t.lastTick,a):a))},t):r=a,t.labelMoments.push(r)},t),t.options.time.min&&(t.firstTick=t.parseTime(t.options.time.min)),t.options.time.max&&(t.lastTick=t.parseTime(t.options.time.max)),t.firstTick=(t.firstTick||i()).clone(),t.lastTick=(t.lastTick||i()).clone()},buildLabelDiffs:function(){var t=this;t.labelDiffs=[];var a=[];t.chart.data.labels&&t.chart.data.labels.length>0&&e.each(t.chart.data.labels,function(e){var i=t.parseTime(e);i.isValid()&&(t.options.time.round&&i.startOf(t.options.time.round),a.push(i.diff(t.firstTick,t.tickUnit,!0)))},t),e.each(t.chart.data.datasets,function(i){var n=[];"object"==typeof i.data[0]&&null!==i.data[0]?e.each(i.data,function(e){var a=t.parseTime(t.getRightValue(e));a.isValid()&&(t.options.time.round&&a.startOf(t.options.time.round),n.push(a.diff(t.firstTick,t.tickUnit,!0)))},t):n=a,t.labelDiffs.push(n)},t)},buildTicks:function(){var i=this;i.ctx.save();var n=e.getValueOrDefault(i.options.ticks.fontSize,t.defaults.global.defaultFontSize),o=e.getValueOrDefault(i.options.ticks.fontStyle,t.defaults.global.defaultFontStyle),r=e.getValueOrDefault(i.options.ticks.fontFamily,t.defaults.global.defaultFontFamily),l=e.fontString(n,o,r);if(i.ctx.font=l,i.ticks=[],i.unitScale=1,i.scaleSizeInUnits=0,i.options.time.unit)i.tickUnit=i.options.time.unit||"day",i.displayFormat=i.options.time.displayFormats[i.tickUnit],i.scaleSizeInUnits=i.lastTick.diff(i.firstTick,i.tickUnit,!0),i.unitScale=e.getValueOrDefault(i.options.time.unitStepSize,1);else{var s=i.isHorizontal()?i.width-(i.paddingLeft+i.paddingRight):i.height-(i.paddingTop+i.paddingBottom),d=i.tickFormatFunction(i.firstTick,0,[]),u=i.ctx.measureText(d).width,c=Math.cos(e.toRadians(i.options.ticks.maxRotation)),h=Math.sin(e.toRadians(i.options.ticks.maxRotation));u=u*c+n*h;var f=s/u;i.tickUnit=i.options.time.minUnit,i.scaleSizeInUnits=i.lastTick.diff(i.firstTick,i.tickUnit,!0),i.displayFormat=i.options.time.displayFormats[i.tickUnit];for(var g=0,p=a.units[g];g<a.units.length;){if(i.unitScale=1,e.isArray(p.steps)&&Math.ceil(i.scaleSizeInUnits/f)<e.max(p.steps)){for(var m=0;m<p.steps.length;++m)if(p.steps[m]>=Math.ceil(i.scaleSizeInUnits/f)){i.unitScale=e.getValueOrDefault(i.options.time.unitStepSize,p.steps[m]);break}break}if(p.maxStep===!1||Math.ceil(i.scaleSizeInUnits/f)<p.maxStep){i.unitScale=e.getValueOrDefault(i.options.time.unitStepSize,Math.ceil(i.scaleSizeInUnits/f));break}++g,p=a.units[g],i.tickUnit=p.name;var b=i.firstTick.diff(i.getMomentStartOf(i.firstTick),i.tickUnit,!0),v=i.getMomentStartOf(i.lastTick.clone().add(1,i.tickUnit)).diff(i.lastTick,i.tickUnit,!0);i.scaleSizeInUnits=i.lastTick.diff(i.firstTick,i.tickUnit,!0)+b+v,i.displayFormat=i.options.time.displayFormats[p.name]}}var x;if(i.options.time.min?x=i.getMomentStartOf(i.firstTick):(i.firstTick=i.getMomentStartOf(i.firstTick),x=i.firstTick),!i.options.time.max){var y=i.getMomentStartOf(i.lastTick),k=y.diff(i.lastTick,i.tickUnit,!0);0>k?i.lastTick=i.getMomentStartOf(i.lastTick.add(1,i.tickUnit)):k>=0&&(i.lastTick=y),i.scaleSizeInUnits=i.lastTick.diff(i.firstTick,i.tickUnit,!0)}i.options.time.displayFormat&&(i.displayFormat=i.options.time.displayFormat),i.ticks.push(i.firstTick.clone());for(var S=1;S<=i.scaleSizeInUnits;++S){var w=x.clone().add(S,i.tickUnit);if(i.options.time.max&&w.diff(i.lastTick,i.tickUnit,!0)>=0)break;S%i.unitScale===0&&i.ticks.push(w)}var M=i.ticks[i.ticks.length-1].diff(i.lastTick,i.tickUnit);(0!==M||0===i.scaleSizeInUnits)&&(i.options.time.max?(i.ticks.push(i.lastTick.clone()),i.scaleSizeInUnits=i.lastTick.diff(i.ticks[0],i.tickUnit,!0)):(i.ticks.push(i.lastTick.clone()),i.scaleSizeInUnits=i.lastTick.diff(i.firstTick,i.tickUnit,!0))),i.ctx.restore(),i.labelDiffs=void 0},getLabelForIndex:function(t,e){var a=this,i=a.chart.data.labels&&t<a.chart.data.labels.length?a.chart.data.labels[t]:"";return"object"==typeof a.chart.data.datasets[e].data[0]&&(i=a.getRightValue(a.chart.data.datasets[e].data[t])),a.options.time.tooltipFormat&&(i=a.parseTime(i).format(a.options.time.tooltipFormat)),i},tickFormatFunction:function(t,a,i){var n=t.format(this.displayFormat),o=this.options.ticks,r=e.getValueOrDefault(o.callback,o.userCallback);return r?r(n,a,i):n},convertTicksToLabels:function(){var t=this;t.tickMoments=t.ticks,t.ticks=t.ticks.map(t.tickFormatFunction,t)},getPixelForValue:function(t,e,a){var i=this,n=null;if(void 0!==e&&void 0!==a&&(n=i.getLabelDiff(a,e)),null===n&&(t&&t.isValid||(t=i.parseTime(i.getRightValue(t))),t&&t.isValid&&t.isValid()&&(n=t.diff(i.firstTick,i.tickUnit,!0))),null!==n){var o=0!==n?n/i.scaleSizeInUnits:n;if(i.isHorizontal()){var r=i.width-(i.paddingLeft+i.paddingRight),l=r*o+i.paddingLeft;return i.left+Math.round(l)}var s=i.height-(i.paddingTop+i.paddingBottom),d=s*o+i.paddingTop;return i.top+Math.round(d)}},getPixelForTick:function(t){return this.getPixelForValue(this.tickMoments[t],null,null)},getValueForPixel:function(t){var e=this,a=e.isHorizontal()?e.width-(e.paddingLeft+e.paddingRight):e.height-(e.paddingTop+e.paddingBottom),n=(t-(e.isHorizontal()?e.left+e.paddingLeft:e.top+e.paddingTop))/a;return n*=e.scaleSizeInUnits,e.firstTick.clone().add(i.duration(n,e.tickUnit).asSeconds(),"seconds")},parseTime:function(t){var e=this;return"string"==typeof e.options.time.parser?i(t,e.options.time.parser):"function"==typeof e.options.time.parser?e.options.time.parser(t):"function"==typeof t.getMonth||"number"==typeof t?i(t):t.isValid&&t.isValid()?t:"string"!=typeof e.options.time.format&&e.options.time.format.call?(console.warn("options.time.format is deprecated and replaced by options.time.parser. See http://nnnick.github.io/Chart.js/docs-v2/#scales-time-scale"),e.options.time.format(t)):i(t,e.options.time.format)}});t.scaleService.registerScaleType("time",o,n)}},{1:1}]},{},[7])(7)});
js/frontend.js CHANGED
@@ -1,14 +1,14 @@
1
  ( function ( $ ) {
2
 
3
- $( document ).ready( function () {
4
-
5
- $.post( pvcArgsFrontend.ajaxURL, {
6
- action: 'pvc-check-post',
7
- pvc_nonce: pvcArgsFrontend.nonce,
8
- post_id: pvcArgsFrontend.postID,
9
- post_type: pvcArgsFrontend.postType
10
- } );
11
 
 
 
 
 
 
12
  } );
13
 
 
 
14
  } )( jQuery );
1
  ( function ( $ ) {
2
 
3
+ $( document ).ready( function () {
 
 
 
 
 
 
 
4
 
5
+ $.post( pvcArgsFrontend.ajaxURL, {
6
+ action: 'pvc-check-post',
7
+ pvc_nonce: pvcArgsFrontend.nonce,
8
+ post_id: pvcArgsFrontend.postID,
9
+ post_type: pvcArgsFrontend.postType
10
  } );
11
 
12
+ } );
13
+
14
  } )( jQuery );
post-views-counter.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Post Views Counter
4
  Description: Forget WP-PostViews. Display how many times a post, page or custom post type had been viewed in a simple, fast and reliable way.
5
- Version: 1.2.3
6
  Author: dFactory
7
  Author URI: http://www.dfactory.eu/
8
  Plugin URI: http://www.dfactory.eu/plugins/post-views-counter/
@@ -23,338 +23,358 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
23
 
24
  // exit if accessed directly
25
  if ( ! defined( 'ABSPATH' ) )
26
- exit;
27
 
28
  if ( ! class_exists( 'Post_Views_Counter' ) ) :
29
 
30
- /**
31
- * Post Views Counter final class.
32
- *
33
- * @class Post_Views_Counter
34
- * @version 1.2.3
35
- */
36
- final class Post_Views_Counter {
37
-
38
- private static $instance;
39
- public $options;
40
- public $defaults = array(
41
- 'general' => array(
42
- 'post_types_count' => array( 'post' ),
43
- 'counter_mode' => 'php',
44
- 'post_views_column' => true,
45
- 'time_between_counts' => array(
46
- 'number' => 24,
47
- 'type' => 'hours'
48
- ),
49
- 'reset_counts' => array(
50
- 'number' => 30,
51
- 'type' => 'days'
52
- ),
53
- 'flush_interval' => array(
54
- 'number' => 0,
55
- 'type' => 'minutes'
56
- ),
57
- 'exclude' => array(
58
- 'groups' => array(),
59
- 'roles' => array()
60
- ),
61
- 'exclude_ips' => array(),
62
- 'restrict_edit_views' => false,
63
- 'deactivation_delete' => false,
64
- 'cron_run' => true,
65
- 'cron_update' => true
66
- ),
67
- 'display' => array(
68
- 'label' => 'Post Views:',
69
- 'post_types_display' => array( 'post' ),
70
- 'page_types_display' => array( 'singular' ),
71
- 'restrict_display' => array(
72
- 'groups' => array(),
73
- 'roles' => array()
74
  ),
75
- 'position' => 'after',
76
- 'display_style' => array(
77
- 'icon' => true,
78
- 'text' => true
 
 
 
 
 
 
 
 
 
 
 
79
  ),
80
- 'link_to_post' => true,
81
- 'icon_class' => 'dashicons-chart-bar'
82
- ),
83
- 'version' => '1.2.3'
84
- );
85
 
86
- /**
87
- * Disable object clone.
88
- */
89
- private function __clone() {}
 
 
90
 
91
- /**
92
- * Disable unserializing of the class.
93
- */
94
- private function __wakeup() {}
 
 
95
 
96
- /**
97
- * Main Post_Views_Counter instance,
98
- * Insures that only one instance of Post_Views_Counter exists in memory at one time.
99
- *
100
- * @return object
101
- */
102
- public static function instance() {
103
- if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Post_Views_Counter ) ) {
104
- self::$instance = new Post_Views_Counter;
105
- self::$instance->define_constants();
106
-
107
- add_action( 'plugins_loaded', array( self::$instance, 'load_textdomain' ) );
108
-
109
- self::$instance->includes();
110
- self::$instance->update = new Post_Views_Counter_Update();
111
- self::$instance->settings = new Post_Views_Counter_Settings();
112
- self::$instance->query = new Post_Views_Counter_Query();
113
- self::$instance->cron = new Post_Views_Counter_Cron();
114
- self::$instance->counter = new Post_Views_Counter_Counter();
115
- self::$instance->columns = new Post_Views_Counter_Columns();
116
- self::$instance->frontend = new Post_Views_Counter_Frontend();
117
- self::$instance->dashboard = new Post_Views_Counter_Dashboard();
118
- self::$instance->widgets = new Post_Views_Counter_Widgets();
 
 
 
119
  }
120
- return self::$instance;
121
- }
122
 
123
- /**
124
- * Setup plugin constants.
125
- *
126
- * @return void
127
- */
128
- private function define_constants() {
129
- define( 'POST_VIEWS_COUNTER_URL', plugins_url( '', __FILE__ ) );
130
- define( 'POST_VIEWS_COUNTER_PATH', plugin_dir_path( __FILE__ ) );
131
- define( 'POST_VIEWS_COUNTER_REL_PATH', dirname( plugin_basename( __FILE__ ) ) . '/' );
132
- }
133
 
134
- /**
135
- * Include required files
136
- *
137
- * @return void
138
- */
139
- private function includes() {
140
- include_once( POST_VIEWS_COUNTER_PATH . 'includes/update.php' );
141
- include_once( POST_VIEWS_COUNTER_PATH . 'includes/settings.php' );
142
- include_once( POST_VIEWS_COUNTER_PATH . 'includes/columns.php' );
143
- include_once( POST_VIEWS_COUNTER_PATH . 'includes/query.php' );
144
- include_once( POST_VIEWS_COUNTER_PATH . 'includes/cron.php' );
145
- include_once( POST_VIEWS_COUNTER_PATH . 'includes/counter.php' );
146
- include_once( POST_VIEWS_COUNTER_PATH . 'includes/frontend.php' );
147
- include_once( POST_VIEWS_COUNTER_PATH . 'includes/dashboard.php' );
148
- include_once( POST_VIEWS_COUNTER_PATH . 'includes/widgets.php' );
149
- }
 
150
 
151
- /**
152
- * Class constructor.
153
- *
154
- * @return void
155
- */
156
- public function __construct() {
157
- register_activation_hook( __FILE__, array( $this, 'activation' ) );
158
- register_deactivation_hook( __FILE__, array( $this, 'deactivation' ) );
159
-
160
- // settings
161
- $this->options = array(
162
- 'general' => array_merge( $this->defaults['general'], get_option( 'post_views_counter_settings_general', $this->defaults['general'] ) ),
163
- 'display' => array_merge( $this->defaults['display'], get_option( 'post_views_counter_settings_display', $this->defaults['display'] ) )
164
- );
165
 
166
- // actions
167
- add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts_styles' ) );
168
- add_action( 'wp_loaded', array( $this, 'load_pluggable_functions' ), 10 );
169
 
170
- // filters
171
- add_filter( 'plugin_row_meta', array( $this, 'plugin_extend_links' ), 10, 2 );
172
- add_filter( 'plugin_action_links', array( $this, 'plugin_settings_link' ), 10, 2 );
173
- }
174
 
175
- /**
176
- * Plugin activation function.
177
- */
178
- public function activation() {
179
- global $wpdb, $charset_collate;
180
-
181
- // required for dbdelta
182
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
183
-
184
- // create post views table
185
- dbDelta( '
186
- CREATE TABLE IF NOT EXISTS ' . $wpdb->prefix . 'post_views (
187
- id bigint unsigned NOT NULL,
188
- type tinyint(1) unsigned NOT NULL,
189
- period varchar(8) NOT NULL,
190
- count bigint unsigned NOT NULL,
191
- PRIMARY KEY (type, period, id),
192
- UNIQUE INDEX id_period (id, period) USING BTREE,
193
- INDEX type_period_count (type, period, count) USING BTREE
194
- ) ' . $charset_collate . ';'
195
- );
196
 
197
- // add default options
198
- add_option( 'post_views_counter_settings_general', $this->defaults['general'], '', 'no' );
199
- add_option( 'post_views_counter_settings_display', $this->defaults['display'], '', 'no' );
200
- add_option( 'post_views_counter_version', $this->defaults['version'], '', 'no' );
201
 
202
- // schedule cache flush
203
- $this->schedule_cache_flush();
204
- }
205
 
206
- /**
207
- * Plugin deactivation function.
208
- */
209
- public function deactivation() {
210
- // delete default options
211
- if ( $this->options['general']['deactivation_delete'] ) {
212
- delete_option( 'post_views_counter_settings_general' );
213
- delete_option( 'post_views_counter_settings_display' );
214
 
215
- global $wpdb;
216
 
217
- // delete table from database
218
- $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'post_views' );
219
- }
220
 
221
- // remove schedule
222
- wp_clear_scheduled_hook( 'pvc_reset_counts' );
223
- remove_action( 'pvc_reset_counts', array( Post_Views_Counter()->cron, 'reset_counts' ) );
224
 
225
- $this->remove_cache_flush();
226
- }
227
 
228
- /**
229
- * Schedule cache flushing if it's not already scheduled.
230
- */
231
- public function schedule_cache_flush( $forced = true ) {
232
- if ( $forced || ! wp_next_scheduled( 'pvc_flush_cached_counts' ) ) {
233
- wp_schedule_event( time(), 'post_views_counter_flush_interval', 'pvc_flush_cached_counts' );
 
 
 
234
  }
235
- }
236
 
237
- /**
238
- * Remove scheduled cache flush and the corresponding action.
239
- */
240
- public function remove_cache_flush() {
241
- wp_clear_scheduled_hook( 'pvc_flush_cached_counts' );
242
- remove_action( 'pvc_flush_cached_counts', array( Post_Views_Counter()->cron, 'flush_cached_counts' ) );
243
- }
244
 
245
- /**
246
- * Load text domain.
247
- */
248
- public function load_textdomain() {
249
- load_plugin_textdomain( 'post-views-counter', false, POST_VIEWS_COUNTER_REL_PATH . 'languages/' );
250
- }
251
 
252
- /**
253
- * Load pluggable template functions.
254
- */
255
- public function load_pluggable_functions() {
256
- include_once( POST_VIEWS_COUNTER_PATH . 'includes/functions.php' );
257
- }
258
 
259
- /**
260
- * Enqueue admin scripts and styles.
261
- */
262
- public function admin_scripts_styles( $page ) {
263
- wp_register_style(
 
 
 
264
  'pvc-admin', POST_VIEWS_COUNTER_URL . '/css/admin.css'
265
- );
266
 
267
- wp_register_script(
268
  'pvc-admin-settings', POST_VIEWS_COUNTER_URL . '/js/admin-settings.js', array( 'jquery' ), $this->defaults['version']
269
- );
270
 
271
- wp_register_script(
272
  'pvc-admin-post', POST_VIEWS_COUNTER_URL . '/js/admin-post.js', array( 'jquery' ), $this->defaults['version']
273
- );
274
-
275
- wp_register_script(
276
  'pvc-admin-quick-edit', POST_VIEWS_COUNTER_URL . '/js/admin-quick-edit.js', array( 'jquery', 'inline-edit-post' ), $this->defaults['version']
277
- );
278
 
279
- // load on PVC settings page
280
- if ( $page === 'settings_page_post-views-counter' ) {
281
 
282
- wp_enqueue_script( 'pvc-admin-settings' );
283
 
284
- wp_localize_script(
285
  'pvc-admin-settings', 'pvcArgsSettings', array(
286
- 'resetToDefaults' => __( 'Are you sure you want to reset these settings to defaults?', 'post-views-counter' )
287
  )
288
- );
289
 
290
- wp_enqueue_style( 'pvc-admin' );
291
 
292
- // load on single post page
293
- } elseif ( $page === 'post.php' || $page === 'post-new.php' ) {
294
 
295
- $post_types = Post_Views_Counter()->options['general']['post_types_count'];
296
 
297
- global $post_type;
298
 
299
- if ( ! in_array( $post_type, (array) $post_types ) )
300
- return;
301
-
302
- wp_enqueue_style( 'pvc-admin' );
303
- wp_enqueue_script( 'pvc-admin-post' );
304
- } elseif ( $page === 'edit.php' ) {
305
- $post_types = Post_Views_Counter()->options['general']['post_types_count'];
306
-
307
- global $post_type;
308
 
309
- if ( ! in_array( $post_type, (array) $post_types ) )
310
- return;
 
 
311
 
312
- wp_enqueue_style( 'pvc-admin' );
313
- wp_enqueue_script( 'pvc-admin-quick-edit' );
 
 
 
 
 
 
314
  }
315
- }
316
-
317
- /**
318
- * Add links to plugin support forum.
319
- */
320
- public function plugin_extend_links( $links, $file ) {
321
 
322
- if ( ! current_user_can( 'install_plugins' ) )
323
- return $links;
 
 
 
 
 
 
324
 
325
- $plugin = plugin_basename( __FILE__ );
 
326
 
327
- if ( $file == $plugin ) {
328
- return array_merge(
 
 
329
  $links, array( sprintf( '<a href="http://www.dfactory.eu/support/forum/post-views-counter/" target="_blank">%s</a>', __( 'Support', 'post-views-counter' ) ) )
330
- );
 
 
 
331
  }
332
 
333
- return $links;
334
- }
 
 
 
 
 
 
 
 
 
335
 
336
- /**
337
- * Add link to settings page.
338
- */
339
- public function plugin_settings_link( $links, $file ) {
340
- if ( ! is_admin() || ! current_user_can( 'manage_options' ) )
341
- return $links;
342
 
343
- static $plugin;
344
 
345
- $plugin = plugin_basename( __FILE__ );
 
346
 
347
- if ( $file == $plugin ) {
348
- $settings_link = sprintf( '<a href="%s">%s</a>', admin_url( 'options-general.php' ) . '?page=post-views-counter', __( 'Settings', 'post-views-counter' ) );
349
 
350
- array_unshift( $links, $settings_link );
351
  }
352
 
353
- return $links;
354
  }
355
 
356
- }
357
-
358
  endif; // end if class_exists check
359
 
360
  /**
@@ -372,4 +392,4 @@ function Post_Views_Counter() {
372
  return $instance;
373
  }
374
 
375
- Post_Views_Counter();
2
  /*
3
  Plugin Name: Post Views Counter
4
  Description: Forget WP-PostViews. Display how many times a post, page or custom post type had been viewed in a simple, fast and reliable way.
5
+ Version: 1.2.4
6
  Author: dFactory
7
  Author URI: http://www.dfactory.eu/
8
  Plugin URI: http://www.dfactory.eu/plugins/post-views-counter/
23
 
24
  // exit if accessed directly
25
  if ( ! defined( 'ABSPATH' ) )
26
+ exit;
27
 
28
  if ( ! class_exists( 'Post_Views_Counter' ) ) :
29
 
30
+ /**
31
+ * Post Views Counter final class.
32
+ *
33
+ * @class Post_Views_Counter
34
+ * @version 1.2.4
35
+ */
36
+ final class Post_Views_Counter {
37
+
38
+ private static $instance;
39
+ public $options;
40
+ public $defaults = array(
41
+ 'general' => array(
42
+ 'post_types_count' => array( 'post' ),
43
+ 'counter_mode' => 'php',
44
+ 'post_views_column' => true,
45
+ 'time_between_counts' => array(
46
+ 'number' => 24,
47
+ 'type' => 'hours'
48
+ ),
49
+ 'reset_counts' => array(
50
+ 'number' => 30,
51
+ 'type' => 'days'
52
+ ),
53
+ 'flush_interval' => array(
54
+ 'number' => 0,
55
+ 'type' => 'minutes'
56
+ ),
57
+ 'exclude' => array(
58
+ 'groups' => array(),
59
+ 'roles' => array()
60
+ ),
61
+ 'exclude_ips' => array(),
62
+ 'restrict_edit_views' => false,
63
+ 'deactivation_delete' => false,
64
+ 'cron_run' => true,
65
+ 'cron_update' => true
 
 
 
 
 
 
 
 
66
  ),
67
+ 'display' => array(
68
+ 'label' => 'Post Views:',
69
+ 'post_types_display' => array( 'post' ),
70
+ 'page_types_display' => array( 'singular' ),
71
+ 'restrict_display' => array(
72
+ 'groups' => array(),
73
+ 'roles' => array()
74
+ ),
75
+ 'position' => 'after',
76
+ 'display_style' => array(
77
+ 'icon' => true,
78
+ 'text' => true
79
+ ),
80
+ 'link_to_post' => true,
81
+ 'icon_class' => 'dashicons-chart-bar'
82
  ),
83
+ 'version' => '1.2.4'
84
+ );
 
 
 
85
 
86
+ /**
87
+ * Disable object clone.
88
+ */
89
+ private function __clone() {
90
+
91
+ }
92
 
93
+ /**
94
+ * Disable unserializing of the class.
95
+ */
96
+ private function __wakeup() {
97
+
98
+ }
99
 
100
+ /**
101
+ * Main plugin instance,
102
+ * Insures that only one instance of the plugin exists in memory at one time.
103
+ *
104
+ * @return object
105
+ */
106
+ public static function instance() {
107
+ if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Post_Views_Counter ) ) {
108
+ self::$instance = new Post_Views_Counter;
109
+ self::$instance->define_constants();
110
+
111
+ add_action( 'plugins_loaded', array( self::$instance, 'load_textdomain' ) );
112
+
113
+ self::$instance->includes();
114
+ self::$instance->update = new Post_Views_Counter_Update();
115
+ self::$instance->settings = new Post_Views_Counter_Settings();
116
+ self::$instance->query = new Post_Views_Counter_Query();
117
+ self::$instance->cron = new Post_Views_Counter_Cron();
118
+ self::$instance->counter = new Post_Views_Counter_Counter();
119
+ self::$instance->columns = new Post_Views_Counter_Columns();
120
+ self::$instance->crawler_detect = new Post_Views_Counter_Crawler_Detect();
121
+ self::$instance->frontend = new Post_Views_Counter_Frontend();
122
+ self::$instance->dashboard = new Post_Views_Counter_Dashboard();
123
+ self::$instance->widgets = new Post_Views_Counter_Widgets();
124
+ }
125
+ return self::$instance;
126
  }
 
 
127
 
128
+ /**
129
+ * Setup plugin constants.
130
+ *
131
+ * @return void
132
+ */
133
+ private function define_constants() {
134
+ define( 'POST_VIEWS_COUNTER_URL', plugins_url( '', __FILE__ ) );
135
+ define( 'POST_VIEWS_COUNTER_PATH', plugin_dir_path( __FILE__ ) );
136
+ define( 'POST_VIEWS_COUNTER_REL_PATH', dirname( plugin_basename( __FILE__ ) ) . '/' );
137
+ }
138
 
139
+ /**
140
+ * Include required files.
141
+ *
142
+ * @return void
143
+ */
144
+ private function includes() {
145
+ include_once( POST_VIEWS_COUNTER_PATH . 'includes/update.php' );
146
+ include_once( POST_VIEWS_COUNTER_PATH . 'includes/settings.php' );
147
+ include_once( POST_VIEWS_COUNTER_PATH . 'includes/columns.php' );
148
+ include_once( POST_VIEWS_COUNTER_PATH . 'includes/query.php' );
149
+ include_once( POST_VIEWS_COUNTER_PATH . 'includes/cron.php' );
150
+ include_once( POST_VIEWS_COUNTER_PATH . 'includes/counter.php' );
151
+ include_once( POST_VIEWS_COUNTER_PATH . 'includes/crawler-detect.php' );
152
+ include_once( POST_VIEWS_COUNTER_PATH . 'includes/frontend.php' );
153
+ include_once( POST_VIEWS_COUNTER_PATH . 'includes/dashboard.php' );
154
+ include_once( POST_VIEWS_COUNTER_PATH . 'includes/widgets.php' );
155
+ }
156
 
157
+ /**
158
+ * Class constructor.
159
+ *
160
+ * @return void
161
+ */
162
+ public function __construct() {
163
+ register_activation_hook( __FILE__, array( $this, 'activation' ) );
164
+ register_deactivation_hook( __FILE__, array( $this, 'deactivation' ) );
165
+
166
+ // settings
167
+ $this->options = array(
168
+ 'general' => array_merge( $this->defaults['general'], get_option( 'post_views_counter_settings_general', $this->defaults['general'] ) ),
169
+ 'display' => array_merge( $this->defaults['display'], get_option( 'post_views_counter_settings_display', $this->defaults['display'] ) )
170
+ );
171
 
172
+ // actions
173
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts_styles' ) );
174
+ add_action( 'wp_loaded', array( $this, 'load_pluggable_functions' ), 10 );
175
 
176
+ // filters
177
+ add_filter( 'plugin_row_meta', array( $this, 'plugin_extend_links' ), 10, 2 );
178
+ add_filter( 'plugin_action_links', array( $this, 'plugin_settings_link' ), 10, 2 );
179
+ }
180
 
181
+ /**
182
+ * Plugin activation function.
183
+ */
184
+ public function activation() {
185
+ global $wpdb, $charset_collate;
186
+
187
+ // required for dbdelta
188
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
189
+
190
+ // create post views table
191
+ dbDelta( '
192
+ CREATE TABLE IF NOT EXISTS ' . $wpdb->prefix . 'post_views (
193
+ id bigint unsigned NOT NULL,
194
+ type tinyint(1) unsigned NOT NULL,
195
+ period varchar(8) NOT NULL,
196
+ count bigint unsigned NOT NULL,
197
+ PRIMARY KEY (type, period, id),
198
+ UNIQUE INDEX id_period (id, period) USING BTREE,
199
+ INDEX type_period_count (type, period, count) USING BTREE
200
+ ) ' . $charset_collate . ';'
201
+ );
202
 
203
+ // add default options
204
+ add_option( 'post_views_counter_settings_general', $this->defaults['general'], '', 'no' );
205
+ add_option( 'post_views_counter_settings_display', $this->defaults['display'], '', 'no' );
206
+ add_option( 'post_views_counter_version', $this->defaults['version'], '', 'no' );
207
 
208
+ // schedule cache flush
209
+ $this->schedule_cache_flush();
210
+ }
211
 
212
+ /**
213
+ * Plugin deactivation function.
214
+ */
215
+ public function deactivation() {
216
+ // delete default options
217
+ if ( $this->options['general']['deactivation_delete'] ) {
218
+ delete_option( 'post_views_counter_settings_general' );
219
+ delete_option( 'post_views_counter_settings_display' );
220
 
221
+ global $wpdb;
222
 
223
+ // delete table from database
224
+ $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'post_views' );
225
+ }
226
 
227
+ // remove schedule
228
+ wp_clear_scheduled_hook( 'pvc_reset_counts' );
229
+ remove_action( 'pvc_reset_counts', array( Post_Views_Counter()->cron, 'reset_counts' ) );
230
 
231
+ $this->remove_cache_flush();
232
+ }
233
 
234
+ /**
235
+ * Schedule cache flushing if it's not already scheduled.
236
+ *
237
+ * @param bool $forced
238
+ */
239
+ public function schedule_cache_flush( $forced = true ) {
240
+ if ( $forced || ! wp_next_scheduled( 'pvc_flush_cached_counts' ) ) {
241
+ wp_schedule_event( time(), 'post_views_counter_flush_interval', 'pvc_flush_cached_counts' );
242
+ }
243
  }
 
244
 
245
+ /**
246
+ * Remove scheduled cache flush and the corresponding action.
247
+ */
248
+ public function remove_cache_flush() {
249
+ wp_clear_scheduled_hook( 'pvc_flush_cached_counts' );
250
+ remove_action( 'pvc_flush_cached_counts', array( Post_Views_Counter()->cron, 'flush_cached_counts' ) );
251
+ }
252
 
253
+ /**
254
+ * Load text domain.
255
+ */
256
+ public function load_textdomain() {
257
+ load_plugin_textdomain( 'post-views-counter', false, POST_VIEWS_COUNTER_REL_PATH . 'languages/' );
258
+ }
259
 
260
+ /**
261
+ * Load pluggable template functions.
262
+ */
263
+ public function load_pluggable_functions() {
264
+ include_once( POST_VIEWS_COUNTER_PATH . 'includes/functions.php' );
265
+ }
266
 
267
+ /**
268
+ * Enqueue admin scripts and styles.
269
+ *
270
+ * @global string $post_type
271
+ * @param string $page
272
+ */
273
+ public function admin_scripts_styles( $page ) {
274
+ wp_register_style(
275
  'pvc-admin', POST_VIEWS_COUNTER_URL . '/css/admin.css'
276
+ );
277
 
278
+ wp_register_script(
279
  'pvc-admin-settings', POST_VIEWS_COUNTER_URL . '/js/admin-settings.js', array( 'jquery' ), $this->defaults['version']
280
+ );
281
 
282
+ wp_register_script(
283
  'pvc-admin-post', POST_VIEWS_COUNTER_URL . '/js/admin-post.js', array( 'jquery' ), $this->defaults['version']
284
+ );
285
+
286
+ wp_register_script(
287
  'pvc-admin-quick-edit', POST_VIEWS_COUNTER_URL . '/js/admin-quick-edit.js', array( 'jquery', 'inline-edit-post' ), $this->defaults['version']
288
+ );
289
 
290
+ // load on PVC settings page
291
+ if ( $page === 'settings_page_post-views-counter' ) {
292
 
293
+ wp_enqueue_script( 'pvc-admin-settings' );
294
 
295
+ wp_localize_script(
296
  'pvc-admin-settings', 'pvcArgsSettings', array(
297
+ 'resetToDefaults' => __( 'Are you sure you want to reset these settings to defaults?', 'post-views-counter' )
298
  )
299
+ );
300
 
301
+ wp_enqueue_style( 'pvc-admin' );
302
 
303
+ // load on single post page
304
+ } elseif ( $page === 'post.php' || $page === 'post-new.php' ) {
305
 
306
+ $post_types = Post_Views_Counter()->options['general']['post_types_count'];
307
 
308
+ global $post_type;
309
 
310
+ if ( ! in_array( $post_type, (array) $post_types ) )
311
+ return;
 
 
 
 
 
 
 
312
 
313
+ wp_enqueue_style( 'pvc-admin' );
314
+ wp_enqueue_script( 'pvc-admin-post' );
315
+ } elseif ( $page === 'edit.php' ) {
316
+ $post_types = Post_Views_Counter()->options['general']['post_types_count'];
317
 
318
+ global $post_type;
319
+
320
+ if ( ! in_array( $post_type, (array) $post_types ) )
321
+ return;
322
+
323
+ wp_enqueue_style( 'pvc-admin' );
324
+ wp_enqueue_script( 'pvc-admin-quick-edit' );
325
+ }
326
  }
 
 
 
 
 
 
327
 
328
+ /**
329
+ * Add links to plugin support forum.
330
+ *
331
+ * @param array $links
332
+ * @param string $file
333
+ * @return array
334
+ */
335
+ public function plugin_extend_links( $links, $file ) {
336
 
337
+ if ( ! current_user_can( 'install_plugins' ) )
338
+ return $links;
339
 
340
+ $plugin = plugin_basename( __FILE__ );
341
+
342
+ if ( $file == $plugin ) {
343
+ return array_merge(
344
  $links, array( sprintf( '<a href="http://www.dfactory.eu/support/forum/post-views-counter/" target="_blank">%s</a>', __( 'Support', 'post-views-counter' ) ) )
345
+ );
346
+ }
347
+
348
+ return $links;
349
  }
350
 
351
+ /**
352
+ * Add link to settings page.
353
+ *
354
+ * @staticvar string $plugin
355
+ * @param array $links
356
+ * @param string $file
357
+ * @return array
358
+ */
359
+ public function plugin_settings_link( $links, $file ) {
360
+ if ( ! is_admin() || ! current_user_can( 'manage_options' ) )
361
+ return $links;
362
 
363
+ static $plugin;
 
 
 
 
 
364
 
365
+ $plugin = plugin_basename( __FILE__ );
366
 
367
+ if ( $file == $plugin ) {
368
+ $settings_link = sprintf( '<a href="%s">%s</a>', admin_url( 'options-general.php' ) . '?page=post-views-counter', __( 'Settings', 'post-views-counter' ) );
369
 
370
+ array_unshift( $links, $settings_link );
371
+ }
372
 
373
+ return $links;
374
  }
375
 
 
376
  }
377
 
 
 
378
  endif; // end if class_exists check
379
 
380
  /**
392
  return $instance;
393
  }
394
 
395
+ Post_Views_Counter();
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: dfactory
3
  Donate link: http://www.dfactory.eu/
4
  Tags: counter, hits, postviews, post views, views, count
5
  Requires at least: 4.0.0
6
- Tested up to: 4.6
7
- Stable tag: 1.2.3
8
  License: MIT License
9
  License URI: http://opensource.org/licenses/MIT
10
 
@@ -58,6 +58,10 @@ No questions yet.
58
 
59
  == Changelog ==
60
 
 
 
 
 
61
  = 1.2.3 =
62
  * New: IP wildcard support
63
  * Tweak: Delete post_views database table on deactivation
@@ -136,6 +140,6 @@ Initial release
136
 
137
  == Upgrade Notice ==
138
 
139
- = 1.2.3 =
140
- * New: IP wildcard support
141
- * Tweak: Delete post_views database table on deactivation
3
  Donate link: http://www.dfactory.eu/
4
  Tags: counter, hits, postviews, post views, views, count
5
  Requires at least: 4.0.0
6
+ Tested up to: 4.7
7
+ Stable tag: 1.2.4
8
  License: MIT License
9
  License URI: http://opensource.org/licenses/MIT
10
 
58
 
59
  == Changelog ==
60
 
61
+ = 1.2.4 =
62
+ * New: Advanced crawler detection
63
+ * Tweak: Chart.js script update to 2.4.0
64
+
65
  = 1.2.3 =
66
  * New: IP wildcard support
67
  * Tweak: Delete post_views database table on deactivation
140
 
141
  == Upgrade Notice ==
142
 
143
+ = 1.2.4 =
144
+ * New: Advanced crawler detection
145
+ * Tweak: Chart.js script update to 2.4.0