source: trunk/LATMOS-Accounts-Web/root/html/stat/display.tt @ 2121

Last change on this file since 2121 was 1903, checked in by nanardon, 8 years ago

Don't display tick on graph

File size: 3.7 KB
Line 
1
2[% ostat = c.model('Accounts').db.get_object('stat', statname) %]
3<h3>[% ostat.get_attributes('description') || 'No description' | html %]</h3>
4<div >
5[% r = c.forward('/json/stat/index', [ statname ]) %]
6
7
8[% total = 0 %]
9[% FOREACH row = r %]
10    [% total = total + row.1 %]
11[% END %]
12
13[% FOREACH row = r %]
14[% IF loop.first %]
15<table class=datatable style="float:left; padding-top: 10px;">
16[% END %]
17
18<tr>
19<th>[% row.0 | html %]</th>
20<td>[% row.1 %]</td>
21<td>[% row.1 / total * 100 | format('%.2f') %] %</td>
22</tr>
23
24[% IF loop.last %]
25<tr>
26<th>Total:</th>
27<td>[% total %]</td>
28<td> 100 %</td>
29</tr>
30</table>
31[% END %]
32[% END %]
33
34<script>
35$(document).ready(function(){
36  // Our ajax data renderer which here retrieves a text file.
37  // it could contact any source and pull data, however.
38  // The options argument isn't used in this renderer.
39 
40    $.ajax({
41      // have to use synchronous here, else the function
42      // will return before the data is fetched
43      // async: false,
44      url: "[% c.uri_for('/json/stat', statname) %]",
45      dataType:"json",
46      success: function(data) {
47          var plot2 = $.jqplot('chartdpmt',
48            [ data ],
49
50            {
51                title: '[% ostat.get_attributes('description') || 'No description' %]',
52                seriesDefaults: {
53                    shadow: false,
54                    renderer: jQuery.jqplot.PieRenderer,
55                    rendererOptions: { padding: 2, sliceMargin: 2, showDataLabels: true }
56                },
57            legend: {
58                renderer: $.jqplot.EnhancedLegendRenderer,
59                show:true,
60                location: 'e',
61            }
62          });
63        }
64    });
65
66    $.jqplot.config.enablePlugins = true;
67
68    $.ajax({
69      // have to use synchronous here, else the function
70      // will return before the data is fetched
71      // async: false,
72      url: "[% c.uri_for('/json/stat/history', statname) %]",
73      dataType:"json",
74      success: function(data) {
75          var plot2 = $.jqplot('charth', data.data,
76            {
77                title: '[% ostat.get_attributes('description') || 'No description' %]',
78                axes: {
79                    xaxis: {
80                        renderer: $.jqplot.DateAxisRenderer,
81                        rendererOptions:{
82                            tickRenderer:$.jqplot.CanvasAxisTickRenderer
83                        },
84                        tickOptions: {
85                            formatString:'%d/%m/%Y',
86                            fontSize:'10pt',
87                            fontFamily:'Tahoma',
88                            angle:-40
89                        },
90                        tickInterval:'1 months',
91                    },
92                    yaxis: {
93                        min: 0,
94                    },
95                },
96                seriesDefaults: {
97                    shadow: false,
98                    lineWidth: 2,
99                    rendererOptions: {
100                        padding: 1,
101                        sliceMargin: 2,
102                        showDataLabels: true,
103                        smooth: true
104                    },
105                    markerOptions:{style:'square', show: false, }
106                },
107                legend:{
108                    renderer: $.jqplot.EnhancedLegendRenderer,
109                    placement: 'outside',
110                    show: true
111                },
112                cursor:{
113                    zoom:true,
114                    tooltipLocation:'sw',
115                    looseZoom: true
116                },
117                series: data.series
118            }
119          );
120        }
121    });
122});
123</script>
124
125<div id="chartdpmt" style="width:60%; height:500px; float:left"></div>
126</div>
127
128<div id="charth" style="width:80%; height:600px; clear: both"></div>
129</div>
Note: See TracBrowser for help on using the repository browser.