linkquality colors in geomap

alfred-data
Nils Schneider 2012-09-05 03:34:39 +02:00
parent 4d98854ce3
commit 205d4f4d10
5 changed files with 24 additions and 13 deletions

View File

@ -372,16 +372,6 @@ function reload() {
})
}
var linkcolor = {'default':
d3.scale.linear()
.domain([1, 1.25, 1.5])
.range(["#0a3", "orange", "red"]),
'wifi':
d3.scale.linear()
.domain([1, 3, 10])
.range(["#0a3", "orange", "red"]),
}
var dragging = false
var node_drag = d3.behavior.drag()

View File

@ -20,6 +20,7 @@
<script src="http://maps.burningsilicon.net/OpenLayers-2.8/OpenLayers.js"></script>
<script src="http://maps.burningsilicon.net/OpenLayers-2.8/OpenStreetMap.js"></script>
<script type="text/javascript" src="d3.v2.js"></script>
<script type="text/javascript" src="links.js"></script>
<script type="text/javascript" src="geomap.js"></script>
<script type="text/javascript">

View File

@ -130,6 +130,14 @@ function load_json(layer, map) {
.transform( new OpenLayers.Projection("EPSG:4326"),
map.getProjectionObject()
);
var color;
switch (d.type) {
case "vpn":
color = linkcolor['default'](Math.max.apply(null, d.quality.split(",")))
break;
default:
color = linkcolor['wifi'](Math.max.apply(null, d.quality.split(",")))
}
var feature = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.LineString(
[new OpenLayers.Geometry.Point(a.lon, a.lat),
@ -137,9 +145,9 @@ function load_json(layer, map) {
]),
{name: d.name, description: d.id},
{
strokeColor: '#00ff00',
strokeOpacity: 0.5,
strokeWidth: 5
strokeColor: color,
strokeOpacity: 0.8,
strokeWidth: 3
})
layer.addFeatures([feature])
})

11
html/links.js Normal file
View File

@ -0,0 +1,11 @@
var linkcolor = {'default':
d3.scale.linear()
.domain([1, 1.25, 1.5])
.range(["#0a3", "orange", "red"]),
'wifi':
d3.scale.linear()
.domain([1, 3, 10])
.range(["#0a3", "orange", "red"]),
}

View File

@ -87,6 +87,7 @@
<footer>
<a href="http://tcatm.github.com/ffmap-d3/">ffmap-d3</a> — © Nils Schneider</a>
</footer>
<script src='links.js' type='text/javascript'></script>
<script src='force.js' type='text/javascript'></script>
</body>
</html>