diff --git a/src/core_plugins/kbn_vislib_vis_types/public/editors/__tests__/point_series.js b/src/core_plugins/kbn_vislib_vis_types/public/editors/__tests__/point_series.js
index 57db9b330962d..a4384ae2a1fea 100644
--- a/src/core_plugins/kbn_vislib_vis_types/public/editors/__tests__/point_series.js
+++ b/src/core_plugins/kbn_vislib_vis_types/public/editors/__tests__/point_series.js
@@ -87,7 +87,7 @@ describe('point series editor', function () {
});
it('should update series when new agg is added', function () {
- const aggConfig = new AggConfig($parentScope.vis, { type: 'avg', schema: 'metric', params: { field: 'bytes' } });
+ const aggConfig = new AggConfig($parentScope.vis.aggs, { type: 'avg', schema: 'metric', params: { field: 'bytes' } });
$parentScope.vis.aggs.push(aggConfig);
$parentScope.$digest();
expect($parentScope.editorState.params.seriesParams.length).to.be(2);
diff --git a/src/core_plugins/kibana/public/discover/controllers/discover.js b/src/core_plugins/kibana/public/discover/controllers/discover.js
index b2b1ef1bbe152..fee5c13ff5304 100644
--- a/src/core_plugins/kibana/public/discover/controllers/discover.js
+++ b/src/core_plugins/kibana/public/discover/controllers/discover.js
@@ -768,7 +768,8 @@ function discoverController(
schema: 'segment',
params: {
field: $scope.opts.timefield,
- interval: $state.interval
+ interval: $state.interval,
+ timeRange: timefilter.getTime(),
}
}
];
diff --git a/src/core_plugins/tile_map/public/coordinate_maps_visualization.js b/src/core_plugins/tile_map/public/coordinate_maps_visualization.js
index 2cb2da826e83e..7018db87c89d2 100644
--- a/src/core_plugins/tile_map/public/coordinate_maps_visualization.js
+++ b/src/core_plugins/tile_map/public/coordinate_maps_visualization.js
@@ -186,7 +186,7 @@ export function CoordinateMapsVisualizationProvider(Notifier, Private) {
return;
}
- const indexPatternName = agg._indexPattern.id;
+ const indexPatternName = agg.getIndexPattern().id;
const field = agg.fieldName();
const filter = { meta: { negate: false, index: indexPatternName } };
filter[filterName] = { ignore_unmapped: true };
diff --git a/src/core_plugins/tile_map/public/coordinatemap_response_handler.js b/src/core_plugins/tile_map/public/coordinatemap_response_handler.js
index f742a651ed6a8..e1bc9b9592107 100644
--- a/src/core_plugins/tile_map/public/coordinatemap_response_handler.js
+++ b/src/core_plugins/tile_map/public/coordinatemap_response_handler.js
@@ -34,7 +34,7 @@ export function makeGeoJsonResponseHandler() {
//double conversion, first to table, then to geojson
//This is to future-proof this code for Canvas-refactoring
- const tabifiedResponse = tabifyAggResponse(vis.getAggConfig(), esResponse);
+ const tabifiedResponse = tabifyAggResponse(vis.getAggConfig(), esResponse, { partialRows: true });
lastGeoJsonResponse = convertToGeoJson(tabifiedResponse);
return lastGeoJsonResponse;
diff --git a/src/ui/public/agg_response/point_series/__tests__/_add_to_siri.js b/src/ui/public/agg_response/point_series/__tests__/_add_to_siri.js
index b7e97639d0525..d7fbb223a2210 100644
--- a/src/ui/public/agg_response/point_series/__tests__/_add_to_siri.js
+++ b/src/ui/public/agg_response/point_series/__tests__/_add_to_siri.js
@@ -18,16 +18,9 @@
*/
import expect from 'expect.js';
-import ngMock from 'ng_mock';
-import { PointSeriesAddToSiriProvider } from '../_add_to_siri';
+import { addToSiri } from '../_add_to_siri';
describe('addToSiri', function () {
- let addToSiri;
-
- beforeEach(ngMock.module('kibana'));
- beforeEach(ngMock.inject(function (Private) {
- addToSiri = Private(PointSeriesAddToSiriProvider);
- }));
it('creates a new series the first time it sees an id', function () {
const series = new Map();
diff --git a/src/ui/public/agg_response/point_series/__tests__/_fake_x_aspect.js b/src/ui/public/agg_response/point_series/__tests__/_fake_x_aspect.js
index ecd374871fe73..3b6ac3b31d9e6 100644
--- a/src/ui/public/agg_response/point_series/__tests__/_fake_x_aspect.js
+++ b/src/ui/public/agg_response/point_series/__tests__/_fake_x_aspect.js
@@ -18,36 +18,20 @@
*/
import expect from 'expect.js';
-import ngMock from 'ng_mock';
-import { VisProvider } from '../../../vis';
-import { AggConfig } from '../../../vis/agg_config';
import { AggType } from '../../../agg_types/agg_type';
-import { PointSeriesFakeXAxisProvider } from '../_fake_x_aspect';
+import { makeFakeXAspect } from '../_fake_x_aspect';
describe('makeFakeXAspect', function () {
- let makeFakeXAspect;
- let Vis;
- let indexPattern;
-
- beforeEach(ngMock.module('kibana'));
- beforeEach(ngMock.inject(function (Private) {
- Vis = Private(VisProvider);
- indexPattern = Private(VisProvider);
- makeFakeXAspect = Private(PointSeriesFakeXAxisProvider);
- }));
-
it('creates an object that looks like an aspect', function () {
- const vis = new Vis(indexPattern, { type: 'histogram' });
- const aspect = makeFakeXAspect(vis);
+ const aspect = makeFakeXAspect();
expect(aspect)
.to.have.property('i', -1)
- .and.have.property('aggConfig')
- .and.have.property('title');
+ .and.have.property('aggConfig');
expect(aspect.aggConfig)
- .to.be.an(AggConfig)
+ .to.have.property('fieldFormatter')
.and.to.have.property('type');
expect(aspect.aggConfig.type)
diff --git a/src/ui/public/agg_response/point_series/__tests__/_get_aspects.js b/src/ui/public/agg_response/point_series/__tests__/_get_aspects.js
index 8dabce275d507..21a61b4d276ad 100644
--- a/src/ui/public/agg_response/point_series/__tests__/_get_aspects.js
+++ b/src/ui/public/agg_response/point_series/__tests__/_get_aspects.js
@@ -22,19 +22,16 @@ import moment from 'moment';
import expect from 'expect.js';
import ngMock from 'ng_mock';
import { VisProvider } from '../../../vis';
-import { AggConfig } from '../../../vis/agg_config';
-import { PointSeriesGetAspectsProvider } from '../_get_aspects';
+import { getAspects } from '../_get_aspects';
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
describe('getAspects', function () {
let Vis;
let indexPattern;
- let getAspects;
beforeEach(ngMock.module('kibana'));
beforeEach(ngMock.inject(function (Private) {
Vis = Private(VisProvider);
- getAspects = Private(PointSeriesGetAspectsProvider);
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
}));
@@ -114,7 +111,7 @@ describe('getAspects', function () {
it('produces an aspect object for each of the aspect types found in the columns', function () {
init(1, 1, 1);
- const aspects = getAspects(vis, table);
+ const aspects = getAspects(table);
validate(aspects.x, 0);
validate(aspects.series, 1);
validate(aspects.y, 2);
@@ -123,7 +120,7 @@ describe('getAspects', function () {
it('uses arrays only when there are more than one aspect of a specific type', function () {
init(0, 1, 2);
- const aspects = getAspects(vis, table);
+ const aspects = getAspects(table);
validate(aspects.x, 0);
expect(aspects.series == null).to.be(true);
@@ -137,14 +134,14 @@ describe('getAspects', function () {
init(0, 2, 1);
expect(function () {
- getAspects(vis, table);
+ getAspects(table);
}).to.throwError(TypeError);
});
it('creates a fake x aspect if the column does not exist', function () {
init(0, 0, 1);
- const aspects = getAspects(vis, table);
+ const aspects = getAspects(table);
expect(aspects.x)
.to.be.an('object')
@@ -152,7 +149,5 @@ describe('getAspects', function () {
.and.have.property('aggConfig')
.and.have.property('title');
- expect(aspects.x.aggConfig).to.be.an(AggConfig);
-
});
});
diff --git a/src/ui/public/agg_response/point_series/__tests__/_get_point.js b/src/ui/public/agg_response/point_series/__tests__/_get_point.js
index 92a1fc871e694..24c0a0ce3768a 100644
--- a/src/ui/public/agg_response/point_series/__tests__/_get_point.js
+++ b/src/ui/public/agg_response/point_series/__tests__/_get_point.js
@@ -19,21 +19,13 @@
import _ from 'lodash';
import expect from 'expect.js';
-import ngMock from 'ng_mock';
-import { PointSeriesGetPointProvider } from '../_get_point';
+import { getPoint } from '../_get_point';
describe('getPoint', function () {
- let getPoint;
-
const truthFormatted = { fieldFormatter: _.constant(_.constant(true)) };
const identFormatted = { fieldFormatter: _.constant(_.identity) };
- beforeEach(ngMock.module('kibana'));
- beforeEach(ngMock.inject(function (Private) {
- getPoint = Private(PointSeriesGetPointProvider);
- }));
-
describe('Without series aspect', function () {
let seriesAspect;
let xAspect;
diff --git a/src/ui/public/agg_response/point_series/__tests__/_get_series.js b/src/ui/public/agg_response/point_series/__tests__/_get_series.js
index 67c1522299253..a63ec0c3c753d 100644
--- a/src/ui/public/agg_response/point_series/__tests__/_get_series.js
+++ b/src/ui/public/agg_response/point_series/__tests__/_get_series.js
@@ -19,19 +19,11 @@
import _ from 'lodash';
import expect from 'expect.js';
-import ngMock from 'ng_mock';
-import { PointSeriesGetSeriesProvider } from '../_get_series';
+import { getSeries } from '../_get_series';
describe('getSeries', function () {
- let getSeries;
-
const agg = { fieldFormatter: _.constant(_.identity) };
- beforeEach(ngMock.module('kibana'));
- beforeEach(ngMock.inject(function (Private) {
- getSeries = Private(PointSeriesGetSeriesProvider);
- }));
-
function wrapRows(row) {
return row.map(function (v) {
return { value: v };
diff --git a/src/ui/public/agg_response/point_series/__tests__/_init_x_axis.js b/src/ui/public/agg_response/point_series/__tests__/_init_x_axis.js
index 0389a393ad15a..43872dba8af54 100644
--- a/src/ui/public/agg_response/point_series/__tests__/_init_x_axis.js
+++ b/src/ui/public/agg_response/point_series/__tests__/_init_x_axis.js
@@ -19,17 +19,12 @@
import _ from 'lodash';
import expect from 'expect.js';
-import ngMock from 'ng_mock';
-import { PointSeriesInitXAxisProvider } from '../_init_x_axis';
+import { initXAxis } from '../_init_x_axis';
describe('initXAxis', function () {
- let initXAxis;
-
- beforeEach(ngMock.module('kibana'));
- beforeEach(ngMock.inject(function (Private) {
- initXAxis = Private(PointSeriesInitXAxisProvider);
- }));
+ const field = {};
+ const indexPattern = {};
const baseChart = {
aspects: {
@@ -37,14 +32,16 @@ describe('initXAxis', function () {
aggConfig: {
fieldFormatter: _.constant({}),
write: _.constant({ params: {} }),
+ aggConfigs: {},
+ getIndexPattern: () => {
+ return indexPattern;
+ },
type: {}
},
title: 'label'
}
}
};
- const field = {};
- const indexPattern = {};
it('sets the xAxisFormatter if the agg is not ordered', function () {
const chart = _.cloneDeep(baseChart);
@@ -60,9 +57,7 @@ describe('initXAxis', function () {
chart.aspects.x.aggConfig.params = {
field: field
};
- chart.aspects.x.aggConfig.vis = {
- indexPattern: indexPattern
- };
+ chart.aspects.x.aggConfig.aggConfigs.indexPattern = indexPattern;
initXAxis(chart);
expect(chart)
@@ -84,9 +79,7 @@ describe('initXAxis', function () {
chart.aspects.x.aggConfig.params = {
field: field
};
- chart.aspects.x.aggConfig.vis = {
- indexPattern: indexPattern
- };
+ chart.aspects.x.aggConfig.aggConfigs.indexPattern = indexPattern;
initXAxis(chart);
expect(chart)
diff --git a/src/ui/public/agg_response/point_series/__tests__/_init_y_axis.js b/src/ui/public/agg_response/point_series/__tests__/_init_y_axis.js
index d8e06f2b355a2..92776918005d2 100644
--- a/src/ui/public/agg_response/point_series/__tests__/_init_y_axis.js
+++ b/src/ui/public/agg_response/point_series/__tests__/_init_y_axis.js
@@ -19,17 +19,10 @@
import _ from 'lodash';
import expect from 'expect.js';
-import ngMock from 'ng_mock';
-import { PointSeriesInitYAxisProvider } from '../_init_y_axis';
+import { initYAxis } from '../_init_y_axis';
describe('initYAxis', function () {
- let initYAxis;
-
- beforeEach(ngMock.module('kibana'));
- beforeEach(ngMock.inject(function (Private) {
- initYAxis = Private(PointSeriesInitYAxisProvider);
- }));
function agg() {
return {
diff --git a/src/ui/public/agg_response/point_series/__tests__/_main.js b/src/ui/public/agg_response/point_series/__tests__/_main.js
index 3652e537d73df..e7b03a11966e0 100644
--- a/src/ui/public/agg_response/point_series/__tests__/_main.js
+++ b/src/ui/public/agg_response/point_series/__tests__/_main.js
@@ -50,7 +50,7 @@ describe('pointSeriesChartDataFromTable', function () {
table.columns = [ { aggConfig: agg } ];
table.rows.push([ result ]);
- const chartData = pointSeriesChartDataFromTable(vis, table);
+ const chartData = pointSeriesChartDataFromTable(table);
expect(chartData).to.be.an('object');
expect(chartData.series).to.be.an('array');
@@ -92,7 +92,7 @@ describe('pointSeriesChartDataFromTable', function () {
table.rows.push([date, new AggConfigResult(y.agg, date, y.at(i))]);
});
- const chartData = pointSeriesChartDataFromTable(vis, table);
+ const chartData = pointSeriesChartDataFromTable(table);
expect(chartData).to.be.an('object');
expect(chartData.series).to.be.an('array');
@@ -155,7 +155,7 @@ describe('pointSeriesChartDataFromTable', function () {
table.rows.push([dateResult, avgResult, maxResult]);
});
- const chartData = pointSeriesChartDataFromTable(vis, table);
+ const chartData = pointSeriesChartDataFromTable(table);
expect(chartData).to.be.an('object');
expect(chartData.series).to.be.an('array');
expect(chartData.series).to.have.length(2);
@@ -235,7 +235,7 @@ describe('pointSeriesChartDataFromTable', function () {
table.rows.push([dateResult, termResult, avgResult, maxResult]);
});
- const chartData = pointSeriesChartDataFromTable(vis, table);
+ const chartData = pointSeriesChartDataFromTable(table);
expect(chartData).to.be.an('object');
expect(chartData.series).to.be.an('array');
// one series for each extension, and then one for each metric inside
diff --git a/src/ui/public/agg_response/point_series/__tests__/_ordered_date_axis.js b/src/ui/public/agg_response/point_series/__tests__/_ordered_date_axis.js
index 611907733e86b..f46c2bd37c9bc 100644
--- a/src/ui/public/agg_response/point_series/__tests__/_ordered_date_axis.js
+++ b/src/ui/public/agg_response/point_series/__tests__/_ordered_date_axis.js
@@ -21,8 +21,7 @@ import moment from 'moment';
import _ from 'lodash';
import sinon from 'sinon';
import expect from 'expect.js';
-import ngMock from 'ng_mock';
-import { PointSeriesOrderedDateAxisProvider } from '../_ordered_date_axis';
+import { orderedDateAxis } from '../_ordered_date_axis';
describe('orderedDateAxis', function () {
@@ -48,17 +47,10 @@ describe('orderedDateAxis', function () {
}
};
- let orderedDateAxis;
-
- beforeEach(ngMock.module('kibana'));
- beforeEach(ngMock.inject(function (Private) {
- orderedDateAxis = Private(PointSeriesOrderedDateAxisProvider);
- }));
-
describe('xAxisFormatter', function () {
it('sets the xAxisFormatter', function () {
const args = _.cloneDeep(baseArgs);
- orderedDateAxis(args.vis, args.chart);
+ orderedDateAxis(args.chart);
expect(args.chart).to.have.property('xAxisFormatter');
expect(args.chart.xAxisFormatter).to.be.a('function');
@@ -66,7 +58,7 @@ describe('orderedDateAxis', function () {
it('formats values using moment, and returns strings', function () {
const args = _.cloneDeep(baseArgs);
- orderedDateAxis(args.vis, args.chart);
+ orderedDateAxis(args.chart);
const val = '2014-08-06T12:34:01';
expect(args.chart.xAxisFormatter(val))
@@ -77,7 +69,7 @@ describe('orderedDateAxis', function () {
describe('ordered object', function () {
it('sets date: true', function () {
const args = _.cloneDeep(baseArgs);
- orderedDateAxis(args.vis, args.chart);
+ orderedDateAxis(args.chart);
expect(args.chart)
.to.have.property('ordered');
@@ -89,13 +81,13 @@ describe('orderedDateAxis', function () {
it('relies on agg.buckets for the interval', function () {
const args = _.cloneDeep(baseArgs);
const spy = sinon.spy(args.chart.aspects.x.aggConfig.buckets, 'getInterval');
- orderedDateAxis(args.vis, args.chart);
+ orderedDateAxis(args.chart);
expect(spy).to.have.property('callCount', 1);
});
it('sets the min/max when the buckets are bounded', function () {
const args = _.cloneDeep(baseArgs);
- orderedDateAxis(args.vis, args.chart);
+ orderedDateAxis(args.chart);
expect(moment.isMoment(args.chart.ordered.min)).to.be(true);
expect(moment.isMoment(args.chart.ordered.max)).to.be(true);
});
@@ -103,7 +95,7 @@ describe('orderedDateAxis', function () {
it('does not set the min/max when the buckets are unbounded', function () {
const args = _.cloneDeep(baseArgs);
args.chart.aspects.x.aggConfig.buckets.getBounds = _.constant();
- orderedDateAxis(args.vis, args.chart);
+ orderedDateAxis(args.chart);
expect(args.chart.ordered).to.not.have.property('min');
expect(args.chart.ordered).to.not.have.property('max');
});
diff --git a/src/ui/public/agg_response/point_series/_add_to_siri.js b/src/ui/public/agg_response/point_series/_add_to_siri.js
index 855c11963014b..34372819c2413 100644
--- a/src/ui/public/agg_response/point_series/_add_to_siri.js
+++ b/src/ui/public/agg_response/point_series/_add_to_siri.js
@@ -17,21 +17,19 @@
* under the License.
*/
-export function PointSeriesAddToSiriProvider() {
- return function addToSiri(series, point, id, label, agg) {
- id = id == null ? '' : id + '';
+export function addToSiri(series, point, id, label, agg) {
+ id = id == null ? '' : id + '';
- if (series.has(id)) {
- series.get(id).values.push(point);
- return;
- }
+ if (series.has(id)) {
+ series.get(id).values.push(point);
+ return;
+ }
- series.set(id, {
- label: label == null ? id : label,
- aggLabel: agg.type ? agg.type.makeLabel(agg) : label,
- aggId: agg.parentId ? agg.parentId : agg.id,
- count: 0,
- values: [point]
- });
- };
+ series.set(id, {
+ label: label == null ? id : label,
+ aggLabel: agg.type ? agg.type.makeLabel(agg) : label,
+ aggId: agg.parentId ? agg.parentId : agg.id,
+ count: 0,
+ values: [point]
+ });
}
diff --git a/src/ui/public/agg_response/point_series/_fake_x_aspect.js b/src/ui/public/agg_response/point_series/_fake_x_aspect.js
index 1fb873dda1f5d..0020778ef434d 100644
--- a/src/ui/public/agg_response/point_series/_fake_x_aspect.js
+++ b/src/ui/public/agg_response/point_series/_fake_x_aspect.js
@@ -17,28 +17,25 @@
* under the License.
*/
-import { AggConfig } from '../../vis/agg_config';
import { AggType } from '../../agg_types/agg_type';
-export function PointSeriesFakeXAxisProvider() {
+const allAgg = new AggType({
+ name: 'all',
+ title: 'All docs',
+ ordered: false,
+ hasNoDsl: true
+});
- const allAgg = new AggType({
- name: 'all',
- title: 'All docs',
- ordered: false,
- hasNoDsl: true
- });
-
- return function makeFakeXAxis(vis) {
- const fake = new AggConfig(vis, {
- type: allAgg,
- schema: vis.type.schemas.all.byName.segment
- });
+export function makeFakeXAspect() {
+ const fake = {
+ makeLabel: () => 'all',
+ fieldFormatter: () => '',
+ type: allAgg
+ };
- return {
- i: -1,
- aggConfig: fake,
- title: fake.makeLabel(),
- };
+ return {
+ i: -1,
+ aggConfig: fake,
+ title: fake.makeLabel(),
};
}
diff --git a/src/ui/public/agg_response/point_series/_get_aspects.js b/src/ui/public/agg_response/point_series/_get_aspects.js
index 4bb3ab3c8f1cb..de5cc4e9f403d 100644
--- a/src/ui/public/agg_response/point_series/_get_aspects.js
+++ b/src/ui/public/agg_response/point_series/_get_aspects.js
@@ -18,61 +18,57 @@
*/
import _ from 'lodash';
-import { PointSeriesFakeXAxisProvider } from './_fake_x_aspect';
+import { makeFakeXAspect } from './_fake_x_aspect';
-export function PointSeriesGetAspectsProvider(Private) {
- const fakeXAspect = Private(PointSeriesFakeXAxisProvider);
+const map = {
+ segment: 'x',
+ metric: 'y',
+ radius: 'z',
+ width: 'width',
+ group: 'series'
+};
- const map = {
- segment: 'x',
- metric: 'y',
- radius: 'z',
- width: 'width',
- group: 'series'
- };
-
- function columnToAspect(aspects, col, i) {
- const schema = col.aggConfig.schema.name;
+function columnToAspect(aspects, col, i) {
+ const schema = col.aggConfig.schema.name;
- const name = map[schema];
- if (!name) throw new TypeError('unknown schema name "' + schema + '"');
+ const name = map[schema];
+ if (!name) throw new TypeError('unknown schema name "' + schema + '"');
- const aspect = {
- i: i,
- title: col.title,
- aggConfig: col.aggConfig
- };
+ const aspect = {
+ i: i,
+ title: col.title,
+ aggConfig: col.aggConfig
+ };
- if (!aspects[name]) aspects[name] = [];
- aspects[name].push(aspect);
- }
+ if (!aspects[name]) aspects[name] = [];
+ aspects[name].push(aspect);
+}
- /**
- * Identify and group the columns based on the aspect of the pointSeries
- * they represent.
- *
- * @param {array} columns - the list of columns
- * @return {object} - an object with a key for each aspect (see map). The values
- * may be undefined, a single aspect, or an array of aspects.
- */
- return function getAspects(vis, table) {
- const aspects = _(table.columns)
- // write each column into the aspects under it's group
- .transform(columnToAspect, {})
- // unwrap groups that only have one value, and validate groups that have more
- .transform(function (aspects, group, name) {
- if ((name !== 'y' && name !== 'series') && group.length > 1) {
- throw new TypeError('Only multiple metrics and series are supported in point series');
- }
+/**
+ * Identify and group the columns based on the aspect of the pointSeries
+ * they represent.
+ *
+ * @param {array} columns - the list of columns
+ * @return {object} - an object with a key for each aspect (see map). The values
+ * may be undefined, a single aspect, or an array of aspects.
+ */
+export function getAspects(table) {
+ const aspects = _(table.columns)
+ // write each column into the aspects under it's group
+ .transform(columnToAspect, {})
+ // unwrap groups that only have one value, and validate groups that have more
+ .transform(function (aspects, group, name) {
+ if ((name !== 'y' && name !== 'series') && group.length > 1) {
+ throw new TypeError('Only multiple metrics and series are supported in point series');
+ }
- aspects[name] = group.length > 1 ? group : group[0];
- })
- .value();
+ aspects[name] = group.length > 1 ? group : group[0];
+ })
+ .value();
- if (!aspects.x) {
- aspects.x = fakeXAspect(vis);
- }
+ if (!aspects.x) {
+ aspects.x = makeFakeXAspect();
+ }
- return aspects;
- };
+ return aspects;
}
diff --git a/src/ui/public/agg_response/point_series/_get_point.js b/src/ui/public/agg_response/point_series/_get_point.js
index 2713483e3e342..cd46cc7e1217d 100644
--- a/src/ui/public/agg_response/point_series/_get_point.js
+++ b/src/ui/public/agg_response/point_series/_get_point.js
@@ -19,45 +19,43 @@
import _ from 'lodash';
-export function PointSeriesGetPointProvider() {
- function unwrap(aggConfigResult, def) {
- return aggConfigResult ? aggConfigResult.value : def;
- }
+function unwrap(aggConfigResult, def) {
+ return aggConfigResult ? aggConfigResult.value : def;
+}
- return function getPoint(x, series, yScale, row, y, z) {
- const zRow = z && row[z.i];
- const xRow = row[x.i];
-
- const point = {
- x: unwrap(xRow, '_all'),
- y: unwrap(row[y.i]),
- z: zRow && unwrap(zRow),
- aggConfigResult: row[y.i],
- extraMetrics: _.compact([zRow]),
- yScale: yScale
- };
-
- if (point.y === 'NaN') {
- // filter out NaN from stats
- // from metrics that are not based at zero
- return;
- }
-
- if (series) {
- const seriesArray = series.length ? series : [ series ];
- point.aggConfig = seriesArray[0].aggConfig;
- point.series = seriesArray.map(s => s.aggConfig.fieldFormatter()(unwrap(row[s.i]))).join(' - ');
- } else if (y) {
- // If the data is not split up with a series aspect, then
- // each point's "series" becomes the y-agg that produced it
- point.aggConfig = y.aggConfig;
- point.series = y.title;
- }
-
- if (yScale) {
- point.y *= yScale;
- }
-
- return point;
+export function getPoint(x, series, yScale, row, y, z) {
+ const zRow = z && row[z.i];
+ const xRow = row[x.i];
+
+ const point = {
+ x: unwrap(xRow, '_all'),
+ y: unwrap(row[y.i]),
+ z: zRow && unwrap(zRow),
+ aggConfigResult: row[y.i],
+ extraMetrics: _.compact([zRow]),
+ yScale: yScale
};
+
+ if (point.y === 'NaN') {
+ // filter out NaN from stats
+ // from metrics that are not based at zero
+ return;
+ }
+
+ if (series) {
+ const seriesArray = series.length ? series : [ series ];
+ point.aggConfig = seriesArray[0].aggConfig;
+ point.series = seriesArray.map(s => s.aggConfig.fieldFormatter()(unwrap(row[s.i]))).join(' - ');
+ } else if (y) {
+ // If the data is not split up with a series aspect, then
+ // each point's "series" becomes the y-agg that produced it
+ point.aggConfig = y.aggConfig;
+ point.series = y.title;
+ }
+
+ if (yScale) {
+ point.y *= yScale;
+ }
+
+ return point;
}
diff --git a/src/ui/public/agg_response/point_series/_get_series.js b/src/ui/public/agg_response/point_series/_get_series.js
index 31a40ede7e3ef..8b516f6a0a421 100644
--- a/src/ui/public/agg_response/point_series/_get_series.js
+++ b/src/ui/public/agg_response/point_series/_get_series.js
@@ -18,66 +18,61 @@
*/
import _ from 'lodash';
-import { PointSeriesGetPointProvider } from './_get_point';
-import { PointSeriesAddToSiriProvider } from './_add_to_siri';
+import { getPoint } from './_get_point';
+import { addToSiri } from './_add_to_siri';
-export function PointSeriesGetSeriesProvider(Private) {
- const getPoint = Private(PointSeriesGetPointProvider);
- const addToSiri = Private(PointSeriesAddToSiriProvider);
+export function getSeries(rows, chart) {
+ const aspects = chart.aspects;
+ const multiY = Array.isArray(aspects.y);
+ const yScale = chart.yScale;
+ const partGetPoint = _.partial(getPoint, aspects.x, aspects.series, yScale);
- return function getSeries(rows, chart) {
- const aspects = chart.aspects;
- const multiY = Array.isArray(aspects.y);
- const yScale = chart.yScale;
- const partGetPoint = _.partial(getPoint, aspects.x, aspects.series, yScale);
+ let series = _(rows)
+ .transform(function (series, row) {
+ if (!multiY) {
+ const point = partGetPoint(row, aspects.y, aspects.z);
+ if (point) addToSiri(series, point, point.series, point.series, aspects.y.aggConfig);
+ return;
+ }
- let series = _(rows)
- .transform(function (series, row) {
- if (!multiY) {
- const point = partGetPoint(row, aspects.y, aspects.z);
- if (point) addToSiri(series, point, point.series, point.series, aspects.y.aggConfig);
- return;
- }
-
- aspects.y.forEach(function (y) {
- const point = partGetPoint(row, y, aspects.z);
- if (!point) return;
+ aspects.y.forEach(function (y) {
+ const point = partGetPoint(row, y, aspects.z);
+ if (!point) return;
- // use the point's y-axis as it's series by default,
- // but augment that with series aspect if it's actually
- // available
- let seriesId = y.aggConfig.id;
- let seriesLabel = y.title;
+ // use the point's y-axis as it's series by default,
+ // but augment that with series aspect if it's actually
+ // available
+ let seriesId = y.aggConfig.id;
+ let seriesLabel = y.title;
- if (aspects.series) {
- const prefix = point.series ? point.series + ': ' : '';
- seriesId = prefix + seriesId;
- seriesLabel = prefix + seriesLabel;
- }
+ if (aspects.series) {
+ const prefix = point.series ? point.series + ': ' : '';
+ seriesId = prefix + seriesId;
+ seriesLabel = prefix + seriesLabel;
+ }
- addToSiri(series, point, seriesId, seriesLabel, y.aggConfig);
- });
+ addToSiri(series, point, seriesId, seriesLabel, y.aggConfig);
+ });
- }, new Map())
- .thru(series => [...series.values()])
- .value();
+ }, new Map())
+ .thru(series => [...series.values()])
+ .value();
- if (multiY) {
- series = _.sortBy(series, function (siri) {
- const firstVal = siri.values[0];
- let y;
+ if (multiY) {
+ series = _.sortBy(series, function (siri) {
+ const firstVal = siri.values[0];
+ let y;
- if (firstVal) {
- const agg = firstVal.aggConfigResult.aggConfig;
- y = _.find(aspects.y, function (y) {
- return y.aggConfig === agg;
- });
- }
+ if (firstVal) {
+ const agg = firstVal.aggConfigResult.aggConfig;
+ y = _.find(aspects.y, function (y) {
+ return y.aggConfig === agg;
+ });
+ }
- return y ? y.i : series.length;
- });
- }
+ return y ? y.i : series.length;
+ });
+ }
- return series;
- };
+ return series;
}
diff --git a/src/ui/public/agg_response/point_series/_init_x_axis.js b/src/ui/public/agg_response/point_series/_init_x_axis.js
index 74be642a41874..2a37bbd151987 100644
--- a/src/ui/public/agg_response/point_series/_init_x_axis.js
+++ b/src/ui/public/agg_response/point_series/_init_x_axis.js
@@ -18,21 +18,19 @@
*/
-export function PointSeriesInitXAxisProvider() {
- return function initXAxis(chart) {
- const x = chart.aspects.x;
- chart.xAxisFormatter = x.aggConfig ? x.aggConfig.fieldFormatter() : String;
- chart.xAxisLabel = x.title;
+export function initXAxis(chart) {
+ const x = chart.aspects.x;
+ chart.xAxisFormatter = x.aggConfig ? x.aggConfig.fieldFormatter() : String;
+ chart.xAxisLabel = x.title;
- if (!x.aggConfig || !x.aggConfig.type.ordered) return;
+ if (!x.aggConfig || !x.aggConfig.type.ordered) return;
- chart.indexPattern = x.aggConfig.vis.indexPattern;
- chart.xAxisField = x.aggConfig.params.field;
+ chart.indexPattern = x.aggConfig.getIndexPattern();
+ chart.xAxisField = x.aggConfig.params.field;
- chart.ordered = {};
- const xAggOutput = x.aggConfig.write();
- if (xAggOutput.params.interval) {
- chart.ordered.interval = xAggOutput.params.interval;
- }
- };
+ chart.ordered = {};
+ const xAggOutput = x.aggConfig.write();
+ if (xAggOutput.params.interval && xAggOutput.params.interval !== '0ms') {
+ chart.ordered.interval = xAggOutput.params.interval;
+ }
}
diff --git a/src/ui/public/agg_response/point_series/_init_y_axis.js b/src/ui/public/agg_response/point_series/_init_y_axis.js
index 1f38a10030955..e9033e74a71f2 100644
--- a/src/ui/public/agg_response/point_series/_init_y_axis.js
+++ b/src/ui/public/agg_response/point_series/_init_y_axis.js
@@ -17,29 +17,26 @@
* under the License.
*/
-export function PointSeriesInitYAxisProvider() {
+export function initYAxis(chart) {
+ const y = chart.aspects.y;
- return function initYAxis(chart) {
- const y = chart.aspects.y;
+ if (Array.isArray(y)) {
+ // TODO: vis option should allow choosing this format
+ chart.yAxisFormatter = y[0].aggConfig.fieldFormatter();
+ chart.yAxisLabel = ''; // use the legend
+ } else {
+ chart.yAxisFormatter = y.aggConfig.fieldFormatter();
+ chart.yAxisLabel = y.title;
+ }
- if (Array.isArray(y)) {
- // TODO: vis option should allow choosing this format
- chart.yAxisFormatter = y[0].aggConfig.fieldFormatter();
- chart.yAxisLabel = ''; // use the legend
+ const z = chart.aspects.series;
+ if (z) {
+ if (Array.isArray(z)) {
+ chart.zAxisFormatter = z[0].aggConfig.fieldFormatter();
+ chart.zAxisLabel = ''; // use the legend
} else {
- chart.yAxisFormatter = y.aggConfig.fieldFormatter();
- chart.yAxisLabel = y.title;
+ chart.zAxisFormatter = z.aggConfig.fieldFormatter();
+ chart.zAxisLabel = z.title;
}
-
- const z = chart.aspects.series;
- if (z) {
- if (Array.isArray(z)) {
- chart.zAxisFormatter = z[0].aggConfig.fieldFormatter();
- chart.zAxisLabel = ''; // use the legend
- } else {
- chart.zAxisFormatter = z.aggConfig.fieldFormatter();
- chart.zAxisLabel = z.title;
- }
- }
- };
+ }
}
diff --git a/src/ui/public/agg_response/point_series/_ordered_date_axis.js b/src/ui/public/agg_response/point_series/_ordered_date_axis.js
index 0b63e82ebd643..933e93aca2db8 100644
--- a/src/ui/public/agg_response/point_series/_ordered_date_axis.js
+++ b/src/ui/public/agg_response/point_series/_ordered_date_axis.js
@@ -19,29 +19,26 @@
import moment from 'moment';
-export function PointSeriesOrderedDateAxisProvider() {
+export function orderedDateAxis(chart) {
+ const xAgg = chart.aspects.x.aggConfig;
+ const buckets = xAgg.buckets;
+ const format = buckets.getScaledDateFormat();
- return function orderedDateAxis(vis, chart) {
- const xAgg = chart.aspects.x.aggConfig;
- const buckets = xAgg.buckets;
- const format = buckets.getScaledDateFormat();
-
- chart.xAxisFormatter = function (val) {
- return moment(val).format(format);
- };
-
- chart.ordered = {
- date: true,
- interval: buckets.getInterval(),
- };
+ chart.xAxisFormatter = function (val) {
+ return moment(val).format(format);
+ };
- const axisOnTimeField = xAgg.fieldIsTimeField();
- const bounds = buckets.getBounds();
- if (bounds && axisOnTimeField) {
- chart.ordered.min = bounds.min;
- chart.ordered.max = bounds.max;
- } else {
- chart.ordered.endzones = false;
- }
+ chart.ordered = {
+ date: true,
+ interval: buckets.getInterval(),
};
+
+ const axisOnTimeField = xAgg.fieldIsTimeField();
+ const bounds = buckets.getBounds();
+ if (bounds && axisOnTimeField) {
+ chart.ordered.min = bounds.min;
+ chart.ordered.max = bounds.max;
+ } else {
+ chart.ordered.endzones = false;
+ }
}
diff --git a/src/ui/public/agg_response/point_series/point_series.js b/src/ui/public/agg_response/point_series/point_series.js
index b6788bbbec00e..10cbd4726034e 100644
--- a/src/ui/public/agg_response/point_series/point_series.js
+++ b/src/ui/public/agg_response/point_series/point_series.js
@@ -17,25 +17,20 @@
* under the License.
*/
-import { PointSeriesGetSeriesProvider } from './_get_series';
-import { PointSeriesGetAspectsProvider } from './_get_aspects';
-import { PointSeriesInitYAxisProvider } from './_init_y_axis';
-import { PointSeriesInitXAxisProvider } from './_init_x_axis';
-import { PointSeriesOrderedDateAxisProvider } from './_ordered_date_axis';
+import { getSeries } from './_get_series';
+import { getAspects } from './_get_aspects';
+import { initYAxis } from './_init_y_axis';
+import { initXAxis } from './_init_x_axis';
+import { orderedDateAxis } from './_ordered_date_axis';
import { PointSeriesTooltipFormatter } from './_tooltip_formatter';
export function AggResponsePointSeriesProvider(Private) {
- const getSeries = Private(PointSeriesGetSeriesProvider);
- const getAspects = Private(PointSeriesGetAspectsProvider);
- const initYAxis = Private(PointSeriesInitYAxisProvider);
- const initXAxis = Private(PointSeriesInitXAxisProvider);
- const setupOrderedDateXAxis = Private(PointSeriesOrderedDateAxisProvider);
const tooltipFormatter = Private(PointSeriesTooltipFormatter);
- return function pointSeriesChartDataFromTable(vis, table) {
+ return function pointSeriesChartDataFromTable(table) {
const chart = {};
- const aspects = chart.aspects = getAspects(vis, table);
+ const aspects = chart.aspects = getAspects(table);
chart.tooltipFormatter = tooltipFormatter;
@@ -44,7 +39,7 @@ export function AggResponsePointSeriesProvider(Private) {
const datedX = aspects.x.aggConfig.type.ordered && aspects.x.aggConfig.type.ordered.date;
if (datedX) {
- setupOrderedDateXAxis(vis, chart);
+ orderedDateAxis(chart);
}
chart.series = getSeries(table.rows, chart);
diff --git a/src/ui/public/agg_types/__tests__/buckets/_geo_hash.js b/src/ui/public/agg_types/__tests__/buckets/_geo_hash.js
index 8b777d919550f..a0736ebd2f526 100644
--- a/src/ui/public/agg_types/__tests__/buckets/_geo_hash.js
+++ b/src/ui/public/agg_types/__tests__/buckets/_geo_hash.js
@@ -30,6 +30,17 @@ describe('Geohash Agg', () => {
top_left: { lat: 1.0, lon: -1.0 },
bottom_right: { lat: -1.0, lon: 1.0 }
};
+
+ const BucketAggTypeMock = (aggOptions) => {
+ return aggOptions;
+ };
+ const AggConfigMock = (parent, aggOptions) => {
+ return aggOptions;
+ };
+ const createAggregationMock = (aggOptions) => {
+ return new AggConfigMock(null, aggOptions);
+ };
+
const aggMock = {
getField: () => {
return {
@@ -41,17 +52,11 @@ describe('Geohash Agg', () => {
useGeocentroid: true,
mapZoom: initialZoom
},
- vis: {
- aggs: []
- },
+ aggConfigs: {},
type: 'geohash_grid',
};
- const BucketAggTypeMock = (aggOptions) => {
- return aggOptions;
- };
- const AggConfigMock = (vis, aggOptions) => {
- return aggOptions;
- };
+ aggMock.aggConfigs.createAggConfig = createAggregationMock;
+
before(function () {
sinon.stub(AggConfigModule, 'AggConfig').callsFake(AggConfigMock);
diff --git a/src/ui/public/agg_types/__tests__/buckets/date_histogram/_editor.js b/src/ui/public/agg_types/__tests__/buckets/date_histogram/_editor.js
index 11326c1e8a736..afacdc522562e 100644
--- a/src/ui/public/agg_types/__tests__/buckets/date_histogram/_editor.js
+++ b/src/ui/public/agg_types/__tests__/buckets/date_histogram/_editor.js
@@ -58,7 +58,10 @@ describe('editor', function () {
]
});
- const $el = $('
- No Compatible Fields: The "{{ agg._indexPattern.title }}" index pattern does not contain any of the following field types: {{ agg.type.params.byName.field.filterFieldTypes | commaList:false }} + No Compatible Fields: The "{{ agg.getIndexPattern().title }}" index pattern does not contain any of the following field types: {{ agg.type.params.byName.field.filterFieldTypes | commaList:false }}