PluginProbe ʕ •ᴥ•ʔ
Post Views Counter / 1.2.0
Post Views Counter v1.2.0
1.7.13 1.7.12 1.7.11 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.2.0 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3 1.3.1 1.3.10 1.3.11 1.3.12 1.3.13 1.3.2 1.3.2.1 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.7.0 1.7.1 1.7.10 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9
post-views-counter / js / admin-dashboard.js
post-views-counter / js Last commit date
admin-dashboard.js 10 years ago admin-post.js 10 years ago admin-quick-edit.js 10 years ago admin-settings.js 10 years ago chart.min.js 10 years ago frontend.js 10 years ago
admin-dashboard.js
98 lines
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 );