Skip to content

Commit

Permalink
Merge branch 'master' into EMT-248_renable_test
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Mar 23, 2020
2 parents d5ca6e3 + 8143c07 commit 1377fd4
Show file tree
Hide file tree
Showing 74 changed files with 1,287 additions and 271 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export declare enum ES_FIELD_TYPES
| GEO\_POINT | <code>&quot;geo_point&quot;</code> | |
| GEO\_SHAPE | <code>&quot;geo_shape&quot;</code> | |
| HALF\_FLOAT | <code>&quot;half_float&quot;</code> | |
| HISTOGRAM | <code>&quot;histogram&quot;</code> | |
| INTEGER | <code>&quot;integer&quot;</code> | |
| IP | <code>&quot;ip&quot;</code> | |
| KEYWORD | <code>&quot;keyword&quot;</code> | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export declare enum KBN_FIELD_TYPES
| DATE | <code>&quot;date&quot;</code> | |
| GEO\_POINT | <code>&quot;geo_point&quot;</code> | |
| GEO\_SHAPE | <code>&quot;geo_shape&quot;</code> | |
| HISTOGRAM | <code>&quot;histogram&quot;</code> | |
| IP | <code>&quot;ip&quot;</code> | |
| MURMUR3 | <code>&quot;murmur3&quot;</code> | |
| NESTED | <code>&quot;nested&quot;</code> | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export declare enum ES_FIELD_TYPES
| GEO\_POINT | <code>&quot;geo_point&quot;</code> | |
| GEO\_SHAPE | <code>&quot;geo_shape&quot;</code> | |
| HALF\_FLOAT | <code>&quot;half_float&quot;</code> | |
| HISTOGRAM | <code>&quot;histogram&quot;</code> | |
| INTEGER | <code>&quot;integer&quot;</code> | |
| IP | <code>&quot;ip&quot;</code> | |
| KEYWORD | <code>&quot;keyword&quot;</code> | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export declare enum KBN_FIELD_TYPES
| DATE | <code>&quot;date&quot;</code> | |
| GEO\_POINT | <code>&quot;geo_point&quot;</code> | |
| GEO\_SHAPE | <code>&quot;geo_shape&quot;</code> | |
| HISTOGRAM | <code>&quot;histogram&quot;</code> | |
| IP | <code>&quot;ip&quot;</code> | |
| MURMUR3 | <code>&quot;murmur3&quot;</code> | |
| NESTED | <code>&quot;nested&quot;</code> | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ class PercentilesUi extends Component {
<EuiFlexItem style={optionsStyle} grow={false}>
<EuiFieldNumber
id={htmlId('fillTo')}
min={0}
max={100}
step={1}
onChange={this.handleTextChange(model, 'percentile')}
value={Number(model.percentile)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const GRID_LINE_CONFIG = {
export const X_ACCESSOR_INDEX = 0;
export const STACK_ACCESSORS = [0];
export const Y_ACCESSOR_INDEXES = [1];
export const Y0_ACCESSOR_INDEXES = [2];

export const STACKED_OPTIONS = {
NONE: 'none',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import React from 'react';
import { ScaleType, AreaSeries } from '@elastic/charts';
import { getAreaStyles } from '../utils/series_styles';
import { ChartsEntities } from '../model/charts';
import { X_ACCESSOR_INDEX, Y_ACCESSOR_INDEXES } from '../../../constants';
import { X_ACCESSOR_INDEX, Y_ACCESSOR_INDEXES, Y0_ACCESSOR_INDEXES } from '../../../constants';

export function AreaSeriesDecorator({
seriesId,
Expand All @@ -40,6 +40,8 @@ export function AreaSeriesDecorator({
enableHistogramMode,
useDefaultGroupDomain,
sortIndex,
y1AccessorFormat,
y0AccessorFormat,
}) {
const id = seriesId;
const groupId = seriesGroupId;
Expand All @@ -54,6 +56,9 @@ export function AreaSeriesDecorator({
hideInLegend,
xAccessor: X_ACCESSOR_INDEX,
yAccessors: Y_ACCESSOR_INDEXES,
y0Accessors: lines.mode === 'band' ? Y0_ACCESSOR_INDEXES : undefined,
y1AccessorFormat,
y0AccessorFormat,
stackAccessors,
stackAsPercentage,
xScaleType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import React from 'react';
import { ScaleType, BarSeries } from '@elastic/charts';
import { getBarStyles } from '../utils/series_styles';
import { ChartsEntities } from '../model/charts';
import { X_ACCESSOR_INDEX, Y_ACCESSOR_INDEXES } from '../../../constants';
import { X_ACCESSOR_INDEX, Y_ACCESSOR_INDEXES, Y0_ACCESSOR_INDEXES } from '../../../constants';

export function BarSeriesDecorator({
seriesId,
Expand All @@ -39,6 +39,8 @@ export function BarSeriesDecorator({
enableHistogramMode,
useDefaultGroupDomain,
sortIndex,
y1AccessorFormat,
y0AccessorFormat,
}) {
const id = seriesId;
const groupId = seriesGroupId;
Expand All @@ -53,6 +55,9 @@ export function BarSeriesDecorator({
hideInLegend,
xAccessor: X_ACCESSOR_INDEX,
yAccessors: Y_ACCESSOR_INDEXES,
y0Accessors: bars.mode === 'band' ? Y0_ACCESSOR_INDEXES : undefined,
y1AccessorFormat,
y0AccessorFormat,
stackAccessors,
stackAsPercentage,
xScaleType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ export const TimeSeries = ({
stack,
points,
useDefaultGroupDomain,
y1AccessorFormat,
y0AccessorFormat,
},
sortIndex
) => {
Expand All @@ -182,6 +184,8 @@ export const TimeSeries = ({
enableHistogramMode={enableHistogramMode}
useDefaultGroupDomain={useDefaultGroupDomain}
sortIndex={sortIndex}
y1AccessorFormat={y1AccessorFormat}
y0AccessorFormat={y0AccessorFormat}
/>
);
}
Expand All @@ -206,6 +210,8 @@ export const TimeSeries = ({
enableHistogramMode={enableHistogramMode}
useDefaultGroupDomain={useDefaultGroupDomain}
sortIndex={sortIndex}
y1AccessorFormat={y1AccessorFormat}
y0AccessorFormat={y0AccessorFormat}
/>
);
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ describe('utils/kbn_field_types', () => {
KBN_FIELD_TYPES.DATE,
KBN_FIELD_TYPES.GEO_POINT,
KBN_FIELD_TYPES.GEO_SHAPE,
KBN_FIELD_TYPES.HISTOGRAM,
KBN_FIELD_TYPES.IP,
KBN_FIELD_TYPES.MURMUR3,
KBN_FIELD_TYPES.NESTED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ export const createKbnFieldTypes = (): KbnFieldType[] => [
name: KBN_FIELD_TYPES._SOURCE,
esTypes: [ES_FIELD_TYPES._SOURCE],
}),
new KbnFieldType({
name: KBN_FIELD_TYPES.HISTOGRAM,
filterable: true,
esTypes: [ES_FIELD_TYPES.HISTOGRAM],
}),
new KbnFieldType({
name: KBN_FIELD_TYPES.CONFLICT,
}),
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/data/common/kbn_field_types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ export enum ES_FIELD_TYPES {
ATTACHMENT = 'attachment',
TOKEN_COUNT = 'token_count',
MURMUR3 = 'murmur3',

HISTOGRAM = 'histogram',
}

/** @public **/
Expand All @@ -77,4 +79,5 @@ export enum KBN_FIELD_TYPES {
CONFLICT = 'conflict',
OBJECT = 'object',
NESTED = 'nested',
HISTOGRAM = 'histogram',
}
3 changes: 2 additions & 1 deletion src/plugins/data/public/field_formats/utils/deserialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ export const deserializeFieldFormat: FormatFactory = function(
const { id } = mapping;
if (id === 'range') {
const RangeFormat = FieldFormat.from((range: any) => {
const format = getFieldFormat(this, id, mapping.params);
const nestedFormatter = mapping.params as SerializedFieldFormat;
const format = getFieldFormat(this, nestedFormatter.id, nestedFormatter.params);
const gte = '\u2265';
const lt = '\u003c';
return i18n.translate('data.aggTypes.buckets.ranges.rangesFormatMessage', {
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/data/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ export enum ES_FIELD_TYPES {
// (undocumented)
HALF_FLOAT = "half_float",
// (undocumented)
HISTOGRAM = "histogram",
// (undocumented)
_ID = "_id",
// (undocumented)
_INDEX = "_index",
Expand Down Expand Up @@ -1126,6 +1128,8 @@ export enum KBN_FIELD_TYPES {
// (undocumented)
GEO_SHAPE = "geo_shape",
// (undocumented)
HISTOGRAM = "histogram",
// (undocumented)
IP = "ip",
// (undocumented)
MURMUR3 = "murmur3",
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/data/public/search/aggs/metrics/cardinality.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export const cardinalityMetricAgg = new MetricAggType({
{
name: 'field',
type: 'field',
filterFieldTypes: Object.values(KBN_FIELD_TYPES).filter(
type => type !== KBN_FIELD_TYPES.HISTOGRAM
),
},
],
});
2 changes: 1 addition & 1 deletion src/plugins/data/public/search/aggs/metrics/median.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const medianMetricAgg = new MetricAggType({
{
name: 'field',
type: 'field',
filterFieldTypes: [KBN_FIELD_TYPES.NUMBER, KBN_FIELD_TYPES.DATE],
filterFieldTypes: [KBN_FIELD_TYPES.NUMBER, KBN_FIELD_TYPES.DATE, KBN_FIELD_TYPES.HISTOGRAM],
write(agg, output) {
output.params.field = agg.getParam('field').name;
output.params.percents = [50];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const percentileRanksMetricAgg = new MetricAggType<IPercentileRanksAggCon
{
name: 'field',
type: 'field',
filterFieldTypes: KBN_FIELD_TYPES.NUMBER,
filterFieldTypes: [KBN_FIELD_TYPES.NUMBER, KBN_FIELD_TYPES.HISTOGRAM],
},
{
name: 'values',
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/public/search/aggs/metrics/percentiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const percentilesMetricAgg = new MetricAggType<IPercentileAggConfig>({
{
name: 'field',
type: 'field',
filterFieldTypes: [KBN_FIELD_TYPES.NUMBER, KBN_FIELD_TYPES.DATE],
filterFieldTypes: [KBN_FIELD_TYPES.NUMBER, KBN_FIELD_TYPES.DATE, KBN_FIELD_TYPES.HISTOGRAM],
},
{
name: 'percents',
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/data/public/search/aggs/metrics/top_hit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ export const topHitMetricAgg = new MetricAggType({
name: 'field',
type: 'field',
onlyAggregatable: false,
filterFieldTypes: '*',
filterFieldTypes: Object.values(KBN_FIELD_TYPES).filter(
type => type !== KBN_FIELD_TYPES.HISTOGRAM
),
write(agg, output) {
const field = agg.getParam('field');
output.params = {};
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/data/server/server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ export enum ES_FIELD_TYPES {
// (undocumented)
HALF_FLOAT = "half_float",
// (undocumented)
HISTOGRAM = "histogram",
// (undocumented)
_ID = "_id",
// (undocumented)
_INDEX = "_index",
Expand Down Expand Up @@ -547,6 +549,8 @@ export enum KBN_FIELD_TYPES {
// (undocumented)
GEO_SHAPE = "geo_shape",
// (undocumented)
HISTOGRAM = "histogram",
// (undocumented)
IP = "ip",
// (undocumented)
MURMUR3 = "murmur3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* under the License.
*/

import _ from 'lodash';
import { getAggValue } from '../../helpers/get_agg_value';
import { getDefaultDecoration } from '../../helpers/get_default_decoration';
import { getSplits } from '../../helpers/get_splits';
Expand All @@ -35,41 +34,45 @@ export function percentile(resp, panel, series, meta) {
getSplits(resp, panel, series, meta).forEach(split => {
metric.percentiles.forEach(percentile => {
const percentileValue = percentile.value ? percentile.value : 0;
const label = `${split.label} (${percentileValue})`;
const id = `${split.id}:${percentile.id}`;
const data = split.timeseries.buckets.map(bucket => {
const m = _.assign({}, metric, { percent: percentileValue });
return [bucket.key, getAggValue(bucket, m)];
const higherMetric = { ...metric, percent: percentileValue };
const serieData = [bucket.key, getAggValue(bucket, higherMetric)];

if (percentile.mode === 'band') {
const lowerMetric = { ...metric, percent: percentile.percentile };
serieData.push(getAggValue(bucket, lowerMetric));
}

return serieData;
});
if (percentile.mode === 'band') {
const fillData = split.timeseries.buckets.map(bucket => {
const m = _.assign({}, metric, { percent: percentile.percentile });
return [bucket.key, getAggValue(bucket, m)];
});
results.push({
id: `${split.id}:${percentile.id}`,
id,
color: split.color,
label,
label: split.label,
data,
lines: { show: true, fill: percentile.shade, lineWidth: 0 },
points: { show: false },
legend: false,
fillBetween: `${split.id}:${percentile.id}:${percentile.percentile}`,
});
results.push({
id: `${split.id}:${percentile.id}:${percentile.percentile}`,
color: split.color,
label,
data: fillData,
lines: { show: true, fill: false, lineWidth: 0 },
legend: false,
lines: {
show: series.chart_type === 'line',
fill: Number(percentile.shade),
lineWidth: 0,
mode: 'band',
},
bars: {
show: series.chart_type === 'bar',
fill: Number(percentile.shade),
mode: 'band',
},
points: { show: false },
y1AccessorFormat: ` (${percentileValue})`,
y0AccessorFormat: ` (${percentile.percentile})`,
});
} else {
const decoration = getDefaultDecoration(series);
results.push({
id: `${split.id}:${percentile.id}`,
id,
color: split.color,
label,
label: `${split.label} (${percentileValue})`,
data,
...decoration,
});
Expand Down
Loading

0 comments on commit 1377fd4

Please sign in to comment.