[aggResponse/geoJson][vislib/tilemap] simplify tilemap chart object

This commit is contained in:
Spencer Alger 2015-05-18 14:36:43 -07:00
parent 230b9f7b62
commit 05a3c0bafa
12 changed files with 343 additions and 521 deletions

View file

@ -1,61 +0,0 @@
define(function (require) {
var decodeGeoHash = require('utils/decode_geo_hash');
var AggConfigResult = require('components/vis/_agg_config_result');
var _ = require('lodash');
function unwrap(val) {
return (val instanceof AggConfigResult) ? val.value : val;
}
function readRows(table, agg, index, chart) {
var geoJson = chart.geoJson;
var props = geoJson.properties;
var metricLabel = agg.metric.makeLabel();
var metricFormatter = agg.metric.fieldFormatter();
props.length = table.rows.length;
props.min = null;
props.max = null;
props.agg = agg;
props.valueFormatter = metricFormatter;
table.rows.forEach(function (row) {
var geohash = unwrap(row[index.geo]);
var valResult = (row[index.metric] instanceof AggConfigResult) ? row[index.metric] : null;
var val = unwrap(row[index.metric]);
var formatted = metricFormatter(val);
if (props.min === null || val < props.min) props.min = val;
if (props.max === null || val > props.max) props.max = val;
var location = decodeGeoHash(geohash);
var center = [location.longitude[2], location.latitude[2]];
var rectangle = [
[location.longitude[0], location.latitude[0]],
[location.longitude[1], location.latitude[0]],
[location.longitude[1], location.latitude[1]],
[location.longitude[0], location.latitude[1]]
];
geoJson.features.push({
type: 'Feature',
geometry: {
type: 'Point',
coordinates: center
},
properties: {
valueLabel: metricLabel,
valueFormatted: formatted,
count: val,
geohash: geohash,
center: center,
aggConfigResult: valResult,
rectangle: rectangle
}
});
});
}
return readRows;
});

View file

@ -5,4 +5,4 @@
<td>{{detail.value}}</td>
</tr>
</tbody>
</table>
</table>

View file

@ -1,33 +1,41 @@
define(function (require) {
return function TileMapTooltipFormatter($compile, $rootScope) {
return function TileMapTooltipFormatter($compile, $rootScope, Private) {
var $ = require('jquery');
var _ = require('lodash');
var fieldFormats = Private(require('registry/field_formats'));
var $tooltipScope = $rootScope.$new();
var $tooltip = $(require('text!components/agg_response/geo_json/_tooltip.html'));
$compile($tooltip)($tooltipScope);
var $el = $('<div>').html(require('text!components/agg_response/geo_json/_tooltip.html'));
$compile($el)($tooltipScope);
return function tooltipFormatter(feature) {
if (!feature) return '';
var details = $tooltipScope.details = [];
var value = feature.properties.value;
var acr = feature.properties.aggConfigResult;
var vis = acr.aggConfig.vis;
var lat = feature.geometry.coordinates[1];
var lng = feature.geometry.coordinates[0];
var metricAgg = acr.aggConfig;
var geoFormat = _.get(vis.aggs, 'byTypeName.geohash_grid[0].format');
if (!geoFormat) geoFormat = fieldFormats.getDefaultInstance('geo_point');
var metric = {
label: feature.properties.valueLabel,
value: feature.properties.valueFormatted
};
var location = {
label: 'Geohash center',
value: lat.toFixed(3) + ', ' + lng.toFixed(3)
};
details.push(metric, location);
$tooltipScope.details = [
{
label: metricAgg.makeLabel(),
value: metricAgg.fieldFormatter()(value)
},
{
label: 'Geohash center',
value: geoFormat.convert({
lat: feature.geometry.coordinates[1],
lon: feature.geometry.coordinates[0]
})
}
];
$tooltipScope.$apply();
return $tooltip[0].outerHTML;
return $el.html();
};
};
});
});

View file

@ -2,63 +2,41 @@ define(function (require) {
return function TileMapConverterFn(Private, timefilter, $compile, $rootScope) {
var _ = require('lodash');
var readRows = require('components/agg_response/geo_json/_read_rows');
var rowsToFeatures = require('components/agg_response/geo_json/rowsToFeatures');
var tooltipFormatter = Private(require('components/agg_response/geo_json/_tooltip_formatter'));
function findCol(table, name) {
return _.findIndex(table.columns, function (col) {
return col.aggConfig.schema.name === name;
});
}
return function (vis, table) {
function createGeoJson(vis, table) {
var index = {
geo: findCol(table, 'segment'),
metric: findCol(table, 'metric')
};
var col = {
geo: table.columns[index.geo],
metric: table.columns[index.metric],
};
var agg = _.mapValues(col, function (col) {
return col && col.aggConfig;
});
var chart = {};
chart.tooltipFormatter = tooltipFormatter;
var geoJson = chart.geoJson = {
type: 'FeatureCollection',
features: []
};
var props = geoJson.properties = {
label: table.title(),
length: 0,
min: 0,
max: 0
};
if (agg.metric._opts.params && agg.metric._opts.params.field) {
props.metricField = agg.metric._opts.params.field;
function columnIndex(schema) {
return _.findIndex(table.columns, function (col) {
return col.aggConfig.schema.name === schema;
});
}
// set precision from the bucketting column, if we have one
if (agg.geo) {
props.precision = _.parseInt(agg.geo.params.precision);
}
var geoI = columnIndex('segment');
var metricI = columnIndex('metric');
var geoAgg = _.get(table.columns, [geoI, 'aggConfig']);
var metricAgg = _.get(table.columns, [metricI, 'aggConfig']);
// we're all done if there are no columns
if (!col.geo || !col.metric || !table.rows.length) return chart;
var features = rowsToFeatures(table, geoI, metricI);
var values = features.map(function (feature) {
return feature.properties.value;
});
// read the rows into the geoJson features list
readRows(table, agg, index, chart);
return chart;
}
return createGeoJson;
return {
title: table.title(),
valueFormatter: metricAgg && metricAgg.fieldFormatter(),
tooltipFormatter: tooltipFormatter,
geohashGridAgg: geoAgg,
geoJson: {
type: 'FeatureCollection',
features: features,
properties: {
min: _.min(values),
max: _.max(values)
}
}
};
};
};
});

View file

@ -0,0 +1,50 @@
define(function (require) {
var decodeGeoHash = require('utils/decode_geo_hash');
var AggConfigResult = require('components/vis/_agg_config_result');
var _ = require('lodash');
function getAcr(val) {
return val instanceof AggConfigResult ? val : null;
}
function unwrap(val) {
return getAcr(val) ? val.value : val;
}
function convertRowsToFeatures(table, geoI, metricI) {
return table.rows.map(function (row) {
var geohash = unwrap(row[geoI]);
var location = decodeGeoHash(geohash);
var center = [
location.longitude[2],
location.latitude[2]
];
var rectangle = [
[location.longitude[0], location.latitude[0]],
[location.longitude[1], location.latitude[0]],
[location.longitude[1], location.latitude[1]],
[location.longitude[0], location.latitude[1]]
];
return {
type: 'Feature',
geometry: {
type: 'Point',
coordinates: center
},
properties: {
geohash: geohash,
value: unwrap(row[metricI]),
aggConfigResult: getAcr(row[metricI]),
center: center,
rectangle: rectangle
}
};
});
}
return convertRowsToFeatures;
});

View file

@ -63,7 +63,7 @@ define(function (require) {
var worldBounds = L.latLngBounds([-90, -220], [90, 220]);
return function (selection) {
selection.each(function (data) {
selection.each(function (chart) {
if (self._attr.mapZoom) {
mapZoom = self._attr.mapZoom;
@ -72,7 +72,7 @@ define(function (require) {
mapCenter = self._attr.mapCenter;
}
var mapData = data.geoJson;
var mapData = chart.geoJson;
var div = $(this).addClass('tilemap');
var featureLayer;
@ -112,7 +112,7 @@ define(function (require) {
var map = L.map(div[0], mapOptions);
if (data.geoJson.features.length) {
if (mapData.features.length) {
map.addControl(new L.Control.Draw(drawOptions));
}
@ -120,7 +120,7 @@ define(function (require) {
self.saturateTiles();
});
featureLayer = self.markerType(map, mapData).addTo(map);
featureLayer = self.markerType(map, chart).addTo(map);
map.on('unload', function () {
tileLayer.off('tileload', self.saturateTiles);
@ -130,7 +130,7 @@ define(function (require) {
mapZoom = self._attr.mapZoom = map.getZoom();
mapCenter = self._attr.mapCenter = map.getCenter();
featureLayer.clearLayers();
featureLayer = self.markerType(map, mapData).addTo(map);
featureLayer = self.markerType(map, chart).addTo(map);
});
map.on('draw:created', function (e) {
@ -156,9 +156,9 @@ define(function (require) {
});
});
// add label for splits
if (mapData.properties.label) {
self.addLabel(mapData.properties.label, map);
// add title for splits
if (chart.title) {
self.addTitle(chart.title, map);
}
var fitContainer = L.DomUtil.create('div', 'leaflet-control leaflet-bar leaflet-control-zoom leaflet-control-fit');
@ -271,21 +271,22 @@ define(function (require) {
* @param mapData {Object}
* @return {Leaflet object} featureLayer
*/
TileMap.prototype.markerType = function (map, mapData) {
var featureLayer;
if (mapData) {
if (this._attr.mapType === 'Scaled Circle Markers') {
featureLayer = this.scaledCircleMarkers(map, mapData);
} else if (this._attr.mapType === 'Shaded Circle Markers') {
featureLayer = this.shadedCircleMarkers(map, mapData);
} else if (this._attr.mapType === 'Shaded Geohash Grid') {
featureLayer = this.shadedGeohashGrid(map, mapData);
} else {
featureLayer = this.scaledCircleMarkers(map, mapData);
}
TileMap.prototype.markerType = function (map, chart) {
if (!chart) return;
if (this._attr.mapType === 'Scaled Circle Markers') {
return this.scaledCircleMarkers(map, chart);
}
return featureLayer;
if (this._attr.mapType === 'Shaded Circle Markers') {
return this.shadedCircleMarkers(map, chart);
}
if (this._attr.mapType === 'Shaded Geohash Grid') {
return this.shadedGeohashGrid(map, chart);
}
return this.scaledCircleMarkers(map, chart);
};
/**
@ -298,8 +299,9 @@ define(function (require) {
* @param mapData {Object}
* @return {Leaflet object} featureLayer
*/
TileMap.prototype.scaledCircleMarkers = function (map, mapData) {
TileMap.prototype.scaledCircleMarkers = function (map, chart) {
var self = this;
var mapData = chart.geoJson;
// super min and max from all chart data
var min = mapData.properties.allmin;
@ -309,8 +311,8 @@ define(function (require) {
var featureLayer = L.geoJson(mapData, {
pointToLayer: function (feature, latlng) {
var count = feature.properties.count;
var scaledRadius = self.radiusScale(count, max, feature) * 2;
var value = feature.properties.value;
var scaledRadius = self.radiusScale(value, max, feature) * 2;
return L.circle(latlng, scaledRadius);
},
onEachFeature: function (feature, layer) {
@ -322,7 +324,7 @@ define(function (require) {
filter: self._filterToMapBounds(map)
});
self.addLegend(mapData, map);
self.addLegend(chart, map);
return featureLayer;
};
@ -337,16 +339,16 @@ define(function (require) {
* @param mapData {Object}
* @return {Leaflet object} featureLayer
*/
TileMap.prototype.shadedCircleMarkers = function (map, mapData) {
TileMap.prototype.shadedCircleMarkers = function (map, chart) {
var self = this;
var mapData = chart.geoJson;
// super min and max from all chart data
var min = mapData.properties.allmin;
var max = mapData.properties.allmax;
var featureLayer = L.geoJson(mapData, {
pointToLayer: function (feature, latlng) {
var count = feature.properties.count;
var value = feature.properties.value;
var radius = self.geohashMinDistance(feature);
return L.circle(latlng, radius);
},
@ -359,7 +361,7 @@ define(function (require) {
filter: self._filterToMapBounds(map)
});
self.addLegend(mapData, map);
self.addLegend(chart, map);
return featureLayer;
};
@ -374,8 +376,9 @@ define(function (require) {
* @param mapData {Object}
* @return {undefined}
*/
TileMap.prototype.shadedGeohashGrid = function (map, mapData) {
TileMap.prototype.shadedGeohashGrid = function (map, chart) {
var self = this;
var mapData = chart.geoJson;
// super min and max from all chart data
var min = mapData.properties.allmin;
@ -412,7 +415,7 @@ define(function (require) {
filter: self._filterToMapBounds(map)
});
self.addLegend(mapData, map);
self.addLegend(chart, map);
return featureLayer;
};
@ -420,12 +423,12 @@ define(function (require) {
/**
* Adds label div to each map when data is split
*
* @method addLabel
* @method addTitle
* @param mapLabel {String}
* @param map {Object}
* @return {undefined}
*/
TileMap.prototype.addLabel = function (mapLabel, map) {
TileMap.prototype.addTitle = function (mapLabel, map) {
var label = L.control();
label.onAdd = function () {
this._div = L.DomUtil.create('div', 'tilemap-info tilemap-label');
@ -447,16 +450,16 @@ define(function (require) {
* @param map {Leaflet Object}
* @return {undefined}
*/
TileMap.prototype.addLegend = function (mapData, map) {
TileMap.prototype.addLegend = function (chart, map) {
// only draw the legend for maps with multiple items
if (mapData.features.length <= 1) return;
if (chart.geoJson.features.length <= 1) return;
var self = this;
var isLegend = $('div.tilemap-legend', this.chartEl).length;
if (isLegend) return; // Don't add Legend if already one
var valueFormatter = mapData.properties.valueFormatter;
var valueFormatter = chart.valueFormatter;
var legend = L.control({position: 'bottomright'});
legend.onAdd = function () {
@ -492,8 +495,8 @@ define(function (require) {
*/
TileMap.prototype.applyShadingStyle = function (feature, min, max) {
var self = this;
var count = feature.properties.count;
var color = self.quantizeColorScale(count, min, max);
var value = feature.properties.value;
var color = self.quantizeColorScale(value, min, max);
return {
fillColor: color,
@ -579,22 +582,22 @@ define(function (require) {
/**
* radiusScale returns a number for scaled circle markers
* approx. square root of count
* approx. square root of value
* which is multiplied by a factor based on the geohash precision
* for relative sizing of markers
*
* @method radiusScale
* @param count {Number}
* @param value {Number}
* @param max {Number}
* @param precision {Number}
* @return {Number}
*/
TileMap.prototype.radiusScale = function (count, max, feature) {
TileMap.prototype.radiusScale = function (value, max, feature) {
// exp = 0.5 for square root ratio
// exp = 1 for linear ratio
var exp = 0.6;
var maxr = this.geohashMinDistance(feature);
return Math.pow(count, exp) / Math.pow(max, exp) * maxr;
return Math.pow(value, exp) / Math.pow(max, exp) * maxr;
};
/**
@ -602,12 +605,12 @@ define(function (require) {
* used for marker fill color
*
* @method quantizeColorScale
* @param count {Number}
* @param value {Number}
* @param min {Number}
* @param max {Number}
* @return {String} hex color
*/
TileMap.prototype.quantizeColorScale = function (count, min, max) {
TileMap.prototype.quantizeColorScale = function (value, min, max) {
var reds5 = ['#fed976', '#feb24c', '#fd8d3c', '#f03b20', '#bd0026'];
var reds3 = ['#fecc5c', '#fd8d3c', '#e31a1c'];
var reds1 = ['#ff6128'];
@ -626,7 +629,7 @@ define(function (require) {
if (max === min) {
return colors[0];
} else {
return cScale(count);
return cScale(value);
}
};

View file

@ -21,12 +21,12 @@ define(function (require) {
},
listeners: {
rectangle: function (event) {
var agg = _.deepGet(event, 'data.geoJson.properties.agg');
var agg = _.deepGet(event, 'data.geohashGridAgg');
if (!agg) return;
var pushFilter = Private(require('components/filter_bar/push_filter'))(getAppState());
var indexPatternName = agg.geo.vis.indexPattern.id;
var field = agg.geo.fieldName();
var indexPatternName = agg.vis.indexPattern.id;
var field = agg.fieldName();
var filter = {geo_bounding_box: {}};
filter.geo_bounding_box[field] = event.bounds;

View file

@ -54,10 +54,20 @@ define(function (require) {
describe('with table ' + JSON.stringify(tableOpts), function () {
it('outputs a chart', function () {
var chart = makeSingleChart();
expect(chart).to.have.property('tooltipFormatter');
var table = makeTable();
var chart = makeSingleChart(table);
expect(chart).to.only.have.keys(
'title',
'tooltipFormatter',
'valueFormatter',
'geohashGridAgg',
'geoJson'
);
expect(chart.title).to.be(table.title());
expect(chart.tooltipFormatter).to.be.a('function');
expect(chart).to.have.property('geoJson');
expect(chart.valueFormatter).to.be(aggs.metric.fieldFormatter());
expect(chart.geohashGridAgg).to.be(aggs.geo);
expect(chart.geoJson).to.be.an('object');
});
@ -77,37 +87,15 @@ define(function (require) {
// props
expect(props).to.be.an('object');
expect(props).to.only.have.keys('min', 'max');
// props.agg
expect(props).to.have.property('agg');
// props.min
expect(props.min).to.be.a('number');
expect(props.min).to.be.greaterThan(0);
// props.agg.metric
expect(props.agg).to.have.property('metric');
expect(props.agg.metric).to.be(aggs.metric);
// props.agg.geo
expect(props.agg).to.have.property('geo');
expect(props.agg.geo).to.be(aggs.geo);
// props.label
expect(props).to.have.property('label');
expect(props.label).to.be.a('string');
// props.length
expect(props).to.have.property('length');
expect(props.length).to.be(geoJson.features.length);
// props.metricField
expect(props).to.have.property('metricField');
expect(props.metricField).to.be(aggs.metric.fieldName());
// props.precision
expect(props).to.have.property('precision');
expect(props.precision).to.be(aggs.geo.params.precision);
// props.valueFormatter
expect(props).to.have.property('valueFormatter');
expect(props.valueFormatter).to.be(aggs.metric.fieldFormatter());
// props.max
expect(props.max).to.be.a('number');
expect(props.max).to.be.greaterThan(0);
});
describe('properties', function () {
@ -134,28 +122,31 @@ define(function (require) {
var props = feature.properties;
expect(props).to.be.an('object');
expect(props).to.have.keys('center', 'count', 'geohash', 'valueFormatted', 'valueLabel');
expect(props).to.only.have.keys(
'value', 'geohash', 'aggConfigResult',
'rectangle', 'center'
);
expect(props.center).to.eql(geometry.coordinates);
if (props.count != null) expect(props.count).to.be.a('number');
if (props.value != null) expect(props.value).to.be.a('number');
expect(props.geohash).to.be.a('string');
expect(props.valueFormatted).to.be(aggs.metric.fieldFormatter()(props.count));
expect(props.valueLabel).to.be(aggs.metric.makeLabel());
if (tableOpts.asAggConfigResults) {
expect(props.aggConfigResult).to.be(row[metricColI]);
expect(props.count).to.be(row[metricColI].value);
expect(props.value).to.be(row[metricColI].value);
expect(props.geohash).to.be(row[geoColI].value);
} else {
expect(props.aggConfigResult).to.be(null);
expect(props.count).to.be(row[metricColI]);
expect(props.value).to.be(row[metricColI]);
expect(props.geohash).to.be(row[geoColI]);
}
});
});
});
});
});
describe('geoJson tooltip formatter', function () {});
});
});

View file

@ -1,7 +1,10 @@
define(function () {
define(function (require) {
var _ = require('lodash');
return {
'columns': [
{
'title': 'Top 2 geo.dest: CN',
'valueFormatter': _.identity,
'geoJson': {
'type': 'FeatureCollection',
'features': [
@ -15,8 +18,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 42,
'value': 42,
'geohash': 's',
'center': [
22.5,
@ -95,8 +97,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 31,
'value': 31,
'geohash': 'd',
'center': [
-67.5,
@ -175,8 +176,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 30,
'value': 30,
'geohash': 'w',
'center': [
112.5,
@ -255,8 +255,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 25,
'value': 25,
'geohash': '9',
'center': [
-112.5,
@ -335,8 +334,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 22,
'value': 22,
'geohash': 't',
'center': [
67.5,
@ -415,8 +413,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 22,
'value': 22,
'geohash': 'k',
'center': [
22.5,
@ -495,8 +492,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 21,
'value': 21,
'geohash': '6',
'center': [
-67.5,
@ -575,8 +571,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 19,
'value': 19,
'geohash': 'u',
'center': [
22.5,
@ -655,8 +650,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 18,
'value': 18,
'geohash': 'v',
'center': [
67.5,
@ -735,8 +729,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 11,
'value': 11,
'geohash': 'c',
'center': [
-112.5,
@ -815,8 +808,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 10,
'value': 10,
'geohash': 'r',
'center': [
157.5,
@ -895,8 +887,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 9,
'value': 9,
'geohash': 'y',
'center': [
112.5,
@ -975,8 +966,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 9,
'value': 9,
'geohash': 'e',
'center': [
-22.5,
@ -1055,8 +1045,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 8,
'value': 8,
'geohash': 'f',
'center': [
-67.5,
@ -1135,8 +1124,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 8,
'value': 8,
'geohash': '7',
'center': [
-22.5,
@ -1215,8 +1203,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 6,
'value': 6,
'geohash': 'q',
'center': [
112.5,
@ -1295,8 +1282,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 6,
'value': 6,
'geohash': 'g',
'center': [
-22.5,
@ -1375,8 +1361,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 4,
'value': 4,
'geohash': 'x',
'center': [
157.5,
@ -1455,8 +1440,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 3,
'value': 3,
'geohash': 'b',
'center': [
-157.5,
@ -1535,8 +1519,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 2,
'value': 2,
'geohash': 'z',
'center': [
157.5,
@ -1615,8 +1598,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 1,
'value': 1,
'geohash': 'm',
'center': [
67.5,
@ -1695,8 +1677,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 1,
'value': 1,
'geohash': '5',
'center': [
-22.5,
@ -1775,8 +1756,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 1,
'value': 1,
'geohash': '4',
'center': [
-67.5,
@ -1855,8 +1835,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 1,
'value': 1,
'geohash': '3',
'center': [
-112.5,
@ -1927,19 +1906,14 @@ define(function () {
}
],
'properties': {
'label': 'Top 2 geo.dest: CN',
'length': 24,
'min': 1,
'max': 42,
'precision': 1,
'valueFormatter': function (str) {
return str;
}
'max': 42
}
},
'label': 'Top 2 geo.dest: CN'
}
},
{
'label': 'Top 2 geo.dest: IN',
'valueFormatter': _.identity,
'geoJson': {
'type': 'FeatureCollection',
'features': [
@ -1953,8 +1927,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 32,
'value': 32,
'geohash': 's',
'center': [
22.5,
@ -2033,8 +2006,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 31,
'value': 31,
'geohash': '6',
'center': [
-67.5,
@ -2113,8 +2085,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 28,
'value': 28,
'geohash': 'd',
'center': [
-67.5,
@ -2193,8 +2164,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 27,
'value': 27,
'geohash': 'w',
'center': [
112.5,
@ -2273,8 +2243,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 24,
'value': 24,
'geohash': 't',
'center': [
67.5,
@ -2353,8 +2322,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 23,
'value': 23,
'geohash': 'k',
'center': [
22.5,
@ -2433,8 +2401,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 17,
'value': 17,
'geohash': 'u',
'center': [
22.5,
@ -2513,8 +2480,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 16,
'value': 16,
'geohash': '9',
'center': [
-112.5,
@ -2593,8 +2559,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 14,
'value': 14,
'geohash': 'v',
'center': [
67.5,
@ -2673,8 +2638,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 13,
'value': 13,
'geohash': 'e',
'center': [
-22.5,
@ -2753,8 +2717,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 9,
'value': 9,
'geohash': 'r',
'center': [
157.5,
@ -2833,8 +2796,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 6,
'value': 6,
'geohash': 'y',
'center': [
112.5,
@ -2913,8 +2875,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 6,
'value': 6,
'geohash': 'g',
'center': [
-22.5,
@ -2993,8 +2954,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 6,
'value': 6,
'geohash': 'f',
'center': [
-67.5,
@ -3073,8 +3033,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 5,
'value': 5,
'geohash': 'c',
'center': [
-112.5,
@ -3153,8 +3112,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 4,
'value': 4,
'geohash': 'b',
'center': [
-157.5,
@ -3233,8 +3191,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 3,
'value': 3,
'geohash': 'q',
'center': [
112.5,
@ -3313,8 +3270,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 2,
'value': 2,
'geohash': '4',
'center': [
-67.5,
@ -3393,8 +3349,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 1,
'value': 1,
'geohash': 'z',
'center': [
157.5,
@ -3473,8 +3428,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 1,
'value': 1,
'geohash': 'x',
'center': [
157.5,
@ -3553,8 +3507,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 1,
'value': 1,
'geohash': 'p',
'center': [
157.5,
@ -3633,8 +3586,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 1,
'value': 1,
'geohash': 'm',
'center': [
67.5,
@ -3713,8 +3665,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 1,
'value': 1,
'geohash': '7',
'center': [
-22.5,
@ -3785,19 +3736,11 @@ define(function () {
}
],
'properties': {
'label': 'Top 2 geo.dest: IN',
'length': 23,
'min': 1,
'max': 32,
'precision': 1,
'valueFormatter': function (str) {
return str;
}
'max': 32
}
},
'label': 'Top 2 geo.dest: IN'
}
}
],
'hits': 1638
};
]
};
});

View file

@ -1,5 +1,8 @@
define(function () {
define(function (require) {
var _ = require('lodash');
return {
'valueFormatter': _.identity,
'geoJson': {
'type': 'FeatureCollection',
'features': [
@ -13,8 +16,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 608,
'value': 608,
'geohash': 's',
'center': [
22.5,
@ -75,8 +77,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 522,
'value': 522,
'geohash': 'w',
'center': [
112.5,
@ -137,8 +138,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 517,
'value': 517,
'geohash': '6',
'center': [
-67.5,
@ -199,8 +199,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 446,
'value': 446,
'geohash': 'd',
'center': [
-67.5,
@ -261,8 +260,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 426,
'value': 426,
'geohash': 'u',
'center': [
22.5,
@ -323,8 +321,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 413,
'value': 413,
'geohash': 't',
'center': [
67.5,
@ -385,8 +382,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 362,
'value': 362,
'geohash': 'k',
'center': [
22.5,
@ -447,8 +443,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 352,
'value': 352,
'geohash': '9',
'center': [
-112.5,
@ -509,8 +504,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 216,
'value': 216,
'geohash': 'e',
'center': [
-22.5,
@ -571,8 +565,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 183,
'value': 183,
'geohash': 'v',
'center': [
67.5,
@ -633,8 +626,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 158,
'value': 158,
'geohash': 'r',
'center': [
157.5,
@ -695,8 +687,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 139,
'value': 139,
'geohash': 'y',
'center': [
112.5,
@ -757,8 +748,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 110,
'value': 110,
'geohash': 'c',
'center': [
-112.5,
@ -819,8 +809,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 101,
'value': 101,
'geohash': 'q',
'center': [
112.5,
@ -881,8 +870,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 101,
'value': 101,
'geohash': '7',
'center': [
-22.5,
@ -943,8 +931,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 92,
'value': 92,
'geohash': 'f',
'center': [
-67.5,
@ -1005,8 +992,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 75,
'value': 75,
'geohash': 'b',
'center': [
-157.5,
@ -1067,8 +1053,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 64,
'value': 64,
'geohash': 'g',
'center': [
-22.5,
@ -1129,8 +1114,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 36,
'value': 36,
'geohash': 'z',
'center': [
157.5,
@ -1191,8 +1175,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 34,
'value': 34,
'geohash': 'x',
'center': [
157.5,
@ -1253,8 +1236,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 30,
'value': 30,
'geohash': '4',
'center': [
-67.5,
@ -1315,8 +1297,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 16,
'value': 16,
'geohash': 'm',
'center': [
67.5,
@ -1377,8 +1358,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 10,
'value': 10,
'geohash': '5',
'center': [
-22.5,
@ -1439,8 +1419,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 6,
'value': 6,
'geohash': 'p',
'center': [
157.5,
@ -1501,8 +1480,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 6,
'value': 6,
'geohash': '2',
'center': [
-157.5,
@ -1563,8 +1541,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 4,
'value': 4,
'geohash': 'h',
'center': [
22.5,
@ -1625,8 +1602,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 2,
'value': 2,
'geohash': 'n',
'center': [
112.5,
@ -1687,8 +1663,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 2,
'value': 2,
'geohash': 'j',
'center': [
67.5,
@ -1749,8 +1724,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 1,
'value': 1,
'geohash': '3',
'center': [
-112.5,
@ -1811,8 +1785,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 1,
'value': 1,
'geohash': '1',
'center': [
-112.5,
@ -1865,18 +1838,9 @@ define(function () {
}
],
'properties': {
'label': null,
'length': 30,
'min': 1,
'max': 608,
'precision': 1,
'allmin': 1,
'allmax': 608,
'valueFormatter': function (str) {
return str;
}
'max': 608
}
},
'hits': 5033
};
});

View file

@ -1,7 +1,11 @@
define(function () {
define(function (require) {
var _ = require('lodash');
return {
'rows': [
{
'title': 'Top 2 geo.dest: CN',
'valueFormatter': _.identity,
'geoJson': {
'type': 'FeatureCollection',
'features': [
@ -15,8 +19,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 39,
'value': 39,
'geohash': 's',
'center': [
22.5,
@ -95,8 +98,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 31,
'value': 31,
'geohash': 'w',
'center': [
112.5,
@ -175,8 +177,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 30,
'value': 30,
'geohash': 'd',
'center': [
-67.5,
@ -255,8 +256,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 25,
'value': 25,
'geohash': '9',
'center': [
-112.5,
@ -335,8 +335,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 23,
'value': 23,
'geohash': 't',
'center': [
67.5,
@ -415,8 +414,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 23,
'value': 23,
'geohash': 'k',
'center': [
22.5,
@ -495,8 +493,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 22,
'value': 22,
'geohash': '6',
'center': [
-67.5,
@ -575,8 +572,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 20,
'value': 20,
'geohash': 'u',
'center': [
22.5,
@ -655,8 +651,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 18,
'value': 18,
'geohash': 'v',
'center': [
67.5,
@ -735,8 +730,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 11,
'value': 11,
'geohash': 'r',
'center': [
157.5,
@ -815,8 +809,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 11,
'value': 11,
'geohash': 'e',
'center': [
-22.5,
@ -895,8 +888,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 10,
'value': 10,
'geohash': 'y',
'center': [
112.5,
@ -975,8 +967,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 10,
'value': 10,
'geohash': 'c',
'center': [
-112.5,
@ -1055,8 +1046,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 8,
'value': 8,
'geohash': 'f',
'center': [
-67.5,
@ -1135,8 +1125,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 8,
'value': 8,
'geohash': '7',
'center': [
-22.5,
@ -1215,8 +1204,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 6,
'value': 6,
'geohash': 'q',
'center': [
112.5,
@ -1295,8 +1283,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 6,
'value': 6,
'geohash': 'g',
'center': [
-22.5,
@ -1375,8 +1362,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 4,
'value': 4,
'geohash': 'x',
'center': [
157.5,
@ -1455,8 +1441,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 3,
'value': 3,
'geohash': 'b',
'center': [
-157.5,
@ -1535,8 +1520,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 2,
'value': 2,
'geohash': 'z',
'center': [
157.5,
@ -1615,8 +1599,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 2,
'value': 2,
'geohash': '4',
'center': [
-67.5,
@ -1695,8 +1678,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 1,
'value': 1,
'geohash': '5',
'center': [
-22.5,
@ -1775,8 +1757,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 1,
'value': 1,
'geohash': '3',
'center': [
-112.5,
@ -1847,19 +1828,14 @@ define(function () {
}
],
'properties': {
'label': 'Top 2 geo.dest: CN',
'length': 23,
'min': 1,
'max': 39,
'precision': 1,
'valueFormatter': function (str) {
return str;
}
'max': 39
}
},
'label': 'Top 2 geo.dest: CN'
}
},
{
'label': 'Top 2 geo.dest: IN',
'valueFormatter': _.identity,
'geoJson': {
'type': 'FeatureCollection',
'features': [
@ -1873,8 +1849,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 31,
'value': 31,
'geohash': '6',
'center': [
-67.5,
@ -1953,8 +1928,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 30,
'value': 30,
'geohash': 's',
'center': [
22.5,
@ -2033,8 +2007,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 29,
'value': 29,
'geohash': 'w',
'center': [
112.5,
@ -2113,8 +2086,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 28,
'value': 28,
'geohash': 'd',
'center': [
-67.5,
@ -2193,8 +2165,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 25,
'value': 25,
'geohash': 't',
'center': [
67.5,
@ -2273,8 +2244,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 24,
'value': 24,
'geohash': 'k',
'center': [
22.5,
@ -2353,8 +2323,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 20,
'value': 20,
'geohash': 'u',
'center': [
22.5,
@ -2433,8 +2402,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 18,
'value': 18,
'geohash': '9',
'center': [
-112.5,
@ -2513,8 +2481,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 14,
'value': 14,
'geohash': 'v',
'center': [
67.5,
@ -2593,8 +2560,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 11,
'value': 11,
'geohash': 'e',
'center': [
-22.5,
@ -2673,8 +2639,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 9,
'value': 9,
'geohash': 'r',
'center': [
157.5,
@ -2753,8 +2718,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 6,
'value': 6,
'geohash': 'y',
'center': [
112.5,
@ -2833,8 +2797,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 6,
'value': 6,
'geohash': 'f',
'center': [
-67.5,
@ -2913,8 +2876,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 5,
'value': 5,
'geohash': 'g',
'center': [
-22.5,
@ -2993,8 +2955,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 5,
'value': 5,
'geohash': 'c',
'center': [
-112.5,
@ -3073,8 +3034,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 4,
'value': 4,
'geohash': 'b',
'center': [
-157.5,
@ -3153,8 +3113,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 3,
'value': 3,
'geohash': 'q',
'center': [
112.5,
@ -3233,8 +3192,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 2,
'value': 2,
'geohash': '4',
'center': [
-67.5,
@ -3313,8 +3271,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 1,
'value': 1,
'geohash': 'z',
'center': [
157.5,
@ -3393,8 +3350,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 1,
'value': 1,
'geohash': 'x',
'center': [
157.5,
@ -3473,8 +3429,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 1,
'value': 1,
'geohash': 'p',
'center': [
157.5,
@ -3553,8 +3508,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 1,
'value': 1,
'geohash': 'm',
'center': [
67.5,
@ -3633,8 +3587,7 @@ define(function () {
]
},
'properties': {
'valueLabel': 'Count',
'count': 1,
'value': 1,
'geohash': '7',
'center': [
-22.5,
@ -3705,17 +3658,10 @@ define(function () {
}
],
'properties': {
'label': 'Top 2 geo.dest: IN',
'length': 23,
'min': 1,
'max': 31,
'precision': 1,
'valueFormatter': function (str) {
return str;
}
'max': 31
}
},
'label': 'Top 2 geo.dest: IN'
}
}
],
'hits': 1639

View file

@ -205,22 +205,22 @@ define(function (require) {
});
});
it('should return the min of all features.properties.count', function () {
it('should return the min of all features.properties.value', function () {
vis.handler.charts.forEach(function (chart) {
var data = chart.handler.data.data;
var min = _.chain(data.geoJson.features)
.deepPluck('properties.count')
.deepPluck('properties.value')
.min()
.value();
expect(chart.getMinMax(data).min).to.be(min);
});
});
it('should return the max of all features.properties.count', function () {
it('should return the max of all features.properties.value', function () {
vis.handler.charts.forEach(function (chart) {
var data = chart.handler.data.data;
var max = _.chain(data.geoJson.features)
.deepPluck('properties.count')
.deepPluck('properties.value')
.max()
.value();
expect(chart.getMinMax(data).max).to.be(max);
@ -230,4 +230,4 @@ define(function (require) {
});
});
});
});