Revision 70 hci/trunk/eneraptor-web-app/grails-app/views/statistics/showGraph.gsp

View differences:

showGraph.gsp
10 10

  
11 11
	<erptr:box title="Graph">
12 12
		<g:javascript>
13
			var plot;
13 14
			var data = [${data}];
14 15
			var options = {
15 16
				lines: { show: true },
......
30 31
				}
31 32
			};
32 33
		</g:javascript>
34
		
33 35
		<div class="chart">
34
			<flot:plot id="placeholder" style="width: 900px; height: 300px; padding:5px;" data="data" options="options" />
36
			<div id='placeholder' style='width: 900px; height: 300px; padding:5px;'></div>
37
			<script type='text/javascript'>
38
			jQuery(function (){ 
39
				plot = jQuery.plot(jQuery("#placeholder"),data, options);
40
			});
41
			</script>
35 42
		</div>
43
		
36 44
		<br />
37 45
		<p>Legend:</p>
38 46
		<div id="legendHolder" name="legendHolder"></div>
39
		<br />
47
		
48
		<table>
49
			<g:set var="al2num" value="0" />
50
			<g:each in="${actionLog}" var="al2">
51
				<tr>
52
					<td style="width:20px;"><p style="color:red;font-size:smaller;">${++al2num}</p></td>
53
					<td style="width:150px;">${al2.dateRecieved}</td>
54
					<td>${al2.reportedData}</td>
55
				</tr>
56
			</g:each>
57
		</table>
58
		
40 59
		<p>Display actions:</p>
41 60
		<g:form action="showGraph" method="GET">
42 61
			<g:hiddenField name="id" value="${params.id}" />
......
47 66
		<br />
48 67
		
49 68
	</erptr:box>
69
	
70
	<g:javascript>
71
	jQuery( function () {
72
		var o;
73
		var num = 1;
74
		var placeholder = plot.getPlaceholder();
75
		var vertica = getMax(plot.getData()[0].datapoints.points);
76
		<g:each in="${actionLog}" var="al1">
77
			o = plot.pointOffset({ x: ${al1.dateRecieved.time}, y: vertica});
78
			placeholder.append("<div style=\"position:absolute;left:" + (o.left + 10) + "px;top:" + o.top + "px;color:red;font-size:smaller\"><a href=\"#\" onclick=\"return false;\" title=\"${al1.reportedData}\">" + num + "</a></div>");
79
			num++;
80
		</g:each>
81
	});
82
	function getMax(points) {
83
		var max = points[1];
84
		for(i = 1; i < points.length; i += 2) {
85
			if(points[i] > max) max = points[i];
86
		}
87
		return max;
88
	}
89
	</g:javascript>
50 90

  
51 91
</body>
52 92

  

Also available in: Unified diff