Created
January 15, 2014 17:02
-
-
Save vicwue/8440065 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#svg_2 { | |
fill: rgba(0,0,0,0.7); | |
} | |
path {fill: #0f0; | |
stroke:#660000;} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script> | |
<script src="http://d3js.org/d3.v3.min.js"></script> | |
<meta charset=utf-8 /> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<div class='turtlescales'><svg></svg></div> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var hexwid = 300, width = 2500, hexhei = 260, height = 390, rightshift = 0; | |
var dataset = [{"title":"Files","chunkKPI":"No new files"},{"title":"Customer","chunkKPI":"No meeting","chunkKPI2":"planned"},{"title":"Milestones","chunkKPI":"No milestones"},{"title":"Team","chunkKPI":"{0} available"},{"title":"To-Dos","chunkKPI":"No to-dos"}]; | |
var sHexagonSVG = "m-67.79999,133.271c-4.40002,0 -9.79999,-3.117 -12,-6.92798l-68,-117.77905c-2.20001,-3.81097 -2.20001,-10.04498 0,-13.85596l68,-117.77899c2.20001,-3.81104 7.59998,-6.92902 12,-6.92902l136.00006,0c4.40002,0 9.80103,3.11798 12,6.92902l68,117.77899c2.20093,3.81097 2.20093,10.04498 0,13.85596l-68,117.77905c-2.19897,3.81097 -7.59998,6.92798 -12,6.92798l-136.00006,0z";//30y | |
$(".turtlescales").empty(); | |
/*$(".turtlescales").append("<svg>"+sHexagonSVG+"</svg>");*/ | |
var availablebubbles = Math.floor(width / 228); | |
var puffer, str =""; | |
puffer = (availablebubbles-dataset.length)/2; | |
var n = dataset.length; | |
alert("test"); | |
for (var i=0; i<availablebubbles; i++) { | |
var x, y, isactive; | |
if (i-Math.floor(puffer)>=n) { | |
isactive = false; | |
} else { | |
var step = i-Math.floor(puffer); | |
if (step>=0) { | |
isactive = true; | |
} else { | |
isactive = false; | |
} | |
} | |
x = 228*i+150; | |
str+= placehexagon(isactive, i, x); | |
} | |
$(".turtlescales").append("<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"></svg>"); | |
function placehexagon(isactive, i , x) { | |
var y, str; | |
if (i % 2 === 0) { | |
y=height-(hexhei/2); | |
// deko | |
str="<path d=\""+sHexagonSVG+"\" transform=\"translate("+x+","+y+")\" />"; | |
// real | |
str+="<path d=\""+sHexagonSVG+"\" transform=\"translate("+x+","+y+")\" "; | |
if(isactive) { }//str+="fill=\"#f00\"";} | |
str+=" />"; | |
} else { | |
// isodd | |
y=hexhei/2; | |
// real | |
str="<path d=\""+sHexagonSVG+"\" transform=\"translate("+x+","+y+")\" "; | |
if(isactive) {} //str+="fill=\"#f00\"";} | |
str+=" />"; | |
// deko | |
str+="<path d=\""+sHexagonSVG+"\" transform=\"translate("+x+","+y+")\" />"; | |
} | |
return str; | |
} | |
$(".turtlescales svg").attr("width", width).attr("height", height).append("<g>"+str+"</g>"); | |
//////////////////////////////////////// | |
/* | |
var textdiv = d3.select(".turtlescales").append("div").attr("class", | |
"turtlescalesheadings"); | |
var text = textdiv.selectAll("span").data(dataset.apples).enter() | |
.append("span").style("top", function(d, i) { | |
var result; | |
if (i % 2 == 0) { | |
result = 10; | |
} else { | |
// isodd | |
result = height - 22; | |
} | |
return result + "px"; | |
}).style("left", function(d, i) { | |
var result; | |
if (i % 2 == 0) { | |
result = width - rightshift - (i * (radius / 2)); | |
} else { | |
// isodd | |
result = width - rightshift - (i * (radius / 2)); | |
} | |
return result + "px"; | |
}).style("position", "absolute").attr("class", "labels").text( | |
function(d) { | |
if (d.title) | |
return d.title; | |
}).attr("data-keyinarray", function(d, i) { | |
if (d.title) | |
return d.title.toLowerCase(); | |
}); | |
var textediv = d3.select(".turtlescales").append("div").attr("class", | |
"turtlescalestexts"); | |
var texte = textediv.selectAll("div").data(dataset.apples).enter() | |
.append("div").style("top", function(d, i) { | |
var result; | |
if (i % 2 == 0) { | |
result = 30; | |
} else { | |
// isodd | |
result = height - 75; | |
} | |
return result + "px"; | |
}).style("left", function(d, i) { | |
var result; | |
if (i % 2 == 0) { | |
result = width - rightshift - (i * (radius / 2)); | |
} else { | |
// isodd | |
result = width - rightshift - (i * (radius / 2)); | |
} | |
return result + "px"; | |
}).style("position", "absolute").attr("class", "indicator") | |
.html(function(d) { | |
if (d.chunkKPI3) { | |
return "<span class='threelines'>"+d.chunkKPI+"</span><span class='threelines'>"+d.chunkKPI2+"</span><span class='threelines'>"+d.chunkKPI3+"</span>"; | |
} | |
else if (d.chunkKPI2) { | |
return "<span class='twolines'>"+d.chunkKPI+"</span><span class='twolines'>"+d.chunkKPI2+"</span>"; | |
} | |
else if (d.chunkKPI) | |
{ | |
return "<span class='oneline'>"+d.chunkKPI+"</span>"; | |
} | |
}).attr("data-keyinarray", function(d) { | |
if (d.title) | |
return d.title.toLowerCase(); | |
}); | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment