Skip to content

Commit 7584ffc

Browse files
authored
simplified tabify (#19061) (#22540)
1 parent 1e3ca94 commit 7584ffc

66 files changed

Lines changed: 684 additions & 1377 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/core_plugins/kbn_vislib_vis_types/public/gauge.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ export default function GaugeVisType(Private) {
110110
aggFilter: ['!geohash_grid', '!filter']
111111
}
112112
])
113-
}
113+
},
114+
useCustomNoDataScreen: true
114115
});
115116
}

src/core_plugins/kbn_vislib_vis_types/public/goal.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ export default function GoalVisType(Private) {
105105
aggFilter: ['!geohash_grid', '!filter']
106106
}
107107
])
108-
}
108+
},
109+
useCustomNoDataScreen: true
109110
});
110111
}

src/core_plugins/kibana/public/discover/controllers/discover.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import 'ui/query_bar';
3535
import { hasSearchStategyForIndexPattern, isDefaultTypeIndexPattern } from 'ui/courier';
3636
import { toastNotifications } from 'ui/notify';
3737
import { VisProvider } from 'ui/vis';
38-
import { BasicResponseHandlerProvider } from 'ui/vis/response_handlers/basic';
38+
import { VislibResponseHandlerProvider } from 'ui/vis/response_handlers/vislib';
3939
import { DocTitleProvider } from 'ui/doc_title';
4040
import PluginsKibanaDiscoverHitSortFnProvider from '../_hit_sort_fn';
4141
import { FilterBarQueryFilterProvider } from 'ui/filter_bar/query_filter';
@@ -156,7 +156,7 @@ function discoverController(
156156
const docTitle = Private(DocTitleProvider);
157157
const HitSortFn = Private(PluginsKibanaDiscoverHitSortFnProvider);
158158
const queryFilter = Private(FilterBarQueryFilterProvider);
159-
const responseHandler = Private(BasicResponseHandlerProvider).handler;
159+
const responseHandler = Private(VislibResponseHandlerProvider).handler;
160160
const filterManager = Private(FilterManagerProvider);
161161
const notify = new Notifier({
162162
location: 'Discover'

src/core_plugins/metric_vis/public/__tests__/metric_vis.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { VisProvider } from 'ui/vis';
2525
import LogstashIndexPatternStubProvider from 'fixtures/stubbed_logstash_index_pattern';
2626
import MetricVisProvider from '../metric_vis';
2727

28-
describe('metric_vis', () => {
28+
describe('metric vis', () => {
2929
let setup = null;
3030
let vis;
3131

@@ -62,10 +62,8 @@ describe('metric_vis', () => {
6262

6363
const ip = '235.195.237.208';
6464
render({
65-
tables: [{
66-
columns: [{ title: 'ip', aggConfig: vis.aggs[0] }],
67-
rows: [[ ip ]]
68-
}]
65+
columns: [{ id: 'col-0', title: 'ip', aggConfig: vis.aggs[0] }],
66+
rows: [{ 'col-0': ip }]
6967
});
7068

7169
const $link = $(el)

src/core_plugins/metric_vis/public/__tests__/metric_vis_controller.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import expect from 'expect.js';
2121
import { MetricVisComponent } from '../metric_vis_controller';
2222

23-
describe('metric vis', function () {
23+
describe('metric vis controller', function () {
2424

2525
const vis = {
2626
params: {
@@ -53,10 +53,8 @@ describe('metric vis', function () {
5353

5454
it('should set the metric label and value', function () {
5555
const metrics = metricController._processTableGroups({
56-
tables: [{
57-
columns: [{ title: 'Count', aggConfig: { ...aggConfig, makeLabel: () => 'Count' } }],
58-
rows: [[ 4301021 ]]
59-
}]
56+
columns: [{ id: 'col-0', title: 'Count', aggConfig: { ...aggConfig, makeLabel: () => 'Count' } }],
57+
rows: [{ 'col-0': 4301021 }]
6058
});
6159

6260
expect(metrics.length).to.be(1);
@@ -66,13 +64,11 @@ describe('metric vis', function () {
6664

6765
it('should support multi-value metrics', function () {
6866
const metrics = metricController._processTableGroups({
69-
tables: [{
70-
columns: [
71-
{ aggConfig: { ...aggConfig, makeLabel: () => '1st percentile of bytes' } },
72-
{ aggConfig: { ...aggConfig, makeLabel: () => '99th percentile of bytes' } }
73-
],
74-
rows: [[ 182, 445842.4634666484 ]]
75-
}]
67+
columns: [
68+
{ id: 'col-0', aggConfig: { ...aggConfig, makeLabel: () => '1st percentile of bytes' } },
69+
{ id: 'col-1', aggConfig: { ...aggConfig, makeLabel: () => '99th percentile of bytes' } }
70+
],
71+
rows: [{ 'col-0': 182, 'col-1': 445842.4634666484 }]
7672
});
7773

7874
expect(metrics.length).to.be(2);

src/core_plugins/metric_vis/public/metric_vis.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ function MetricVisProvider(Private) {
100100
}
101101
])
102102
},
103+
responseHandler: 'tabify',
103104
});
104105
}
105106

src/core_plugins/metric_vis/public/metric_vis_controller.js

Lines changed: 43 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export class MetricVisComponent extends Component {
8989
return fieldFormatter(value);
9090
}
9191

92-
_processTableGroups(tableGroups) {
92+
_processTableGroups(table) {
9393
const config = this.props.vis.params.metric;
9494
const isPercentageMode = config.percentageMode;
9595
const min = config.colorsRange[0].from;
@@ -98,56 +98,55 @@ export class MetricVisComponent extends Component {
9898
const labels = this._getLabels();
9999
const metrics = [];
100100

101-
tableGroups.tables.forEach((table, tableIndex) => {
102-
let bucketAgg;
103-
let rowHeaderIndex;
101+
let bucketAgg;
102+
let bucketColumnId;
103+
let rowHeaderIndex;
104104

105-
table.columns.forEach((column, columnIndex) => {
106-
const aggConfig = column.aggConfig;
105+
table.columns.forEach((column, columnIndex) => {
106+
const aggConfig = column.aggConfig;
107107

108-
if (aggConfig && aggConfig.type.type === 'buckets') {
109-
bucketAgg = aggConfig;
110-
// Store the current index, so we later know in which position in the
111-
// row array, the bucket agg key will be, so we can create filters on it.
112-
rowHeaderIndex = columnIndex;
113-
return;
114-
}
108+
if (aggConfig && aggConfig.type.type === 'buckets') {
109+
bucketAgg = aggConfig;
110+
// Store the current index, so we later know in which position in the
111+
// row array, the bucket agg key will be, so we can create filters on it.
112+
rowHeaderIndex = columnIndex;
113+
bucketColumnId = column.id;
114+
return;
115+
}
115116

116-
table.rows.forEach((row, rowIndex) => {
117+
table.rows.forEach((row, rowIndex) => {
117118

118-
let title = column.title;
119-
let value = row[columnIndex];
120-
const color = this._getColor(value, labels, colors);
119+
let title = column.name;
120+
let value = row[column.id];
121+
const color = this._getColor(value, labels, colors);
121122

122-
if (isPercentageMode) {
123-
const percentage = Math.round(100 * (value - min) / (max - min));
124-
value = `${percentage}%`;
125-
}
123+
if (isPercentageMode) {
124+
const percentage = Math.round(100 * (value - min) / (max - min));
125+
value = `${percentage}%`;
126+
}
126127

127-
if (aggConfig) {
128-
if (!isPercentageMode) value = this._getFormattedValue(aggConfig.fieldFormatter('html'), value);
129-
if (bucketAgg) {
130-
const bucketValue = bucketAgg.fieldFormatter('text')(row[0]);
131-
title = `${bucketValue} - ${aggConfig.makeLabel()}`;
132-
} else {
133-
title = aggConfig.makeLabel();
134-
}
128+
if (aggConfig) {
129+
if (!isPercentageMode) value = this._getFormattedValue(aggConfig.fieldFormatter('html'), value);
130+
if (bucketAgg) {
131+
const bucketValue = bucketAgg.fieldFormatter('text')(row[bucketColumnId]);
132+
title = `${bucketValue} - ${aggConfig.makeLabel()}`;
133+
} else {
134+
title = aggConfig.makeLabel();
135135
}
136+
}
136137

137-
const shouldColor = config.colorsRange.length > 1;
138-
139-
metrics.push({
140-
label: title,
141-
value: value,
142-
color: shouldColor && config.style.labelColor ? color : null,
143-
bgColor: shouldColor && config.style.bgColor ? color : null,
144-
lightText: shouldColor && config.style.bgColor && this._needsLightText(color),
145-
filterKey: rowHeaderIndex !== undefined ? row[rowHeaderIndex] : null,
146-
tableIndex: tableIndex,
147-
rowIndex: rowIndex,
148-
columnIndex: rowHeaderIndex,
149-
bucketAgg: bucketAgg,
150-
});
138+
const shouldColor = config.colorsRange.length > 1;
139+
140+
metrics.push({
141+
label: title,
142+
value: value,
143+
color: shouldColor && config.style.labelColor ? color : null,
144+
bgColor: shouldColor && config.style.bgColor ? color : null,
145+
lightText: shouldColor && config.style.bgColor && this._needsLightText(color),
146+
filterKey: bucketColumnId !== undefined ? row[bucketColumnId] : null,
147+
rowIndex: rowIndex,
148+
columnIndex: rowHeaderIndex,
149+
bucketAgg: bucketAgg,
151150
});
152151
});
153152
});
@@ -159,7 +158,7 @@ export class MetricVisComponent extends Component {
159158
if (!metric.filterKey || !metric.bucketAgg) {
160159
return;
161160
}
162-
const table = this.props.visData.tables[metric.tableIndex];
161+
const table = this.props.visData;
163162
this.props.vis.API.events.addFilter(table, metric.columnIndex, metric.rowIndex);
164163
};
165164

src/core_plugins/region_map/public/__tests__/region_map_visualization.js

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -108,22 +108,26 @@ describe('RegionMapsVisualizationTests', function () {
108108
const _makeJsonAjaxCallOld = ChoroplethLayer.prototype._makeJsonAjaxCall;
109109

110110
const dummyTableGroup = {
111-
tables: [
112-
{
113-
columns: [{
114-
'aggConfig': {
115-
'id': '2',
116-
'enabled': true,
117-
'type': 'terms',
118-
'schema': 'segment',
119-
'params': { 'field': 'geo.dest', 'size': 5, 'order': 'desc', 'orderBy': '1' }
120-
}, 'title': 'geo.dest: Descending'
121-
}, {
122-
'aggConfig': { 'id': '1', 'enabled': true, 'type': 'count', 'schema': 'metric', 'params': {} },
123-
'title': 'Count'
124-
}],
125-
rows: [['CN', 26], ['IN', 17], ['US', 6], ['DE', 4], ['BR', 3]]
126-
}
111+
columns: [{
112+
'id': 'col-0',
113+
'aggConfig': {
114+
'id': '2',
115+
'enabled': true,
116+
'type': 'terms',
117+
'schema': 'segment',
118+
'params': { 'field': 'geo.dest', 'size': 5, 'order': 'desc', 'orderBy': '1' }
119+
}, 'title': 'geo.dest: Descending'
120+
}, {
121+
'id': 'col-1',
122+
'aggConfig': { 'id': '1', 'enabled': true, 'type': 'count', 'schema': 'metric', 'params': {} },
123+
'title': 'Count'
124+
}],
125+
rows: [
126+
{ 'col-0': 'CN', 'col-1': 26 },
127+
{ 'col-0': 'IN', 'col-1': 17 },
128+
{ 'col-0': 'US', 'col-1': 6 },
129+
{ 'col-0': 'DE', 'col-1': 4 },
130+
{ 'col-0': 'BR', 'col-1': 3 }
127131
]
128132
};
129133

@@ -293,7 +297,7 @@ describe('RegionMapsVisualizationTests', function () {
293297
});
294298

295299
const newTableGroup = _.cloneDeep(dummyTableGroup);
296-
newTableGroup.tables[0].rows.pop();//remove one shape
300+
newTableGroup.rows.pop();//remove one shape
297301

298302
await regionMapsVisualization.render(newTableGroup, {
299303
resize: false,
@@ -306,7 +310,7 @@ describe('RegionMapsVisualizationTests', function () {
306310

307311

308312
const anotherTableGroup = _.cloneDeep(newTableGroup);
309-
anotherTableGroup.tables[0].rows.pop();//remove one shape
313+
anotherTableGroup.rows.pop();//remove one shape
310314
domNode.style.width = '412px';
311315
domNode.style.height = '112px';
312316
await regionMapsVisualization.render(anotherTableGroup, {
@@ -336,7 +340,7 @@ describe('RegionMapsVisualizationTests', function () {
336340
});
337341

338342
const newTableGroup = _.cloneDeep(dummyTableGroup);
339-
newTableGroup.tables[0].rows.pop();//remove one shape
343+
newTableGroup.rows.pop();//remove one shape
340344
vis.params.colorSchema = 'Blues';
341345
await regionMapsVisualization.render(newTableGroup, {
342346
resize: false,

src/core_plugins/region_map/public/region_map_visualization.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,17 @@ export function RegionMapsVisualizationProvider(Private, config) {
4646
}
4747
}
4848

49-
async _updateData(tableGroup) {
50-
this._chartData = tableGroup;
49+
async _updateData(table) {
50+
this._chartData = table;
5151
let results;
52-
if (!tableGroup || !tableGroup.tables || !tableGroup.tables.length || tableGroup.tables[0].columns.length !== 2) {
52+
if (!table || !table.rows.length || table.columns.length !== 2) {
5353
results = [];
5454
} else {
55-
const buckets = tableGroup.tables[0].rows;
56-
results = buckets.map(([term, value]) => {
55+
const termColumn = table.columns[0].id;
56+
const valueColumn = table.columns[1].id;
57+
results = table.rows.map(row => {
58+
const term = row[termColumn];
59+
const value = row[valueColumn];
5760
return { term: term, value: value };
5861
});
5962
}
@@ -150,8 +153,8 @@ export function RegionMapsVisualizationProvider(Private, config) {
150153
return;
151154
}
152155

153-
const rowIndex = this._chartData.tables[0].rows.findIndex(row => row[0] === event);
154-
this._vis.API.events.addFilter(this._chartData.tables[0], 0, rowIndex, event);
156+
const rowIndex = this._chartData.rows.findIndex(row => row[0] === event);
157+
this._vis.API.events.addFilter(this._chartData, 0, rowIndex, event);
155158
});
156159

157160
this._choroplethLayer.on('styleChanged', (event) => {

0 commit comments

Comments
 (0)