-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathvista_pkg_dep.php
257 lines (226 loc) · 8.45 KB
/
vista_pkg_dep.php
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
<!DOCTYPE html>
<html>
<title>VistA Package Dependency</title>
<head>
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700|Roboto:400,700' rel='stylesheet' type='text/css'>
<?php
include_once "d3.dependencyedgebundling.css";
include_once "vivian_common.php";
?>
<script>
$(function() {
fileName = window.location.href.substring(window.location.href.lastIndexOf('/')+1)
$('a[href="'+fileName+'"]').parents("#navigation_buttons li").each(function (i) {
$(this).removeClass().addClass("active");
});
});
</script>
</head>
<body>
<div style="position:relative; left:20px; top:-15px;">
<div id="legend_placeholder" style="float: left;"></div>
<div style="float: left; margin-left:15px; margin-right:35px;">
<label class="btn-primary btn-sm">
<input type="checkbox" id="colorMode" onclick="javascript:swapColorScheme()"> Colorblind Mode </input>
</label>
</div>
</div>
<textarea class="hint" style="position:relative; top:-15px; resize:none;" rows="6" cols="75" readonly>
This circle plot captures the interrelationships among VistA packages.
Hover over any of the packages in this graph to see incoming links (dependents) in one color and the outgoing links (dependencies) in a second.
Click on any of the packages to view package dependency details.
</textarea>
<div id="chart_placeholder"></div>
<div id="toolTip" class="tooltip" style="opacity:0;">
<div id="header1" class="header"></div>
<div id="dependency" ></div>
<div id="bothDeps"></div>
<div id="dependents"></div>
<div class="tooltipTail"></div>
</div>
<div id="groupToolTip" class="tooltip" style="opacity:0;">
<div id="groupName" class="header"></div>
<div class="tooltipTail"></div>
</div>
<style type="text/css">
${demo.css}
</style>
<script type="text/javascript">
var jsonData = [];
var palette = "rg";
var colorLegend = [{name: "Depends", colorClass: palette + "-link--source"},
{name: "Dependents", colorClass: palette + "-link--target"},
{name: "Both", colorClass: "link--target link--source"}];
var legendColorChart = d3.chart.treeview()
.height(50)
.width(300)
.margins({top:42, left:10, right:0, bottom:0})
.textwidth(110);
function swapColorScheme() {
var shapeLegendText = legendColorChart.svg().selectAll("text")
$("#colorMode").toggleClass("active");
if(palette == "rg") {
palette = "cb";
}
else {
palette = "rg";
}
shapeLegendText
.filter( function(l) { if(l) return l.name === "Dependents"})
.attr("class", function(d) {return palette + "-link--target";});
shapeLegendText
.filter( function(l) { if(l) return l.name === "Depends"})
.attr("class", function(d) {return palette + "-link--source";});
shapeLegendText.transition();
}
d3.json("PackageCategories.json", function(error, data) {
var categories = data;
function getPackageDoxLink(node) {
var package_link_url = DOX_URL+"/Package_";
var doxLinkName = node.name.replace(/ /g, '_').replace(/-/g, '_')
return package_link_url + doxLinkName + ".html";
}
function packageHierarchyByGroups(classes) {
var map = {};
map[categories.name] = {name: name, children: []};
function setdata(name, data) {
var node = map[name];
if (!node) {
node = map[name] = data || {name: name, children: []};
}
}
classes.forEach(function(d) {
setdata(d.name, d);
});
function setCategory(data) {
var child_node;
var name = data.name;
var node = map[name];
if (!node) {
// ignore package that are in categorized but
// not in the data
if (data.children !== undefined) {
node = map[name] = {name: name, children: []};
}
}
if (data.children !== undefined && data.children) {
var length = data.children.length;
for (var i=0; i<length; i++) {
var primary_function = 'Yes';
if ('primaryfunction' in data.children[i]) {
primary_function = data.children[i].primaryfunction;
}
if (primary_function === 'Yes') {
child_node = setCategory(data.children[i]);
if (node && child_node) {
child_node.parent = node;
node.children.push(child_node);
}
}
else {
node.hasHiddenChildren = true;
}
}
}
return node;
} // end setCategory()
setCategory(categories);
for (var node_name in map) {
if (map[node_name].parent === undefined && node_name !== categories.name) {
map[node_name].parent = map[categories.name];
map[categories.name].children.push(map[node_name]);
}
}
return map[categories.name];
} // end packageHierarchyByGroups
function mouseOvered(d) {
var header1Text = "Name: " + d.name + "</br> Group: " + d.parent.name + "</br>";
$('#header1').html(header1Text);
var localDepends = [];
if (d.depends && d.dependents) {
localDepends = d.depends.filter(function(n) {
return d.dependents.indexOf(n) != -1
});
}
if (d.depends) {
var depends = "Depends: " + ( d.depends.length - localDepends.length);
$('#dependency').html(depends).addClass(palette+"-link--source");
}
if (localDepends.length > 0 ) {
var both = "Both: " + localDepends.length;
$('#bothDeps').html(both).addClass("link--source link--target");;
}
if (d.dependents) {
var dependents = "Dependents: " + (d.dependents.length - localDepends.length);
$('#dependents').html(dependents).addClass(palette+"-link--target");
}
$( document ).uitooltip('option', 'content', $("#toolTip").html())
}
function mouseOuted(d) {
$('#header1').text("");
$('#dependents').text("").removeClass(palette+"-link--target");
$('#dependency').text("").removeClass(palette+"-link--source");
$('#bothDeps').text("").removeClass(palette+"-link--both");
}
function mouseOverArc(d) {
$('#groupName').html("Group: " + d.name);
d3.select("#groupToolTip").style("left", (d3.event.pageX ) + "px")
.style("top", (d3.event.pageY + 5) + "px")
.style("opacity", ".9");
}
function mouseOutArc(d) {
$('#groupName').text("");
$( document ).uitooltip('option', 'content', "")
d3.select("#groupToolTip").style("opacity", "0");
}
var chart = d3.chart.dependencyedgebundling()
.packageHierarchy(packageHierarchyByGroups)
.mouseOvered(mouseOvered)
.mouseOuted(mouseOuted)
.mouseOverArc(mouseOverArc)
.mouseOutArc(mouseOutArc)
.nodeTextHyperLink(getPackageDoxLink);
d3.select("#legend_placeholder").datum(null).call(legendColorChart);
var vivianDataPath = FILES_URL
d3.json(vivianDataPath + "pkgdep.json", function(error, classes) {
jsonData = classes;
if (error){
errormsg = "json error " + error + " data: " + classes;
document.write(errormsg);
return;
}
classes.sort();
d3.select('#chart_placeholder')
.datum(classes)
.call(chart);
createColorLegend(legendColorChart);
});
});
function createColorLegend(legendColorChart) {
var colorLegendDisplay = legendColorChart.svg().selectAll("g.shapeLegend")
.data(colorLegend)
.enter().append("svg:g")
.attr("class", "shapeLegend")
.attr("transform", function(d, i) { return "translate("+(i * 115) +", -10)"; });
colorLegendDisplay.append("path")
.attr("class", function(d) {return d.colorClass;})
.attr("r", 3);
colorLegendDisplay.append("svg:text")
.attr("class", function(d) {return d.colorClass;})
.attr("id", function(d) {return d.name;})
.attr("x", 13)
.attr("dy", ".31em")
.text(function(d) {
return d.name;
});
var colorLegendDisplay = legendColorChart.svg();
colorLegendDisplay.append("text")
.attr("x", 0)
.attr("y", -28 )
.attr("text-anchor", "left")
.style("font-size", "16px")
.text("Color Legend");
}
</script>
</body>
</html>