Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bipartite graph of tracking traffic between 28 sites and 26 trackers
!function(){
var bP={};
var b=30, bb=200, height=600, buffMargin=1, minHeight=14;
//var c1=[-180, 40], c2=[-50, 160], c3=[0, 210]; //Column positions of labels.
var c1=[-150, 40], c2=[-7, 230], c3=[-10, 230];
// c1 : 1. distance between sites and traffic
//2. distance between bars and trackers
//c2: 1. position of header(left raffic)
//2. position of header(right traffic)
//c3: 1. distance between bars and traffic(sites)
//2. distance between trackers and traffic
//var colors =["#FF99CC", "#66CCCC", "#FFCC33", "#6666CC", "#99CC33", "#99CCFF", "#999999", "#CC6699", "#0099CC", "#FF9900"];
var colors = ["#000000"]
bP.partData = function(data,p){
var sData={};
sData.keys=[
d3.set(data.map(function(d){ return d[0];})).values().sort(function(a,b){ return ( a<b? -1 : a>b ? 1 : 0);}),
d3.set(data.map(function(d){ return d[1];})).values().sort(function(a,b){ return ( a<b? -1 : a>b ? 1 : 0);})
];
sData.data = [ sData.keys[0].map( function(d){ return sData.keys[1].map( function(v){ return 0; }); }),
sData.keys[1].map( function(d){ return sData.keys[0].map( function(v){ return 0; }); })
];
data.forEach(function(d){
sData.data[0][sData.keys[0].indexOf(d[0])][sData.keys[1].indexOf(d[1])]=d[p];
sData.data[1][sData.keys[1].indexOf(d[1])][sData.keys[0].indexOf(d[0])]=d[p];
});
return sData;
}
function visualize(data){
var vis ={};
function calculatePosition(a, s, e, b, m){
var total=d3.sum(a);
var sum=0, neededHeight=0, leftoverHeight= e-s-2*b*a.length;
var ret =[];
a.forEach(
function(d){
var v={};
v.percent = (total == 0 ? 0 : d/total);
v.value=d;
v.height=Math.max(v.percent*(e-s-2*b*a.length), m);
(v.height==m ? leftoverHeight-=m : neededHeight+=v.height );
ret.push(v);
}
);
var scaleFact=leftoverHeight/Math.max(neededHeight,1), sum=0;
ret.forEach(
function(d){
d.percent = scaleFact*d.percent;
d.height=(d.height==m? m : d.height*scaleFact);
d.middle=sum+b+d.height/2;
d.y=s + d.middle - d.percent*(e-s-2*b*a.length)/2;
d.h= d.percent*(e-s-2*b*a.length);
d.percent = (total == 0 ? 0 : d.value/total);
sum+=2*b+d.height;
}
);
return ret;
}
vis.mainBars = [
calculatePosition( data.data[0].map(function(d){ return d3.sum(d);}), 0, height, buffMargin, minHeight),
calculatePosition( data.data[1].map(function(d){ return d3.sum(d);}), 0, height, buffMargin, minHeight)
];
vis.subBars = [[],[]];
vis.mainBars.forEach(function(pos,p){
pos.forEach(function(bar, i){
calculatePosition(data.data[p][i], bar.y, bar.y+bar.h, 0, 0).forEach(function(sBar,j){
sBar.key1=(p==0 ? i : j);
sBar.key2=(p==0 ? j : i);
vis.subBars[p].push(sBar);
});
});
});
vis.subBars.forEach(function(sBar){
sBar.sort(function(a,b){
return (a.key1 < b.key1 ? -1 : a.key1 > b.key1 ?
1 : a.key2 < b.key2 ? -1 : a.key2 > b.key2 ? 1: 0 )});
});
vis.edges = vis.subBars[0].map(function(p,i){
return {
key1: p.key1,
key2: p.key2,
y1:p.y,
y2:vis.subBars[1][i].y,
h1:p.h,
h2:vis.subBars[1][i].h
};
});
vis.keys=data.keys;
return vis;
}
function arcTween(a) {
var i = d3.interpolate(this._current, a);
this._current = i(0);
return function(t) {
return edgePolygon(i(t));
};
}
function drawPart(data, id, p){
d3.select("#"+id).append("g").attr("class","part"+p)
.attr("transform","translate("+( p*(bb+b))+",0)");
d3.select("#"+id).select(".part"+p).append("g").attr("class","subbars");
d3.select("#"+id).select(".part"+p).append("g").attr("class","mainbars");
var mainbar = d3.select("#"+id).select(".part"+p).select(".mainbars")
.selectAll(".mainbar").data(data.mainBars[p])
.enter().append("g").attr("class","mainbar");
mainbar.append("rect").attr("class","mainrect")
.attr("x", 0).attr("y",function(d){ return d.middle-d.height/2; })
.attr("width",b).attr("height",function(d){ return d.height; })
.style("shape-rendering","auto")
.style("fill-opacity",0).style("stroke-width","0.5")
.style("stroke","black").style("stroke-opacity",0);
mainbar.append("text").attr("class","barlabel")
.attr("x", c1[p]).attr("y",function(d){ return d.middle+5;})
.text(function(d,i){ return data.keys[p][i];})
.attr("text-anchor","start" );
// mainbar.append("text").attr("class","barvalue")
// .attr("x", c2[p]).attr("y",function(d){ return d.middle+5;})
// .text(function(d,i){ return d.value ;})
// .attr("value",function(d,i){ return d.value ;})
// .attr("text-anchor","end");
mainbar.append("text").attr("class","barpercent")
.attr("x", c3[p]).attr("y",function(d){ return d.middle+5;})
.text(function(d,i){ if((100*d.percent)<0.1){
return 0.1}
else{return (100*d.percent).toFixed(1)+"%" ;}})
.attr("text-anchor","end").style("fill","grey");
d3.select("#"+id).select(".part"+p).select(".subbars")
.selectAll(".subbar").data(data.subBars[p]).enter()
.append("rect").attr("class","subbar")
.attr("x", 0).attr("y",function(d){ return d.y})
.attr("width",b).attr("height",function(d){ return d.h})
.style("fill",function(d){ return colors[d.key1];});
}
function drawEdges(data, id){
d3.select("#"+id).append("g").attr("class","edges").attr("transform","translate("+ b+",0)");
d3.select("#"+id).select(".edges").selectAll(".edge")
.data(data.edges).enter().append("polygon").attr("class","edge")
.attr("points", edgePolygon).style("fill",function(d){ return colors[d.key1];})
.style("opacity",0.5).each(function(d) { this._current = d; });
}
function drawHeader(header, id){
d3.select("#"+id).append("g").attr("class","header").append("text").text(header[2])
.style("font-size","20").attr("x",130).attr("y",-20).style("text-anchor","middle")
.style("font-weight","bold");
[0,1].forEach(function(d){
var h = d3.select("#"+id).select(".part"+d).append("g").attr("class","header");
h.append("text").text(header[d]).attr("x", (c1[d]+5))
.attr("y", -5).style("fill","grey");
h.append("text").text("Percent").attr("x", (c2[d]-40))
.attr("y", -5).style("fill","grey");
h.append("line").attr("x1",c1[d]-10).attr("y1", -2)
.attr("x2",c3[d]+5).attr("y2", -2).style("stroke","black")
.style("stroke-width","1").style("shape-rendering","crispEdges");
});
}
//tips
var populationData = {};
var tip = d3.tip()
.attr('class','d3-tip')
.offset([-10,0])
.html(function(d){
var data = populationData[0]["data"]["data"][1];
//console.log(data);
var key = populationData[0]["data"]["keys"][1];
//console.log(key);
var stateData = {};
var i = 0;
data.forEach(function(d){
stateData[key[i]] = data[i];
i++;
});
return d.id;
});
function drawMap(svg){
var w = 700;
var h = 700;
var projection = d3.geo.albersUsa()
.translate([w/2, h/2])
.scale([700]);
var path = d3.geo.path()
.projection(projection);
//Load in GeoJSON data
d3.json("us-state.json", function(json) {
g = svg.append("g")
.attr("class", "created")
.selectAll("path")
.data(json.features)
.enter()
.append("path")
.attr("d", path)
.attr("transform", "translate(380,-150)")
.style("fill","white").style('stroke', '#666').style('stroke-width', 0.5);
});
}
function edgePolygon(d){
return [0, d.y1, bb, d.y2, bb, d.y2+d.h2, 0, d.y1+d.h1].join(" ");
}
function transitionPart(data, id, p){
var mainbar = d3.select("#"+id).select(".part"+p).select(".mainbars")
.selectAll(".mainbar").data(data.mainBars[p]);
mainbar.select(".mainrect").transition().duration(500)
.attr("y",function(d){ return d.middle-d.height/2;})
.attr("height",function(d){ return d.height;});
mainbar.select(".barlabel").transition().duration(500)
.attr("y",function(d){ return d.middle+5;})
.text(function (d,i){if(d.value==0){return ""}else{return data.keys[p][i];}});
mainbar.select(".barvalue").transition().duration(500)
.attr("y",function(d){ return d.middle+5;}).text(function(d,i){ if(d.value==0){return "";}
else{return d.value;}});
mainbar.select(".barpercent").transition().duration(500)
.attr("y",function(d){ return d.middle+5;})
.text(function(d,i){ if(d.value==0){return "";}
else if((100*d.percent)<0.1){return "0.1%";}
else{return (100*d.percent).toFixed(1)+"%" ;}});
d3.select("#"+id).select(".part"+p).select(".subbars")
.selectAll(".subbar").data(data.subBars[p])
.transition().duration(500)
.attr("y",function(d){ return d.y}).attr("height",function(d){ return d.h});
}
function transitionEdges(data, id){
d3.select("#"+id).append("g").attr("class","edges")
.attr("transform","translate("+ b+",0)");
d3.select("#"+id).select(".edges").selectAll(".edge").data(data.edges)
.transition().duration(500)
.attrTween("points", arcTween)
.style("opacity",function(d){ return (d.h1 ==0 || d.h2 == 0 ? 0 : 0.5);});
}
function transition(data, id){
transitionPart(data, id, 0);
transitionPart(data, id, 1);
transitionEdges(data, id);
}
bP.draw = function(data, svg){
//drawMap(svg)
//populationData = data;
//svg.call(tip);
//d3.selectAll(".d3-tip");
data.forEach(function(biP,s){
svg.append("g")
.attr("id", biP.id)
.attr("transform","translate("+ (550*s)+",0)");
var visData = visualize(biP.data);
drawPart(visData, biP.id, 0);
drawPart(visData, biP.id, 1);
drawEdges(visData, biP.id);
drawHeader(biP.header, biP.id);
[0,1].forEach(function(p){
d3.select("#"+biP.id)
.select(".part"+p)
.select(".mainbars")
.selectAll(".mainbar")
.on("mouseover",function(d, i){ return bP.selectSegment(data, p, i,svg); })
.on("mouseout",function(d, i){ return bP.deSelectSegment(data, p, i,svg); });
// .on("mouseover",function(d, i){ return bP.clickSegment(data, p, i,svg); });
});
});
}
/*
function sleep(seconds)
{
var e = new Date().getTime() + (seconds * 1000);
while (new Date().getTime() <= e) {}
}
var flag = true;*/
bP.selectSegment = function(data, m, s,svg){
data.forEach(function(k){
var newdata = {keys:[], data:[]};
newdata.keys = k.data.keys.map( function(d){ return d;});
newdata.data[m] = k.data.data[m].map( function(d){ return d;});
newdata.data[1-m] = k.data.data[1-m]
.map( function(v){ return v.map(function(d, i){ return (s==i ? d : 0);}); });
transition(visualize(newdata), k.id);
var selectedBar = d3.select("#"+k.id).select(".part"+m).select(".mainbars")
.selectAll(".mainbar").filter(function(d,i){ return (i==s);});
selectedBar.select(".mainrect").style("stroke-opacity",1);
selectedBar.select(".barlabel").style('font-weight','bold');
selectedBar.select(".barvalue").style('font-weight','bold');
selectedBar.select(".barpercent").style('font-weight','bold');
});
//removeCreatedGroup = d3.select("g").selectAll(".created").remove();
if(m==0){
removeCreatedGroup = d3.select("g").selectAll(".created").remove();
var chosenData = data["0"]["data"]["data"][0][s];
var chosenState = data["0"]["data"]["keys"][1];
var sortArray = {};
var i = 0;
chosenData.forEach(function(d){
sortArray[chosenState[i]] = chosenData[i];
i++;
});
var keys = [];
for(var key in sortArray) keys.push(key);
var afterSort = keys.sort(function(a,b){return sortArray[b]-sortArray[a]});
var statesHL = afterSort.slice(0,10);
/*
var w = 700;
var h = 700;
var projection = d3.geo.albersUsa()
.translate([w/2, h/2])
.scale([700]);
var path = d3.geo.path()
.projection(projection);
//Load in GeoJSON data
d3.json("us-state.json", function(json) {
g = svg.append("g")
.attr("class", "created")
.selectAll("path")
.data(json.features)
.enter()
.append("path")
.attr("d", path)
.attr("transform", "translate(380,-150)")
.style('stroke', '#666')
.style('stroke-width', 0.5)
.style("fill",function(d){
var statesName = d.properties.name;
if(statesHL.indexOf(statesName)>-1){
return colors[s];
}else{
return "white"; }
})
.style("fill-opacity",function(d){
var statesName = d.properties.name;
if(statesHL.indexOf(statesName)>-1){
var index = statesHL.indexOf(statesName)
return 1-index/10;
}else{return 1;}
});
svg.selectAll('.created').selectAll("text")
.data(json.features)
.enter()
.append("svg:text")
.text(function(d){
var statesName = d.properties.name;
if(statesHL.indexOf(statesName)>-1){
return statesShortName[statesName];
}else{
return ""; }
})
.attr("x", function(d){
if(path.centroid(d)[0]){
return path.centroid(d)[0]+380;
}
})
.attr("y", function(d){
if(path.centroid(d)[1]){
return path.centroid(d)[1]-150;
}
})
.attr("text-anchor","middle")
.attr('fill','#444');
}); */
}
}
bP.deSelectSegment = function(data, m, s,svg){
data.forEach(function(k){
transition(visualize(k.data), k.id);
var selectedBar = d3.select("#"+k.id).select(".part"+m).select(".mainbars")
.selectAll(".mainbar").filter(function(d,i){ return (i==s);});
selectedBar.select(".mainrect").style("stroke-opacity",0);
selectedBar.select(".barlabel").style('font-weight','normal');
selectedBar.select(".barvalue").style('font-weight','normal');
selectedBar.select(".barpercent").style('font-weight','normal');
});
//drawMap(svg);
}
this.bP = bP;
}();
<!DOCTYPE html>
<meta charset="utf-8">
<header>
<title>Factors</title>
<link rel="stylesheet" href="style.css"/>
</header>
<body>
<div class="main">
</div>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://code.jquery.com/jquery-1.11.0.min.js" type="text/javascript" charset="utf-8"></script>
<script src="http://d3js.org/topojson.v1.min.js"></script>
<script src="http://labratrevenge.com/d3-tip/javascripts/d3.tip.v0.6.3.js"></script>
<script src="biPartite.js"></script>
<script>
var data=[
['qq.com','crashlytics.com',871245],
['qq.com','flurry.com',534316],
['qq.com','tanx.com',341268],
['qq.com','scorecardresearch.com',364405],
['qq.com','cnzz.com',295717],
['qq.com','mmstat.com',257879],
['qq.com','weibo.com',147738],
['qq.com','baidustatic.com',221005],
['qq.com','google-analytics.com',271134],
['qq.com','doubleclick.net',164609],
['qq.com','baidu.com',153522],
['qq.com','bdstatic.com',132073],
['qq.com','miaozhen.com',136170],
['qq.com','mediav.com',50371],
['qq.com','sina.com.cn',87727],
['qq.com','inmobi.com',78087],
['qq.com','supercell.net',61216],
['qq.com','adsmogo.com',60975],
['qq.com','googlesyndication.com',45551],
['qq.com','tapjoy.com',52299],
['qq.com','tapjoyads.com',47961],
['qq.com','vungle.com',43141],
['qq.com','wrating.com',22896],
['qq.com','optaim.com',33741],
['qq.com','chartboost.com',39043],
['qq.com','appsflyer.com',37838],
['apple.com','crashlytics.com',374653],
['apple.com','flurry.com',254746],
['apple.com','tanx.com',134282],
['apple.com','scorecardresearch.com',149027],
['apple.com','cnzz.com',118795],
['apple.com','mmstat.com',104421],
['apple.com','weibo.com',51839],
['apple.com','baidustatic.com',94127],
['apple.com','google-analytics.com',129552],
['apple.com','doubleclick.net',67512],
['apple.com','baidu.com',59258],
['apple.com','bdstatic.com',52489],
['apple.com','miaozhen.com',44791],
['apple.com','mediav.com',19104],
['apple.com','sina.com.cn',35982],
['apple.com','inmobi.com',36074],
['apple.com','supercell.net',25224],
['apple.com','adsmogo.com',29768],
['apple.com','googlesyndication.com',18547],
['apple.com','tapjoy.com',29583],
['apple.com','tapjoyads.com',27914],
['apple.com','vungle.com',20680],
['apple.com','wrating.com',10201],
['apple.com','optaim.com',12427],
['apple.com','chartboost.com',15765],
['apple.com','appsflyer.com',14930],
['baidu.com','crashlytics.com',224503],
['baidu.com','flurry.com',140275],
['baidu.com','tanx.com',118924],
['baidu.com','scorecardresearch.com',99613],
['baidu.com','cnzz.com',100320],
['baidu.com','mmstat.com',81873],
['baidu.com','weibo.com',58245],
['baidu.com','baidustatic.com',91842],
['baidu.com','google-analytics.com',76221],
['baidu.com','doubleclick.net',56283],
['baidu.com','baidu.com',63112],
['baidu.com','bdstatic.com',49846],
['baidu.com','miaozhen.com',42153],
['baidu.com','mediav.com',27003],
['baidu.com','sina.com.cn',22372],
['baidu.com','inmobi.com',18290],
['baidu.com','supercell.net',16641],
['baidu.com','adsmogo.com',14915],
['baidu.com','googlesyndication.com',15699],
['baidu.com','tapjoy.com',13580],
['baidu.com','tapjoyads.com',15542],
['baidu.com','vungle.com',10440],
['baidu.com','wrating.com',9184],
['baidu.com','optaim.com',9498],
['baidu.com','chartboost.com',10205],
['baidu.com','appsflyer.com',8399],
['taobao.com','crashlytics.com',89990],
['taobao.com','flurry.com',52404],
['taobao.com','tanx.com',41657],
['taobao.com','scorecardresearch.com',39386],
['taobao.com','cnzz.com',33182],
['taobao.com','mmstat.com',36727],
['taobao.com','weibo.com',16646],
['taobao.com','baidustatic.com',24817],
['taobao.com','google-analytics.com',28279],
['taobao.com','doubleclick.net',18751],
['taobao.com','baidu.com',16674],
['taobao.com','bdstatic.com',14070],
['taobao.com','miaozhen.com',14624],
['taobao.com','mediav.com',7395],
['taobao.com','sina.com.cn',10470],
['taobao.com','inmobi.com',8171],
['taobao.com','supercell.net',7063],
['taobao.com','adsmogo.com',7035],
['taobao.com','googlesyndication.com',5927],
['taobao.com','tapjoy.com',5789],
['taobao.com','tapjoyads.com',5179],
['taobao.com','vungle.com',4321],
['taobao.com','wrating.com',3711],
['taobao.com','optaim.com',3158],
['taobao.com','chartboost.com',4487],
['taobao.com','appsflyer.com',4681],
['tmall.com','crashlytics.com',80327],
['tmall.com','flurry.com',51181],
['tmall.com','tanx.com',29567],
['tmall.com','scorecardresearch.com',32131],
['tmall.com','cnzz.com',27884],
['tmall.com','mmstat.com',20352],
['tmall.com','weibo.com',11759],
['tmall.com','baidustatic.com',20893],
['tmall.com','google-analytics.com',26161],
['tmall.com','doubleclick.net',14904],
['tmall.com','baidu.com',13401],
['tmall.com','bdstatic.com',11238],
['tmall.com','miaozhen.com',9635],
['tmall.com','mediav.com',4247],
['tmall.com','sina.com.cn',6831],
['tmall.com','inmobi.com',7031],
['tmall.com','supercell.net',6691],
['tmall.com','adsmogo.com',3025],
['tmall.com','googlesyndication.com',4507],
['tmall.com','tapjoy.com',4287],
['tmall.com','tapjoyads.com',5889],
['tmall.com','vungle.com',3626],
['tmall.com','wrating.com',1342],
['tmall.com','optaim.com',2404],
['tmall.com','chartboost.com',4347],
['tmall.com','appsflyer.com',2704],
['meituan.com','crashlytics.com',73604],
['meituan.com','flurry.com',44943],
['meituan.com','tanx.com',28262],
['meituan.com','scorecardresearch.com',28298],
['meituan.com','cnzz.com',21872],
['meituan.com','mmstat.com',20093],
['meituan.com','weibo.com',10219],
['meituan.com','baidustatic.com',16971],
['meituan.com','google-analytics.com',23760],
['meituan.com','doubleclick.net',12579],
['meituan.com','baidu.com',10982],
['meituan.com','bdstatic.com',9439],
['meituan.com','miaozhen.com',9965],
['meituan.com','mediav.com',4011],
['meituan.com','sina.com.cn',5627],
['meituan.com','inmobi.com',5627],
['meituan.com','supercell.net',5191],
['meituan.com','adsmogo.com',5101],
['meituan.com','googlesyndication.com',3812],
['meituan.com','tapjoy.com',4102],
['meituan.com','tapjoyads.com',4574],
['meituan.com','vungle.com',2450],
['meituan.com','wrating.com',1924],
['meituan.com','optaim.com',2686],
['meituan.com','chartboost.com',1851],
['meituan.com','appsflyer.com',2977],
['163.com','crashlytics.com',43660],
['163.com','flurry.com',23229],
['163.com','tanx.com',30251],
['163.com','scorecardresearch.com',21375],
['163.com','cnzz.com',23452],
['163.com','mmstat.com',19177],
['163.com','weibo.com',18182],
['163.com','baidustatic.com',21341],
['163.com','google-analytics.com',13855],
['163.com','doubleclick.net',13048],
['163.com','baidu.com',13580],
['163.com','bdstatic.com',9735],
['163.com','miaozhen.com',11005],
['163.com','mediav.com',8155],
['163.com','sina.com.cn',4842],
['163.com','inmobi.com',3571],
['163.com','supercell.net',3811],
['163.com','adsmogo.com',3348],
['163.com','googlesyndication.com',4773],
['163.com','tapjoy.com',2215],
['163.com','tapjoyads.com',1751],
['163.com','vungle.com',1889],
['163.com','wrating.com',4344],
['163.com','optaim.com',1889],
['163.com','chartboost.com',2026],
['163.com','appsflyer.com',1391],
['uber.com','crashlytics.com',58274],
['uber.com','flurry.com',37417],
['uber.com','tanx.com',20496],
['uber.com','scorecardresearch.com',25656],
['uber.com','cnzz.com',21030],
['uber.com','mmstat.com',14255],
['uber.com','weibo.com',7621],
['uber.com','baidustatic.com',15902],
['uber.com','google-analytics.com',18850],
['uber.com','doubleclick.net',11134],
['uber.com','baidu.com',11056],
['uber.com','bdstatic.com',8468],
['uber.com','miaozhen.com',7402],
['uber.com','mediav.com',2007],
['uber.com','sina.com.cn',7355],
['uber.com','inmobi.com',5928],
['uber.com','supercell.net',3873],
['uber.com','adsmogo.com',4940],
['uber.com','googlesyndication.com',3748],
['uber.com','tapjoy.com',5081],
['uber.com','tapjoyads.com',3968],
['uber.com','vungle.com',2854],
['uber.com','wrating.com',941],
['uber.com','optaim.com',2180],
['uber.com','chartboost.com',2807],
['uber.com','appsflyer.com',1960],
['weibo.com','crashlytics.com',56063],
['weibo.com','flurry.com',33844],
['weibo.com','tanx.com',18824],
['weibo.com','scorecardresearch.com',22275],
['weibo.com','cnzz.com',16151],
['weibo.com','mmstat.com',12884],
['weibo.com','weibo.com',6718],
['weibo.com','baidustatic.com',13620],
['weibo.com','google-analytics.com',19687],
['weibo.com','doubleclick.net',11215],
['weibo.com','baidu.com',10084],
['weibo.com','bdstatic.com',6676],
['weibo.com','miaozhen.com',6591],
['weibo.com','mediav.com',2800],
['weibo.com','sina.com.cn',5332],
['weibo.com','inmobi.com',3889],
['weibo.com','supercell.net',3536],
['weibo.com','adsmogo.com',4625],
['weibo.com','googlesyndication.com',2885],
['weibo.com','tapjoy.com',2928],
['weibo.com','tapjoyads.com',2616],
['weibo.com','vungle.com',2532],
['weibo.com','wrating.com',1358],
['weibo.com','optaim.com',2051],
['weibo.com','chartboost.com',3536],
['weibo.com','appsflyer.com',2532],
['bing.com','crashlytics.com',60130],
['bing.com','flurry.com',33167],
['bing.com','tanx.com',16346],
['bing.com','scorecardresearch.com',22814],
['bing.com','cnzz.com',13873],
['bing.com','mmstat.com',13202],
['bing.com','weibo.com',5504],
['bing.com','baidustatic.com',13244],
['bing.com','google-analytics.com',19098],
['bing.com','doubleclick.net',12280],
['bing.com','baidu.com',6482],
['bing.com','bdstatic.com',6678],
['bing.com','miaozhen.com',5504],
['bing.com','mediav.com',2319],
['bing.com','sina.com.cn',5169],
['bing.com','inmobi.com',4066],
['bing.com','supercell.net',3968],
['bing.com','adsmogo.com',3241],
['bing.com','googlesyndication.com',2459],
['bing.com','tapjoy.com',3437],
['bing.com','tapjoyads.com',3143],
['bing.com','vungle.com',3772],
['bing.com','wrating.com',824],
['bing.com','optaim.com',2179],
['bing.com','chartboost.com',2654],
['bing.com','appsflyer.com',1886],
['google.com','crashlytics.com',34967],
['google.com','flurry.com',21698],
['google.com','tanx.com',20174],
['google.com','scorecardresearch.com',14550],
['google.com','cnzz.com',15899],
['google.com','mmstat.com',14335],
['google.com','weibo.com',12042],
['google.com','baidustatic.com',14254],
['google.com','google-analytics.com',13391],
['google.com','doubleclick.net',8590],
['google.com','baidu.com',9291],
['google.com','bdstatic.com',8550],
['google.com','miaozhen.com',6244],
['google.com','mediav.com',6405],
['google.com','sina.com.cn',2791],
['google.com','inmobi.com',2994],
['google.com','supercell.net',2670],
['google.com','adsmogo.com',3290],
['google.com','googlesyndication.com',3129],
['google.com','tapjoy.com',1888],
['google.com','tapjoyads.com',2090],
['google.com','vungle.com',1524],
['google.com','wrating.com',1322],
['google.com','optaim.com',2090],
['google.com','chartboost.com',1564],
['google.com','appsflyer.com',1767],
['sina.com.cn','crashlytics.com',20898],
['sina.com.cn','flurry.com',11394],
['sina.com.cn','tanx.com',37178],
['sina.com.cn','scorecardresearch.com',11394],
['sina.com.cn','cnzz.com',10354],
['sina.com.cn','mmstat.com',11483],
['sina.com.cn','weibo.com',25326],
['sina.com.cn','baidustatic.com',7245],
['sina.com.cn','google-analytics.com',6395],
['sina.com.cn','doubleclick.net',9415],
['sina.com.cn','baidu.com',5088],
['sina.com.cn','bdstatic.com',4987],
['sina.com.cn','miaozhen.com',6687],
['sina.com.cn','mediav.com',5456],
['sina.com.cn','sina.com.cn',9415],
['sina.com.cn','inmobi.com',1408],
['sina.com.cn','supercell.net',1320],
['sina.com.cn','adsmogo.com',1040],
['sina.com.cn','googlesyndication.com',2830],
['sina.com.cn','tapjoy.com',1040],
['sina.com.cn','tapjoyads.com',381],
['sina.com.cn','vungle.com',89],
['sina.com.cn','wrating.com',7524],
['sina.com.cn','optaim.com',1040],
['sina.com.cn','chartboost.com',939],
['sina.com.cn','appsflyer.com',571],
['haosou.com','crashlytics.com',24241],
['haosou.com','flurry.com',16011],
['haosou.com','tanx.com',20489],
['haosou.com','scorecardresearch.com',14033],
['haosou.com','cnzz.com',12430],
['haosou.com','mmstat.com',10592],
['haosou.com','weibo.com',9929],
['haosou.com','baidustatic.com',12259],
['haosou.com','google-analytics.com',7396],
['haosou.com','doubleclick.net',8754],
['haosou.com','baidu.com',8540],
['haosou.com','bdstatic.com',4339],
['haosou.com','miaozhen.com',7011],
['haosou.com','mediav.com',5729],
['haosou.com','sina.com.cn',3089],
['haosou.com','inmobi.com',2918],
['haosou.com','supercell.net',1454],
['haosou.com','adsmogo.com',1560],
['haosou.com','googlesyndication.com',3025],
['haosou.com','tapjoy.com',1218],
['haosou.com','tapjoyads.com',898],
['haosou.com','vungle.com',1079],
['haosou.com','wrating.com',3089],
['haosou.com','optaim.com',4756],
['haosou.com','chartboost.com',1496],
['haosou.com','appsflyer.com',759],
['xunlei.com','crashlytics.com',38078],
['xunlei.com','flurry.com',23995],
['xunlei.com','tanx.com',13712],
['xunlei.com','scorecardresearch.com',15590],
['xunlei.com','cnzz.com',13712],
['xunlei.com','mmstat.com',10783],
['xunlei.com','weibo.com',5391],
['xunlei.com','baidustatic.com',10284],
['xunlei.com','google-analytics.com',12247],
['xunlei.com','doubleclick.net',6941],
['xunlei.com','baidu.com',7142],
['xunlei.com','bdstatic.com',4892],
['xunlei.com','miaozhen.com',5805],
['xunlei.com','mediav.com',1963],
['xunlei.com','sina.com.cn',3385],
['xunlei.com','inmobi.com',3301],
['xunlei.com','supercell.net',2547],
['xunlei.com','adsmogo.com',2844],
['xunlei.com','googlesyndication.com',1878],
['xunlei.com','tapjoy.com',2420],
['xunlei.com','tapjoyads.com',2717],
['xunlei.com','vungle.com',2377],
['xunlei.com','wrating.com',1794],
['xunlei.com','optaim.com',881],
['xunlei.com','chartboost.com',2462],
['xunlei.com','appsflyer.com',2717],
['instagram.com','crashlytics.com',39652],
['instagram.com','flurry.com',25253],
['instagram.com','tanx.com',14984],
['instagram.com','scorecardresearch.com',14481],
['instagram.com','cnzz.com',11735],
['instagram.com','mmstat.com',9900],
['instagram.com','weibo.com',3710],
['instagram.com','baidustatic.com',8209],
['instagram.com','google-analytics.com',14297],
['instagram.com','doubleclick.net',7338],
['instagram.com','baidu.com',5596],
['instagram.com','bdstatic.com',5780],
['instagram.com','miaozhen.com',6098],
['instagram.com','mediav.com',1968],
['instagram.com','sina.com.cn',4397],
['instagram.com','inmobi.com',3433],
['instagram.com','supercell.net',2244],
['instagram.com','adsmogo.com',2480],
['instagram.com','googlesyndication.com',2296],
['instagram.com','tapjoy.com',2429],
['instagram.com','tapjoyads.com',2429],
['instagram.com','vungle.com',2203],
['instagram.com','wrating.com',779],
['instagram.com','optaim.com',1097],
['instagram.com','chartboost.com',1097],
['instagram.com','appsflyer.com',1650],
['alipay.com','crashlytics.com',38192],
['alipay.com','flurry.com',22862],
['alipay.com','tanx.com',14664],
['alipay.com','scorecardresearch.com',14664],
['alipay.com','cnzz.com',13199],
['alipay.com','mmstat.com',11211],
['alipay.com','weibo.com',5759],
['alipay.com','baidustatic.com',10104],
['alipay.com','google-analytics.com',12092],
['alipay.com','doubleclick.net',6200],
['alipay.com','baidu.com',6691],
['alipay.com','bdstatic.com',5984],
['alipay.com','miaozhen.com',4611],
['alipay.com','mediav.com',2521],
['alipay.com','sina.com.cn',3679],
['alipay.com','inmobi.com',2787],
['alipay.com','supercell.net',2613],
['alipay.com','adsmogo.com',2439],
['alipay.com','googlesyndication.com',2213],
['alipay.com','tapjoy.com',2572],
['alipay.com','tapjoyads.com',1506],
['alipay.com','vungle.com',1681],
['alipay.com','wrating.com',359],
['alipay.com','optaim.com',1599],
['alipay.com','chartboost.com',2254],
['alipay.com','appsflyer.com',1547],
['twitter.com','crashlytics.com',25512],
['twitter.com','flurry.com',16313],
['twitter.com','tanx.com',17562],
['twitter.com','scorecardresearch.com',10961],
['twitter.com','cnzz.com',9300],
['twitter.com','mmstat.com',10300],
['twitter.com','weibo.com',12724],
['twitter.com','baidustatic.com',7014],
['twitter.com','google-analytics.com',8813],
['twitter.com','doubleclick.net',5701],
['twitter.com','baidu.com',4186],
['twitter.com','bdstatic.com',4049],
['twitter.com','miaozhen.com',5389],
['twitter.com','mediav.com',2589],
['twitter.com','sina.com.cn',4939],
['twitter.com','inmobi.com',2974],
['twitter.com','supercell.net',1864],
['twitter.com','adsmogo.com',2139],
['twitter.com','googlesyndication.com',2038],
['twitter.com','tapjoy.com',1900],
['twitter.com','tapjoyads.com',964],
['twitter.com','vungle.com',1212],
['twitter.com','wrating.com',1836],
['twitter.com','optaim.com',1588],
['twitter.com','chartboost.com',1799],
['twitter.com','appsflyer.com',936],
['toutiao.com','crashlytics.com',33551],
['toutiao.com','flurry.com',19007],
['toutiao.com','tanx.com',12699],
['toutiao.com','scorecardresearch.com',14817],
['toutiao.com','cnzz.com',11326],
['toutiao.com','mmstat.com',9753],
['toutiao.com','weibo.com',5427],
['toutiao.com','baidustatic.com',9344],
['toutiao.com','google-analytics.com',9117],
['toutiao.com','doubleclick.net',7272],
['toutiao.com','baidu.com',5381],
['toutiao.com','bdstatic.com',4972],
['toutiao.com','miaozhen.com',3727],
['toutiao.com','mediav.com',1245],
['toutiao.com','sina.com.cn',3454],
['toutiao.com','inmobi.com',2254],
['toutiao.com','supercell.net',2482],
['toutiao.com','adsmogo.com',2436],
['toutiao.com','googlesyndication.com',1427],
['toutiao.com','tapjoy.com',2072],
['toutiao.com','tapjoyads.com',2209],
['toutiao.com','vungle.com',1563],
['toutiao.com','wrating.com',645],
['toutiao.com','optaim.com',964],
['toutiao.com','chartboost.com',1891],
['toutiao.com','appsflyer.com',1473],
['youku.com','crashlytics.com',24206],
['youku.com','flurry.com',12733],
['youku.com','tanx.com',18978],
['youku.com','scorecardresearch.com',12895],
['youku.com','cnzz.com',10537],
['youku.com','mmstat.com',8405],
['youku.com','weibo.com',6587],
['youku.com','baidustatic.com',8072],
['youku.com','google-analytics.com',7019],
['youku.com','doubleclick.net',6515],
['youku.com','baidu.com',4760],
['youku.com','bdstatic.com',4319],
['youku.com','miaozhen.com',6956],
['youku.com','mediav.com',3509],
['youku.com','sina.com.cn',1485],
['youku.com','inmobi.com',2295],
['youku.com','supercell.net',1350],
['youku.com','adsmogo.com',2259],
['youku.com','googlesyndication.com',2160],
['youku.com','tapjoy.com',1755],
['youku.com','tapjoyads.com',1485],
['youku.com','vungle.com',1215],
['youku.com','wrating.com',675],
['youku.com','optaim.com',747],
['youku.com','chartboost.com',477],
['youku.com','appsflyer.com',612],
['hao123.com','crashlytics.com',25735],
['hao123.com','flurry.com',15773],
['hao123.com','tanx.com',16666],
['hao123.com','scorecardresearch.com',11828],
['hao123.com','cnzz.com',10712],
['hao123.com','mmstat.com',8891],
['hao123.com','weibo.com',9819],
['hao123.com','baidustatic.com',9302],
['hao123.com','google-analytics.com',6400],
['hao123.com','doubleclick.net',5579],
['hao123.com','baidu.com',7141],
['hao123.com','bdstatic.com',4535],
['hao123.com','miaozhen.com',5543],
['hao123.com','mediav.com',3312],
['hao123.com','sina.com.cn',2339],
['hao123.com','inmobi.com',1375],
['hao123.com','supercell.net',1455],
['hao123.com','adsmogo.com',2232],
['hao123.com','googlesyndication.com',1901],
['hao123.com','tapjoy.com',1598],
['hao123.com','tapjoyads.com',893],
['hao123.com','vungle.com',893],
['hao123.com','wrating.com',1152],
['hao123.com','optaim.com',964],
['hao123.com','chartboost.com',705],
['hao123.com','appsflyer.com',669],
['wandoujia.com','crashlytics.com',29826],
['wandoujia.com','flurry.com',18027],
['wandoujia.com','tanx.com',13777],
['wandoujia.com','scorecardresearch.com',10193],
['wandoujia.com','cnzz.com',13475],
['wandoujia.com','mmstat.com',10227],
['wandoujia.com','weibo.com',8845],
['wandoujia.com','baidustatic.com',10789],
['wandoujia.com','google-analytics.com',8957],
['wandoujia.com','doubleclick.net',7204],
['wandoujia.com','baidu.com',5148],
['wandoujia.com','bdstatic.com',4630],
['wandoujia.com','miaozhen.com',6124],
['wandoujia.com','mediav.com',2168],
['wandoujia.com','sina.com.cn',2764],
['wandoujia.com','inmobi.com',2911],
['wandoujia.com','supercell.net',1719],
['wandoujia.com','adsmogo.com',2462],
['wandoujia.com','googlesyndication.com',3136],
['wandoujia.com','tapjoy.com',1572],
['wandoujia.com','tapjoyads.com',1607],
['wandoujia.com','vungle.com',1719],
['wandoujia.com','wrating.com',1978],
['wandoujia.com','optaim.com',1157],
['wandoujia.com','chartboost.com',898],
['wandoujia.com','appsflyer.com',933],
['sogou.com','crashlytics.com',21693],
['sogou.com','flurry.com',12700],
['sogou.com','tanx.com',12588],
['sogou.com','scorecardresearch.com',10536],
['sogou.com','cnzz.com',11450],
['sogou.com','mmstat.com',7820],
['sogou.com','weibo.com',7820],
['sogou.com','baidustatic.com',7156],
['sogou.com','google-analytics.com',6242],
['sogou.com','doubleclick.net',6682],
['sogou.com','baidu.com',6389],
['sogou.com','bdstatic.com',4992],
['sogou.com','miaozhen.com',5949],
['sogou.com','mediav.com',2130],
['sogou.com','sina.com.cn',2794],
['sogou.com','inmobi.com',1802],
['sogou.com','supercell.net',914],
['sogou.com','adsmogo.com',1690],
['sogou.com','googlesyndication.com',2276],
['sogou.com','tapjoy.com',1207],
['sogou.com','tapjoyads.com',1173],
['sogou.com','vungle.com',879],
['sogou.com','wrating.com',2130],
['sogou.com','optaim.com',1655],
['sogou.com','chartboost.com',1061],
['sogou.com','appsflyer.com',621],
['amazon.com','crashlytics.com',28079],
['amazon.com','flurry.com',18281],
['amazon.com','tanx.com',11429],
['amazon.com','scorecardresearch.com',12287],
['amazon.com','cnzz.com',9672],
['amazon.com','mmstat.com',9389],
['amazon.com','weibo.com',5183],
['amazon.com','baidustatic.com',6813],
['amazon.com','google-analytics.com',9546],
['amazon.com','doubleclick.net',4694],
['amazon.com','baidu.com',5057],
['amazon.com','bdstatic.com',3347],
['amazon.com','miaozhen.com',3670],
['amazon.com','mediav.com',1512],
['amazon.com','sina.com.cn',3347],
['amazon.com','inmobi.com',2694],
['amazon.com','supercell.net',1961],
['amazon.com','adsmogo.com',1717],
['amazon.com','googlesyndication.com',2119],
['amazon.com','tapjoy.com',859],
['amazon.com','tapjoyads.com',1181],
['amazon.com','vungle.com',937],
['amazon.com','wrating.com',488],
['amazon.com','optaim.com',1670],
['amazon.com','chartboost.com',937],
['amazon.com','appsflyer.com',1221],
['renren.com','crashlytics.com',26274],
['renren.com','flurry.com',17837],
['renren.com','tanx.com',10231],
['renren.com','scorecardresearch.com',11544],
['renren.com','cnzz.com',8918],
['renren.com','mmstat.com',8393],
['renren.com','weibo.com',4762],
['renren.com','baidustatic.com',6249],
['renren.com','google-analytics.com',8656],
['renren.com','doubleclick.net',4550],
['renren.com','baidu.com',3894],
['renren.com','bdstatic.com',4069],
['renren.com','miaozhen.com',4419],
['renren.com','mediav.com',1794],
['renren.com','sina.com.cn',2188],
['renren.com','inmobi.com',2756],
['renren.com','supercell.net',2231],
['renren.com','adsmogo.com',1619],
['renren.com','googlesyndication.com',2538],
['renren.com','tapjoy.com',1925],
['renren.com','tapjoyads.com',1925],
['renren.com','vungle.com',1794],
['renren.com','wrating.com',1181],
['renren.com','optaim.com',1619],
['renren.com','chartboost.com',1706],
['renren.com','appsflyer.com',569],
['xiaomi.com','crashlytics.com',23329],
['xiaomi.com','flurry.com',15892],
['xiaomi.com','tanx.com',9105],
['xiaomi.com','scorecardresearch.com',9713],
['xiaomi.com','cnzz.com',8945],
['xiaomi.com','mmstat.com',7276],
['xiaomi.com','weibo.com',4064],
['xiaomi.com','baidustatic.com',6382],
['xiaomi.com','google-analytics.com',7925],
['xiaomi.com','doubleclick.net',4958],
['xiaomi.com','baidu.com',4713],
['xiaomi.com','bdstatic.com',2926],
['xiaomi.com','miaozhen.com',4553],
['xiaomi.com','mediav.com',1424],
['xiaomi.com','sina.com.cn',2521],
['xiaomi.com','inmobi.com',1829],
['xiaomi.com','supercell.net',1543],
['xiaomi.com','adsmogo.com',1669],
['xiaomi.com','googlesyndication.com',1257],
['xiaomi.com','tapjoy.com',1829],
['xiaomi.com','tapjoyads.com',2032],
['xiaomi.com','vungle.com',691],
['xiaomi.com','wrating.com',607],
['xiaomi.com','optaim.com',978],
['xiaomi.com','chartboost.com',775],
['xiaomi.com','appsflyer.com',810],
['10086.cn','crashlytics.com',27690],
['10086.cn','flurry.com',15312],
['10086.cn','tanx.com',8207],
['10086.cn','scorecardresearch.com',10316],
['10086.cn','cnzz.com',7750],
['10086.cn','mmstat.com',6420],
['10086.cn','weibo.com',3848],
['10086.cn','baidustatic.com',6736],
['10086.cn','google-analytics.com',8986],
['10086.cn','doubleclick.net',5366],
['10086.cn','baidu.com',4218],
['10086.cn','bdstatic.com',3298],
['10086.cn','miaozhen.com',3069],
['10086.cn','mediav.com',1283],
['10086.cn','sina.com.cn',1880],
['10086.cn','inmobi.com',3439],
['10086.cn','supercell.net',2015],
['10086.cn','adsmogo.com',1283],
['10086.cn','googlesyndication.com',1558],
['10086.cn','tapjoy.com',2707],
['10086.cn','tapjoyads.com',2015],
['10086.cn','vungle.com',645],
['10086.cn','wrating.com',645],
['10086.cn','optaim.com',732],
['10086.cn','chartboost.com',920],
['10086.cn','appsflyer.com',645],
['facebook.com','crashlytics.com',18771],
['facebook.com','flurry.com',13576],
['facebook.com','tanx.com',8348],
['facebook.com','scorecardresearch.com',8123],
['facebook.com','cnzz.com',8423],
['facebook.com','mmstat.com',4969],
['facebook.com','weibo.com',3822],
['facebook.com','baidustatic.com',5972],
['facebook.com','google-analytics.com',5044],
['facebook.com','doubleclick.net',3822],
['facebook.com','baidu.com',3153],
['facebook.com','bdstatic.com',3672],
['facebook.com','miaozhen.com',2669],
['facebook.com','mediav.com',1741],
['facebook.com','sina.com.cn',2450],
['facebook.com','inmobi.com',2041],
['facebook.com','supercell.net',1557],
['facebook.com','adsmogo.com',1003],
['facebook.com','googlesyndication.com',1482],
['facebook.com','tapjoy.com',1038],
['facebook.com','tapjoyads.com',1372],
['facebook.com','vungle.com',1078],
['facebook.com','wrating.com',444],
['facebook.com','optaim.com',628],
['facebook.com','chartboost.com',778],
['facebook.com','appsflyer.com',963],
['yahoo.com','crashlytics.com',21982],
['yahoo.com','flurry.com',16196],
['yahoo.com','tanx.com',7197],
['yahoo.com','scorecardresearch.com',12129],
['yahoo.com','cnzz.com',5913],
['yahoo.com','mmstat.com',6172],
['yahoo.com','weibo.com',3598],
['yahoo.com','baidustatic.com',4712],
['yahoo.com','google-analytics.com',6773],
['yahoo.com','doubleclick.net',3516],
['yahoo.com','baidu.com',3213],
['yahoo.com','bdstatic.com',2700],
['yahoo.com','miaozhen.com',4243],
['yahoo.com','mediav.com',1626],
['yahoo.com','sina.com.cn',2485],
['yahoo.com','inmobi.com',2314],
['yahoo.com','supercell.net',1543],
['yahoo.com','adsmogo.com',2188],
['yahoo.com','googlesyndication.com',898],
['yahoo.com','tapjoy.com',1543],
['yahoo.com','tapjoyads.com',2397],
['yahoo.com','vungle.com',1113],
['yahoo.com','wrating.com',259],
['yahoo.com','optaim.com',1670],
['yahoo.com','chartboost.com',1328],
['yahoo.com','appsflyer.com',986]
]
var width = 1400, height = 600, margin ={b:5, t:40, l:200, r:50};
//var width = 1200, height = 650, margin ={b:0, t:50, l:200, r:50};
var svg = d3.select(".main")
.append("svg").attr('width',width).attr('height',(height+margin.b+margin.t))
.append("g").attr("transform","translate("+ margin.l+","+margin.t+")");
var data = [
{data:bP.partData(data,2), id:'final1', header:["Sites","Trackers", "Percentage of tracking traffic"]},
//data:bP.partData(sales_data,3), id:'Sales', header:["Channel","State", "Sales"]}
];
bP.draw(data, svg);
</script>
<script src="main.js"></script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.