[SPIP] v3.2.1-->v3.2.3
[lhc/web/www.git] / www / plugins-dist / statistiques / prive / stats / visites.html
1 <!--[if IE]>[<script type="text/javascript" src="(#CHEMIN{javascript/excanvas.js})"></script>]<![endif]-->
2 [<script type="text/javascript" src="(#CHEMIN{javascript/jquery.flot.js})"></script>]
3 [<script type="text/javascript" src="(#CHEMIN{javascript/jquery.flot.selection.js})"></script>]
4 [<script type="text/javascript" src="(#CHEMIN{javascript/jquery.flot.time.js})"></script>]
5 [<script type="text/javascript" src="(#CHEMIN{javascript/jquery.tflot.js})"></script>]
6
7 <script type="text/javascript">
8
9 function trace_stats_table(table, classes, options) {
10 $table = $(table);
11 if ($table.is(':hidden')) {
12 return true; // pas a faire ou deja fait.
13 }
14
15 // copier le titre des tableaux
16 titre = $table.find("caption").text();
17 $table.siblings('.pagination').before("<h3 class='caption'>" + titre + "</h3>");
18 $table
19
20 .wrap("<div class='" + classes + "'></div>");
21
22 // mettre les visites avec un fond colore pour le graphique
23 $table.find("thead th:eq(1)").data({fill: true, serie: 'bar', color: '#FFD845',lineWidth:0});
24 $table.find("thead th:eq(2)").data({serie: 'line', color: '#7FC4FF'});
25 $table.find("thead th:eq(3)").data({fill: true, serie: 'bar', color: '#A9DD3A',lineWidth:0});
26
27 // mettre les previsions en premier
28 // (pour que les autres graph passent par dessus)
29 $table.find('thead tr th:first-child').after(function(){
30 return $(this).parent().find('th:eq(3)').detach();
31 });
32 $table.find('tbody tr th:first-child').after(function(){
33 return $(this).parent().find('td:last-child').detach();
34 });
35
36 params = {
37 legendeExterne:true,
38 legendeActions:true,
39 width:($('.large #page').length)?'755px':'560px', // 795px, 600px (sans le tableau de resume) ...
40 height:'250px',
41 modeDate:true,
42 zoom:true,
43 parse:{
44 axeOnTitle:true,
45 defaultSerie:{
46 bars:{show:true},
47 lines:{show:true},
48 points:{show:false}
49 }
50 },
51 flot:{
52 grid:{
53 axismargin:10
54 },
55 xaxis:{
56 labelWidth:45,
57 monthNames: [
58 '[(#VAL{2000-01-01}|nom_mois)]',
59 '[(#VAL{2000-02-01}|nom_mois)]',
60 '[(#VAL{2000-03-01}|nom_mois)]',
61 '[(#VAL{2000-04-01}|nom_mois)]',
62 '[(#VAL{2000-05-01}|nom_mois)]',
63 '[(#VAL{2000-06-01}|nom_mois)]',
64 '[(#VAL{2000-07-01}|nom_mois)]',
65 '[(#VAL{2000-08-01}|nom_mois)]',
66 '[(#VAL{2000-09-01}|nom_mois)]',
67 '[(#VAL{2000-10-01}|nom_mois)]',
68 '[(#VAL{2000-11-01}|nom_mois)]',
69 '[(#VAL{2000-12-01}|nom_mois)]'
70 ]
71 },
72 yaxis:{
73 position: "right",
74 tickDecimals: 1,
75 tickFormatter: function nbFormatter(val, axis) {
76 if (val >= 1000000){
77 var fval = (val / 1000000).toFixed(axis.tickDecimals) ;
78 return fval.replace(/\.0$/,"") + " M";
79 }
80 else{
81 if (val >= 100000)
82 return (val / 1000).toFixed(axis.tickDecimals).replace(/\.0$/,"") + " k";
83 else{
84 var fval = val.toFixed(axis.tickDecimals).replace(/\.0$/,"") ;
85 return fval.replace(/(\d{3})$/," $1") ;
86 }
87 }
88 }
89 }
90 },
91 infobulle:{show:true}
92 }
93
94 $table.tFlot($.extend(true, {}, params, options));
95 }
96
97 function trace_stats(){
98 trace_stats_table(
99 "#visites_quotidiennes",
100 "statistiques_visites_quotidiennes statistiques_visites",
101 {
102 grille:{weekend:true},
103 flot:{
104 xaxis:{
105 timeformat:"%d %b",
106 minTickSize: [1, "day"]
107 },
108 bars:{barWidth:24 * 60 * 60 * 1000}
109 }
110 });
111
112 trace_stats_table(
113 "#visites_mensuelles",
114 "statistiques_visites_mensuelles statistiques_visites", {
115 grille:{years:true},
116 flot:{
117 xaxis:{
118 timeformat:"%b %y",
119 minTickSize: [1, "month"]
120 },
121 bars:{barWidth:30.4 * 24 * 60 * 60 * 1000 /* nb de jours... approximatif */}
122 }
123 });
124
125 }
126 jQuery(function($) {
127 trace_stats();
128 onAjaxLoad(trace_stats);
129 });
130 </script>