mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
rename dataToHeatArray, add tests
This commit is contained in:
parent
885087f87e
commit
214e1af00c
2 changed files with 53 additions and 4 deletions
|
@ -29,7 +29,7 @@ define(function (require) {
|
|||
|
||||
HeatmapMarker.prototype._createMarkerGroup = function (options) {
|
||||
var max = _.get(this.geoJson, 'properties.allmax');
|
||||
var points = this.dataToHeatArray(max);
|
||||
var points = this._dataToHeatArray(max);
|
||||
|
||||
this._markerGroup = L.heatLayer(points, options);
|
||||
this._fixTooltips();
|
||||
|
@ -159,10 +159,10 @@ define(function (require) {
|
|||
*
|
||||
* @param mapData {geoJson Object}
|
||||
* @param nax {Number}
|
||||
* @method dataToHeatArray
|
||||
* @method _dataToHeatArray
|
||||
* @return {Array}
|
||||
*/
|
||||
HeatmapMarker.prototype.dataToHeatArray = function (max) {
|
||||
HeatmapMarker.prototype._dataToHeatArray = function (max) {
|
||||
var self = this;
|
||||
var mapData = this.geoJson;
|
||||
|
||||
|
|
|
@ -197,7 +197,6 @@ define(function (require) {
|
|||
});
|
||||
|
||||
describe('Scaled Circles', function () {
|
||||
this.timeout(0);
|
||||
var zoom;
|
||||
|
||||
beforeEach(function () {
|
||||
|
@ -250,5 +249,55 @@ define(function (require) {
|
|||
});
|
||||
});
|
||||
|
||||
describe('Heatmaps', function () {
|
||||
beforeEach(function () {
|
||||
module('MarkerFactory');
|
||||
|
||||
inject(function (Private) {
|
||||
var MarkerClass = Private(require('components/vislib/visualizations/marker_types/heatmap'));
|
||||
markerLayer = createMarker(MarkerClass);
|
||||
});
|
||||
});
|
||||
|
||||
describe('dataToHeatArray method', function () {
|
||||
var max;
|
||||
|
||||
beforeEach(function () {
|
||||
max = mapData.properties.allmax;
|
||||
});
|
||||
|
||||
it('should return an array or values for each feature', function () {
|
||||
var arr = markerLayer._dataToHeatArray(max);
|
||||
expect(arr).to.be.an('array');
|
||||
expect(arr).to.have.length(mapData.features.length);
|
||||
|
||||
});
|
||||
|
||||
it('should return an array item with lat, lng, metric for each feature', function () {
|
||||
_.times(3, function () {
|
||||
var arr = markerLayer._dataToHeatArray(max);
|
||||
var index = _.random(mapData.features.length - 1);
|
||||
var feature = mapData.features[index];
|
||||
var featureValue = feature.properties.value;
|
||||
var featureArr = feature.geometry.coordinates.slice(0).reverse().concat(featureValue);
|
||||
expect(arr[index]).to.eql(featureArr);
|
||||
});
|
||||
});
|
||||
|
||||
it('should return an array item with lat, lng, normalized metric for each feature', function () {
|
||||
_.times(3, function () {
|
||||
markerLayer._attr.heatNormalizeData = true;
|
||||
|
||||
var arr = markerLayer._dataToHeatArray(max);
|
||||
var index = _.random(mapData.features.length - 1);
|
||||
var feature = mapData.features[index];
|
||||
var featureValue = parseInt(feature.properties.value / max * 100);
|
||||
var featureArr = feature.geometry.coordinates.slice(0).reverse().concat(featureValue);
|
||||
expect(arr[index]).to.eql(featureArr);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue