-
Notifications
You must be signed in to change notification settings - Fork 0
/
crossingDisciplines.html
2645 lines (2327 loc) · 59.3 KB
/
crossingDisciplines.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<meta charset="utf-8">
<head>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="css/tipsy.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/d3.min.js"></script>
<script type="text/javascript" src="js/jqueryMain.js"></script>
<!-- <script src="js/jquery.hoverIntent.js" type="text/javascript" async></script>
<script src="js/jquery.tipsy.js" type="text/javascript"></script> -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-52026122-1', 'spatialinformationdesignlab.org');
ga('send', 'pageview');
</script>
</head>
<style>
</style>
<body>
<div id = "container"></div>
<div id="title">Crossing Disciplines</div>
<div id="clearAll">CLEAR
</div>
<div id="backNav">
<a href="http://spatialinformationdesignlab.org/library/"><img src="backNav.png" width="15" height="15"></a>
</div>
<div id = "exitGraph">
<img src="exitGraph.png" width="13" height="13">
</div>
<div id = "graphIcon">
<img src="graphs.png" width="20" height="20">
</div>
<div class = "outerCircleText"></div>
<div id = "hoverbox"></div>
<div class = "listBooks"></div>
<div class = "subjectText"></div>
<div id = "booksColumn">
<img src="books.png" width="30" height="20">
</div>
<div id = "exit">
<img src="exit.png" width="13" height="13">
</div>
<div id = "endIntro">
EXIT GUIDE
</div>
<div id="inner">
</div>
<div id="skip">Enter</div>
<div class="center">
<div id="skip2">Exit Guide</div>
</div>
<div class="intro">
<div id="intro1" style="display: none; opacity: 0;">
</div>
<div id="intro2" style="display: none; opacity: 0;">
<p><b>Crossing Disciplines</b> is a tool to explore the books in the Columbia University Libraries that are at the intersection of two or more disciplines.</p><p>Click two or more subjects around the ring - the top 25 most interdisciplinary subjects in the library - <b>or</b> mouseover inner circles to see their subject connections. Click one to reveal its collection of connected books.</p>
<div id="introNav">
<img src="forwardNav.png" width="15" height="15">
</div>
</div>
</div>
<!-- </div> -->
<div class="center">
<div class="introZoom">
<div id="intro4" style="display: none;">
<p>Circles are placed on tiers according to how many subjects they are connected to </p>
</div>
<div id="intro4half" style="display: none;">
<p><b>2</b> subjects at the outermost tier - many books are related to different pairs of subjects</p>
</div>
<div id="intro5" style="display: none;">
<p><b>3</b> subjects for the next tier</p>
</div>
<div id="intro6" style="display: none;">
<p><b>4</b> subjects</p>
</div>
<div id="intro7" style="display: none;">
<p><b>5</b> subjects</p>
</div>
<div id="intro8" style="display: none;">
<p>...and <b>6</b> subjects - there is only one collection of books related to 6 subjects</p>
</div>
<div id="intro8half" style="display: none;">
<p>Use your mousewheel to zoom in and out of areas</p>
</div>
<div id="intro9" style="display: none;">
<p>Each circle represents a collection of books related to a unique set of subjects</p>
</div>
<div id="intro10" style="display: none;">
<p>Its <b>size</b> relates to how many books it contains. </p><p><b>1</b> in this case</p>
</div>
<div id="intro11" style="display: none;">
<p>Mouseover and lines spike towards the related <b>3</b> subjects: Science, Art and Architecture</p>
</div>
<div id="intro12" style="display: none;">
<p>And vice versa: </p>
<p>Click on subjects around the ring to see which collections of books relate to those unique subjects</p>
</div>
<div id="intro13" style="display: none;">
<p>The book list displays individual titles</p>
</div>
<div id="intro14" style="display: none;">
<p>Click any title to view its record in the Columbia University Libraries.</p><p>The search might incite new discoveries amidst the 125,000 entries that include multiple disciplines in their catalogue description.</p>
</div>
</div>
<div id="introNav2">
<img src="forwardNav.png" width="10" height="10">
</div>
</div>
<div id="byline">
<p>A digital library tool for multidisciplinary exploration.</p>
</div>
<div id="subline">
About
</div>
<div id="subline2">
Guiding Notes
</div>
<div id="about">
Project Team:
<p>Spatial Information Design Lab</p>
<p>Laura Kurgan, Project Director</p>
<p>Jen Lowe, Data Visualization and Data Analysis</p>
<p> <a href="http://www.annelieberner.com" style="
color: black;
text-decoration: none;
">Annelie Berner</a>, Application and Design Development, D3 Progamming.</p>
<p>Columbia Library</p>
<p>Alex Gil, Jeffrey Lancaster, Barbara Rochenbach</p>
</div>
<div id="about2">
<b>Subjects:</b>
<p>Represented subjects are the 25 most interdisciplinary in the Columbia University Libraries. They are arranged around the ring according to frequency - where Claims etc.* has the highest frequency of connected books.</p>
*Claims encompasses four subjects: Legislative Amendments, Military pensions, United States, and Claims.
<b><p>Book Circles:</p></b>
<p>Each circle represents a collection of books related to a unique combination of subjects. For example, Art, Architecture and Science have 1 book in common - the circle that represents this intersection is on the tier of circles with 3 connections. </p>
<p>Each circle's diameter is scaled to how many books are in its "collection." </p>
<p>The inner glyph shows the direction of the subjects it is related to - mouseover and the glyph will extend to touch those specific subjects. </p>
<div class="clickZoom"><b>Click here</b> for a guided explanation of the graphic.</div>
</div>
<div id="reset">RESET</div>
<script type = "text/javascript">
loadBooks();
var colors =
["#FFDAA0","#FFDAA0",
"#5ECBFF",
"#5ECBFF",
"#5ECBFF",
"#5ECBFF",
"#5ECBFF",
"#45E9E9",
"#45E9E9",
"#45E9E9",
"#45E9E9",
"#ADB3FF",
"#ADB3FF",
"#ADB3FF",
"#ADB3FF",
"#ADB3FF",
"#6F79F0",
"#6F79F0",
"#6F79F0",
"#6F79F0",
"#6F79F0",
"#6F79F0"]
var freqscale = 5; //size of circles
var MAX_LEVELS = 20; //number larger than number of levels of circles
var conn_levels = [12, 12, 264, 209, 137, 77,12]; //how far away from the center each level is
var outer_level = [0,265];
var radius_levels = [0, 0, 240, 190, 125, 70, 0, 0, 0, 0]; //how far away from the center each level is
var MIN_LINE = 3.0; //length of the little ones
var TEXT_PAD_X = 5;
var TEXT_PAD_Y = 2;
var LEGEND_X_MARGIN = 20;
var LEGEND_SCALE = 0.0007;
// Make an array of Subjects
var subjects;
// Make an array of Connections
var connections;
var bcolor;
var subtext;
var hsubtext;
var concolor;
var hconcolor;
var legendconcolor;
bcolor = "rgba(0, 0, 0, 255)";
concolor = "rgba(210, 210, 210, 50)";
hconcolor = "rgba(210, 210, 210, 100)";
legendconcolor = "rgba(210, 210, 210, 75)";
subtext = "rgba(150, 150, 150, 255)";
hsubtext = "rgba(210, 210, 210, 255)";
var initialZoom = 1,
maxZoom = 10;
var windowWidth = window.outerWidth,
windowHeight = window.innerHeight;
var boolSelected = 0;
var showReset = false;
var width = 1440,
height = window.innerHeight;
var animateZoom = false;
var animateOpening =true;
d3.select("#container").style("pointer-events","none");
d3.select("#intro2")
.transition()
.style("display", "block")
.style("opacity", 1.0)
.each("end",function(){
d3.select("g").transition().attr("opacity",.5)
console.log(tigReggib)
if (tigReggib>=connDataLength-100){
console.log(tigReggib)
// d3.select("#container").transition().style("opacity", 0.4);
// preDoLines();
}
});
$('#skip').fadeIn("slow");
var countProgress = 0;
$('#skip').on("click",function(){
clearEverything();
d3.selectAll("#intro2,.intro").transition().style("opacity", 0.0).style("display", "none");
$('#skip').fadeOut("fast");
d3.select("#container").transition().style("opacity", 1);
d3.select("g").transition().attr("opacity",1)
// .style("pointer-events","auto");
})
$('.clickZoom').on("click",function(){
clearEverything();
d3.select("#container").style("pointer-events","none");
$('#about2').fadeOut("slow");
$(".introZoom").css("top","250px")
$(".introZoom").css("width","240px")
// 240px
$("#introNav2").css("top","252px")
$("#introNav2").css("left","796px")
$("#skip2").show();
d3.select("#container")
.transition()
.duration(1000)
.style("opacity", .8)
.each("end",function(){
$(".introZoom")
.animate().css("opacity",.8).show("fast", function(){
$("#intro4").fadeIn("fast", function(){
$(".introZoom").animate().css("height","inherit", "left","539px");
});
$(".introZoom").animate({
height:"inherit",
left:"539px"
});
animateZoom = true;
zoomOpening();
})
})
})
$('#skip2').on("click",function(){
animateZoom = false;
skipIntro2();
})
//NEXT THING IS CLICKING TO GET TO THE BOOKS HTML LINK
function skipIntro(){
clearEverything();
animateZoom = false;
d3.select("#container").transition().style("opacity", 1.0);
d3.selectAll("#intro1, #intro2, #introNav, .intro").transition().style("opacity", 0.0).style("display", "none");
$('#skip').fadeOut("slow");
d3.select("#container").style("pointer-events","auto");
}
function skipIntro2(){
d3.select("#container").transition().style("opacity", 1.0);
d3.selectAll("#intro1, #intro2, #intro3, #intro4, #intro4half, #intro5, #intro6, #intro7, #intro8, #intro8half,#intro9, #intro10, #intro11, #intro12, #intro13, #introNav, #introNav2, .intro, .introZoom").transition().style("display", "none");
$('#skip2').fadeOut("slow");
d3.select("#container").style("pointer-events","auto");
for (i=0; i<conn_levels; i++){
d3.selectAll(".ringCircle"+conn_levels[i]).transition().attr("stroke-width",1)
}
clearEverything();
$("#introNav2").hide();
animateZoom = false;
}
if(animateZoom==false){
$("#introNav2").hide();
}
var svg = d3.select("#container")
.append("svg")
.attr({
"width": "100%",
"height": "100%",
});
// .call(zoom);
var vis = svg
.append('svg:g')
.attr("transform",
"translate("+ 0 + "," + 0 + ")");
svg.call(d3.behavior.zoom()
.scale(1.0)
.scaleExtent([initialZoom, maxZoom])
.on("zoom", function(){
var t = d3.event.translate;
var s = d3.event.scale;
zoomInOut(t, s);
})
);
svg
.on("mousedown.zoom", null)
.on("touchstart.zoom", null)
.on("touchmove.zoom", null)
.on("dblclick.zoom", null)
.on("touchend.zoom", null);
var zoomInOut = function(t, s) {
if (showReset==true){
$('#reset').slideDown( "slow", function() {
})
}
if (showReset==false){
$('#reset').slideUp( "slow", function() {
})
}
if (s>=initialZoom){
showReset = true;
}
if (s<initialZoom){
showReset = false;
}
vis.attr("transform",
"translate("+d3.event.translate+ ")"
+ " scale(" + d3.event.scale + ")");
};
d3.select("#reset").on("click", resetZoom);
function resetZoom(){
//Reset map
console.log("reset map")
vis.attr("transform",
"translate("+ 0 + "," + 0 + ")"
+ " scale(" + initialZoom + ")");
showReset = false;
console.log(showReset)
$('#reset').slideUp( "slow", function() {
})
};
var subjX=[];
var subjY=[];
var subjText=[];
var sData = [];
var subjCode = [];
var subjTextInside = [];
var subjLoc = [];
var freqIs=[];
var item;
var subradius = 325;
var scaling = 1.1;
var firstLoad = -1;
var tigReggib = -1;
var clicked = 0;
var checkedIt = [];
var wasItSubj;
var storeClicks = {};
var scienceSubj;
var womenSubj;
var matching = 0;
var rectClicked = false;
var wordWidth = [];
function runOuterCircles(){
d3.tsv("subjects_top25_option1.tsv", function(error, data) {
var jump = Math.PI*2/data.length; // float jump = TWO_PI/(float
var angle = 0;
var text = vis.selectAll('.subjectText')
.data(data)
.enter().append("text")
.attr("class",function(d,i){
subjCode.push(d.subjCode);
freqIs.push(d.freq);
subjLoc.push(d.loc);
subjTextInside.push(d.subject);
subjX.push(width*.5+subradius*Math.cos(jump*(d.loc-1)));
subjY.push(height*.5+subradius*Math.sin(jump*(d.loc-1)));
return "subjectText";
})
.attr("x", function(d,i){
if (subjX[i]>width/2){
$(".subjectText").animate().css('text-align','left');
return subjX[i];
}
else {
if (d.subject.length > 11){
return subjX[i]-d.subject.length*3-55;
}
if (d.subject.length<=11 &&d.subject.length>6){
return subjX[i]-d.subject.length*3-25;
}
else {
return subjX[i]-d.subject.length*3-20;
}
}
})
.attr("y", function(d,i){
return subjY[i];
})
.text(function(d,i) {
return d.subject;
})
.attr("fill", "black")
.attr("opacity",1)
.each(function(d) {
d.width = this.getBBox().width;
})
.on("mouseover", function(d){
d3.select(".surroundingPoints"+d.subjCode)
.transition()
.attr("stroke", colors[d.loc]);
})
.on("click", function(d,i){
count=0;
var d = this.__data__;
console.log(d);
wasItSubj = d.subjCode;
storeClicks[i] = storeClicks[i] ? storeClicks[i]+1 : 1; //now this is counters
whichBooks.length = 0;
booksChecked.length = 0;
hideBooks();
if(storeClicks[i]%2==1){ //if clicked ON
console.log("clicked on"+storeClicks[i]%2)
console.log("this is"+i)
runLines(d.subjCode);
checkedIt.push(d.subjCode);
checked(checkedIt);
d3.select(".surroundingPoints"+d.subjCode)
.transition()
.attr("y", subjY[i]-10)
.attr("height",14);
}
if(storeClicks[i]%2==0){ //if unselected
console.log("clicked off"+storeClicks[i]%2)
d3.select(".surroundingPoints"+d.subjCode)
.transition()
.attr("y", subjY[i]+5)
.attr("height",.1)
//and remove that subject number
for (c=0; c<checkedIt.length; c++){
if (checkedIt[c]==d.subjCode){ // || 2 || 3 || 4
checkedIt.splice(c,1);
}
}
bookColors.length = 0;
d3.selectAll("circle.inCircle"+checkedIndex)
.transition()
.attr("opacity",.1)
.attr("fill","grey");
d3.selectAll(".checkedLinesOut").remove();
d3.selectAll(".mouseoverText").remove();
d3.selectAll(".innerText").remove();
checked(checkedIt);
removeRunnedLines(d.subjCode);
}
});
var surroundingRects = vis.selectAll("surroundingPoints")
.data(data)
.enter().append("rect")
.attr("class", function(d,i){ return "surroundingPoints"+d.subjCode; })
.attr("x", function(d,i){
if (subjX[i]>width/2){
return subjX[i]-5;
}
else {
if (d.subject.length > 11){
return subjX[i]-d.subject.length*3-58;
}
if (d.subject.length<=11 &&d.subject.length>6){
return subjX[i]-d.subject.length*3-28;
}
else {
return subjX[i]-d.subject.length*3-23;
}
}
})
.attr("width", function(d,i){
wordWidth.push(d.width);
if (subjX[i]>width/2){
return d.width+11;
}
else{
return d.width+8; //this.getBBox().width+3)
}
})
.attr("y", function(d,i){
return height*.5+subradius*Math.sin(jump*(d.loc-1))+5;
})
.attr("height", .1)
.attr("stroke-width","1px")
.attr("fill","none")
.attr("stroke", function(d,i){
return "grey";//colors[d.loc];
})
$('.subjectText').tipsy({
gravity: 'nw',
html: true,
title: function() {
var d = this.__data__;
var newNum = Math.round((d.freq) / 1000);
var niceNum = numberWithCommas(newNum)+"k books";
return niceNum;
}
});
})
}
function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
var exitGraphsClicked = false;
$('#graphIcon').click(function(){
if (exitGraphsClicked==false){
makeGraphsBig();
}
if (exitGraphsClicked==true){
justMakeGraphs();
}
d3.select("#graphIcon").transition().style("display","none");
d3.select("#exitGraph").transition().style("display","block")
})
$('#exitGraph').click(function(){
exitGraphsClicked = true;
hideGraphs();
d3.select("#exitGraph").transition().style("display","none");
d3.select("#graphIcon").transition().style("display","block");
})
var mapLittleRect = d3.scale.linear()
.domain([0, freqIs.length])
.range([700,500]);
var maxFreq = d3.max(freqIs, function(d,i){return d; })
var legendMap = d3.scale.linear()
.domain([0, maxFreq])
.range([20,500]);
function hideGraphs(){
d3.selectAll(".rectsAre, .textsAre")
.transition()
.attr("opacity",0)
}
function justMakeGraphs(){
d3.selectAll(".rectsAre")
.transition()
.attr("opacity",.8)
d3.selectAll(".textsAre")
.transition()
.attr("opacity",1)
}
var secondVis = svg
.append('svg:g')
.attr("transform",
"translate("+ 0 + "," + 0 + ")")
function makeGraphsBig(){
d3.tsv("subjects_top25_option1.tsv", function(error, data) {
var mapRect = d3.scale.linear()
.domain([0, freqIs.length])
.range([680,440]); //not 480
// if (freqIs.length>0){
var graphRects = secondVis.selectAll("rectsAre")
.data(data)
.enter()
.append("rect")
.attr("class", function(d){ return "rectsAre"})
.attr("x", function(d){
return 0;
})
.attr("y", function(d,i){
return 0;
// return mapRect(i); //if i want claims on bottom
})
.attr("width", function(d){
return 0;
})
.attr("height",6)
// .attr("fill","lightgray");
.attr("fill", function(d,i){
return colors[d.loc];
})
.attr("opacity",.8)
var graphText = secondVis.selectAll("textsAre")
.data(data)
.enter()
.append("text")
.attr("class", function(d){ return "textsAre"})
.attr("x", function(d){
0;
})
.attr("y", function(d,i){
console.log(mapRect(i))
return windowHeight+100;
})
.text(function(d){
return d.subject;
})
.attr("fill","black");
// if (rectClicked==true){
d3.selectAll(".rectsAre")
.transition()
.duration(100)
.attr("y", function(d,i){
return mapRect(i); //if i want claims on bottom
});
d3.selectAll(".rectsAre")
.transition()
.duration(200)
.delay(300)
.attr("width", function(d,i){
return d.freq*LEGEND_SCALE;
});
d3.selectAll(".textsAre")
.transition()
.delay(800)
.attr("x", function(d){
return d.freq*LEGEND_SCALE+5;
})
.attr("y", function(d,i){
return mapRect(i)+5;
})
// }
})
}
//Move SVG elements to the end of their container,
//so they appear "on top".
var moveToFront = function() {
this.parentNode.appendChild(this);
}
var bigBooks = [];
var saveBigIds = [];
var incomingBig;
var splitBig;
var angles = [];
var first = [];
var r = [];
var calcX=[];
var calcY=[];
var radiusIs = [];
var allCodes = [];
var temp = [];
var thisThing;
var whatRadius = [];
var myVar;
var firstLoadVar;
var secondLoadVar;
var ready = 0;
var connDataLength;
firstVariable();
function firstVariable(){
d3.tsv("connectionfreqcodes_top25.txt", function(error, cData) {
connDataLength = cData.length;
})
}
////PROBLEM OF GETTING THIS VARIABLE BEFORE RUNNING OTHER FUNCTIONS
firstLoadVar = setInterval(function(){
if (connDataLength>0){
if (firstLoad<connDataLength-1){
d3.tsv("connectionfreqcodes_top25.txt", function(error, cData) {
firstLoad++;
if (firstLoad>=0){
// console.log(firstLoad);
storeInnerSubjs(cData[firstLoad].codeName, firstLoad);
}
})
}
else {
runOnce();
clearInterval(firstLoadVar);
}
}
},1);
function runOnce(){
runInnerCircles();
runOuterCircles();
}
var countLittleCircle = 0;
var littleCircIndex;
var littleCircChecked = [];
var circleFreq = [];
function runInnerCircles(){
d3.tsv("connectionfreqcodes_top25.txt", function(error, cData) {
for (i = 0; i < cData.length;i++) {
allCodes.push(cData[i].codeName);
angles.push(holdAngles[i]);
radiusIs.push(radius_levels[storeLengths[i]]);
circleFreq.push(cData[i].freq);
}
for (i=0; i<allCodes.length; i++){
r.push(allCodes[i].split(","));
}
var ringCircle = vis.selectAll("ringCircle")
.data(conn_levels)
.enter()
.append("circle")
.attr("class",function(d,i){ return "ringCircle"+d; })
.attr("cx",width/2)
.attr("cy",height/2)
.attr("r", function(d){
return d;
})
.attr("fill","none")
.attr("opacity",.1)
.attr("stroke","lightgray")
.attr("stroke-width",.5)
var inCircle = vis.selectAll("inCircle")
.data(cData)
.enter().append("circle")
.attr("class", function(d,i){
calcX.push(width*0.5+scaling*radiusIs[i]*Math.cos(angles[i]));
calcY.push(height*0.5+scaling*radiusIs[i]*Math.sin(angles[i]));
whatRadius.push(Math.log(d.freq+2.0)*freqscale/2);
return "inCircle"+i;
})
.attr("cx", function(d,i){
return width*0.5+scaling*radiusIs[i]*Math.cos(angles[i]);
})
.attr("cy", function(d,i){
return height*0.5+scaling*radiusIs[i]*Math.sin(angles[i]);
})
.attr("r", function(d){
return (Math.log(d.freq+2.0)*freqscale/2);
})
.attr("fill", "gray")
.attr("opacity",.1)
.attr("stroke","white")
.attr("stroke-width",1)
.on("mouseover", function(d,i){
d3.select(this)
.attr("opacity", .9);
index = i;
allOut(d.codeName, index); //FIX WHAT THING IS NOW
})
.on("mouseout", function(d,i){
console.log(countLittleCircle%2==0)
if(countLittleCircle%2==0){
d3.select(this)
.attr("opacity",.1)
removeOutwardLines(d.codeName, i); //FIX CODENAME
}
})
.on("click", function(d,i){
console.log("clicked little circle for books")
console.log(d.codeName+"d.codeName on click of little circle")
countLittleCircle++;
console.log(countLittleCircle%2+"countLittleCircle")
littleCircChecked.length=0;
if (countLittleCircle%2==0){
d3.select(this)
.transition()
.attr("fill","grey")
.attr("opacity",.1)
removeOutwardLines(d.codeName, i); //FIX CODENAME
d3.select("#container").transition().style("opacity", 1);
d3.selectAll(".mouseoverText").remove();
hideBooks();
}
else if (countLittleCircle%2==1){
d3.select("#container")
.style("pointer-events","none")
// d3.select("#hideContainer")
.transition()
.style("opacity", ".3");
// d3.select()
d3.select(this)
.transition()
.attr("fill","yellow");
// .style("z-index",1001)
littleCircChecked.push(d.codeName);
littleCircIndex = i;
books(d.codeName,i);
// d3.select("#container")
// .on("click", function(){
// d3.select("#container")
// .transition()
// // .style("pointer-events","none")
// // d3.select("#hideContainer")
// .style("opacity", "1");
// })
}
});
makeGlyph();
// $('#container').click(function(d,i) {
// d3.select("#container").transition().style("opacity", 1);
// console.log("clicked container")
// d3.selectAll("inCircle"+i)
// .transition()
// .attr("fill","grey")
// d3.select("#booksColumn.selected").classed("selected", false);
// d3.selectAll(".mouseoverText").remove();
// hideBooks();
// });
function makeGlyph(){
myVar = setInterval(function(){
if (tigReggib<connDataLength-1){
tigReggib++;
runLinesOut(cData[tigReggib].codeName, tigReggib); //FIX CODENAME
}
else {}
},1);
if (tigReggib>=connDataLength-1){
clearInterval(myVar);
}
}
})
processBigs1("1,1",0);
processBigs1("1,21",1);
processBigs1("1,21,2",2);
processBigs1("5,20",3);
processBigs1("5,12",4);
processBigs1("9,7",5);
}
var thisIs = [];
var otherThis = [];
var storeLengths = [];
var countLengths = {};
var jumps = {};
var anglesAre = [];
var holdAngles = [];
var countIt = 0;
var thisCircle;
function storeInnerSubjs(arrayOfSubjs, index){
otherThis = arrayOfSubjs.split(",");
storeLengths.push(otherThis.length); //now this is "q"
countLengths[otherThis.length] = countLengths[otherThis.length] ? countLengths[otherThis.length]+1 : 1; //now this is counters
checkLengths(otherThis,index); //here we finish counters array and create the new jumps thing
}
var stop;
function checkLengths(otherThis,index){
for (i=0; i<MAX_LEVELS; i++){
anglesAre[i] = 0;
if (countLengths[i]===undefined){
console.log("undefined");
countLengths[i] = 0;
}
else {}
jumps[i]=((Math.PI*2)/countLengths[i]);
}
if (index==connDataLength-1){
console.log(connDataLength);
newFunction();
}
}
function newFunction(){
var onlyThis = 3;
console.log(jumps[3]);
for (i=0; i<storeLengths.length; i++){
anglesAre[storeLengths[i]]+=jumps[storeLengths[i]];
holdAngles.push(anglesAre[storeLengths[i]]);
}
}
// console.log("hey")
// if(firstLoad>300){
// console.log(codeSorted.length+"codesorted")
// // if(manyBooks.length==126634 && manyIds.length==126634 && codeSorted.length==126634){
// // console.log("predolines")
// preDoLines();
// // }
// }
var count = 0;
var theseNums = [];
var boolUnselect = 0;