diff --git a/includes/admin/admin.php b/includes/admin/admin.php index 252020e..7b57ea2 100644 --- a/includes/admin/admin.php +++ b/includes/admin/admin.php @@ -31,28 +31,26 @@ function tptn_add_admin_pages_links() { global $tptn_settings_page, $tptn_settings_tools_help, $tptn_settings_popular_posts, $tptn_settings_popular_posts_daily, $tptn_settings_exim_help; - $tptn_settings_page = add_menu_page( esc_html__( 'Top 10 Settings', 'top-10' ), esc_html__( 'Top 10', 'top-10' ), 'manage_options', 'tptn_options_page', 'tptn_options_page', 'dashicons-editor-ol' ); - add_action( "load-$tptn_settings_page", 'tptn_settings_help' ); // Load the settings contextual help. - - $plugin_page = add_submenu_page( 'tptn_options_page', esc_html__( 'Top 10 Settings', 'top-10' ), esc_html__( 'Settings', 'top-10' ), 'manage_options', 'tptn_options_page', 'tptn_options_page' ); + $tptn_settings_page = add_submenu_page( 'tptn_dashboard', esc_html__( 'Top 10 Settings', 'top-10' ), esc_html__( 'Settings', 'top-10' ), 'manage_options', 'tptn_options_page', 'tptn_options_page' ); + add_action( "load-$tptn_settings_page", 'tptn_settings_help' ); // Initialise Top 10 Statistics pages. $tptn_stats_screen = new Top_Ten_Statistics(); - $tptn_settings_popular_posts = add_submenu_page( 'tptn_options_page', __( 'Top 10 Popular Posts', 'top-10' ), __( 'Popular Posts', 'top-10' ), 'manage_options', 'tptn_popular_posts', array( $tptn_stats_screen, 'plugin_settings_page' ) ); + $tptn_settings_popular_posts = add_submenu_page( 'tptn_dashboard', __( 'Top 10 Popular Posts', 'top-10' ), __( 'Popular Posts', 'top-10' ), 'manage_options', 'tptn_popular_posts', array( $tptn_stats_screen, 'plugin_settings_page' ) ); add_action( "load-$tptn_settings_popular_posts", array( $tptn_stats_screen, 'screen_option' ) ); - $tptn_settings_popular_posts_daily = add_submenu_page( 'tptn_options_page', __( 'Top 10 Daily Popular Posts', 'top-10' ), __( 'Daily Popular Posts', 'top-10' ), 'manage_options', 'tptn_popular_posts&orderby=daily_count&order=desc', array( $tptn_stats_screen, 'plugin_settings_page' ) ); + $tptn_settings_popular_posts_daily = add_submenu_page( 'tptn_dashboard', __( 'Top 10 Daily Popular Posts', 'top-10' ), __( 'Daily Popular Posts', 'top-10' ), 'manage_options', 'tptn_popular_posts&orderby=daily_count&order=desc', array( $tptn_stats_screen, 'plugin_settings_page' ) ); add_action( "load-$tptn_settings_popular_posts_daily", array( $tptn_stats_screen, 'screen_option' ) ); // Add links to Tools pages. - $tptn_settings_tools_help = add_submenu_page( 'tptn_options_page', esc_html__( 'Top 10 Tools', 'top-10' ), esc_html__( 'Tools', 'top-10' ), 'manage_options', 'tptn_tools_page', 'tptn_tools_page' ); + $tptn_settings_tools_help = add_submenu_page( 'tptn_dashboard', esc_html__( 'Top 10 Tools', 'top-10' ), esc_html__( 'Tools', 'top-10' ), 'manage_options', 'tptn_tools_page', 'tptn_tools_page' ); add_action( "load-$tptn_settings_tools_help", 'tptn_settings_tools_help' ); - $tptn_settings_exim_help = add_submenu_page( 'tptn_options_page', esc_html__( 'Top 10 Import Export Tables', 'top-10' ), esc_html__( 'Import/Export', 'top-10' ), 'manage_options', 'tptn_exim_page', 'tptn_exim_page' ); + $tptn_settings_exim_help = add_submenu_page( 'tptn_dashboard', esc_html__( 'Top 10 Import Export Tables', 'top-10' ), esc_html__( 'Import/Export', 'top-10' ), 'manage_options', 'tptn_exim_page', 'tptn_exim_page' ); add_action( "load-$tptn_settings_exim_help", 'tptn_settings_exim_help' ); } -add_action( 'admin_menu', 'tptn_add_admin_pages_links' ); +add_action( 'admin_menu', 'tptn_add_admin_pages_links', 11 ); /** @@ -106,7 +104,7 @@ function tptn_tax_id( $value, $name, $id ) { */ function tptn_admin_footer( $footer_text ) { - if ( get_current_screen()->parent_base === 'tptn_options_page' ) { + if ( get_current_screen()->parent_base === 'tptn_dashboard' ) { $text = sprintf( /* translators: 1: Top 10 website, 2: Plugin reviews link. */ @@ -156,7 +154,7 @@ function tptn_plugin_actions_links( $links ) { return array_merge( array( - 'settings' => '' . __( 'Settings', 'top-10' ) . '', + 'settings' => '' . __( 'Settings', 'top-10' ) . '', ), $links ); @@ -217,7 +215,6 @@ function tptn_load_admin_scripts( $hook ) { wp_register_script( 'top-ten-admin-js', TOP_TEN_PLUGIN_URL . 'includes/admin/js/admin-scripts.min.js', array( 'jquery', 'jquery-ui-tabs', 'jquery-ui-datepicker' ), '1.0', true ); wp_register_script( 'top-ten-suggest-js', TOP_TEN_PLUGIN_URL . 'includes/admin/js/top-10-suggest.min.js', array( 'jquery', 'jquery-ui-autocomplete' ), '1.0', true ); - wp_register_style( 'tptn-admin-customizer-css', TOP_TEN_PLUGIN_URL . 'includes/admin/css/top-10-customizer.min.css', diff --git a/includes/admin/class-top-ten-dashboard.php b/includes/admin/class-top-ten-dashboard.php new file mode 100644 index 0000000..9df236f --- /dev/null +++ b/includes/admin/class-top-ten-dashboard.php @@ -0,0 +1,529 @@ + +
+ | + |
' . sprintf( __( 'For more information or how to get support visit the WebberZone support site.', 'top-10' ), esc_url( 'https://webberzone.com/support/' ) ) . '
' . + /* translators: 1: Forum link. */ + '' . sprintf( __( 'Support queries should be posted in the WordPress.org support forums.', 'top-10' ), esc_url( 'https://wordpress.org/support/plugin/top-10' ) ) . '
' . + '' . sprintf( + /* translators: 1: Github Issues link, 2: Github page. */ + __( 'Post an issue on GitHub (bug reports only).', 'top-10' ), + esc_url( 'https://github.com/WebberZone/top-10/issues' ), + esc_url( 'https://github.com/WebberZone/top-10' ) + ) . '
' + ); + + $screen->add_help_tab( + array( + 'id' => 'tptn-dashboard-general', + 'title' => __( 'General', 'top-10' ), + 'content' => + '' . __( 'This screen displays the historical traffic on your site.', 'top-10' ) . '
' . + /* translators: 1: Constant holding number of days data is stored. */ + '' . sprintf( __( 'The data is pulled from the daily tables in the database. If you have enabled maintenance then the amount of historical data that is available will be limited to %d days.', 'top-10' ), TOP_TEN_STORE_DATA ) . '
' . + '' . __( 'You can change this by setting the constant TOP_TEN_STORE_DATA to the number of days of your choice in your wp-config.php.', 'top-10' ) . '
', + ) + ); + + } +} + +/** + * Function to initialise stats page. + * + * @since 3.0.0 + */ +function tptn_load_dashboard() { + Top_Ten_Dashboard::get_instance(); +} +add_action( 'plugins_loaded', 'tptn_load_dashboard' ); diff --git a/includes/admin/default-settings.php b/includes/admin/default-settings.php index 186dc89..93698d2 100644 --- a/includes/admin/default-settings.php +++ b/includes/admin/default-settings.php @@ -688,7 +688,8 @@ function tptn_settings_maintenance() { 'cron_on' => array( 'id' => 'cron_on', 'name' => esc_html__( 'Enable scheduled maintenance', 'top-10' ), - 'desc' => esc_html__( 'Cleaning the database at regular intervals could improve performance, especially on high traffic blogs. Enabling maintenance will automatically delete entries older than 90 days in the daily tables.', 'top-10' ), + /* translators: 1: Constant holding number of days data is stored. */ + 'desc' => sprintf( esc_html__( 'Cleaning the database at regular intervals could improve performance, especially on high traffic blogs. Enabling maintenance will automatically delete entries older than %d days in the daily tables.', 'top-10' ), TOP_TEN_STORE_DATA ), 'type' => 'checkbox', 'options' => false, ), @@ -900,11 +901,11 @@ function tptn_get_styles() { ); /** - * Filter the array containing the types of trackers to add your own. + * Filter the array containing the types of styles to add your own. * * @since 2.5.0 * - * @param string $trackers Different trackers. + * @param string $styles Different styles. */ return apply_filters( 'tptn_get_styles', $styles ); } diff --git a/includes/admin/js/chart-data.js b/includes/admin/js/chart-data.js new file mode 100644 index 0000000..ff9de45 --- /dev/null +++ b/includes/admin/js/chart-data.js @@ -0,0 +1,115 @@ +// Function to clear the cache. +function updateChart() { + jQuery.post(ajaxurl, { + action: 'tptn_chart_data', + security: tptn_chart_data.security, + from_date: jQuery('#datepicker-from').val(), + to_date: jQuery('#datepicker-to').val() + }, function (data) { + var date = []; + var visits = []; + + for(var i in data) { + date.push(data[i].date); + visits.push(data[i].visits); + } + console.log(date); + console.log(visits); + window.top10chart.data.labels = date; + window.top10chart.data.datasets.forEach((dataset) => { + dataset.data = visits; + }); + window.top10chart.update(); + }, 'json'); +} + +jQuery(document).ready(function($) { + + $.ajax({ + type: 'POST', + dataType: 'json', + url: ajaxurl, + data: { + action: 'tptn_chart_data', + security: tptn_chart_data.security, + from_date: $('#datepicker-from').val(), + to_date: $('#datepicker-to').val() + }, + success: function(data) { + var date = []; + var visits = []; + + for(var i in data) { + date.push(data[i].date); + visits.push(data[i].visits); + } + + var ctx = $("#visits"); + var config = { + type: 'bar', + data: { + labels: date, + datasets : [ + { + label: tptn_chart_data.datasetlabel, + backgroundColor: '#70c4e1', + borderColor: '#70c4e1', + hoverBackgroundColor: '#ffbf00', + hoverBorderColor: '#ffbf00', + data: visits + } + ] + }, + plugins: [ChartDataLabels], + options: { + plugins: { + title: { + text: tptn_chart_data.charttitle, + display: true + }, + legend: { + display: false, + position: 'bottom' + }, + datalabels: { + color: '#000000', + anchor: 'end', + align: 'top' + } + }, + scales: { + x: { + type: 'time', + time: { + tooltipFormat: 'll', + unit: 'day', + displayFormats: { + day: 'DD MMM YY' + } + }, + scaleLabel: { + display: false, + labelString: 'Date' + } + }, + y: { + grace: '5%', + suggestedMin: 0, + scaleLabel: { + display: true, + labelString: tptn_chart_data.datasetlabel + } + } + }, + } + }; + + + window.top10chart = new Chart(ctx, config); + }, + error: function(data) { + console.log(data); + } + }); + +}); diff --git a/includes/admin/js/chart-data.min.js b/includes/admin/js/chart-data.min.js new file mode 100644 index 0000000..026b74c --- /dev/null +++ b/includes/admin/js/chart-data.min.js @@ -0,0 +1 @@ +function updateChart(){jQuery.post(ajaxurl,{action:"tptn_chart_data",security:tptn_chart_data.security,from_date:jQuery("#datepicker-from").val(),to_date:jQuery("#datepicker-to").val()},(function(data){var date=[],visits=[];for(var i in data)date.push(data[i].date),visits.push(data[i].visits);console.log(date),console.log(visits),window.top10chart.data.labels=date,window.top10chart.data.datasets.forEach(dataset=>{dataset.data=visits}),window.top10chart.update()}),"json")}jQuery(document).ready((function($){$.ajax({type:"POST",dataType:"json",url:ajaxurl,data:{action:"tptn_chart_data",security:tptn_chart_data.security,from_date:$("#datepicker-from").val(),to_date:$("#datepicker-to").val()},success:function(data){var date=[],visits=[];for(var i in data)date.push(data[i].date),visits.push(data[i].visits);var ctx=$("#visits"),config={type:"bar",data:{labels:date,datasets:[{label:tptn_chart_data.datasetlabel,backgroundColor:"#70c4e1",borderColor:"#70c4e1",hoverBackgroundColor:"#ffbf00",hoverBorderColor:"#ffbf00",data:visits}]},plugins:[ChartDataLabels],options:{plugins:{title:{text:tptn_chart_data.charttitle,display:!0},legend:{display:!1,position:"bottom"},datalabels:{color:"#000000",anchor:"end",align:"top"}},scales:{x:{type:"time",time:{tooltipFormat:"ll",unit:"day",displayFormats:{day:"DD MMM YY"}},scaleLabel:{display:!1,labelString:"Date"}},y:{grace:"5%",suggestedMin:0,scaleLabel:{display:!0,labelString:tptn_chart_data.datasetlabel}}}}};window.top10chart=new Chart(ctx,config)},error:function(data){console.log(data)}})})); \ No newline at end of file diff --git a/includes/admin/js/chart.min.js b/includes/admin/js/chart.min.js new file mode 100644 index 0000000..fbc93c6 --- /dev/null +++ b/includes/admin/js/chart.min.js @@ -0,0 +1,13 @@ +/*! + * Chart.js v3.1.0 + * https://www.chartjs.org + * (c) 2021 Chart.js Contributors + * Released under the MIT License + */ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Chart=e()}(this,(function(){"use strict";const t="undefined"==typeof window?function(t){return t()}:window.requestAnimationFrame;function e(e,i,n){const o=n||(t=>Array.prototype.slice.call(t));let s=!1,a=[];return function(...n){a=o(n),s||(s=!0,t.call(window,(()=>{s=!1,e.apply(i,a)})))}}function i(t,e){let i;return function(){return e?(clearTimeout(i),i=setTimeout(t,e)):t(),e}}const n=t=>"start"===t?"left":"end"===t?"right":"center",o=(t,e,i)=>"start"===t?e:"end"===t?i:(e+i)/2,s=(t,e,i)=>"right"===t?i:"center"===t?(e+i)/2:e;var a=new class{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,e,i,n){const o=e.listeners[n],s=e.duration;o.forEach((n=>n({chart:t,numSteps:s,currentStep:Math.min(i-e.start,s)})))}_refresh(){const e=this;e._request||(e._running=!0,e._request=t.call(window,(()=>{e._update(),e._request=null,e._running&&e._refresh()})))}_update(t=Date.now()){const e=this;let i=0;e._charts.forEach(((n,o)=>{if(!n.running||!n.items.length)return;const s=n.items;let a,r=s.length-1,l=!1;for(;r>=0;--r)a=s[r],a._active?(a._total>n.duration&&(n.duration=a._total),a.tick(t),l=!0):(s[r]=s[s.length-1],s.pop());l&&(o.draw(),e._notify(o,n,t,"progress")),s.length||(n.running=!1,e._notify(o,n,t,"complete")),i+=s.length})),e._lastDate=t,0===i&&(e._running=!1)}_getAnims(t){const e=this._charts;let i=e.get(t);return i||(i={running:!1,items:[],listeners:{complete:[],progress:[]}},e.set(t,i)),i}listen(t,e,i){this._getAnims(t).listeners[e].push(i)}add(t,e){e&&e.length&&this._getAnims(t).items.push(...e)}has(t){return this._getAnims(t).items.length>0}start(t){const e=this._charts.get(t);e&&(e.running=!0,e.start=Date.now(),e.duration=e.items.reduce(((t,e)=>Math.max(t,e._duration)),0),this._refresh())}running(t){if(!this._running)return!1;const e=this._charts.get(t);return!!(e&&e.running&&e.items.length)}stop(t){const e=this._charts.get(t);if(!e||!e.items.length)return;const i=e.items;let n=i.length-1;for(;n>=0;--n)i[n].cancel();e.items=[],this._notify(t,e,Date.now(),"complete")}remove(t){return this._charts.delete(t)}}; +/*! + * @kurkle/color v0.1.9 + * https://github.com/kurkle/color#readme + * (c) 2020 Jukka Kurkela + * Released under the MIT License + */const r={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},l="0123456789ABCDEF",c=t=>l[15&t],h=t=>l[(240&t)>>4]+l[15&t],d=t=>(240&t)>>4==(15&t);function u(t){var e=function(t){return d(t.r)&&d(t.g)&&d(t.b)&&d(t.a)}(t)?c:h;return t?"#"+e(t.r)+e(t.g)+e(t.b)+(t.a<255?e(t.a):""):t}function f(t){return t+.5|0}const g=(t,e,i)=>Math.max(Math.min(t,i),e);function p(t){return g(f(2.55*t),0,255)}function m(t){return g(f(255*t),0,255)}function x(t){return g(f(t/2.55)/100,0,1)}function b(t){return g(f(100*t),0,100)}const _=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;const y=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function v(t,e,i){const n=e*Math.min(i,1-i),o=(e,o=(e+t/30)%12)=>i-n*Math.max(Math.min(o-3,9-o,1),-1);return[o(0),o(8),o(4)]}function w(t,e,i){const n=(n,o=(n+t/60)%6)=>i-i*e*Math.max(Math.min(o,4-o,1),0);return[n(5),n(3),n(1)]}function M(t,e,i){const n=v(t,1,.5);let o;for(e+i>1&&(o=1/(e+i),e*=o,i*=o),o=0;o<3;o++)n[o]*=1-e-i,n[o]+=e;return n}function k(t){const e=t.r/255,i=t.g/255,n=t.b/255,o=Math.max(e,i,n),s=Math.min(e,i,n),a=(o+s)/2;let r,l,c;return o!==s&&(c=o-s,l=a>.5?c/(2-o-s):c/(o+s),r=o===e?(i-n)/c+(i=0;--u)if(!m()){i.updateRangeFromParsed(c,t,g,l);break}return c}getAllParsedValues(t){const e=this._cachedMeta._parsed,i=[];let n,o,s;for(n=0,o=e.length;n0?e.y:t.y}}function gn(t,e,i,n){const o={x:t.cp2x,y:t.cp2y},s={x:e.cp1x,y:e.cp1y},a=un(t,o,i),r=un(o,s,i),l=un(s,e,i),c=un(a,r,i),h=un(r,l,i);return un(c,h,i)}function pn(t,e,i){return t?function(t,e){return{x:i=>t+t+e-i,setWidth(t){e=t},textAlign:t=>"center"===t?t:"right"===t?"left":"right",xPlus:(t,e)=>t-e,leftForLtr:(t,e)=>t-e}}(e,i):{x:t=>t,setWidth(t){},textAlign:t=>t,xPlus:(t,e)=>t+e,leftForLtr:(t,e)=>t}}function mn(t,e){let i,n;"ltr"!==e&&"rtl"!==e||(i=t.canvas.style,n=[i.getPropertyValue("direction"),i.getPropertyPriority("direction")],i.setProperty("direction",e,"important"),t.prevTextDirection=n)}function xn(t,e){void 0!==e&&(delete t.prevTextDirection,t.canvas.style.setProperty("direction",e[0],e[1]))}function bn(t){return"angle"===t?{between:Wt,compare:Vt,normalize:Bt}:{between:(t,e,i)=>t>=Math.min(e,i)&&t<=Math.max(i,e),compare:(t,e)=>t-e,normalize:t=>t}}function _n({start:t,end:e,count:i,loop:n,style:o}){return{start:t%i,end:e%i,loop:n&&(e-t+1)%i==0,style:o}}function yn(t,e,i){if(!i)return[t];const{property:n,start:o,end:s}=i,a=e.length,{compare:r,between:l,normalize:c}=bn(n),{start:h,end:d,loop:u,style:f}=function(t,e,i){const{property:n,start:o,end:s}=i,{between:a,normalize:r}=bn(n),l=e.length;let c,h,{start:d,end:u,loop:f}=t;if(f){for(d+=l,u+=l,c=0,h=l;cWt(t,r,l)?1:Math.max(e,e*i,n,n*i),g=(t,e,n)=>Wt(t,r,l)?-1:Math.min(e,e*i,n,n*i),p=f(0,c,d),m=f(wt,h,u),x=g(xt,c,d),b=g(xt+wt,h,u);n=(p-x)/2,o=(m-b)/2,s=-(p+x)/2,a=-(m+b)/2}return{ratioX:n,ratioY:o,offsetX:s,offsetY:a}}(d,h,l),m=(n.width-a)/u,x=(n.height-a)/f,b=Math.max(Math.min(m,x)/2,0),_=Z(e.options.radius,b),y=(_-Math.max(_*l,0))/e._getVisibleDatasetWeightTotal();e.offsetX=g*_,e.offsetY=p*_,o.total=e.calculateTotal(),e.outerRadius=_-y*e._getRingWeightOffset(e.index),e.innerRadius=Math.max(e.outerRadius-y*c,0),e.updateElements(s,0,s.length,t)}_circumference(t,e){const i=this,n=i.options,o=i._cachedMeta,s=i._getCircumference();return e&&n.animation.animateRotate||!this.chart.getDataVisibility(t)||null===o._parsed[t]?0:i.calculateCircumference(o._parsed[t]*s/bt)}updateElements(t,e,i,n){const o=this,s="reset"===n,a=o.chart,r=a.chartArea,l=a.options.animation,c=(r.left+r.right)/2,h=(r.top+r.bottom)/2,d=s&&l.animateScale,u=d?0:o.innerRadius,f=d?0:o.outerRadius,g=o.resolveDataElementOptions(e,n),p=o.getSharedOptions(g),m=o.includeOptions(n,p);let x,b=o._getRotation();for(x=0;x{const n=t.getDatasetMeta(0).controller.getStyle(i);return{text:e,fillStyle:n.backgroundColor,strokeStyle:n.borderColor,lineWidth:n.borderWidth,hidden:!t.getDataVisibility(i),index:i}})):[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.chart.update()}},tooltip:{callbacks:{title:()=>"",label(t){let e=t.label;const i=": "+t.formattedValue;return Y(e)?(e=e.slice(),e[0]+=i):e+=i,e}}}}};class co extends Ti{initialize(){this.enableOptionSharing=!0,super.initialize()}update(t){const e=this,i=e._cachedMeta,{dataset:n,data:o=[],_dataset:s}=i,a=e.chart._animationsDisabled;let{start:r,count:l}=function(t,e,i){const n=e.length;let o=0,s=n;if(t._sorted){const{iScale:a,_parsed:r}=t,l=a.axis,{min:c,max:h,minDefined:d,maxDefined:u}=a.getUserBounds();d&&(o=Nt(Math.min(ne(r,a.axis,c).lo,i?n:ne(e,l,a.getPixelForValue(c)).lo),0,n-1)),s=u?Nt(Math.max(ne(r,a.axis,h).hi+1,i?0:ne(e,l,a.getPixelForValue(h)).hi+1),o,n)-o:n-o}return{start:o,count:s}}(i,o,a);e._drawStart=r,e._drawCount=l,function(t){const{xScale:e,yScale:i,_scaleRanges:n}=t,o={xmin:e.min,xmax:e.max,ymin:i.min,ymax:i.max};if(!n)return t._scaleRanges=o,!0;const s=n.xmin!==e.min||n.xmax!==e.max||n.ymin!==i.min||n.ymax!==i.max;return Object.assign(n,o),s}(i)&&(r=0,l=o.length),n._decimated=!!s._decimated,n.points=o;const c=e.resolveDatasetElementOptions(t);e.options.showLine||(c.borderWidth=0),c.segment=e.options.segment,e.updateElement(n,void 0,{animated:!a,options:c},t),e.updateElements(o,r,l,t)}updateElements(t,e,i,n){const o=this,s="reset"===n,{xScale:a,yScale:r,_stacked:l}=o._cachedMeta,c=o.resolveDataElementOptions(e,n),h=o.getSharedOptions(c),d=o.includeOptions(n,h),u=o.options.spanGaps,f=Ot(u)?u:Number.POSITIVE_INFINITY,g=o.chart._animationsDisabled||s||"none"===n;let p=e>0&&o.getParsed(e-1);for(let c=e;c0!==t))?(t.beginPath(),t.fillStyle=o.multiKeyBackground,ee(t,{x:e,y:g,w:c,h:l,radius:s}),t.fill(),t.stroke(),t.fillStyle=a.backgroundColor,t.beginPath(),ee(t,{x:i,y:g+1,w:c-2,h:l-2,radius:s}),t.fill()):(t.fillStyle=o.multiKeyBackground,t.fillRect(e,g,c,l),t.strokeRect(e,g,c,l),t.fillStyle=a.backgroundColor,t.fillRect(i,g+1,c-2,l-2))}t.fillStyle=s.labelTextColors[i]}drawBody(t,e,i){const n=this,{body:o}=n,{bodySpacing:s,bodyAlign:a,displayColors:r,boxHeight:l,boxWidth:c}=i,h=Fe(i.bodyFont);let d=h.lineHeight,u=0;const f=pn(i.rtl,n.x,n.width),g=function(i){e.fillText(i,f.x(t.x+u),t.y+d/2),t.y+=d+s},p=f.textAlign(a);let m,x,b,_,y,v,w;for(e.textAlign=a,e.textBaseline="middle",e.font=h.string,t.x=vs(n,p,i),e.fillStyle=i.bodyColor,J(n.beforeBody,g),u=r&&"right"!==p?"center"===a?c/2+1:c+2:0,_=0,v=o.length;_=0&&(e[l].major=!0);return e}(t,n,o,i):n}class Xs extends Yi{constructor(t){super(t),this._cache={data:[],labels:[],all:[]},this._unit="day",this._majorUnit=void 0,this._offsets={},this._normalized=!1}init(t,e){const i=t.time||(t.time={}),n=this._adapter=new eo._date(t.adapters.date);st(i.displayFormats,n.formats()),super.init(t),this._normalized=e.normalized}parse(t,e){return void 0===t?null:js(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){const t=this,e=t.options,i=t._adapter,n=e.time.unit||"day";let{min:o,max:s,minDefined:a,maxDefined:r}=t.getUserBounds();function l(t){a||isNaN(t.min)||(o=Math.min(o,t.min)),r||isNaN(t.max)||(s=Math.max(s,t.max))}a&&r||(l(t._getLabelBounds()),"ticks"===e.bounds&&"labels"===e.ticks.source||l(t.getMinMax(!1))),o=X(o)&&!isNaN(o)?o:+i.startOf(Date.now(),n),s=X(s)&&!isNaN(s)?s:+i.endOf(Date.now(),n)+1,t.min=Math.min(o,s-1),t.max=Math.max(o+1,s)}_getLabelBounds(){const t=this.getLabelTimestamps();let e=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;return t.length&&(e=t[0],i=t[t.length-1]),{min:e,max:i}}buildTicks(){const t=this,e=t.options,i=e.time,n=e.ticks,o="labels"===n.source?t.getLabelTimestamps():t._generate();"ticks"===e.bounds&&o.length&&(t.min=t._userMin||o[0],t.max=t._userMax||o[o.length-1]);const s=t.min,a=se(o,s,t.max);return t._unit=i.unit||(n.autoSkip?$s(i.minUnit,t.min,t.max,t._getLabelCapacity(s)):function(t,e,i,n,o){for(let s=Ns.length-1;s>=Ns.indexOf(i);s--){const i=Ns[s];if(Ws[i].common&&t._adapter.diff(o,n,i)>=e-1)return i}return Ns[i?Ns.indexOf(i):0]}(t,a.length,i.minUnit,t.min,t.max)),t._majorUnit=n.major.enabled&&"year"!==t._unit?function(t){for(let e=Ns.indexOf(t)+1,i=Ns.length;e1e5*r)throw new Error(i+" and "+n+" are too far apart with stepSize of "+r+" "+a);const g="data"===o.ticks.source&&t.getDataTimestamps();for(d=f,u=0;dthis.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()},pn.isLocal=function(){return!!this.isValid()&&!this._isUTC},pn.isUtcOffset=function(){return!!this.isValid()&&this._isUTC},pn.isUtc=At,pn.isUTC=At,pn.zoneAbbr=function(){return this._isUTC?"UTC":""},pn.zoneName=function(){return this._isUTC?"Coordinated Universal Time":""},pn.dates=n("dates accessor is deprecated. Use date instead.",fn),pn.months=n("months accessor is deprecated. Use month instead",Ue),pn.years=n("years accessor is deprecated. Use year instead",Le),pn.zone=n("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",function(e,t){return null!=e?("string"!=typeof e&&(e=-e),this.utcOffset(e,t),this):-this.utcOffset()}),pn.isDSTShifted=n("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",function(){if(!r(this._isDSTShifted))return this._isDSTShifted;var e,t={};return v(t,this),(t=bt(t))._a?(e=(t._isUTC?_:Tt)(t._a),this._isDSTShifted=this.isValid()&&0