// js object graphs function duo_jsGraph(data,id){ //console.log('drawing new graph'); var object=this; this.container=id; this.data = data; this.title = this.data['graph_title']; this.direction = this.data['graph_direction']; this.graphdata = this.data['graph_data']; // this.extractData = extractData(this.graphdata); this.initGraph = initGraph(this.graphdata,this.title,this.direction); function initGraph(data,title,dir){ if(document.getElementById(object.container)){ var ga = document.getElementById(object.container); ga.innerHTML = ''; var width = parseInt(ga.style.width.replace(/px/,"")); var height = parseInt(ga.style.height.replace(/px/,"")); var width = ga.offsetWidth; var height = ga.offsetHeight; var graphtitle = document.createElement("DIV"); graphtitle.className="graphTitle"; graphtitle.innerHTML = title; ga.appendChild(graphtitle); if(dir == "h"){ drawHorizontalGraph(data,width,height,ga); } else if(dir == "v"){ drawVerticalGraph(data,width,height,ga); } } } function drawVerticalGraph(data,width,height,parent){ height-=40; var labelwidth = Math.floor(((width-6)/data.length) - 5); var percentagewidth = Math.floor((100-(data.length))/data.length); var graphouter = document.createElement("DIV"); graphouter.className = "graphouter"; //graphouter.style.width = width+"px"; graphouter.style.height = height+"px"; graphouter.style.position = "relative"; parent.appendChild(graphouter); var graphlabels = document.createElement("DIV"); graphlabels.className = "graphlabels"; //graphlabels.style.width = width-1+"px"; parent.appendChild(graphlabels); var margin = 1; var leftpos = 1; // var multiplier = height/100; var bar; var label; var rowData = new Array(); var returnData = new Array(); var highestValue = 0; for(var x=0;x parseInt(highestValue)){ highestValue = data[x]['value']; } } var multiplier = 100/highestValue; for(var i=0;i parseInt(highestValue)){ highestValue = data[x]['value']; } } var multiplier = 100/highestValue; for(var i=0;i