OXIESEC PANEL
- Current Dir:
/
/
home
/
cubot
/
docroot
/
showcase
/
js
/
tree
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
12/31/2022 06:53:36 AM
rwxr-xr-x
📄
bar.js
7.96 KB
08/14/2022 11:05:12 AM
rw-r--r--
📄
heatmap.js
5.87 KB
08/14/2022 11:05:12 AM
rw-r--r--
📄
makeJson.js
1.64 KB
08/14/2022 11:05:12 AM
rw-r--r--
📄
radar.js
6.48 KB
08/14/2022 11:05:12 AM
rw-r--r--
📄
stock.js
5.6 KB
08/14/2022 11:05:12 AM
rw-r--r--
📄
tree.css
1.35 KB
08/14/2022 11:05:12 AM
rw-r--r--
📄
tree.js
4.79 KB
08/14/2022 11:05:12 AM
rw-r--r--
Editing: stock.js
Close
function drawStockChart(data, divId, Title, Width, Height, Ndim, Nmeas, MeasFormats,dispObj,tooltip){ Height=makeProperHeight(Height, divId); Width=makeProperWidth(Width, divId); var Ndim=1; var margin = {top: 10, right: 20, bottom: 20, left: 30}, width = Width - margin.left - margin.right, height = Height - margin.top - margin.bottom-40; //var parseDate = d3.time.format("%Y/%m/%d").parse; var parseDate = d3.time.format("%Y-%m-%d %H:%M:%S").parse; var x = d3.time.scale() .range([0, width]); var y = d3.scale.linear() .range([height, 0]); var xAxis = d3.svg.axis() .scale(x) .tickSize(-height, 0, 0) //For X Grid .ticks(8) .orient("bottom"); var yAxis = d3.svg.axis() .scale(y) .tickSize(-width, 0, 0)// For Y Grid .orient("left") .tickFormat( function(d) { return formatSmallScale(d, MeasFormats[0]) }); var line = new Array(); for(var i=0; i<Nmeas; i++){ line[i] = d3.svg.line() .x(function(d){ return x(d[0]);}) .y(function(d){ return y(d[Ndim+i]);}) .defined(function(d) {return d[Ndim+i] != 0}); } d3.select("#"+divId).html(""); var svg = d3.select("#"+divId).append("svg") .attr("class", "mainsvg") .attr("width", width + margin.left + margin.right) .attr("height", height + margin.top + margin.bottom) .append("g") .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); d3.select("#"+divId).append("div") .attr("class", "tipsy"); var Heading=data.splice(0,1); data.forEach(function(d) { d[0]=parseDate(d[0]); for(i=0; i<Nmeas; i++){ d[Ndim+i]=+d[Ndim+i]; } }); x.domain(d3.extent(data, function(d) { return d[0]; })); //x.domain([new Date(2013, 07, 16, 09, 16, 0, 0), new Date(2013, 07, 22, 15, 16, 0, 0)]); //x.domain([parseDate('2013-07-16 09:00:00'), parseDate('2013-07-16 16:00:00'), parseDate('2013-07-17 09:00:00'), parseDate('2013-07-17 16:00:00')]); //y.domain(d3.extent(data, function(d) { return d[1]; })); var minMax=new Array(); for(i=0; i<Nmeas; i++){ minMax[i]=d3.extent(data, function(d) { return d[Ndim+i]; }); } var Min=d3.extent(minMax, function(d) { return d[0]; })[0]; var Max=d3.extent(minMax, function(d) { return d[1]; })[1]; y.domain([Min, Max]); svg.append("g") .attr("class", "x axis") .attr("transform", "translate(0," + height + ")") .call(xAxis); svg.append("g") .attr("class", "y axis") .call(yAxis) /*.append("text") .attr("transform", "rotate(-90)") .attr("y", 6) .attr("dy", ".71em") .style("text-anchor", "end") .text("Price ($)");*/ for(var i=0; i<line.length; i++){ svg.append("path") .datum(data) .style("fill", "none") .style("stroke", G_seriesColors[i] ) .style("stroke-width", "1.3px") .attr("d", line[i]); svg.selectAll(".xcirc"+i) .data(data) .enter().append("circle") .attr("class", "xcirc"+i) .attr("fill", "none") .attr("stroke", G_seriesColors[i]) .attr("cx", function(d) { return x(d[0]) ; }) .attr("cy", function(d) { return y(d[Ndim+i]); }) .attr("r", function(d) { return d[Ndim+i] != 0 ? 0.5 :0}) .attr("ycol", Ndim+i) .on("mouseover", function(d,i){ toolTipStock(d, i, divId, Heading, MeasFormats, this); }) .on("mouseout", function(d,i){ d3.select(this).transition().duration(300).attr("r","0.5"); d3.select(".tipsy").style("visibility", "hidden"); }); } if(Nmeas>1){ var htmlStr="<center><table border=0><tr class=stockRow>"; for(var i=0; i<Nmeas; i++){ htmlStr+="<td><span style=\"background-color:"+G_seriesColors[i]+"\"> </span>"+Heading[0][Ndim+i].split('~_')[0]+"</td>"; } htmlStr+="</tr></table></center>"; d3.select("#"+divId).append("div").style("width", "99%").html(htmlStr); } } function toolTipStock(d, i, divId, Heading, MeasFormats, obj){ d3.select(obj).transition().duration(300).attr("r","5"); var p = d3.select(".tipsy").style("visibility", "visible"); var ycolNo=d3.select(obj).attr("ycol"); p.html('<div class="tipsy-arrow"></div><div class="tipsy-inner"></div>').select(".tipsy-inner").html(Heading[0][0]+" : " + d[0].toString().split("GMT")[0] + "<br>"+Heading[0][ycolNo]+" : " +formatData(d[ycolNo], MeasFormats[ycolNo],0)); var arrowClass = p.select(".tipsy-arrow"); var svg = d3.select("#"+divId).select(".mainsvg")[0][0]; var svgLeft = svg.offsetLeft, svgTop = svg.offsetTop, svgHeight = svg.offsetHeight, svgWidth = svg.offsetWidth; var mouseLeft = d3.event.pageX, mouseTop = d3.event.pageY; var tooltipHeight = p[0][0].clientHeight, tooltipWidth = p[0][0].clientWidth; var top = 0, left = 0, pad=20; if(( svgLeft + tooltipWidth/2 < mouseLeft ) && (mouseTop + tooltipHeight + pad < svgTop + svgHeight )){ //North p.attr("class", "tipsy tipsy-n"); arrowClass.attr("class", "tipsy-arrow tipsy-arrow-n"); top = mouseTop + pad ; left = mouseLeft - tooltipWidth/2 ; } else if((svgLeft + tooltipWidth/2 < mouseLeft ) && (mouseTop - tooltipHeight - pad > svgTop)){ //South p.attr("class", "tipsy tipsy-s"); arrowClass.attr("class", "tipsy-arrow tipsy-arrow-s"); top = mouseTop - tooltipHeight -pad ; left = mouseLeft - tooltipWidth/2 ; } else if( mouseTop + tooltipHeight/2 > svgTop ){ if( svgLeft + tooltipWidth + pad < mouseLeft ){// East p.attr("class", "tipsy tipsy-e"); arrowClass.attr("class", "tipsy-arrow tipsy-arrow-e"); top = mouseTop - tooltipHeight/2; left = mouseLeft - tooltipWidth - pad; } else if(mouseLeft + tooltipWidth < svgLeft + svgWidth){ // West p.attr("class", "tipsy tipsy-w"); arrowClass.attr("class", "tipsy-arrow tipsy-arrow-w"); top = mouseTop - tooltipHeight/2; left = mouseLeft + pad; } } p.style("left", left + "px"); p.style("top", top + "px"); }