Advertisement
katariina

studentworkdayvisualization

Oct 10th, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.38 KB | None | 0 0
  1. <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
  2.  
  3. <%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
  4. <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
  5. <%@ taglib prefix="joda" uri="http://www.joda.org/joda/time/tags" %>
  6.  
  7. <div id="visualization-container">
  8. <div id="left-container">
  9.  
  10. <div class="text">
  11. <div>
  12. <spring:message code="studentworkdays.graph"/> <joda:format value="${startDate}" pattern="${dateFormat}"/>&nbsp;-&nbsp;<joda:format value="${endDate}" pattern="${dateFormat}"/>
  13. </div>
  14. <div>
  15. <label for="s-orientation">Orientation: </label>
  16. <select name="s-orientation" id="s-orientation">
  17. <option value="h" selected>horizontal</option>
  18. <option value="v">vertical</option>
  19. </select>
  20. <br>
  21. <div id="max-levels">
  22. <label for="i-levels-to-show">Max levels: </label>
  23. <select id="i-levels-to-show" name="i-levels-to-show" style="width: 50px">
  24. <option>all</option>
  25. <option>1</option>
  26. <option selected="selected">2</option>
  27. <option>3</option>
  28. <option>4</option>
  29. <option>5</option>
  30. </select>
  31. </div>
  32. <div id="startDate">
  33. <label for="month">kuukausi: </label>
  34. <select id="month" name="month" style="width: 50px">
  35. <option>1</option>
  36. <option>2</option>
  37. <option>3</option>
  38. <option>4</option>
  39. <option>5</option>
  40. <option>6</option>
  41. <option>7</option>
  42. <option>8</option>
  43. <option>9</option>
  44. <option>10</option>
  45. <option>11</option>
  46. <option>12</option>
  47. </select>
  48. </div>
  49. </div>
  50. </div>
  51.  
  52. <a id="update" href="#" class="theme button white">Go to Parent</a>
  53.  
  54. <div id="id-list"></div>
  55.  
  56.  
  57. </div>
  58.  
  59. <div id="center-container">
  60. <div id="infovis"><div id="loadingmessage"><spring:message code="loading.data"/></div></div>
  61. </div>
  62.  
  63. <div id="right-container">
  64.  
  65. <div id="inner-details"></div>
  66.  
  67. </div>
  68.  
  69. <div id="log"></div>
  70. </div>
  71. <c:url value="/app/studentworkdayvisualization/data?content=json" var="dataUrl"/>
  72. <script type="text/javascript">
  73. var labelType, useGradients, nativeTextSupport, animate;
  74.  
  75. (function() {
  76. var ua = navigator.userAgent,
  77. iStuff = ua.match(/iPhone/i) || ua.match(/iPad/i),
  78. typeOfCanvas = typeof HTMLCanvasElement,
  79. nativeCanvasSupport = (typeOfCanvas == 'object' || typeOfCanvas == 'function'),
  80. textSupport = nativeCanvasSupport
  81. && (typeof document.createElement('canvas').getContext('2d').fillText == 'function');
  82. //I'm setting this based on the fact that ExCanvas provides text support for IE
  83. //and that as of today iPhone/iPad current text support is lame
  84. labelType = (!nativeCanvasSupport || (textSupport && !iStuff))? 'Native' : 'HTML';
  85. nativeTextSupport = labelType == 'Native';
  86. useGradients = nativeCanvasSupport;
  87. animate = !(iStuff || !nativeCanvasSupport);
  88. })();
  89.  
  90. var Log = {
  91. elem: false,
  92. write: function(text){
  93. if (!this.elem)
  94. this.elem = document.getElementById('log');
  95. this.elem.innerHTML = text;
  96. this.elem.style.left = (500 - this.elem.offsetWidth / 2) + 'px';
  97. }
  98. };
  99.  
  100.  
  101. var icicle;
  102.  
  103. function init(data){
  104. //left panel controls
  105. controls();
  106.  
  107. // init Icicle
  108. icicle = new $jit.Icicle({
  109. // id of the visualization container
  110. injectInto: 'infovis',
  111. // whether to add transition animations
  112. animate: animate,
  113. // nodes offset
  114. offset: 1,
  115. // whether to add cushion type nodes
  116. cushion: false,
  117. //show only three levels at a time
  118. constrained: true,
  119. levelsToShow: 2,
  120. // enable tips
  121. Tips: {
  122. enable: true,
  123. type: 'Native',
  124. // add positioning offsets
  125. offsetX: 20,
  126. offsetY: 20,
  127. // implement the onShow method to
  128. // add content to the tooltip when a node
  129. // is hovered
  130. onShow: function(tip, node){
  131. // add tooltip info
  132. tip.innerHTML = "<div class=\"tip-title\"><b>" + node.name + "</b>"
  133. + "</div><div class=\"tip-text\">" + node.data.height + " otp</div>";
  134. }
  135. },
  136. // Add events to nodes
  137. Events: {
  138. enable: true,
  139. onMouseEnter: function(node) {
  140. //add border and replot node
  141. node.setData('border', '#33dddd');
  142. icicle.fx.plotNode(node, icicle.canvas);
  143. icicle.labels.plotLabel(icicle.canvas, node, icicle.controller);
  144. },
  145. onMouseLeave: function(node) {
  146. node.removeData('border');
  147. icicle.fx.plot();
  148. },
  149. onClick: function(node){
  150. if (node) {
  151. //hide tips and selections
  152. icicle.tips.hide();
  153. if(icicle.events.hovered)
  154. this.onMouseLeave(icicle.events.hovered);
  155. //perform the enter animation
  156. icicle.enter(node);
  157. }
  158. },
  159. onRightClick: function(){
  160. //hide tips and selections
  161. icicle.tips.hide();
  162. if(icicle.events.hovered)
  163. this.onMouseLeave(icicle.events.hovered);
  164. //perform the out animation
  165. icicle.out();
  166. }
  167. },
  168. // Add canvas label styling
  169. Label: {
  170. type: labelType // "Native" or "HTML"
  171. },
  172. // Add the name of the node in the corresponding label
  173. // This method is called once, on label creation and only for DOM and not
  174. // Native labels.
  175. onCreateLabel: function(domElement, node){
  176. domElement.innerHTML = node.name;
  177. var style = domElement.style;
  178. style.fontSize = '0.9em';
  179. style.display = '';
  180. style.cursor = 'pointer';
  181. style.color = '#333';
  182. style.overflow = 'hidden';
  183. },
  184. // Change some label dom properties.
  185. // This method is called each time a label is plotted.
  186. onPlaceLabel: function(domElement, node){
  187. var style = domElement.style,
  188. width = node.getData('width'),
  189. height = node.getData('height');
  190. if(width < 7 || height < 7) {
  191. style.display = 'none';
  192. } else {
  193. style.display = '';
  194. style.width = width + 'px';
  195. style.height = height + 'px';
  196. }
  197. }
  198. });
  199. // load data
  200. icicle.loadJSON(data);
  201. $("#loadingmessage").remove();
  202. // compute positions and plot
  203. icicle.refresh();
  204. //end
  205. }
  206.  
  207. //init controls
  208. function controls() {
  209. var jit = $jit;
  210. var gotoparent = jit.id('update');
  211. jit.util.addEvent(gotoparent, 'click', function() {
  212. icicle.out();
  213. });
  214. var select = jit.id('s-orientation');
  215. jit.util.addEvent(select, 'change', function () {
  216. icicle.layout.orientation = select[select.selectedIndex].value;
  217. icicle.refresh();
  218. });
  219. var levelsToShowSelect = jit.id('i-levels-to-show');
  220. jit.util.addEvent(levelsToShowSelect, 'change', function () {
  221. var index = levelsToShowSelect.selectedIndex;
  222. if(index == 0) {
  223. icicle.config.constrained = false;
  224. } else {
  225. icicle.config.constrained = true;
  226. icicle.config.levelsToShow = index;
  227. }
  228. icicle.refresh();
  229. });
  230. var monthSelect = jit.id('month');
  231. jit.util.addEvent(monthSelect, 'change', function () {
  232. //do something here
  233. icicle.refresh();
  234. });
  235. }
  236. //end
  237.  
  238. $(function() {
  239. $.getJSON('${dataUrl}', function(data) {
  240. init(data);
  241. })
  242. });
  243. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement