// START FUNCTION: This function creates the canvas, the everything bundle within the canvas, the axes (given scale functions), and the axes labels start = function(xLab,yLab,xMap,yMap,canvasWidth,canvasHeight,width,height,selector){ var canvas = d3.select(selector) .append('svg') .attr('height',canvasHeight) .attr('width', canvasWidth); var everything = canvas.append('g'); everything.attr('transform','translate('+(width * 0.2)+','+height*0.1+')'); var xAxis = d3.svg.axis() .scale(xMap); var yAxis = d3.svg.axis() .scale(yMap) .orient('left'); everything.append('g') .attr('transform','translate(0,'+height+')') .call(xAxis); everything.append('g') .call(yAxis); var xLabel = everything.append('text') .attr('x',canvasWidth*0.4) .attr('y',height+45) .text(xLab) .attr('text-anchor','middle'); var yLabel = everything.append('text') .attr('x', -canvasHeight*0.4) .attr('y', -canvasWidth*0.1) .attr('transform','rotate(-90)') .text(yLab) .attr('text-anchor','middle'); var objects = [canvas,everything]; return objects; } // END OF START FUNCTION // HISTO FUNCTION: creats histogram plot histo = function(data,config){ if (typeof config === 'undefined'){config = {}}; var xLab=config.xLab,selector=config.selector,canvasWidth=config.width,canvasHeight=config.height; if(typeof canvasWidth === 'undefined'){ canvasWidth = 500; } if(typeof canvasHeight === 'undefined'){ canvasHeight = 500; } if(typeof selector === 'undefined'){ selector = 'body'; } if(typeof xLab === 'undefined'){ xLab = ''; } var hist = function(arr){ var newArr = arr.slice().sort(function(a,b){ return a-b; }); var max = newArr[arr.length -1]; var min = newArr[0]; var bins = Math.round(Math.sqrt(arr.length)); var binSize = (max-min)/bins; var obj= {}; var keys = []; for (var i=0; i