Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Map Panel #53

Merged
merged 37 commits into from
Apr 19, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
bdd11db
Initial code dump of the new map panel
polyfractal Apr 5, 2013
a4f503d
Update Angular-Strap to 0.7.1
polyfractal Apr 5, 2013
a1fea1e
Start of map settings, tab control
polyfractal Apr 5, 2013
b7a5afc
Geopoint settings
polyfractal Apr 5, 2013
54bc5dd
Binning settings, data settings
polyfractal Apr 5, 2013
5be9474
Binning encoding types
polyfractal Apr 5, 2013
12e540b
Fix bug with placeholder text color in chrome
polyfractal Apr 5, 2013
e12f131
Update module editor form
polyfractal Apr 5, 2013
49b383f
Allow binning on secondary field
polyfractal Apr 5, 2013
0f77646
Save zoom level and translation
polyfractal Apr 5, 2013
f18b90a
Add choropleth map
polyfractal Apr 8, 2013
4f3f29b
Refactoring
polyfractal Apr 8, 2013
37161ba
Fix bug with duplicate svgs being appended
polyfractal Apr 8, 2013
9edfb21
Initial base for bullseye feature
polyfractal Apr 9, 2013
604fc06
Initial base for orthographic
polyfractal Apr 9, 2013
c68e68a
Fix bug where key listeners would die if >1 graph present
polyfractal Apr 9, 2013
b26cf20
Remove temp default
polyfractal Apr 9, 2013
d3debd1
Big refactor, moving initialization code to own function, so that mul…
polyfractal Apr 10, 2013
88609fb
Cleaning up misconceptions with d3
polyfractal Apr 10, 2013
1dcf9d6
Cleaning up, commenting
polyfractal Apr 11, 2013
a3c8b09
Merge remote-tracking branch 'upstream/master'
polyfractal Apr 11, 2013
a16b38a
Auto-scale svg with viewport
polyfractal Apr 15, 2013
18276ed
refactor facet counting metric into facet if/else
polyfractal Apr 15, 2013
62de4a4
Remove hard-coded isNumber, use underscore
polyfractal Apr 18, 2013
260cf9e
Fix for mercator->orthographic changes
polyfractal Apr 18, 2013
d5f9da6
Add `keylistener` service
polyfractal Apr 18, 2013
f8c5e46
Merge remote-tracking branch 'upstream/master'
polyfractal Apr 18, 2013
35c59fd
Merge branch 'master' into map2
polyfractal Apr 18, 2013
7dc708d
Update tab spacing
polyfractal Apr 18, 2013
5a5e4ce
Integrate keypress service for sphere dragging
polyfractal Apr 18, 2013
2593805
Move directive-level variables out of scope
polyfractal Apr 18, 2013
9a91a49
Fix clipping issues with geopoints on sphere
polyfractal Apr 18, 2013
e0a0013
Fix clipping issues with bullseye on sphere
polyfractal Apr 18, 2013
d693457
Update editor with better description
polyfractal Apr 19, 2013
8691498
Move dropdown options into scope so that it appears on panel creation
polyfractal Apr 19, 2013
a8ecf25
Remove unused lib files
polyfractal Apr 19, 2013
707e3da
Rolling back angular-strap, no need for a more recent version anymore
polyfractal Apr 19, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion common/css/bootstrap.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var config = new Settings(
{
elasticsearch: 'http://localhost:9200',
kibana_index: "kibana-int",
modules: ['histogram','map','pie','table','stringquery','sort',
modules: ['histogram','map','map2','pie','table','stringquery','sort',
'timepicker','text','fields','hits','dashcontrol',
'column', 'parallelcoordinates'],
}
Expand Down
14 changes: 14 additions & 0 deletions js/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,18 @@ angular.module('kibana.services', [])
timers = new Array();
}

})
.service('keylistener', function($rootScope) {
var keys = [];
$(document).keydown(function (e) {
keys[e.which] = true;
});

$(document).keyup(function (e) {
delete keys[e.which];
});

this.keyActive = function(key) {
return keys[key] == true;
}
});
92 changes: 92 additions & 0 deletions panels/map2/display/binning.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/**
* Hexagonal binning
* Rendered as normally projected svg paths, which mean they *do not*
* clip on spheres appropriately. To fix this, we would need to translate
* the svg path into a geo-path
*/
function displayBinning(scope, dr, dimensions) {

var hexbin = d3.hexbin()
.size(dimensions)
.radius(scope.panel.display.binning.hexagonSize);


var binPoints = [],
binnedPoints = [],
binRange = 0;


if (scope.panel.display.binning.enabled) {
/**
* primary field is just binning raw counts
*
* Secondary field is binning some metric like mean/median/total. Hexbins doesn't support that,
* so we cheat a little and just add more points to compensate.
* However, we don't want to add a million points, so normalize against the largest value
*/
if (scope.panel.display.binning.areaEncodingField === 'secondary') {
var max = Math.max.apply(Math, _.map(scope.data, function(k,v){return k;})),
scale = 50/max;

_.map(scope.data, function (k, v) {
var decoded = geohash.decode(v);
return _.map(_.range(0, k*scale), function(a,b) {
binPoints.push(dr.projection([decoded.longitude, decoded.latitude]));
})
});

} else {
binPoints = dr.projectedPoints;
}

//bin and sort the points, so we can set the various ranges appropriately
binnedPoints = hexbin(binPoints).sort(function(a, b) { return b.length - a.length; });
binRange = binnedPoints[0].length;

//clean up some memory
binPoints = [];
} else {

//not enabled, so just set an empty array. D3.exit will take care of the rest
binnedPoints = [];
binRange = 0;
}



var radius = d3.scale.sqrt()
.domain([0, binRange])
.range([0, scope.panel.display.binning.hexagonSize]);

var color = d3.scale.linear()
.domain([0,binRange])
.range(["white", "steelblue"])
.interpolate(d3.interpolateLab);


var hex = dr.g.selectAll(".hexagon")
.data(binnedPoints);

hex.enter().append("path")
.attr("d", function (d) {
if (scope.panel.display.binning.areaEncoding === false) {
return hexbin.hexagon();
} else {
return hexbin.hexagon(radius(d.length));
}
})
.attr("class", "hexagon")
.attr("transform", function (d) {
return "translate(" + d.x + "," + d.y + ")";
})
.style("fill", function (d) {
if (scope.panel.display.binning.colorEncoding === false) {
return color(binnedPoints[0].length / 2);
} else {
return color(d.length);
}
})
.attr("opacity", scope.panel.display.binning.hexagonAlpha);

hex.exit().remove();
}
28 changes: 28 additions & 0 deletions panels/map2/display/bullseye.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Renders bullseyes as geo-json poly gon entities
* Allows for them to clip on spheres correctly
*/
function displayBullseye(scope, dr) {

var degrees = 180 / Math.PI
var circle = d3.geo.circle();
var data = [];

if (scope.panel.display.bullseye.enabled) {
data = [
circle.origin(parseFloat(scope.panel.display.bullseye.coord.lat), parseFloat(scope.panel.display.bullseye.coord.lon)).angle(1000 / 6371 * degrees)()
];
}

var arcs = dr.g.selectAll(".arc")
.data(data);

arcs.enter().append("path")

.attr("d", dr.path)
.attr("class", "arc");

arcs.exit().remove();


}
44 changes: 44 additions & 0 deletions panels/map2/display/geopoints.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* Renders geopoints as geo-json poly gon entities
* Allows for them to clip on spheres correctly
*/
function displayGeopoints(scope, dr) {

var points = [];
var circle = d3.geo.circle();
var degrees = 180 / Math.PI

if (scope.panel.display.geopoints.enabled) {
//points = dr.points;

points = _.map(dr.points, function(v) {
return {
type: "Point",
coordinates: [v[0], v[1]]
};
});

}


dr.geopoints = dr.g.selectAll("path.geopoint")
.data(points);



dr.geopoints.enter().append("path")
/*
.datum(function(d) {
return circle.origin([d[0], d[1]]).angle(scope.panel.display.geopoints.pointSize / 6371 * degrees)();
})
*/
.attr("class", "geopoint")
.attr("d", dr.path);

dr.geopoints.exit().remove();





}
Loading