From f24023b761a27188ba24bf5634c3005fb5775abb Mon Sep 17 00:00:00 2001 From: sulemanof Date: Mon, 23 Mar 2020 16:15:14 +0300 Subject: [PATCH] Use accessor formatters --- .../public/components/aggs/percentile_ui.js | 2 ++ .../views/timeseries/decorators/area_decorator.js | 4 ++++ .../views/timeseries/decorators/bar_decorator.js | 4 ++++ .../public/visualizations/views/timeseries/index.js | 6 ++++++ .../response_processors/series/percentile.js | 12 +++++++----- 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/legacy/core_plugins/vis_type_timeseries/public/components/aggs/percentile_ui.js b/src/legacy/core_plugins/vis_type_timeseries/public/components/aggs/percentile_ui.js index b931c8084a61e..f94c2f609da8f 100644 --- a/src/legacy/core_plugins/vis_type_timeseries/public/components/aggs/percentile_ui.js +++ b/src/legacy/core_plugins/vis_type_timeseries/public/components/aggs/percentile_ui.js @@ -135,6 +135,8 @@ class PercentilesUi extends Component { { @@ -182,6 +184,8 @@ export const TimeSeries = ({ enableHistogramMode={enableHistogramMode} useDefaultGroupDomain={useDefaultGroupDomain} sortIndex={sortIndex} + y1AccessorFormat={y1AccessorFormat} + y0AccessorFormat={y0AccessorFormat} /> ); } @@ -206,6 +210,8 @@ export const TimeSeries = ({ enableHistogramMode={enableHistogramMode} useDefaultGroupDomain={useDefaultGroupDomain} sortIndex={sortIndex} + y1AccessorFormat={y1AccessorFormat} + y0AccessorFormat={y0AccessorFormat} /> ); } diff --git a/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/percentile.js b/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/percentile.js index 856fb4d736911..00fb48c88ec3f 100644 --- a/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/percentile.js +++ b/src/plugins/vis_type_timeseries/server/lib/vis_data/response_processors/series/percentile.js @@ -34,7 +34,7 @@ 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 higherMetric = { ...metric, percent: percentileValue }; const serieData = [bucket.key, getAggValue(bucket, higherMetric)]; @@ -48,9 +48,9 @@ export function percentile(resp, panel, series, meta) { }); if (percentile.mode === 'band') { results.push({ - id: `${split.id}:${percentile.id}`, + id, color: split.color, - label, + label: split.label, data, lines: { show: series.chart_type === 'line', @@ -64,13 +64,15 @@ export function percentile(resp, panel, series, meta) { 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, });