Skip to content

Commit 4afb600

Browse files
committed
Update config and display
1 parent d463175 commit 4afb600

7 files changed

Lines changed: 38 additions & 53 deletions

File tree

.DS_Store

12 KB
Binary file not shown.

data/FactCheck.tsv

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

javascripts/init.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const initWidth = 1500,
2-
initHeight = 500,
2+
initHeight = 520,
33
initMinFont = 14,
44
initMaxFont = 36,
55
initFlag = "none";// none / fa/ f / a

javascripts/main.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -370,26 +370,26 @@ function draw(data) {
370370
//Try
371371
let prevColor;
372372
//Highlight
373-
mainGroup.selectAll('text').on('mouseenter', function () {
373+
mainGroup.selectAll('.textData').on('mouseenter', function () {
374374
let thisText = d3.select(this);
375375
thisText.style('cursor', 'pointer');
376376
prevColor = thisText.attr('fill');
377377
let text = thisText.text();
378378
let topic = thisText.attr('topic');
379-
let allTexts = mainGroup.selectAll('text').filter(t => {
379+
let allTexts = mainGroup.selectAll('.textData').filter(t => {
380380
return t && t.text === text && t.topic === topic;
381381
});
382382
allTexts.attr({
383383
stroke: prevColor,
384384
'stroke-width': 1
385385
});
386386
});
387-
mainGroup.selectAll('text').on('mouseout', function () {
387+
mainGroup.selectAll('.textData').on('mouseout', function () {
388388
let thisText = d3.select(this);
389389
thisText.style('cursor', 'default');
390390
let text = thisText.text();
391391
let topic = thisText.attr('topic');
392-
let allTexts = mainGroup.selectAll('text').filter(t => {
392+
let allTexts = mainGroup.selectAll('.textData').filter(t => {
393393
return t && !t.cloned && t.text === text && t.topic === topic;
394394
});
395395
allTexts.attr({
@@ -398,11 +398,11 @@ function draw(data) {
398398
});
399399
});
400400
//Click
401-
mainGroup.selectAll('text').on('click', function () {
401+
mainGroup.selectAll('.textData').on('click', function () {
402402
let thisText = d3.select(this);
403403
let text = thisText.text();
404404
let topic = thisText.attr('topic');
405-
let allTexts = mainGroup.selectAll('text').filter(t => {
405+
let allTexts = mainGroup.selectAll('.textData').filter(t => {
406406
return t && t.text === text && t.topic === topic;
407407
});
408408
//Select the data for the stream layers
@@ -461,14 +461,14 @@ function draw(data) {
461461
wordStream: true
462462
});
463463
//Hide all other texts
464-
let allOtherTexts = mainGroup.selectAll('text').filter(t => {
464+
let allOtherTexts = mainGroup.selectAll('.textData').filter(t => {
465465
return t && !t.cloned && t.topic === topic;
466466
});
467467
allOtherTexts.attr('visibility', 'hidden');
468468
});
469469
topics.forEach(topic => {
470470
d3.select("path[topic='" + topic + "']").on('click', function () {
471-
mainGroup.selectAll('text').filter(t => {
471+
mainGroup.selectAll('.textData').filter(t => {
472472
return t && !t.cloned && t.placed && t.topic === topic;
473473
}).attr({
474474
visibility: 'visible'

javascripts/update.js

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ function updateData() {
258258

259259
function drawWordsUpdate() {
260260
let placed = true;
261+
let prevColor;
261262
// mainGroup.selectAll('.word').remove();
262263
var texts = mainGroup.select("#main").selectAll('.word').data(allWordsUpdate, d => d.id);
263264

@@ -271,30 +272,35 @@ function updateData() {
271272
return 'translate(' + d.x + ', ' + d.y + ')rotate(' + d.rotate + ')';
272273
}
273274
})
274-
.select(".textData")
275+
.select("text")
275276
.style('font-size', d => d.fontSize)
276277
.attr({
277278
visibility: function (d) {
278279
return d.placed ? (placed ? "visible" : "hidden") : (placed ? "hidden" : "visible");
279280
}
280281
});
281282

282-
texts.enter()
283+
let t = texts.enter()
283284
.append("g")
284285
.attr({
285286
transform: function (d) {
286287
return 'translate(' + d.x + ', ' + d.y + ')rotate(' + d.rotate + ')';
287288
}
288289
})
289-
.attr("class", "word new")
290+
.attr("class", "word");
291+
292+
t.transition()
293+
.duration(1000)
294+
295+
t
290296
.append("text")
291297
.text(function (d) {
292298
return d.text;
293299
})
300+
.style('cursor', 'pointer')
294301
.style('font-size', d => d.fontSize)
295302
.attr({
296303
"class": "textData",
297-
298304
fill: function (d) {
299305
return color(categories.indexOf(d.topic));
300306
},
@@ -309,11 +315,24 @@ function updateData() {
309315
visibility: function (d) {
310316
return d.placed ? (placed ? "visible" : "hidden") : (placed ? "hidden" : "visible");
311317
}
312-
});
313-
314-
let prevColor;
315-
// --- Highlight when mouse enter ---
316-
318+
})
319+
.on('mouseenter', function(){
320+
let thisText = d3.select(this);
321+
thisText.style('cursor', 'pointer');
322+
prevColor = thisText.attr('fill');
323+
thisText.attr({
324+
stroke: prevColor,
325+
'stroke-width': 1
326+
});})
327+
328+
.on('mouseout', function(){
329+
let thisText = d3.select(this);
330+
thisText.style('cursor', 'default');
331+
thisText.attr({
332+
stroke: 'none',
333+
'stroke-width': '0'
334+
});
335+
});
317336

318337

319338
}

lib/d3.layout.wordstream.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ d3.layout.wordStream = function(){
1919
cw = (fileName.indexOf("Quantum")) >= 0 ? 25000 : 1<< 14 ,
2020
ch = 1 << 11;
2121

22-
console.log(cw);
2322
let maxSud, minSud, maxFreq;
2423

2524
wordStream.boxes = function(){

test.html

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)