Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
- <%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
- <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
- <%@ taglib prefix="joda" uri="http://www.joda.org/joda/time/tags" %>
- <div id="visualization-container">
- <div id="left-container">
- <div class="text">
- <div>
- <spring:message code="studentworkdays.graph"/> <joda:format value="${startDate}" pattern="${dateFormat}"/> - <joda:format value="${endDate}" pattern="${dateFormat}"/>
- </div>
- <div>
- <label for="s-orientation">Orientation: </label>
- <select name="s-orientation" id="s-orientation">
- <option value="h" selected>horizontal</option>
- <option value="v">vertical</option>
- </select>
- <br>
- <div id="max-levels">
- <label for="i-levels-to-show">Max levels: </label>
- <select id="i-levels-to-show" name="i-levels-to-show" style="width: 50px">
- <option>all</option>
- <option>1</option>
- <option selected="selected">2</option>
- <option>3</option>
- <option>4</option>
- <option>5</option>
- </select>
- </div>
- <div id="startDate">
- <label for="month">kuukausi: </label>
- <select id="month" name="month" style="width: 50px">
- <option>1</option>
- <option>2</option>
- <option>3</option>
- <option>4</option>
- <option>5</option>
- <option>6</option>
- <option>7</option>
- <option>8</option>
- <option>9</option>
- <option>10</option>
- <option>11</option>
- <option>12</option>
- </select>
- </div>
- </div>
- </div>
- <a id="update" href="#" class="theme button white">Go to Parent</a>
- <div id="id-list"></div>
- </div>
- <div id="center-container">
- <div id="infovis"><div id="loadingmessage"><spring:message code="loading.data"/></div></div>
- </div>
- <div id="right-container">
- <div id="inner-details"></div>
- </div>
- <div id="log"></div>
- </div>
- <c:url value="/app/studentworkdayvisualization/data?content=json" var="dataUrl"/>
- <script type="text/javascript">
- var labelType, useGradients, nativeTextSupport, animate;
- (function() {
- var ua = navigator.userAgent,
- iStuff = ua.match(/iPhone/i) || ua.match(/iPad/i),
- typeOfCanvas = typeof HTMLCanvasElement,
- nativeCanvasSupport = (typeOfCanvas == 'object' || typeOfCanvas == 'function'),
- textSupport = nativeCanvasSupport
- && (typeof document.createElement('canvas').getContext('2d').fillText == 'function');
- //I'm setting this based on the fact that ExCanvas provides text support for IE
- //and that as of today iPhone/iPad current text support is lame
- labelType = (!nativeCanvasSupport || (textSupport && !iStuff))? 'Native' : 'HTML';
- nativeTextSupport = labelType == 'Native';
- useGradients = nativeCanvasSupport;
- animate = !(iStuff || !nativeCanvasSupport);
- })();
- var Log = {
- elem: false,
- write: function(text){
- if (!this.elem)
- this.elem = document.getElementById('log');
- this.elem.innerHTML = text;
- this.elem.style.left = (500 - this.elem.offsetWidth / 2) + 'px';
- }
- };
- var icicle;
- function init(data){
- //left panel controls
- controls();
- // init Icicle
- icicle = new $jit.Icicle({
- // id of the visualization container
- injectInto: 'infovis',
- // whether to add transition animations
- animate: animate,
- // nodes offset
- offset: 1,
- // whether to add cushion type nodes
- cushion: false,
- //show only three levels at a time
- constrained: true,
- levelsToShow: 2,
- // enable tips
- Tips: {
- enable: true,
- type: 'Native',
- // add positioning offsets
- offsetX: 20,
- offsetY: 20,
- // implement the onShow method to
- // add content to the tooltip when a node
- // is hovered
- onShow: function(tip, node){
- // add tooltip info
- tip.innerHTML = "<div class=\"tip-title\"><b>" + node.name + "</b>"
- + "</div><div class=\"tip-text\">" + node.data.height + " otp</div>";
- }
- },
- // Add events to nodes
- Events: {
- enable: true,
- onMouseEnter: function(node) {
- //add border and replot node
- node.setData('border', '#33dddd');
- icicle.fx.plotNode(node, icicle.canvas);
- icicle.labels.plotLabel(icicle.canvas, node, icicle.controller);
- },
- onMouseLeave: function(node) {
- node.removeData('border');
- icicle.fx.plot();
- },
- onClick: function(node){
- if (node) {
- //hide tips and selections
- icicle.tips.hide();
- if(icicle.events.hovered)
- this.onMouseLeave(icicle.events.hovered);
- //perform the enter animation
- icicle.enter(node);
- }
- },
- onRightClick: function(){
- //hide tips and selections
- icicle.tips.hide();
- if(icicle.events.hovered)
- this.onMouseLeave(icicle.events.hovered);
- //perform the out animation
- icicle.out();
- }
- },
- // Add canvas label styling
- Label: {
- type: labelType // "Native" or "HTML"
- },
- // Add the name of the node in the corresponding label
- // This method is called once, on label creation and only for DOM and not
- // Native labels.
- onCreateLabel: function(domElement, node){
- domElement.innerHTML = node.name;
- var style = domElement.style;
- style.fontSize = '0.9em';
- style.display = '';
- style.cursor = 'pointer';
- style.color = '#333';
- style.overflow = 'hidden';
- },
- // Change some label dom properties.
- // This method is called each time a label is plotted.
- onPlaceLabel: function(domElement, node){
- var style = domElement.style,
- width = node.getData('width'),
- height = node.getData('height');
- if(width < 7 || height < 7) {
- style.display = 'none';
- } else {
- style.display = '';
- style.width = width + 'px';
- style.height = height + 'px';
- }
- }
- });
- // load data
- icicle.loadJSON(data);
- $("#loadingmessage").remove();
- // compute positions and plot
- icicle.refresh();
- //end
- }
- //init controls
- function controls() {
- var jit = $jit;
- var gotoparent = jit.id('update');
- jit.util.addEvent(gotoparent, 'click', function() {
- icicle.out();
- });
- var select = jit.id('s-orientation');
- jit.util.addEvent(select, 'change', function () {
- icicle.layout.orientation = select[select.selectedIndex].value;
- icicle.refresh();
- });
- var levelsToShowSelect = jit.id('i-levels-to-show');
- jit.util.addEvent(levelsToShowSelect, 'change', function () {
- var index = levelsToShowSelect.selectedIndex;
- if(index == 0) {
- icicle.config.constrained = false;
- } else {
- icicle.config.constrained = true;
- icicle.config.levelsToShow = index;
- }
- icicle.refresh();
- });
- var monthSelect = jit.id('month');
- jit.util.addEvent(monthSelect, 'change', function () {
- //do something here
- icicle.refresh();
- });
- }
- //end
- $(function() {
- $.getJSON('${dataUrl}', function(data) {
- init(data);
- })
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement