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

[WIP] visualizations field formatting refactoring #26951

Closed
wants to merge 49 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
58a93cd
field formatting (metric)
ppisljar Dec 11, 2018
1be1b9c
tagcloud
ppisljar Dec 19, 2018
4757eaf
tilemap
ppisljar Dec 19, 2018
f00feae
regionmap
ppisljar Dec 19, 2018
765ac21
pie
ppisljar Dec 19, 2018
55da8d8
vislib
ppisljar Dec 19, 2018
67a48c7
vislib filtering
ppisljar Dec 20, 2018
ebd99d4
table
ppisljar Dec 20, 2018
64a5082
table
ppisljar Dec 21, 2018
24b1a68
splits
ppisljar Dec 21, 2018
db62110
map fixes
ppisljar Jan 7, 2019
bca01df
vislib fixes
ppisljar Jan 7, 2019
2cd42a5
table fixes
ppisljar Jan 7, 2019
13abcea
fixes
ppisljar Jan 7, 2019
4a42336
fixes
ppisljar Jan 7, 2019
47f809a
fixes
ppisljar Jan 7, 2019
a88028c
support for agg formats
ppisljar Jan 8, 2019
457c2df
fixes
ppisljar Jan 8, 2019
f3bb650
fixes
ppisljar Jan 8, 2019
2d36900
fixing date histogram
ppisljar Jan 8, 2019
66e0919
Update build pipeline helper unit tests and add more typings.
lukeelmers Jan 8, 2019
dc7b38d
fixes
ppisljar Jan 9, 2019
ee9abda
fixes
ppisljar Jan 9, 2019
a5596c5
fixes
ppisljar Jan 9, 2019
35120d9
fixes
ppisljar Jan 9, 2019
917a1c3
fixes
ppisljar Jan 9, 2019
e956ef0
fixes brush event
ppisljar Jan 9, 2019
a16b7b1
fixes
ppisljar Jan 9, 2019
69e2de3
fixes
ppisljar Jan 9, 2019
7ef7e57
fixes
ppisljar Jan 9, 2019
618ac2a
Mock date_histogram in build pipeline tests
lukeelmers Jan 10, 2019
aeea936
fixes
ppisljar Jan 10, 2019
db0fb2c
cleanup
ppisljar Jan 10, 2019
7acd51c
fixes
ppisljar Jan 10, 2019
de15b27
unit tests
ppisljar Jan 10, 2019
661cf7a
unit tests
ppisljar Jan 10, 2019
4e5f483
unit tests
ppisljar Jan 10, 2019
7a7a7eb
unit tests
ppisljar Jan 10, 2019
84eb2a6
fixes
ppisljar Jan 11, 2019
1aeeca8
Extract table converter from BuildHierarchicalDataProvider for easier…
lukeelmers Jan 11, 2019
5efb890
Remove vis to simplify hierarchical data tests.
lukeelmers Jan 11, 2019
0384a59
Port hierarchical data test to jest.
lukeelmers Jan 11, 2019
6d16207
fix table split
ppisljar Jan 14, 2019
cd27702
unit tests
ppisljar Jan 14, 2019
9343c5e
fixing table split
ppisljar Jan 14, 2019
c06c966
jest test wip
ppisljar Jan 14, 2019
3204f48
Fix broken build_hierarchical jest tests.
lukeelmers Jan 14, 2019
292900c
fixing splits
ppisljar Jan 15, 2019
26c66df
fixing regionmap
ppisljar Jan 15, 2019
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
18 changes: 9 additions & 9 deletions src/fixtures/vislib/mock_data/terms/_seriesMultiple.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,44 @@ export default {
'yScale': null,
'series': [{
'label': 'ios',
'aggLabel': 'Count',
'aggId': '1',
'id': '1',
'yAxisFormatter': _.identity,
'values': [{
'x': '_all',
'y': 2820,
'series': 'ios'
}]
}, {
'label': 'win 7',
'aggLabel': 'Count',
'aggId': '1',
'yAxisFormatter': _.identity,
'values': [{
'x': '_all',
'y': 2319,
'series': 'win 7'
}]
}, {
'label': 'win 8',
'aggLabel': 'Count',
'aggId': '1',
'id': '1',
'yAxisFormatter': _.identity,
'values': [{
'x': '_all',
'y': 1835,
'series': 'win 8'
}]
}, {
'label': 'windows xp service pack 2 version 20123452',
'aggLabel': 'Count',
'aggId': '1',
'id': '1',
'yAxisFormatter': _.identity,
'values': [{
'x': '_all',
'y': 734,
'series': 'win xp'
}]
}, {
'label': 'osx',
'aggLabel': 'Count',
'aggId': '1',
'id': '1',
'yAxisFormatter': _.identity,
'values': [{
'x': '_all',
'y': 1352,
Expand Down
19 changes: 0 additions & 19 deletions src/legacy/core_plugins/interpreter/public/functions/metric.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,13 @@ export const metric = () => ({
defaultMessage: 'Metric visualization'
}),
args: {
bucket: {
types: ['string', 'null'],
default: null,
},
metric: {
types: ['string'],
default: '1',
},
visConfig: {
types: ['string', 'null'],
default: '"{}"',
},
},
fn(context, args) {
const visConfigParams = JSON.parse(args.visConfig);
const metrics = args.metric.split(',');
metrics.forEach(metric => {
const metricColumn = context.columns.find((column, i) =>
column.id === metric || column.name === metric || i === parseInt(metric));
metricColumn.aggConfig.schema = 'metric';
});
if (args.bucket) {
const bucketColumn = context.columns.find((column, i) =>
column.id === args.bucket || column.name === args.bucket || i === parseInt(args.bucket));
bucketColumn.aggConfig.schema = 'segment';
}

return {
type: 'render',
Expand Down
22 changes: 1 addition & 21 deletions src/legacy/core_plugins/interpreter/public/functions/pie.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* under the License.
*/

import { VisTypesRegistryProvider } from 'ui/registry/vis_types';
import { VislibSlicesResponseHandlerProvider } from 'ui/vis/response_handlers/vislib';
import chrome from 'ui/chrome';
import { i18n } from '@kbn/i18n';
Expand All @@ -34,10 +33,6 @@ export const kibanaPie = () => ({
defaultMessage: 'Pie visualization'
}),
args: {
schemas: {
types: ['string'],
default: '"{}"',
},
visConfig: {
types: ['string', 'null'],
default: '"{}"',
Expand All @@ -47,24 +42,9 @@ export const kibanaPie = () => ({
const $injector = await chrome.dangerouslyGetActiveInjector();
const Private = $injector.get('Private');
const responseHandler = Private(VislibSlicesResponseHandlerProvider).handler;
const visTypes = Private(VisTypesRegistryProvider);
const visConfigParams = JSON.parse(args.visConfig);
const visType = visTypes.byName.pie;
const schemas = JSON.parse(args.schemas);

if (context.columns) {
context.columns.forEach(column => {
column.aggConfig.aggConfigs.schemas = visType.schemas.all;
});

Object.keys(schemas).forEach(key => {
schemas[key].forEach(i => {
context.columns[i].aggConfig.schema = key;
});
});
}

const convertedData = await responseHandler(context);
const convertedData = await responseHandler(context, visConfigParams.dimensions);

return {
type: 'render',
Expand Down
17 changes: 0 additions & 17 deletions src/legacy/core_plugins/interpreter/public/functions/regionmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,13 @@ export const regionmap = () => ({
defaultMessage: 'Regionmap visualization'
}),
args: {
bucket: {
types: ['string'],
default: '0',
},
metric: {
types: ['string'],
default: '1',
},
visConfig: {
types: ['string', 'null'],
default: '"{}"',
},
},
fn(context, args) {
const visConfigParams = JSON.parse(args.visConfig);
const metricColumn = context.columns.find((column, i) =>
column.id === args.metric || column.name === args.metric || i === parseInt(args.metric)
);
const bucketColumn = context.columns.find((column, i) =>
column.id === args.bucket || column.name === args.bucket || i === parseInt(args.bucket)
);

metricColumn.aggConfig.schema = 'metric';
bucketColumn.aggConfig.schema = 'segment';

return {
type: 'render',
Expand Down
42 changes: 1 addition & 41 deletions src/legacy/core_plugins/interpreter/public/functions/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,55 +35,15 @@ export const kibanaTable = () => ({
defaultMessage: 'Table visualization'
}),
args: {
bucket: {
types: ['string'],
},
splitRow: {
types: ['string'],
},
splitColumn: {
types: ['string'],
},
metric: {
types: ['string'],
default: '1',
},
visConfig: {
types: ['string', 'null'],
default: '"{}"',
},
},
async fn(context, args) {
const visConfigParams = JSON.parse(args.visConfig);
args.metric.split(',').forEach(metric => {
const metricColumn = context.columns.find((column, i) =>
column.id === metric || column.name === metric || i === parseInt(metric));
metricColumn.aggConfig.schema = 'metric';
});
if (args.bucket) {
args.bucket.split(',').forEach(bucket => {
const bucketColumn = context.columns.find((column, i) =>
column.id === bucket || column.name === bucket || i === parseInt(bucket));
bucketColumn.aggConfig.schema = 'bucket';
});
}
if (args.splitColumn) {
args.splitColumn.split(',').forEach(split => {
const splitColumn = context.columns.find((column, i) =>
column.id === split || column.name === split || i === parseInt(split));
splitColumn.aggConfig.schema = 'split';
});
}
if (args.splitRow) {
args.splitRow.split(',').forEach(split => {
const splitColumn = context.columns.find((column, i) =>
column.id === split || column.name === split || i === parseInt(split));
splitColumn.aggConfig.schema = 'split';
splitColumn.aggConfig.params.row = true;
});
}

const convertedData = await responseHandler(context);
const convertedData = await responseHandler(context, visConfigParams.dimensions);

return {
type: 'render',
Expand Down
17 changes: 0 additions & 17 deletions src/legacy/core_plugins/interpreter/public/functions/tagcloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,13 @@ export const tagcloud = () => ({
defaultMessage: 'Tagcloud visualization'
}),
args: {
bucket: {
types: ['string'],
default: '0',
},
metric: {
types: ['string'],
default: '1',
},
visConfig: {
types: ['string', 'null'],
default: '"{}"',
},
},
fn(context, args) {
const visConfigParams = JSON.parse(args.visConfig);
const metricColumn = context.columns.find((column, i) =>
column.id === args.metric || column.name === args.metric || i === parseInt(args.metric)
);
const bucketColumn = context.columns.find((column, i) =>
column.id === args.bucket || column.name === args.bucket || i === parseInt(args.bucket)
);

metricColumn.aggConfig.schema = 'metric';
bucketColumn.aggConfig.schema = 'segment';

return {
type: 'render',
Expand Down
27 changes: 6 additions & 21 deletions src/legacy/core_plugins/interpreter/public/functions/tilemap.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
* under the License.
*/

import { makeGeoJsonResponseHandler } from 'plugins/tile_map/coordinatemap_response_handler';
import { convertToGeoJson } from 'ui/vis/map/convert_to_geojson';
import { i18n } from '@kbn/i18n';

const responseHandler = makeGeoJsonResponseHandler();

export const tilemap = () => ({
name: 'tilemap',
type: 'render',
Expand All @@ -34,32 +32,19 @@ export const tilemap = () => ({
defaultMessage: 'Tilemap visualization'
}),
args: {
bucket: {
types: ['string'],
default: '0',
},
metric: {
types: ['string'],
default: '1',
},
visConfig: {
types: ['string', 'null'],
default: '"{}"',
},
},
fn(context, args) {
const visConfigParams = JSON.parse(args.visConfig);
const metricColumn = context.columns.find((column, i) =>
column.id === args.metric || column.name === args.metric || i === parseInt(args.metric)
);
const bucketColumn = context.columns.find((column, i) =>
column.id === args.bucket || column.name === args.bucket || i === parseInt(args.bucket)
);

metricColumn.aggConfig.schema = 'metric';
bucketColumn.aggConfig.schema = 'segment';

const convertedData = responseHandler(context);
const convertedData = convertToGeoJson(context, {
geohash: visConfigParams.geohash,
metric: visConfigParams.metric,
geocentroid: visConfigParams.geocentroid,
});

return {
type: 'render',
Expand Down
31 changes: 1 addition & 30 deletions src/legacy/core_plugins/interpreter/public/functions/vislib.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/

import { i18n } from '@kbn/i18n';
import { VisTypesRegistryProvider } from 'ui/registry/vis_types';
import { VislibSeriesResponseHandlerProvider } from 'ui/vis/response_handlers/vislib';
import chrome from 'ui/chrome';

Expand All @@ -34,14 +33,6 @@ export const vislib = () => ({
defaultMessage: 'Vislib visualization'
}),
args: {
type: {
types: ['string'],
default: 'metric',
},
schemas: {
types: ['string'],
default: '"{}"',
},
visConfig: {
types: ['string', 'null'],
default: '"{}"',
Expand All @@ -51,29 +42,9 @@ export const vislib = () => ({
const $injector = await chrome.dangerouslyGetActiveInjector();
const Private = $injector.get('Private');
const responseHandler = Private(VislibSeriesResponseHandlerProvider).handler;
const visTypes = Private(VisTypesRegistryProvider);
const visConfigParams = JSON.parse(args.visConfig);
const schemas = JSON.parse(args.schemas);
const visType = visTypes.byName[args.type || 'histogram'];

if (context.columns) {
// assign schemas to aggConfigs
context.columns.forEach(column => {
column.aggConfig.aggConfigs.schemas = visType.schemas.all;
});

Object.keys(schemas).forEach(key => {
schemas[key].forEach(i => {
const schema = key.split('_');
context.columns[i].aggConfig.schema = schema[0];
if (schema[1] === 'row') {
context.columns[i].aggConfig.params.row = true;
}
});
});
}

const convertedData = await responseHandler(context);
const convertedData = await responseHandler(context, visConfigParams.dimensions);

return {
type: 'render',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import { tabifyAggResponse } from 'ui/agg_response/tabify';
import { showSaveModal } from 'ui/saved_objects/show_saved_object_save_modal';
import { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_save_modal';
import { getRootBreadcrumbs, getSavedSearchBreadcrumbs } from '../breadcrumbs';
import { buildVislibDimensions } from 'ui/visualize/loader/pipeline_helpers/build_pipeline';

const app = uiModules.get('apps/discover', [
'kibana/notify',
Expand Down Expand Up @@ -760,7 +761,7 @@ function discoverController(
const tabifiedData = tabifyAggResponse($scope.vis.aggs, merged);
$scope.searchSource.rawResponse = merged;
Promise
.resolve(responseHandler(tabifiedData))
.resolve(responseHandler(tabifiedData, buildVislibDimensions($scope.vis, $scope.timeRange)))
.then(resp => {
visualizeHandler.render({ value: resp });
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ describe('metric vis', () => {
aggs: [{ id: '1', type: 'top_hits', schema: 'metric', params: { field: 'ip' } }],
});

vis.params.metric.metrics = [{ accessor: 0, format: { id: 'url', params: {
urlTemplate: 'http://ip.info?address={{value}}',
labelTemplate: 'ip[{{value}}]'
} } }];

const el = document.createElement('div');
const Controller = metricVisType.visualization;
const controller = new Controller(el, vis);
Expand All @@ -62,7 +67,7 @@ describe('metric vis', () => {

const ip = '235.195.237.208';
render({
columns: [{ id: 'col-0', title: 'ip', aggConfig: vis.aggs[0] }],
columns: [{ id: 'col-0', name: 'ip' }],
rows: [{ 'col-0': ip }]
});

Expand Down
Loading