Skip to content

Commit 4116161

Browse files
authored
Merge pull request #21 from iDataVisualizationLab/General
Update time format detail box + transition
2 parents 5397ae5 + 0bc321f commit 4116161

File tree

5 files changed

+84
-95
lines changed

5 files changed

+84
-95
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
.idea/workspace.xml
33
.idea/workspace.xml
44
*.xml
5+
.idea/workspace.xml

.idea/workspace.xml

+48-51
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/detailOnDemand.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function createTableTooltip(wsTooltipDiv, info){
5353
})
5454
.enter()
5555
.append("td")
56-
.text(d => d.column === "time"? formatTimeLegend(d.value):d.value);
56+
.text(d => d.column === "time"? formatTimeDetailBox(d.value):d.value);
5757
}
5858

5959
function highlight(info, wsData, timestep) {

js/main.js

+28-37
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ const streamStepUnit = 0.5; // half hour
55
const formatTimeLegend = d3.timeFormat("%B %d, %-I:%M:%S %p");
66
// const formatTimeReadData = d3.timeFormat("%Y %B %d %-I%p");
77
const formatTimeReadData = d3.timeFormat("%-m/%-d %-I%p");
8+
const formatTimeDetailBox = d3.timeFormat("%B %d, %-I:%M %p");
89
const topics = ["message", "location"];
9-
const topicColor = ["#919191", "#660000"];
10+
const topicColor = ["#919191", "#770000"];
1011
const margin = {top: 30, right: 20, bottom: 50, left: 50},
1112
width = 1200 - margin.left - margin.right,
1213
height = 500 - margin.top - margin.bottom;
@@ -16,6 +17,9 @@ const bisect = d3.bisector(d => {
1617
}).left;
1718
const initOption = "resource";
1819
const columns = ["time", "location", "account", "message"];
20+
const firstStrike = [1586200114000, 1586204242000];
21+
const secondStrike = [1586350794000, 1586356642000];
22+
const thirdStrike = [1586459159000, 1586468448000];
1923

2024
let data;
2125
let streamStep = streamStepUnit * hourToMS;
@@ -281,7 +285,10 @@ function drawGraph() {
281285
.attr("fill", (d, i) => {
282286
return taxonomy.find(d => d.id === keyList[i]).color;
283287
});
284-
// initDataSelection(dataSelection);
288+
289+
// markers
290+
291+
285292
// Running tooltip for date and time
286293
let tooltip = d3.select(main)
287294
.append("div")
@@ -390,24 +397,6 @@ function drawGraph() {
390397

391398
dashedGroup.call(drag);
392399

393-
// highlight layers
394-
// svg.selectAll(".layer")
395-
// .attr("opacity", 1)
396-
// .on("mouseover", function (d, i) {
397-
// svg.selectAll(".layer").transition()
398-
// .duration(250)
399-
// .attr("opacity", function (d, j) {
400-
// return j != i ? 0.5 : 1;
401-
// })
402-
// })
403-
// .on("mouseout", function (d, i) {
404-
// svg.selectAll(".layer")
405-
// .transition()
406-
// .duration(250)
407-
// .attr("opacity", "1");
408-
// })
409-
// ;
410-
411400
g.append("rect")
412401
.attr('class', 'overlay')
413402
.attr('width', width)
@@ -538,22 +527,12 @@ function updateStream() {
538527
let newchartstack = d3.select("#streamG")
539528
.selectAll("path").data(stacks,d=>d.key);
540529

541-
let enterArr = newchartstack.enter()._groups[0];
542-
let enterItem = (enterArr.includes(undefined) && enterArr.length > 1);
543-
let exitArr = newchartstack.exit()._groups[0];
544-
let exitItem = (exitArr.includes(undefined) && exitArr.length > 1);
545-
546-
newchartstack.enter()
547-
.append('path') .attr("class", "layer")
548-
.attr("opacity", 0)
549-
.transition()
550-
.delay(enterItem ? 1000 : 0)
551-
.duration(1000)
552-
.attr("d", areaGen)
553-
.attr("fill", (d, i) => {
554-
return taxonomy.find(d => d.id === keyList[i]).color;
555-
})
556-
.attr("opacity", 1);
530+
let enterArr = newchartstack._enter[0];
531+
let enterItem = enterArr.filter(d => d !== undefined).length;
532+
let exitArr = newchartstack._exit[0];
533+
let exitItem = exitArr.filter(d => d !== undefined).length;
534+
let updateArr = newchartstack._groups[0];
535+
let updateItem = updateArr.filter(d => d !== undefined).length;
557536

558537
newchartstack.exit()
559538
.attr("opacity", 1)
@@ -563,11 +542,23 @@ function updateStream() {
563542

564543
newchartstack
565544
.transition()
566-
.delay(exitItem ? 1000 : 0)
545+
.delay((exitItem && updateItem) ? 1000 : 0)
567546
.duration(1000).attr("d", areaGen)
568547
.attr("fill", (d, i) => {
569548
return taxonomy.find(d => d.id === keyList[i]).color;
570549
});
550+
551+
newchartstack.enter()
552+
.append('path') .attr("class", "layer")
553+
.attr("opacity", 0)
554+
.transition()
555+
.delay((enterItem && updateItem)? 1000 : 0)
556+
.duration(1000)
557+
.attr("d", areaGen)
558+
.attr("fill", (d, i) => {
559+
return taxonomy.find(d => d.id === keyList[i]).color;
560+
})
561+
.attr("opacity", 1);
571562
}
572563

573564
function processStreamData(streamData00){

js/source.js

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)