Skip to content

Commit 22d4b2b

Browse files
committed
Merge branch 'master' of github.com:discreteoptimization/visualization
2 parents 2cbe045 + 5717b4f commit 22d4b2b

9 files changed

Lines changed: 607 additions & 2 deletions

File tree

common.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,21 @@ function errorMessage(itemList, error, itemName, pluralItemName) {
7676
return pluralItemName + " " + itemList.slice(0,4).join(", ")
7777
+ " and others " + error + ".";
7878
}
79-
}
79+
}
80+
81+
function constraintProportions(o, width, height) {
82+
var spanX = o['x_max'] - o['x_min']
83+
var spanY = o['y_max'] - o['y_min']
84+
if (height != 0 && spanY != 0) {
85+
var ratio = width / height
86+
if (spanX / spanY > ratio) {
87+
var yMiddle = (o['y_min'] + o['y_max']) / 2
88+
o['y_min'] = yMiddle - spanX / ratio / 2
89+
o['y_max'] = yMiddle + spanX / ratio / 2
90+
} else {
91+
var xMiddle = (o['x_min'] + o['x_max']) / 2
92+
o['x_min'] = xMiddle - spanY * ratio / 2
93+
o['x_max'] = xMiddle + spanY * ratio / 2
94+
}
95+
}
96+
}

facility/facility.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ function vizBenchmark() {
176176
reportError(ex);
177177
}
178178

179+
constraintProportions(metadata, metadata.graphWidth, metadata.graphHeight)
180+
179181
//var height = Math.round(width * (metadata['y_span'] / metadata['x_span']));
180182
metadata.circle_size = Math.min(Math.max(1, metadata.graphWidth / metadata['customerCount']), 5);;
181183

@@ -302,7 +304,7 @@ function vizBenchmark() {
302304
.style("top", (d3.event.pageY - 25) + "px");
303305
div.html("C" + d.index + ": Demand " + d.demand + " (X:"
304306
+ roundNumber(d.x,2) + ", Y:" + roundNumber(d.y,2) + ") Facility: "
305-
+ (d.facility === null ? "None": d.facility.index));
307+
+ (d.facility === null ? "None": d.facility.index + " [distance: " + roundNumber(dist(d.facility,d),2) + "]"));
306308
})
307309
.on("mouseout", function (d) {
308310
div.transition()

setcover/images/circle.png

1.01 KB
Loading

setcover/images/square.png

931 Bytes
Loading

setcover/setcover.css

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
The MIT License (MIT)
3+
4+
Copyright (c) 2014 Jerry Gamble
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.
23+
*/
24+
25+
div.tooltip {
26+
min-width: 100px;
27+
}
28+
.graph line.highlighted {
29+
stroke-width: 4;
30+
}
31+
32+
33+
circle.highlighted, rect.highlighted{
34+
stroke-width: 3;
35+
stroke: #4488ff;
36+
}
37+
38+
circle.covered {
39+
fill: #00aa00;
40+
}
41+
42+
#viewSelector {
43+
margin-top: 10px;
44+
}

setcover/setcover.html

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta http-equiv="content-type" content="text/html; charset=UTF8">
5+
<title>Setcover Problem</title>
6+
7+
<link rel="stylesheet" type="text/css" href="../viz.css" media="screen" />
8+
<link href="setcover.css" rel="stylesheet" />
9+
10+
<script type="text/javascript" src="http://d3js.org/d3.v3.js"></script>
11+
<script type="text/javascript" src="../constants.js"></script>
12+
<script type="text/javascript" src="../common.js"></script>
13+
<script type="text/javascript" src="setcover.js"></script>
14+
15+
</head>
16+
<body>
17+
18+
<div id="controls">
19+
<div id="benchmark_zone" class="drop_zone">Step 1 - Drop benchmark file here</div>
20+
<div id="solution_zone" class="drop_zone">Step 2 - Drop solution file here</div>
21+
<div style="clear:both;"><p id="feedback"></p></div>
22+
</div>
23+
<div id="data">
24+
<table id="problemTable" class="metadataTable">
25+
<tbody>
26+
</tbody>
27+
</table>
28+
<table id="solutionTable" class="metadataTable">
29+
<tbody>
30+
</tbody>
31+
</table>
32+
<div id="viewSelector">
33+
View:
34+
<select name="vizType" id="vizType" onchange="selectViz(this.value)">
35+
<option value="matrix">Matrix</option>
36+
<option value="bipartiteGraph">Graph</option>
37+
</select>
38+
</div>
39+
</div>
40+
<div id="viz"><svg id="svgMain"></svg></div>
41+
<pre id="debug"></pre>
42+
43+
<script type="text/javascript" src="../viz.js"></script>
44+
45+
</body>
46+
</html>

0 commit comments

Comments
 (0)