Skip to content

Commit 97601b1

Browse files
committed
added event handling for linear map on the circos plot
1 parent 95a1a32 commit 97601b1

File tree

4 files changed

+52
-26
lines changed

4 files changed

+52
-26
lines changed

build/assets/style.css

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,13 @@ text.cloneMarkerText {
5050
fill: white;
5151
}
5252

53-
.tooltip {
54-
background-color: white;
55-
padding: 20px;
53+
.tooltip, .tooltip-circularMap {
54+
background-color: #dcd5d5;
55+
padding: 10px;
56+
font-family: sans-serif;
57+
text-transform: capitalize;
58+
font-size: 12px;
59+
font-weight: bold;
5660
}
5761

5862
/* ///////////////////////////// Style for Circular Map //////////////////////////////// */
@@ -87,4 +91,8 @@ text.cloneMarkerText {
8791
font-weight: bold;
8892
vertical-align: top;
8993
padding-left: 10px;
94+
}
95+
96+
.mainContainer {
97+
margin: 0px auto;
9098
}

src/app.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ import { symbol, symbolCircle, symbolSquare, symbolTriangle, symbolStar } from "
33
import axios from 'axios';
44
import _ from 'lodash';
55
import processGcadOutput from './processGcadOutput';
6-
import cloneMap from './cloneMap';
76
import circularMap from './circularMap';
87
import matrix from './matrix';
8+
import cloneMap from './cloneMap';
99
import { blueColor, redColor, greenColor, grayColor } from './colors';
1010

11+
1112
// Temporary params fix to test mutltiple input files
1213
let fileParamMapper = {
1314
'argo': 'gcad_argo_uml_output.txt',
@@ -30,7 +31,8 @@ const getParams = query => {
3031

3132
axios.get('assets/files/' + fileParamMapper[getParams(window.location.search).source]).then(function (response) {
3233

33-
let cloneData = processGcadOutput(response);
34+
let cloneData = processGcadOutput(response),
35+
cloneDataCopy = _.clone(cloneData);
3436

3537
// intial information regarding the project , its version count and the gcad paramters
3638
d3.select('#root').append('div').attr('class', 'SubHeadingTitleContainer')
@@ -62,6 +64,10 @@ axios.get('assets/files/' + fileParamMapper[getParams(window.location.search).so
6264
// calling circular map
6365
d3.select('#root').append('h3').attr('class', 'SubHeadingTitle plotTitle').text('Circos Plot - Representation of Change Patterns in Clones');
6466
circularMap(cloneData);
67+
// calling clone map for first element - first set as default
68+
d3.select('#root').append('h3').attr('class', 'SubHeadingTitle plotTitle historyTitle').text('Clone Change History');
69+
cloneDataCopy.genealogyList = cloneDataCopy.genealogyList.slice(0, 1);
70+
cloneMap(cloneDataCopy);
6571
// calling linear map
6672
d3.select('#root').append('h3').attr('class', 'SubHeadingTitle plotTitle').text('Scatter Plot - Representation of Change Patterns in Clones');
6773
matrix(cloneData);

src/circularMap.js

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as d3 from 'd3';
22
import { symbol, symbolCircle, symbolSquare, symbolTriangle, symbolStar } from "d3-shape";
33
import _ from 'lodash';
44
import { blueColor, redColor, greenColor } from './colors';
5+
import cloneMap from './cloneMap';
56

67
export default function (cloneData) {
78

@@ -11,13 +12,11 @@ export default function (cloneData) {
1112
width = 0.75 * squareRange,
1213
radius = width / 2;
1314

14-
// if a map exists remove it , could probably handle this better in a future version
15-
d3.selectAll('mainContainer').remove()
1615
let circularMainContainer = d3.select('#root').append('div');
1716
circularMainContainer.attr('class', 'circularMainContainer')
18-
.style("width", width + 'px');
17+
.style("width", width + 'px').selectAll("*").remove();
18+
1919

20-
//
2120
let circularRootSVG = circularMainContainer.append('svg')
2221
.attr('class', 'circularRootSVG')
2322
.attr('height', width)
@@ -29,6 +28,14 @@ export default function (cloneData) {
2928
arcPadding = (radius / versionCount) * 0.25,
3029
arcAnglePadding = 0.05 * (360 / genealogyList.length);
3130

31+
let tooltip = d3.select("body")
32+
.append("div")
33+
.attr("class", "tooltip-circularMap")
34+
.style("position", "absolute")
35+
.style("z-index", "10")
36+
.style("visibility", "hidden")
37+
.text("");
38+
3239
circularRootSVG.append('g')
3340
.attr('class', 'centeredGraphic')
3441
.attr('transform', 'translate(' + radius + "," + radius + ')')
@@ -58,6 +65,17 @@ export default function (cloneData) {
5865
return d.changeType.indexOf('no_change') > -1 ? greenColor : d.changeType.indexOf('inconsistent_change') > -1 ? redColor : blueColor;
5966
})
6067
})
68+
.on("mouseover", function (d) {
69+
tooltip.html(d.info.replace(/\n/g, '<br />'));
70+
return tooltip.style("visibility", "visible");
71+
})
72+
.on("click", function (d) {
73+
d3.select('.historyTitle').remove();
74+
d3.select('#root').append('h3').attr('class', 'SubHeadingTitle plotTitle historyTitle').text('Clone Change History');
75+
cloneMap({ 'genealogyList': [d], versionCount, uniqueVersionList });
76+
})
77+
.on("mousemove", function () { return tooltip.style("top", (event.pageY - 10) + "px").style("left", (event.pageX + 10) + "px"); })
78+
.on("mouseout", function () { return tooltip.style("visibility", "hidden"); })
6179

6280

6381
}

src/cloneMap.js

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ import { blueColor, redColor, greenColor, grayColor } from './colors';
55

66
export default function (cloneData) {
77

8-
let { genealogyList, projectName, genealogyInfo, versionCount, uniqueVersionList } = cloneData;
9-
10-
let paddingHeightPerGroup = 40;
11-
let marginPadding = 80;
12-
let height = (genealogyList.length * paddingHeightPerGroup) + 100;
13-
let width = document.body.clientWidth - marginPadding;
8+
let { genealogyList, versionCount, uniqueVersionList } = cloneData,
9+
paddingHeightPerGroup = 20,
10+
height = (genealogyList.length * paddingHeightPerGroup) + 100,
11+
squareRange = document.body.clientWidth,
12+
width = squareRange - (squareRange / 10);
1413

1514
// if a map exists remove it , could probably handle this better in a future version
16-
d3.selectAll('mainContainer').remove()
15+
d3.selectAll('.mainContainer').remove();
1716

1817
let mainContainer = d3.select('#root').append('div')
1918
mainContainer.attr('class', 'mainContainer')
@@ -28,6 +27,7 @@ export default function (cloneData) {
2827
.append('h2')
2928
.style("width", width / versionCount + 'px')
3029
.text((d) => d)
30+
.style('font-size', (width / versionCount) * 0.15 + 'px')
3131

3232
let contentContainer = mainContainer.append('svg')
3333
.attr('class', 'contentContainer')
@@ -38,10 +38,7 @@ export default function (cloneData) {
3838
.data(genealogyList)
3939
.enter()
4040
.append('g')
41-
.attr('transform', (d, i) => "translate(0," + paddingHeightPerGroup * i + ")")
42-
.on('mouseover', function () {
43-
debugger;
44-
})
41+
.attr('transform', (d, i) => "translate(0," + paddingHeightPerGroup * i + ")");
4542

4643
genealogySetGroup.selectAll('.changeLine').data((d) => d.set)
4744
.enter()
@@ -84,12 +81,7 @@ export default function (cloneData) {
8481
.append('path')
8582
.attr("class", 'cloneMarker ')
8683
.attr("d", symbol().size(375).type((d, i) => symbolCircle))
87-
.style("fill", (d, i) => {
88-
if (d.cloneType.length > 1) {
89-
return grayColor;
90-
}
91-
else this.remove();
92-
})
84+
.style("fill", (d, i) => (d.cloneType.length > 1) ? grayColor : 'white')
9385
.attr("transform", function (d, i) {
9486
return "translate(" + (((width / versionCount) * i) + (width / (versionCount * 2))) + "," + paddingHeightPerGroup + ")";
9587
})
@@ -105,5 +97,7 @@ export default function (cloneData) {
10597
return "translate(" + (((width / versionCount) * i) + (width / (versionCount * 2)) - 4) + "," + (paddingHeightPerGroup + 5) + ")";
10698
});
10799

100+
101+
108102
}
109103

0 commit comments

Comments
 (0)