From ca63ee3ebfe35cc7ac15537b4d5fe39b8f32c8ef Mon Sep 17 00:00:00 2001 From: Hans Bakker Date: Mon, 17 Dec 2007 01:28:09 +0000 Subject: [PATCH] corrected demo data as suggested by jacopo git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk/specialpurpose@604760 13f79535-47bb-0310-9956-ffa450edef68 --- projectmgr/data/ProjectMgrDemoData.xml | 44 +-- projectmgr/webapp/projectmgr/js/gantt.js | 324 ----------------------- 2 files changed, 22 insertions(+), 346 deletions(-) delete mode 100644 projectmgr/webapp/projectmgr/js/gantt.js diff --git a/projectmgr/data/ProjectMgrDemoData.xml b/projectmgr/data/ProjectMgrDemoData.xml index 02ac73665..68a98643f 100644 --- a/projectmgr/data/ProjectMgrDemoData.xml +++ b/projectmgr/data/ProjectMgrDemoData.xml @@ -3,38 +3,38 @@ - - - + + + - - - + + + - - + + + - - - - + + + - - - - - - - + + + + + + + - - - + + + \ No newline at end of file diff --git a/projectmgr/webapp/projectmgr/js/gantt.js b/projectmgr/webapp/projectmgr/js/gantt.js deleted file mode 100644 index 0970d0d5a..000000000 --- a/projectmgr/webapp/projectmgr/js/gantt.js +++ /dev/null @@ -1,324 +0,0 @@ - dojo.require("dojo.collections.Store"); - dojo.require("dojo.charting.Chart"); - dojo.require('dojo.json'); - dojo.require("dojo.date.common"); - dojo.require("dojo.event.*"); - dojo.require("dojo.io.*"); - - var interv = dojo.date.dateParts.DAY; - - - // our sample data for our gantt chart. - - var docData = null; - var xml = { - url: "/projectmgr/js/data.xml", - mimetype: "text/xml", - load: callBack, - error: function(type, error){ - dojo.debug("type: " + type); - dojo.debug("error: " + error.message); - } - } - - dojo.io.bind(xml); - -/* - function xml2json(dataNode, json){ - var taskNodes = dataNode.getDocumentElement(); - // Convert the xml data to json - for(var i = 0; i < taskNodes.length; i++){ - var taskNode = taskNodes.item(i); - if(taskNode.childNodes.length){ - json.push({high: taskNode.attributes["end"], low: taskNode.attributes["start"], task: taskNode.attribute["label"], type: "p"}); - //Recursive call to crawl the dom - xml2json(taskNode); - }else{ - var dtStart = new Date(taskNode.attributes["start"]); - var dtEnd = new Date(taskNode.attributes["end"]); - json.push({high: dtEnd.getTime(), low: dtStart.getTime(), task: taskNode.attributes["label"], type: taskNode.attributes["type"]}); - } - } - - return json; - } -*/ - function callBack(type, xmlDom, httpreq){ - - var taskNodes = xmlDom.getElementsByTagName("task"); - var json = []; - - // Convert the xml data to json - for(var i = 0; i < taskNodes.length; i++){ - var taskNode = taskNodes.item(i); - var dtStart = new Date(taskNode.getAttribute("start")); - var dtEnd = new Date(taskNode.getAttribute("end")); - if(taskNode.childNodes.length){ - json.push({high: dtEnd.getTime(), low: dtStart.getTime(), task: taskNode.getAttribute("label"), type: "p"}); - }else{ - json.push({high: dtEnd.getTime(), low: dtStart.getTime(), task: taskNode.getAttribute("label"), type: taskNode.getAttribute("type")}); - } - } - - //Parameters - var chartStart = new Date(taskNodes.item(0).getAttribute("start")); //Origin of the chart - var dtEnd = new Date(taskNodes.item(taskNodes.length - 1).getAttribute("end")); //End of the chart -// var duration = 14; //Duration of the chart - //Calculated parameters - var nbDays = dojo.date.diff(chartStart, dtEnd, interv); - - var store = new dojo.collections.Store(); - store.setData(json); - - // define the chart. - var s1 = new dojo.charting.Series({ - dataSource:store, - bindings:{ id:"id", high:"high", low:"low", label:"task", type:"type" }, - label:"Project tasks" - }); - - // test the evaluate -/* - var data = s1.evaluate(); - var a=[]; - for(var i=0; i=0; i--){ - yB2.labels.push({ label: data[i].label, value: parseInt((data.length - i)*30) }); - } - - //create the first x-axis (day-based) - var xB = new dojo.charting.Axis(); - xB.range={upper:dtEnd.getTime(), lower:chartStart.getTime()}; - //setting the origin to more than y-axis.upper cause it to appear above the chart - xB.origin = parseInt(yB2.range.upper + 30); - xB.showTicks = true; - xB.showLines = false; - - var dtStart = chartStart; - for(var i = 0; i < nbDays; i++){ - xB.labels.push({ label: dateFormat(dtStart, '!ddd'), value: dtStart.getTime() }); - dtStart = dojo.date.add(dtStart, interv, 1); - } - - //create the second x-axis (week-based) - var xB2 = new dojo.charting.Axis(); - //use the same range as first axis - xB2.range = xB.range; - xB2.origin="min"; - xB2.showTicks = true; - xB2.showLines = true; - - dtStart = chartStart; - for(var i = 0; i < nbDays; i++){ - if(dateFormat(dtStart, '!ddd') == "Mon"){ - xB2.labels.push({ label: dateFormat(dtStart, '!dd/!mm'), value: dtStart.getTime() }); - } - dtStart = dojo.date.add(dtStart, interv, 1); - } - - - -//gantt series - //to display second axis and labels on same chart, we need a first Plot object - var p2 = new dojo.charting.Plot(xB2, yB2); - - //The second Plot object hold the data Series - var p3 = new dojo.charting.Plot(xB, yB2); - p3.renderType = dojo.charting.RenderPlotSeries.Grouped; - p3.addSeries({ data:s1, plotter: dojo.charting.Plotters.Gantt }); - - var pa2 = new dojo.charting.PlotArea(); - //Add the 2 Plot to the PlotArea - pa2.plots.push(p2); - pa2.plots.push(p3); - - //Calculate chart height & width - var chartH = data.length * 30; - var chartW = nbDays * 50; - - pa2.size={width:chartW, height:chartH}; - pa2.padding={top:30, right:30, bottom:30, left:60 }; - - // auto assign colors, and increase the step - s1.color = pa2.nextColor(); - - // Create the Chart and add the PlotArea - var chart = new dojo.charting.Chart(null, "Test chart", "This is a potential description"); - chart.addPlotArea({ x:0,y:0, plotArea:pa2 }); - - - dojo.addOnLoad(function(){ - chart.node = dojo.byId("chartTest1"); - chart.render(); - document.getElementById("chartTest1").setAttribute("style", "width:" + chartW + "; height:" + chartH + ";"); - document.getElementById("plotLabels1").setAttribute("style", "width:" + chartW + "; height:" + chartH + ";"); - //Call PlotArea.render with the custom function - pa2.render(s1, customPlot); - - }); - dojo.debug("--end callBack"); - } - dojo.event.connect(dojo, "loaded", "init") - - function loadData(){ - var xml = { - url: "/projectmgr/js/data.xml", - mimetype: "text/xml", - load: function(type, xmlDom, httpreq){ - docData = xmlDom; - dojo.debug("load " + docData); - -// var params = new Array(); -// var content = navTreeProc.getResultString(xmlDom, params, document); - }, - error: function(type, error){ - dojo.debug("type: " + type); - dojo.debug("error: " + error); - } - } - dojo.io.bind(xml); - } - - function customPlot(node, srcObject){ - //First solution for custom labels - //Display labels in a div elt overlapping the graph - - var x = parseInt(node.getAttribute("x")); - var y = parseInt(node.getAttribute("y")); - var width = parseInt(node.getAttribute("width")) - 10; - - - if(srcObject.type == "p"){ - node.setAttribute("y", y + 15); - node.setAttribute("rx", "10"); - node.setAttribute("ry", "10"); - node.setAttribute("height", "5"); - node.setAttribute("type", "arc"); - node.setAttribute("style", "fill:#000000;fill-opacity:0.75000000;fill-rule:evenodd;stroke:#000000;stroke-width:1.0000000px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000"); -// dojo.debug(srcObject.type); - }else if(srcObject.type == "j"){ - node.setAttribute("x", x + 15); - node.setAttribute("y", y + 10); - node.setAttribute("rx", "10"); - node.setAttribute("ry", "10"); - node.setAttribute("width", "10"); - node.setAttribute("height", "10"); - node.setAttribute("type", "arc"); - node.setAttribute("style", "fill:#00FF00;fill-opacity:0.75000000;fill-rule:evenodd;stroke:#000000;stroke-width:1.0000000px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000"); -// dojo.debug(srcObject.type); - }else{ - node.setAttribute("height", "20"); - } - - var div = document.createElement("div"); - if(srcObject.type != "p"){ - if(srcObject.type == "j"){ - div.setAttribute("class", "milestone-label"); - x += 15; - }else{ - div.setAttribute("class", "bar-label"); - } - div.setAttribute("style", "top:" + parseInt(y + 4) + "px; left:" + parseInt(x + 5) + "px; width:" + width + "px"); - div.appendChild(document.createTextNode(srcObject.task)); - document.getElementById("plotLabels1").appendChild(div); - } - //connect the mouseover event to the task label - dojo.event.connect(div, "onmouseover", dj_global, "onMouseOver"); - - } - - function onMouseOver(evt){ - logMe(evt); - } - - function logMe(evt){ - // FIXME: it appears that we're not actually getting this passed from IE!?! - //if(!evt){ evt = window.event; } - dojo.debug(evt.type + ' was fired'); -/* - lastEvt = dump(evt); - for(var x in evt){ - dojo.debug(x+": "+evt[x]); - } -*/ - dojo.debug("some event was fired"); - } - -function dateFormat(aDate, displayPat){ - /******************************************************** - * Valid Masks: - * !mmmm = Long month (eg. January) - * !mmm = Short month (eg. Jan) - * !mm = Numeric date (eg. 07) - * !m = Numeric date (eg. 7) - * !dddd = Long day (eg. Monday) - * !ddd = Short day (eg. Mon) - * !dd = Numeric day (eg. 07) - * !d = Numeric day (eg. 7) - * !yyyy = Year (eg. 1999) - * !yy = Year (eg. 99) - ********************************************************/ - - intMonth = aDate.getMonth(); - intDate = aDate.getDate(); - intDay = aDate.getDay(); - intYear = aDate.getFullYear(); - - var months_long = new Array ('January','February','March','April', - 'May','June','July','August','September','October','November','December') - var months_short = new Array('Jan','Feb','Mar','Apr','May','Jun', - 'Jul','Aug','Sep','Oct','Nov','Dec') - var days_long = new Array('Sunday','Monday','Tuesday','Wednesday', - 'Thursday','Friday','Saturday') - var days_short = new Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat') - - var mmmm = months_long[intMonth] - var mmm = months_short[intMonth] - var mm = intMonth < 9?'0'+ (1 + intMonth) + '':(1+intMonth)+''; - var m = 1+intMonth+''; - var dddd = days_long[intDay]; - var ddd = days_short[intDay]; - var dd = intDate<10?'0'+intDate+'':intDate+''; - var d = intDate+''; - var yyyy = intYear; - - century = 0; - while((intYear-century)>=100) - century = century + 100; - - var yy = intYear - century - if(yy<10) - yy = '0' + yy + ''; - - displayDate = new String(displayPat); - - displayDate = displayDate.replace(/!mmmm/i,mmmm); - displayDate = displayDate.replace(/!mmm/i,mmm); - displayDate = displayDate.replace(/!mm/i,mm); - displayDate = displayDate.replace(/!m/i,m); - displayDate = displayDate.replace(/!dddd/i,dddd); - displayDate = displayDate.replace(/!ddd/i,ddd); - displayDate = displayDate.replace(/!dd/i,dd); - displayDate = displayDate.replace(/!d/i,d); - displayDate = displayDate.replace(/!yyyy/i,yyyy); - displayDate = displayDate.replace(/!yy/i,yy); - - return displayDate; -} \ No newline at end of file