From 5be94741a1e1c960b0e66d544977aad02b140cb0 Mon Sep 17 00:00:00 2001 From: Zachary Tong Date: Fri, 5 Apr 2013 13:24:18 -0400 Subject: [PATCH] Binning encoding types --- panels/map2/editor.html | 10 ++++++++++ panels/map2/module.js | 37 +++++++++++++++++++++++++++---------- 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/panels/map2/editor.html b/panels/map2/editor.html index 7a640e5118b..34de0f2b3df 100644 --- a/panels/map2/editor.html +++ b/panels/map2/editor.html @@ -138,6 +138,16 @@ value="{{panel.display.binning.hexagonAlpha}}" /> + + Encoding + +
+ + + +
+ + diff --git a/panels/map2/module.js b/panels/map2/module.js index d35867ae47f..6754184a4a6 100644 --- a/panels/map2/module.js +++ b/panels/map2/module.js @@ -24,8 +24,8 @@ angular.module('kibana.map2', []) binning: { enabled: true, hexagonSize: 10, - hexagonAlpha: 1.0 - + hexagonAlpha: 1.0, + encoding: "color" } }, displayTabs: ["Geopoints", "Binning", "Data"], @@ -235,27 +235,44 @@ angular.module('kibana.map2', []) //hexagonal binning if (scope.panel.display.binning.enabled) { - var color = d3.scale.linear() - .domain([0, 20]) - .range(["white", "steelblue"]) - .interpolate(d3.interpolateLab); - var hexbin = d3.hexbin() .size([width, height]) .radius(scope.panel.display.binning.hexagonSize); + var binnedPoints = hexbin(points).sort(function(a, b) { return b.length - a.length; }); + console.log(binnedPoints); + + + var radius = d3.scale.sqrt() + .domain([0, binnedPoints[0].length]) + .range([0, scope.panel.display.binning.hexagonSize]); + + + var color = d3.scale.linear() + .domain([0,binnedPoints[0].length]) + .range(["white", "steelblue"]) + .interpolate(d3.interpolateLab); + g.selectAll(".hexagon") - .data(hexbin(points)) + .data(binnedPoints) .enter().append("path") .attr("d", function (d) { - return hexbin.hexagon(); + if (scope.panel.display.binning.encoding === 'color') { + 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) { - return color(d.length); + if (scope.panel.display.binning.encoding === 'area') { + return color(10); + } else { + return color(d.length); + } }) .attr("opacity", scope.panel.display.binning.hexagonAlpha); }