biojs-vis-genvenn
Version:
Venn diagram list comparisons
777 lines (693 loc) • 243 kB
JavaScript
require("d3");
//--- include simple sets
var sets = require('simplesets');
var s1 = new sets.Set([]);
var s2 = new sets.Set([]);
var s3 = new sets.Set([]);
var s4 = new sets.Set([]);
var s5 = new sets.Set([]);
var s6 = new sets.Set([]);
var s7 = new sets.Set([]);
//define drawing canvas
var w = 746,
h = 900;
var gvennStage = d3.select("#first")
.append("svg")
.attr("width", w)
.attr("height", h)
//-----
//add tooltip for showing list values
var tooltip = d3.select("body").append("div")
.attr("class", "genvenntooltip");
//--- include exportImage, fileManager, ...
// var imgExport = require("./exportImage");
// var exportImage = imgExport.exportImage;
var fileManager = require("./fileManager");
//var uploadFile = fileManager.uploadFile;
//var exportFile = fileManager.exportFile;
var exportFile2 = fileManager.exportFile2;
//var loadSampleData = fileManager.loadSampleData;
//var updateInputData = fileManager.updateInputData;
//var listOperation = fileManager.listOperation;
// var drawGenven = require("./drawGenven");
// var drawCircles = drawGenven.drawCircles;
// var drawEllipseBase = drawGenven.drawEllipseBase;
// var drawFourSetIntersectionArea = drawGenven.drawFourSetIntersectionArea;
// var drawFiveSetIntersectionArea = drawGenven.drawFiveSetIntersectionArea;
// var drawSevenSetIntersectionArea = drawGenven.drawSevenSetIntersectionArea;
// var drawTriangle = drawGenven.drawTriangle;
// var drawTriangleIntersectionArea = drawGenven.drawTriangleIntersectionArea;
// var listOpConf = require("./listOpConf");
// var setListConf = listOpConf.setListConf;
// var pathListConf = listOpConf.pathListConf;
loadSampleData = function() {
d3.select("#clear1").on("click" ,function(){
d3.select("#s1").node().value = "";
s1 = new sets.Set([]);
listOperation();
});
d3.select("#clear2").on("click" ,function(){
d3.select("#s2").node().value = "";
s2 = new sets.Set([]);
listOperation();
});
d3.select("#clear3").on("click" ,function(){
d3.select("#s3").node().value = "";
s3 = new sets.Set([]);
listOperation();
});
d3.select("#clear4").on("click" ,function(){
d3.select("#s4").node().value = "";
s4 = new sets.Set([]);
listOperation();
});
d3.select("#clear5").on("click" ,function(){
d3.select("#s5").node().value = "";
s5 = new sets.Set([]);
listOperation();
});
d3.select("#clear6").on("click" ,function(){
d3.select("#s6").node().value = "";
s6 = new sets.Set([]);
listOperation();
});
d3.select("#clear7").on("click" ,function(){
d3.select("#s7").node().value = "";
s7 = new sets.Set([]);
listOperation();
});
d3.select("#button").on("click" ,function() {
var json = require('../data/sample.json');
var listvalue;
var counter = 0;
d3.select('#s1').node().value = "";
d3.select('#s2').node().value = "";
d3.select('#s3').node().value = "";
d3.select('#s4').node().value = "";
d3.select('#s5').node().value = "";
d3.select('#s6').node().value = "";
d3.select('#s7').node().value = "";
d3.select('#s1_title').node().value = "List 1";
d3.select('#s2_title').node().value = "List 2";
d3.select('#s3_title').node().value = "List 3";
d3.select('#s4_title').node().value = "List 4";
d3.select('#s5_title').node().value = "List 5";
d3.select('#s6_title').node().value = "List 6";
d3.select('#s7_title').node().value = "List 7";
for (key in json) {
counter++;
if (counter === 8) {break;};
d3.select("#s"+counter+"_title").node().value = key ;
for (subKey in json[key]) {
d3.select('#s'+counter).node().value += json[key][subKey];
if(subKey != Object.keys(json[key]).sort().reverse()[0]){
d3.select('#s'+counter).node().value += "\n";
}
}
}
s1 = new sets.Set(d3.select("#s1").node().value.split("\n"));
s2 = new sets.Set(d3.select("#s2").node().value.split("\n"));
s3 = new sets.Set(d3.select("#s3").node().value.split("\n"));
s4 = new sets.Set(d3.select("#s4").node().value.split("\n"));
s5 = new sets.Set(d3.select("#s5").node().value.split("\n"));
s6 = new sets.Set(d3.select("#s6").node().value.split("\n"));
s7 = new sets.Set(d3.select("#s7").node().value.split("\n"));
listOperation();
});
}
updateInputData = function() {
//take user input from textarea
//once the value changed it calls fucntion update to update the list
d3.select("#s1").on("change" ,function() {
update(this.value.split("\n"));
});
function update (listvalue){
if(listvalue == ""){s1 = new sets.Set([]);}
else{s1 = new sets.Set(listvalue);}
listOperation();
}
//---
d3.select("#s2").on("change" ,function() {
update2(this.value.split("\n"));
});
function update2 (listvalue){
if(listvalue == ""){s2 = new sets.Set([]);}
else{s2 = new sets.Set(listvalue);}
listOperation();
}
//---
d3.select("#s3").on("change" ,function() {
update3(this.value.split("\n"));
});
function update3 (listvalue){
if(listvalue == ""){s3 = new sets.Set([]);}
else{s3 = new sets.Set(listvalue);}
listOperation();
}
//
d3.select("#s4").on("change" ,function() {
update4(this.value.split("\n"));
});
function update4 (listvalue){
if(listvalue == ""){s4 = new sets.Set([]);}
else{s4 = new sets.Set(listvalue);}
listOperation();
}
//---
d3.select("#s5").on("change" ,function() {
update5(this.value.split("\n"));
});
function update5 (listvalue){
if(listvalue == ""){s5 = new sets.Set([]);}
else{s5 = new sets.Set(listvalue);}
listOperation();
}
//---
d3.select("#s6").on("change" ,function() {
update6(this.value.split("\n"));
});
function update6 (listvalue){
if(listvalue == ""){s6 = new sets.Set([]);}
else{s6 = new sets.Set(listvalue);}
listOperation();
}
//---
d3.select("#s7").on("change" ,function() {
update7(this.value.split("\n"));
});
function update7 (listvalue){
if(listvalue == ""){s7 = new sets.Set([]);}
else{s7 = new sets.Set(listvalue);}
listOperation();
}
/*----------------------------------------------*/
d3.select("#s1_title").on("change" ,function() {
listOperation();
}).on("keydown",Key);
d3.select("#s2_title").on("change" ,function() {
listOperation();
}).on("keydown",Key);
d3.select("#s3_title").on("change" ,function() {
listOperation();
}).on("keydown",Key);
d3.select("#s4_title").on("change" ,function() {
listOperation();
}).on("keydown",Key);
d3.select("#s5_title").on("change" ,function() {
listOperation();
}).on("keydown",Key);
d3.select("#s6_title").on("change" ,function() {
listOperation();
}).on("keydown",Key);
d3.select("#s7_title").on("change" ,function() {
listOperation();
}).on("keydown",Key);
function Key() {
if(d3.event.keyCode === 13){
d3.event.preventDefault();
listOperation();
}
}
/*----------------------------------------------*/
}
//export svg into image
exportImage = function() {
d3.select("img").remove();
d3.select("#exportImage").on("click", function(){
var html = d3.select("svg")
.attr("version", 1.1)
.attr("xmlns", "http://www.w3.org/2000/svg")
.node().parentNode.innerHTML;
var imgsrc = 'data:image/svg+xml;base64,'+ btoa(html);
var img = '<img src="'+imgsrc+'">';
var canvas = document.querySelector("canvas"),
context = canvas.getContext("2d");
var image = new Image;
image.src = imgsrc;
image.onload = function() {
context.drawImage(image, 0, 0);
var groupOfTexts = [];
if(d3.select("#e7th1").empty() != true){
var length = 0;
groupOfTexts = [];
//add back llist length
for ( var i = 1; i <= 7; i++ ) {
if (i == 1){length = s1.array().length}
if (i == 2){length = s2.array().length}
if (i == 3){length = s3.array().length}
if (i == 4){length = s4.array().length}
if (i == 5){length = s5.array().length}
if (i == 6){length = s6.array().length}
if (i == 7){length = s7.array().length}
var text = d3.select( "#e7thTl" + i )
if ( text.node() )
groupOfTexts.push( { x: text.attr( "x" ), y: text.attr( "y" ), text: length } );
}
//add intersections
//groupOfTexts = [];
groupOfTexts.push( { x: 90, y: 225, text: s1.intersection(s2).array().length } );
groupOfTexts.push( { x: 180, y: 110, text: s2.intersection(s3).array().length } );
groupOfTexts.push( { x: 333, y: 112, text: s3.intersection(s4).array().length } );
groupOfTexts.push( { x: 427, y: 236, text: s4.intersection(s5).array().length } );
groupOfTexts.push( { x: 391, y: 381, text: s5.intersection(s6).array().length } );
groupOfTexts.push( { x: 248, y: 441, text: s6.intersection(s7).array().length } );
groupOfTexts.push( { x: 112, y: 374, text: s1.intersection(s7).array().length } );
groupOfTexts.push( { x: 256, y: 270, text: s1ns2ns3ns4ns5ns6.intersection(s7).array().length } );
//add labels
//groupOfTexts = [];
groupOfTexts.push( { x: 00, y: 240, text: d3.select("#s1_title").node().value } );
groupOfTexts.push( { x: 45, y: 80 , text: d3.select("#s2_title").node().value } );
groupOfTexts.push( { x: 270, y: 10, text: d3.select("#s3_title").node().value } );
groupOfTexts.push( { x: 490, y: 152, text: d3.select("#s4_title").node().value } );
groupOfTexts.push( { x: 510, y: 341, text: d3.select("#s5_title").node().value } );
groupOfTexts.push( { x: 330, y: 520, text: d3.select("#s6_title").node().value } );
groupOfTexts.push( { x: 60, y: 470, text: d3.select("#s7_title").node().value } );
if ( groupOfTexts.length > 0 ){
context.font = "18px serif";
for ( i = 0; i < groupOfTexts.length; i++ ){
context.fillStyle = "black";
var obj = groupOfTexts[i];
context.fillText(obj.text, obj.x, obj.y);
}
}
}
if(d3.select("#tr1").empty() != true){
var length = 0;
groupOfTexts = [];
//add back llist length
for ( var i = 1; i <= 6; i++ ) {
if (i == 1){length = s1.array().length}
if (i == 2){length = s2.array().length}
if (i == 3){length = s3.array().length}
if (i == 4){length = s4.array().length}
if (i == 5){length = s5.array().length}
if (i == 6){length = s6.array().length}
var text = d3.select( "#trx" + i )
if ( text.node() )
groupOfTexts.push( { x: text.attr( "x" ), y: text.attr( "y" ), text: length } );
}
groupOfTexts.push( { x: 227, y: 365, text: s1.intersection(s6).array().length } );
groupOfTexts.push( { x: 225, y: 435, text: s2.intersection(s6).array().length } );
groupOfTexts.push( { x: 341, y: 235, text: s3.intersection(s6).array().length } );
groupOfTexts.push( { x: 315, y: 410, text: s4.intersection(s6).array().length } );
groupOfTexts.push( { x: 272, y: 447, text: s5.intersection(s6).array().length } );
groupOfTexts.push( { x: 290.66335, y: 347.0728, text: s1ns2ns3ns4ns5.intersection(s6).array().length } );
groupOfTexts.push( { x: 00, y: 85, text: d3.select("#s1_title").node().value } );
groupOfTexts.push( { x: 318, y: 88 , text: d3.select("#s2_title").node().value } );
groupOfTexts.push( { x: 500, y: 145, text: d3.select("#s3_title").node().value } );
groupOfTexts.push( { x: 532, y: 480, text: d3.select("#s4_title").node().value } );
groupOfTexts.push( { x: 368, y: 538, text: d3.select("#s5_title").node().value } );
groupOfTexts.push( { x: 00, y: 520, text: d3.select("#s6_title").node().value } );
if ( groupOfTexts.length > 0 ){
context.font = "18px serif";
for ( i = 0; i < groupOfTexts.length; i++ ){
context.fillStyle = "black";
var obj = groupOfTexts[i];
context.fillText(obj.text, obj.x, obj.y);
}
}
}
if(d3.select("#e5th1").empty() != true){
var length = 0;
groupOfTexts = [];
//add back llist length
for ( var i = 1; i <= 5; i++ ) {
if (i == 1){length = s1.array().length}
if (i == 2){length = s2.array().length}
if (i == 3){length = s3.array().length}
if (i == 4){length = s4.array().length}
if (i == 5){length = s5.array().length}
var text = d3.select( "#e5thTl" + i )
if ( text.node() )
groupOfTexts.push( { x: text.attr( "x" ), y: text.attr( "y" ), text: length } );
}
groupOfTexts.push( { x: 351, y: 157, text: s1.intersection(s2).array().length } );
groupOfTexts.push( { x: 358, y: 339, text: s2.intersection(s3).array().length } );
groupOfTexts.push( { x: 193, y: 403, text: s3.intersection(s4).array().length } );
groupOfTexts.push( { x: 294, y: 126, text: s1.intersection(s4).array().length } );
groupOfTexts.push( { x: 103, y: 336, text: s2.intersection(s4).array().length } );
groupOfTexts.push( { x: 265, y: 401, text: s1.intersection(s3).array().length } );
groupOfTexts.push( { x: 180, y: 112, text: s1.intersection(s5).array().length } );
groupOfTexts.push( { x: 372, y: 269, text: s2.intersection(s5).array().length } );
groupOfTexts.push( { x: 120, y: 165, text: s3.intersection(s5).array().length } );
groupOfTexts.push( { x: 78, y: 266, text: s4.intersection(s5).array().length } );
groupOfTexts.push( { x: 236, y: 250, text: s1ns2ns3ns4.intersection(s5).array().length } );
groupOfTexts.push( { x: 243, y: 10, text: d3.select("#s1_title").node().value } );
groupOfTexts.push( { x: 488, y: 216 , text: d3.select("#s2_title").node().value } );
groupOfTexts.push( { x: 370, y: 483, text: d3.select("#s3_title").node().value } );
groupOfTexts.push( { x: 33, y: 459, text: d3.select("#s4_title").node().value } );
groupOfTexts.push( { x: 0, y: 106, text: d3.select("#s5_title").node().value } );
if ( groupOfTexts.length > 0 ){
context.font = "18px serif";
for ( i = 0; i < groupOfTexts.length; i++ ){
context.fillStyle = "black";
var obj = groupOfTexts[i];
context.fillText(obj.text, obj.x, obj.y);
}
}
}
if(d3.select("#e4th1").empty() != true){
var length = 0;
groupOfTexts = [];
//add back llist length
for ( var i = 1; i <= 4; i++ ) {
if (i == 1){length = s1.array().length}
if (i == 2){length = s2.array().length}
if (i == 3){length = s3.array().length}
if (i == 4){length = s4.array().length}
var text = d3.select( "#e4thTl" + i )
if ( text.node() )
groupOfTexts.push( { x: text.attr( "x" ), y: text.attr( "y" ), text: length } );
}
groupOfTexts.push( { x: 146, y: 127, text: s1.intersection(s2).array().length } );
groupOfTexts.push( { x: 194, y: 311, text: s1.intersection(s3).array().length } );
groupOfTexts.push( { x: 294, y: 368, text: s1.intersection(s4).array().length } );
groupOfTexts.push( { x: 291, y: 118, text: s2.intersection(s3).array().length } );
groupOfTexts.push( { x: 389, y: 309, text: s2.intersection(s4).array().length } );
groupOfTexts.push( { x: 433, y: 141, text: s3.intersection(s4).array().length } );
groupOfTexts.push( { x: 223, y: 201, text: s1ns2.intersection(s3).array().length } );
groupOfTexts.push( { x: 341, y: 328, text: s1ns2.intersection(s4).array().length } );
groupOfTexts.push( { x: 246, y: 329, text: s1ns3.intersection(s4).array().length } );
groupOfTexts.push( { x: 366, y: 208, text: s2ns3.intersection(s4).array().length } );
groupOfTexts.push( { x: 290, y: 278, text: s1ns2ns3.intersection(s4).array().length } );
groupOfTexts.push( { x: 20, y: 85, text: d3.select("#s1_title").node().value } );
groupOfTexts.push( { x: 88, y: 15 , text: d3.select("#s2_title").node().value } );
groupOfTexts.push( { x: 475, y: 18, text: d3.select("#s3_title").node().value } );
groupOfTexts.push( { x: 548, y: 85, text: d3.select("#s4_title").node().value } );
if ( groupOfTexts.length > 0 ){
context.font = "18px serif";
for ( i = 0; i < groupOfTexts.length; i++ ){
context.fillStyle = "black";
var obj = groupOfTexts[i];
context.fillText(obj.text, obj.x, obj.y);
}
}
}
if(d3.select("#circle1").empty() != true){
groupOfTexts = [];
var text = d3.select( "#text1")
if ( text.node() )
groupOfTexts.push( { x: text.attr( "x" ), y: text.attr( "y" ), text: s1.array().length } );
var text = d3.select( "#c1label")
if ( text.node() )
groupOfTexts.push( { x: text.attr( "x" ), y: text.attr( "y" ), text: d3.select("#s1_title").node().value } );
if ( groupOfTexts.length > 0 ){
context.font = "18px serif";
for ( i = 0; i < groupOfTexts.length; i++ ){
context.fillStyle = "black";
var obj = groupOfTexts[i];
context.fillText(obj.text, obj.x, obj.y);
}
}
}
if(d3.select("#circle2").empty() != true){
groupOfTexts = [];
var text = d3.select( "#text2")
if ( text.node() )
groupOfTexts.push( { x: text.attr( "x" ), y: text.attr( "y" ), text: s2.array().length } );
var text = d3.select( "#c2label")
if ( text.node() )
groupOfTexts.push( { x: text.attr( "x" ), y: text.attr( "y" ), text: d3.select("#s2_title").node().value } );
if ( groupOfTexts.length > 0 ){
context.font = "18px serif";
for ( i = 0; i < groupOfTexts.length; i++ ){
context.fillStyle = "black";
var obj = groupOfTexts[i];
context.fillText(obj.text, obj.x, obj.y);
}
}
}
if(d3.select("#circle3").empty() != true){
groupOfTexts = [];
var text = d3.select( "#text4")
if ( text.node() )
groupOfTexts.push( { x: text.attr( "x" ), y: text.attr( "y" ), text: s3.array().length } );
var text = d3.select( "#c3label")
if ( text.node() )
groupOfTexts.push( { x: text.attr( "x" ), y: text.attr( "y" ), text: d3.select("#s3_title").node().value } );
if ( groupOfTexts.length > 0 ){
context.font = "18px serif";
for ( i = 0; i < groupOfTexts.length; i++ ){
context.fillStyle = "black";
var obj = groupOfTexts[i];
context.fillText(obj.text, obj.x, obj.y);
}
}
}
if(d3.select("#circle1").empty() != true && d3.select("#circle2").empty() != true){
groupOfTexts = [];
var text = d3.select( "#text1")
if ( text.node() )
groupOfTexts.push( { x: text.attr( "x" ), y: text.attr( "y" ), text: s1.array().length } );
var text = d3.select( "#c1label")
if ( text.node() )
groupOfTexts.push( { x: text.attr( "x" ), y: text.attr( "y" ), text: d3.select("#s1_title").node().value } );
var text = d3.select( "#text2")
if ( text.node() )
groupOfTexts.push( { x: text.attr( "x" ), y: text.attr( "y" ), text: s2.array().length } );
var text = d3.select( "#c2label")
if ( text.node() )
groupOfTexts.push( { x: text.attr( "x" ), y: text.attr( "y" ), text: d3.select("#s2_title").node().value } );
//intersection
var text = d3.select( "#text3")
if ( text.node() )
groupOfTexts.push( { x: text.attr( "x" ), y: text.attr( "y" ), text: s1.intersection(s2).array().length } );
if ( groupOfTexts.length > 0 ){
context.font = "18px serif";
for ( i = 0; i < groupOfTexts.length; i++ ){
context.fillStyle = "black";
var obj = groupOfTexts[i];
context.fillText(obj.text, obj.x, obj.y);
}
}
}
if(d3.select("#circle1").empty() != true && d3.select("#circle3").empty() != true){
groupOfTexts = [];
var text = d3.select( "#text1")
if ( text.node() )
groupOfTexts.push( { x: text.attr( "x" ), y: text.attr( "y" ), text: s1.array().length } );
var text = d3.select( "#c1label")
if ( text.node() )
groupOfTexts.push( { x: text.attr( "x" ), y: text.attr( "y" ), text: d3.select("#s1_title").node().value } );
var text = d3.select( "#text4")
if ( text.node() )
groupOfTexts.push( { x: text.attr( "x" ), y: text.attr( "y" ), text: s3.array().length } );
var text = d3.select( "#c3label")
if ( text.node() )
groupOfTexts.push( { x: text.attr( "x" ), y: text.attr( "y" ), text: d3.select("#s3_title").node().value } );
//intersection
var text = d3.select( "#text5")
if ( text.node() )
groupOfTexts.push( { x: text.attr( "x" ), y: text.attr( "y" ), text: s1.intersection(s3).array().length } );
if ( groupOfTexts.length > 0 ){
context.font = "18px serif";
for ( i = 0; i < groupOfTexts.length; i++ ){
context.fillStyle = "black";
var obj = groupOfTexts[i];
context.fillText(obj.text, obj.x, obj.y);
}
}
}
if(d3.select("#circle2").empty() != true && d3.select("#circle3").empty() != true){
groupOfTexts = [];
var text = d3.select( "#text2")
if ( text.node() )
groupOfTexts.push( { x: text.attr( "x" ), y: text.attr( "y" ), text: s2.array().length } );
var text = d3.select( "#c2label")
if ( text.node() )
groupOfTexts.push( { x: text.attr( "x" ), y: text.attr( "y" ), text: d3.select("#s2_title").node().value } );
var text = d3.select( "#text4")
if ( text.node() )
groupOfTexts.push( { x: text.attr( "x" ), y: text.attr( "y" ), text: s3.array().length } );
var text = d3.select( "#c3label")
if ( text.node() )
groupOfTexts.push( { x: text.attr( "x" ), y: text.attr( "y" ), text: d3.select("#s3_title").node().value } );
var text = d3.select( "#text6")
if ( text.node() )
groupOfTexts.push( { x: text.attr( "x" ), y: text.attr( "y" ), text: s2.intersection(s3).array().length } );
if ( groupOfTexts.length > 0 ){
context.font = "18px serif";
for ( i = 0; i < groupOfTexts.length; i++ ){
context.fillStyle = "black";
var obj = groupOfTexts[i];
context.fillText(obj.text, obj.x, obj.y);
}
}
}
if(d3.select("#circle1").empty() != true && d3.select("#circle2").empty() != true && d3.select("#circle3").empty() != true){
groupOfTexts = [];
var text = d3.select( "#text1")
if ( text.node() )
groupOfTexts.push( { x: text.attr( "x" ), y: text.attr( "y" ), text: s1.array().length } );
var text = d3.select( "#c1label")
if ( text.node() )
groupOfTexts.push( { x: text.attr( "x" ), y: text.attr( "y" ), text: d3.select("#s1_title").node().value } );
var text = d3.select( "#text2")
if ( text.node() )
groupOfTexts.push( { x: text.attr( "x" ), y: text.attr( "y" ), text: s2.array().length } );
var text = d3.select( "#c2label")
if ( text.node() )
groupOfTexts.push( { x: text.attr( "x" ), y: text.attr( "y" ), text: d3.select("#s2_title").node().value } );
var text = d3.select( "#text4")
if ( text.node() )
groupOfTexts.push( { x: text.attr( "x" ), y: text.attr( "y" ), text: s3.array().length } );
var text = d3.select( "#c3label")
if ( text.node() )
groupOfTexts.push( { x: text.attr( "x" ), y: text.attr( "y" ), text: d3.select("#s3_title").node().value } );
//intersection
var text = d3.select( "#text3")
if ( text.node() )
groupOfTexts.push( { x: text.attr( "x" ), y: text.attr( "y" ), text: s1.intersection(s2).array().length } );
var text = d3.select( "#text5")
if ( text.node() )
groupOfTexts.push( { x: text.attr( "x" ), y: text.attr( "y" ), text: s1.intersection(s3).array().length } );
var text = d3.select( "#text6")
if ( text.node() )
groupOfTexts.push( { x: text.attr( "x" ), y: text.attr( "y" ), text: s2.intersection(s3).array().length } );
var text = d3.select( "#text7")
if ( text.node() )
groupOfTexts.push( { x: text.attr( "x" ), y: text.attr( "y" ), text: s1ns2.intersection(s3).array().length } );
if ( groupOfTexts.length > 0 ){
context.font = "18px serif";
for ( i = 0; i < groupOfTexts.length; i++ ){
context.fillStyle = "black";
var obj = groupOfTexts[i];
context.fillText(obj.text, obj.x, obj.y);
}
}
}
var canvasdata = canvas.toDataURL("image/png");
var pngimg = '<img src="'+canvasdata+'">';
var a = document.createElement("a");
a.download = "exportedImage.png";
a.href = canvasdata;
document.body.appendChild(a);
a.click();
context.clearRect ( 0 , 0 , canvas.width, canvas.height );
};
});
}
exportFile = function() {
d3.select("#DownloadButton").on("click" ,function() {
// grab the content of the form field and place it into a variable
var textToWrite = "";
if(d3.select("#circle1").empty() != true && d3.select("#circle2").empty() != true){
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + " and " + d3.select("#s2_title").node().value + ": " + s1.intersection(s2).array().join(" ") + "\n";
}
if(d3.select("#circle1").empty() != true && d3.select("#circle3").empty() != true){
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + " and " + d3.select("#s3_title").node().value + ": " + s1.intersection(s3).array().join(" ") + "\n";
}
if(d3.select("#circle2").empty() != true && d3.select("#circle3").empty() != true){
textToWrite += "Common elements in " + d3.select("#s2_title").node().value + " and " + d3.select("#s3_title").node().value + ": " + s2.intersection(s3).array().join(" ") + "\n";
}
if(d3.select("#circle1").empty() != true && d3.select("#circle2").empty() != true && d3.select("#circle3").empty() != true){
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s2_title").node().value + " and " + d3.select("#s3_title").node().value + ": " + s1ns2.intersection(s3).array().join(" ") + "\n";
}
if(d3.select("#e4th1").empty() != true){
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + " and " + d3.select("#s2_title").node().value + ": " + s1.intersection(s2).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + " and " + d3.select("#s3_title").node().value + ": " + s1.intersection(s3).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + " and " + d3.select("#s4_title").node().value + ": " + s1.intersection(s4).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s2_title").node().value + " and " + d3.select("#s3_title").node().value + ": " + s2.intersection(s3).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s2_title").node().value + " and " + d3.select("#s4_title").node().value + ": " + s2.intersection(s4).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s3_title").node().value + " and " + d3.select("#s4_title").node().value + ": " + s3.intersection(s4).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s2_title").node().value + " and " + d3.select("#s3_title").node().value + ": " + s1ns2.intersection(s3).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s2_title").node().value + " and " + d3.select("#s4_title").node().value + ": " + s1ns2.intersection(s4).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s3_title").node().value + " and " + d3.select("#s4_title").node().value + ": " + s1ns3.intersection(s4).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s2_title").node().value + ", " + d3.select("#s3_title").node().value + " and " + d3.select("#s4_title").node().value + ": " + s2ns3.intersection(s4).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s2_title").node().value + ", " + d3.select("#s3_title").node().value + " and " + d3.select("#s4_title").node().value + ": " + s1ns2ns3.intersection(s4).array().join(" ") + "\n";
}
if(d3.select("#e5th1").empty() != true){
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + " and " + d3.select("#s2_title").node().value + ": " + s1.intersection(s2).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + " and " + d3.select("#s3_title").node().value + ": " + s1.intersection(s3).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + " and " + d3.select("#s4_title").node().value + ": " + s1.intersection(s4).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + " and " + d3.select("#s5_title").node().value + ": " + s1.intersection(s5).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s2_title").node().value + " and " + d3.select("#s3_title").node().value + ": " + s2.intersection(s3).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s2_title").node().value + " and " + d3.select("#s4_title").node().value + ": " + s2.intersection(s4).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s2_title").node().value + " and " + d3.select("#s5_title").node().value + ": " + s2.intersection(s5).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s3_title").node().value + " and " + d3.select("#s4_title").node().value + ": " + s3.intersection(s4).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s3_title").node().value + " and " + d3.select("#s5_title").node().value + ": " + s3.intersection(s5).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s4_title").node().value + " and " + d3.select("#s5_title").node().value + ": " + s4.intersection(s5).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s2_title").node().value + " and " + d3.select("#s3_title").node().value + ": " + s1ns2.intersection(s3).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s2_title").node().value + " and " + d3.select("#s4_title").node().value + ": " + s1ns2.intersection(s4).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s2_title").node().value + " and " + d3.select("#s5_title").node().value + ": " + s1ns2.intersection(s5).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s3_title").node().value + " and " + d3.select("#s4_title").node().value + ": " + s1ns3.intersection(s4).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s3_title").node().value + " and " + d3.select("#s5_title").node().value + ": " + s1ns3.intersection(s5).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s4_title").node().value + " and " + d3.select("#s5_title").node().value + ": " + s1ns4.intersection(s5).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s2_title").node().value + ", " + d3.select("#s3_title").node().value + " and " + d3.select("#s4_title").node().value + ": " + s2ns3.intersection(s4).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s2_title").node().value + ", " + d3.select("#s3_title").node().value + " and " + d3.select("#s5_title").node().value + ": " + s2ns3.intersection(s5).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s2_title").node().value + ", " + d3.select("#s4_title").node().value + " and " + d3.select("#s5_title").node().value + ": " + s2ns4.intersection(s5).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s3_title").node().value + ", " + d3.select("#s4_title").node().value + " and " + d3.select("#s5_title").node().value + ": " + s3ns4.intersection(s5).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s2_title").node().value + ", " + d3.select("#s3_title").node().value + " and " + d3.select("#s4_title").node().value + ": " + s1ns2ns3.intersection(s4).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s2_title").node().value + ", " + d3.select("#s3_title").node().value + " and " + d3.select("#s5_title").node().value + ": " + s1ns2ns3.intersection(s5).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s2_title").node().value + ", " + d3.select("#s4_title").node().value + " and " + d3.select("#s5_title").node().value + ": " + s1ns2ns4.intersection(s5).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s3_title").node().value + ", " + d3.select("#s4_title").node().value + " and " + d3.select("#s5_title").node().value + ": " + s1ns3ns4.intersection(s5).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s2_title").node().value + ", " + d3.select("#s3_title").node().value + ", " + d3.select("#s4_title").node().value + " and " + d3.select("#s5_title").node().value + ": " + s2ns3ns4.intersection(s5).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s2_title").node().value + ", " + d3.select("#s3_title").node().value + ", " + d3.select("#s4_title").node().value + " and " + d3.select("#s5_title").node().value + ": " + s1ns2ns3ns4.intersection(s5).array().join(" ") + "\n";
}
if(d3.select("#tr1").empty() != true){
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + " and " + d3.select("#s2_title").node().value + ": " + s1.intersection(s2).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + " and " + d3.select("#s3_title").node().value + ": " + s1.intersection(s3).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + " and " + d3.select("#s4_title").node().value + ": " + s1.intersection(s4).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + " and " + d3.select("#s5_title").node().value + ": " + s1.intersection(s5).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + " and " + d3.select("#s6_title").node().value + ": " + s1.intersection(s6).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s2_title").node().value + " and " + d3.select("#s3_title").node().value + ": " + s2.intersection(s3).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s2_title").node().value + " and " + d3.select("#s4_title").node().value + ": " + s2.intersection(s4).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s2_title").node().value + " and " + d3.select("#s5_title").node().value + ": " + s2.intersection(s5).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s2_title").node().value + " and " + d3.select("#s6_title").node().value + ": " + s2.intersection(s6).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s3_title").node().value + " and " + d3.select("#s4_title").node().value + ": " + s3.intersection(s4).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s3_title").node().value + " and " + d3.select("#s5_title").node().value + ": " + s3.intersection(s5).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s3_title").node().value + " and " + d3.select("#s6_title").node().value + ": " + s3.intersection(s6).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s4_title").node().value + " and " + d3.select("#s5_title").node().value + ": " + s4.intersection(s5).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s4_title").node().value + " and " + d3.select("#s6_title").node().value + ": " + s4.intersection(s6).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s5_title").node().value + " and " + d3.select("#s6_title").node().value + ": " + s5.intersection(s6).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s2_title").node().value + " and " + d3.select("#s3_title").node().value + ": " + s1ns2.intersection(s3).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s2_title").node().value + " and " + d3.select("#s4_title").node().value + ": " + s1ns2.intersection(s4).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s2_title").node().value + " and " + d3.select("#s5_title").node().value + ": " + s1ns2.intersection(s5).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s2_title").node().value + " and " + d3.select("#s6_title").node().value + ": " + s1ns2.intersection(s6).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s3_title").node().value + " and " + d3.select("#s4_title").node().value + ": " + s1ns3.intersection(s4).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s3_title").node().value + " and " + d3.select("#s5_title").node().value + ": " + s1ns3.intersection(s5).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s3_title").node().value + " and " + d3.select("#s6_title").node().value + ": " + s1ns3.intersection(s6).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s4_title").node().value + " and " + d3.select("#s5_title").node().value + ": " + s1ns4.intersection(s5).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s4_title").node().value + " and " + d3.select("#s6_title").node().value + ": " + s1ns4.intersection(s6).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s5_title").node().value + " and " + d3.select("#s6_title").node().value + ": " + s1ns5.intersection(s6).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s2_title").node().value + ", " + d3.select("#s3_title").node().value + " and " + d3.select("#s4_title").node().value + ": " + s2ns3.intersection(s4).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s2_title").node().value + ", " + d3.select("#s3_title").node().value + " and " + d3.select("#s5_title").node().value + ": " + s2ns3.intersection(s5).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s2_title").node().value + ", " + d3.select("#s3_title").node().value + " and " + d3.select("#s6_title").node().value + ": " + s2ns3.intersection(s6).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s2_title").node().value + ", " + d3.select("#s4_title").node().value + " and " + d3.select("#s5_title").node().value + ": " + s2ns4.intersection(s5).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s2_title").node().value + ", " + d3.select("#s4_title").node().value + " and " + d3.select("#s6_title").node().value + ": " + s2ns4.intersection(s6).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s2_title").node().value + ", " + d3.select("#s5_title").node().value + " and " + d3.select("#s6_title").node().value + ": " + s2ns5.intersection(s6).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s3_title").node().value + ", " + d3.select("#s4_title").node().value + " and " + d3.select("#s5_title").node().value + ": " + s3ns4.intersection(s5).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s3_title").node().value + ", " + d3.select("#s4_title").node().value + " and " + d3.select("#s6_title").node().value + ": " + s3ns4.intersection(s6).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s3_title").node().value + ", " + d3.select("#s5_title").node().value + " and " + d3.select("#s6_title").node().value + ": " + s3ns5.intersection(s6).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s4_title").node().value + ", " + d3.select("#s5_title").node().value + " and " + d3.select("#s6_title").node().value + ": " + s4ns5.intersection(s6).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s2_title").node().value + ", " + d3.select("#s3_title").node().value + " and " + d3.select("#s4_title").node().value + ": " + s1ns2ns3.intersection(s4).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s2_title").node().value + ", " + d3.select("#s3_title").node().value + " and " + d3.select("#s5_title").node().value + ": " + s1ns2ns3.intersection(s5).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s2_title").node().value + ", " + d3.select("#s3_title").node().value + " and " + d3.select("#s6_title").node().value + ": " + s1ns2ns3.intersection(s6).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s2_title").node().value + ", " + d3.select("#s4_title").node().value + " and " + d3.select("#s5_title").node().value + ": " + s1ns2ns4.intersection(s5).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s2_title").node().value + ", " + d3.select("#s4_title").node().value + " and " + d3.select("#s6_title").node().value + ": " + s1ns2ns4.intersection(s6).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s2_title").node().value + ", " + d3.select("#s5_title").node().value + " and " + d3.select("#s6_title").node().value + ": " + s1ns2ns5.intersection(s6).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s3_title").node().value + ", " + d3.select("#s4_title").node().value + " and " + d3.select("#s5_title").node().value + ": " + s1ns3ns4.intersection(s5).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s3_title").node().value + ", " + d3.select("#s4_title").node().value + " and " + d3.select("#s6_title").node().value + ": " + s1ns3ns4.intersection(s6).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s3_title").node().value + ", " + d3.select("#s5_title").node().value + " and " + d3.select("#s6_title").node().value + ": " + s1ns3ns5.intersection(s6).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s4_title").node().value + ", " + d3.select("#s5_title").node().value + " and " + d3.select("#s6_title").node().value + ": " + s1ns4ns5.intersection(s6).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s2_title").node().value + ", " + d3.select("#s3_title").node().value + ", " + d3.select("#s4_title").node().value + " and " + d3.select("#s5_title").node().value + ": " + s2ns3ns4.intersection(s5).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s2_title").node().value + ", " + d3.select("#s3_title").node().value + ", " + d3.select("#s4_title").node().value + " and " + d3.select("#s6_title").node().value + ": " + s2ns3ns4.intersection(s6).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s2_title").node().value + ", " + d3.select("#s3_title").node().value + ", " + d3.select("#s5_title").node().value + " and " + d3.select("#s6_title").node().value + ": " + s2ns3ns5.intersection(s6).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s2_title").node().value + ", " + d3.select("#s4_title").node().value + ", " + d3.select("#s5_title").node().value + " and " + d3.select("#s6_title").node().value + ": " + s2ns4ns5.intersection(s6).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s3_title").node().value + ", " + d3.select("#s4_title").node().value + ", " + d3.select("#s5_title").node().value + " and " + d3.select("#s6_title").node().value + ": " + s3ns4ns5.intersection(s6).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s2_title").node().value + ", " + d3.select("#s3_title").node().value + ", " + d3.select("#s4_title").node().value + " and " + d3.select("#s5_title").node().value + ": " + s1ns2ns3ns4.intersection(s5).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s2_title").node().value + ", " + d3.select("#s3_title").node().value + ", " + d3.select("#s4_title").node().value + " and " + d3.select("#s6_title").node().value + ": " + s1ns2ns3ns4.intersection(s6).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s2_title").node().value + ", " + d3.select("#s3_title").node().value + ", " + d3.select("#s5_title").node().value + " and " + d3.select("#s6_title").node().value + ": " + s1ns2ns3ns5.intersection(s6).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s2_title").node().value + ", " + d3.select("#s4_title").node().value + ", " + d3.select("#s5_title").node().value + " and " + d3.select("#s6_title").node().value + ": " + s1ns2ns4ns5.intersection(s6).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s3_title").node().value + ", " + d3.select("#s4_title").node().value + ", " + d3.select("#s5_title").node().value + " and " + d3.select("#s6_title").node().value + ": " + s1ns3ns4ns5.intersection(s6).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s2_title").node().value + ", " + d3.select("#s3_title").node().value + ", " + d3.select("#s4_title").node().value + ", " + d3.select("#s5_title").node().value + " and " + d3.select("#s6_title").node().value + ": " + s2ns3ns4ns5.intersection(s6).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + ", " + d3.select("#s2_title").node().value + ", " + d3.select("#s3_title").node().value + ", " + d3.select("#s4_title").node().value + ", " + d3.select("#s5_title").node().value + " and " + d3.select("#s6_title").node().value + ": " + s1ns2ns3ns4ns5.intersection(s6).array().join(" ") + "\n";
}
if(d3.select("#e7th1").empty() != true){
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + " and " + d3.select("#s2_title").node().value + ": " + s1.intersection(s2).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + " and " + d3.select("#s3_title").node().value + ": " + s1.intersection(s3).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + " and " + d3.select("#s4_title").node().value + ": " + s1.intersection(s4).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + " and " + d3.select("#s5_title").node().value + ": " + s1.intersection(s5).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + " and " + d3.select("#s6_title").node().value + ": " + s1.intersection(s6).array().join(" ") + "\n";
textToWrite += "Common elements in " + d3.select("#s1_title").node().value + " and " + d3.select("#s7_title").node().value + ": " + s1.intersection(s7).array().join(" ") + "\n";
tex