-
Notifications
You must be signed in to change notification settings - Fork 8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TSVB][Lens] Navigate to Lens context converting improvement. (#139719)
* Added NavigateToLens types. * Removed math/overall* columns to be replaced by Formula. * Removed Lens specific columns/fields. * Added percentile column convertion. * Fixed labels. * Add percentile_rank converter * Added math formula and timeScale support. * Added MovingAverage and Derivative support. * Updated formula and supported metrics. * Fixed pipeline aggs. * CumulativeSum added. * Fixed formula, timeScale and etc. * Removed console.log. * Other aggs to formula convertion added. * Filter ratio added. * Add XY Configuration * Added last_value convertion. * Updated ColumnWithMeta types. * Fixed for loop. * Added StaticValue convertion. * Added default agg convertion. * Add filters column * Refactored filter part. * Added meta to all the cols. * Fixed problem with columns. * Added date_histogram column, fixed layer configuration * Added terms support. * Refactored for consistancy. * Removed `getVisualizationSuggestionFromContext` fn. * Added references. * Fixed percentile and percentile ranks. * removed unused return statement. * Refactoring 'getEmptyLayersSuggestionsForVisualizeCharts' method * TimeScaleUnit fix. * Fixed references. * Fixed types. * Fixed terms column * Fixed count custom label. * Fix multi series * Fixed custom labels. * Fixed 'insertReferences' method * Revert "Fixed custom labels." This reverts commit 9bd61fb. * Fixed custom labels. * Fixed filter ratio and derivative metrics * fix last_value and series agg * Added CounterRate formula support. * Replaced usage of timeseries. * Added window everywhere. * Add std_deviation and value_count, fix some issues * Fix interval for date_histogram and fix getting filter for metrics and difference * Fix tests for 'getDatasourceSuggestionsForVisualizeCharts' except test for 'format' * Refactored code. * Refactoring 'createNewLayerWithMetricAggregationFromVizEditor' * Removed not used code. * Removed unused import. * Fixed types. * Removed tests with type troubles. * Some code refactoring + formatter. * Removed not used comment. * Added formatter validation. * Added tests for getFormat. * Fix `getFormat` method * createColumn test added. * Added tests for `excludeMetaFromColumn` and `isColumnWithMeta`. * Added tests for counter_rate. * Added tests for cumulative_sum. * Updated cumulative_sum tests. * Added date_histogram tests. * Added filter ratio tests. * Filters test added. * createFormulaColumn test added. * convertMathToFormulaColumn test added. * Added one more case to check. * Added test for convertOtherAggsToFormulaColumn * added more tests for formula. * Added last_value tests. * Added tests for moving average. * Style fix. * Added test for convertMetricAggregationColumnWithoutSpecialParams * Add tests for metrics_helper. Update tests for filter ratio and counter rate formulas * Added tests for convertMetricAggregationToColumn * Added tests for computeParentPipelineColumns * Added tests for convertParentPipelineAggToColumns * Add tests for getParentPipelineSeriesFormula * Added tests for createParentPipelineAggregationColumn * Added tests for isPercentileRanksColumnWithMeta * Added tests for convertToPercentileRankParams * Update and add tests for getSiblingPipelineSeriesFormula * Fixed tests. * Added tests for convertToPercentileRankColumn. * Added tests for convertToPercentileRankColumns. * Added tests for percentile. * Added tests for static_value. * Add tests for isValidMetrics * Added std_deviation tests. * Added tests for terms. * Added tests. * Add tests for getLayers in xy configuration * Rename window to reducedTimeRange * Added test for getBucketsColumns * Fixed tests for parent_pipeline. * Added tests for getValidColumns * Added tests for getMetricsColumns * Removed empty new.index.ts of top_n. * Configuration refactored. * Added tests for getConfigurationForTimeseries and getConfigurationForTopN * Added tests for timeseries/index.ts * Added test for top_n. * Refactored getSuggestionFromConvertToLensContext at suggestion_helpers. * Fix format * Fix types * Remove unused code * Fix tests * Fix bucket columns test * Fix counter rate metric and remove unused comments * Fixed pipeline and terms aggs. Added timeShift arg. * [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix' * Fixed tests * Fixed cumulative sum by value count. * Fixed percentile and percentile ranks. * Fixed tests. * One more fix. * Fixed timeShift * [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix' * Fixed getDataSourceInfo method Co-authored-by: Uladzislau Lasitsa <vlad.lasitsa@gmail.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Joe Reuter <johannes.reuter@elastic.co>
- Loading branch information
1 parent
929cdc0
commit 4d3e76c
Showing
120 changed files
with
8,106 additions
and
4,029 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/plugins/vis_types/timeseries/public/convert_to_lens/lib/__mocks__/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { PANEL_TYPES } from '../../../../common/enums'; | ||
import { Panel, Series } from '../../../../common/types'; | ||
|
||
export const createSeries = (partialSeries?: Partial<Series>): Series => ({ | ||
axis_position: 'right', | ||
chart_type: 'line', | ||
color: '#68BC00', | ||
fill: '0.5', | ||
formatter: '', | ||
id: '3bb3c1d2-5af8-44cc-9759-86725e34b157', | ||
label: '', | ||
line_width: 1, | ||
metrics: [], | ||
override_index_pattern: 0, | ||
palette: { name: 'default', type: 'palette' }, | ||
point_size: 1, | ||
separate_axis: 0, | ||
series_drop_last_bucket: 0, | ||
split_mode: 'everything', | ||
stacked: 'none', | ||
time_range_mode: 'entire_time_range', | ||
value_template: '{{value}}', | ||
seperate_axis: 0, | ||
series_index_pattern: { id: 'test' }, | ||
series_max_bars: 0, | ||
steps: 0, | ||
...partialSeries, | ||
}); | ||
|
||
export const createPanel = (parialPanel?: Partial<Panel>): Panel => ({ | ||
annotations: [], | ||
axis_formatter: '', | ||
axis_max: 100, | ||
axis_min: 0, | ||
axis_position: 'right', | ||
axis_scale: '', | ||
bar_color_rules: [], | ||
drop_last_bucket: 0, | ||
hide_last_value_indicator: false, | ||
id: 'some-id', | ||
ignore_daylight_time: true, | ||
index_pattern: { id: 'test' }, | ||
interval: '', | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
markdown_openLinksInNewTab: 0, | ||
markdown_scrollbars: 0, | ||
max_bars: 0, | ||
series: [createSeries()], | ||
show_grid: 0, | ||
show_legend: 0, | ||
type: PANEL_TYPES.TIMESERIES, | ||
...parialPanel, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,4 @@ | |
* Side Public License, v 1. | ||
*/ | ||
|
||
export * from './get_layer'; | ||
export * from './xy'; |
41 changes: 41 additions & 0 deletions
41
src/plugins/vis_types/timeseries/public/convert_to_lens/lib/configurations/xy/chart_type.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { SeriesType, SeriesTypes } from '@kbn/visualizations-plugin/common/convert_to_lens'; | ||
import { Series } from '../../../../../common/types'; | ||
import { PANEL_TYPES } from '../../../../../common/enums'; | ||
|
||
export const getChartType = (series: Series, type: PANEL_TYPES): SeriesType => { | ||
let layerChartType: SeriesType = SeriesTypes.LINE; | ||
switch (series.chart_type) { | ||
case SeriesTypes.LINE: | ||
layerChartType = Number(series.fill) > 0 ? SeriesTypes.AREA : SeriesTypes.LINE; | ||
break; | ||
case SeriesTypes.AREA: | ||
layerChartType = SeriesTypes.AREA; | ||
break; | ||
case SeriesTypes.BAR: | ||
layerChartType = SeriesTypes.BAR; | ||
break; | ||
} | ||
|
||
if (type === PANEL_TYPES.TOP_N) { | ||
return SeriesTypes.BAR_HORIZONTAL; | ||
} | ||
|
||
if (series.stacked !== 'none' && series.stacked !== 'percent') { | ||
return layerChartType !== SeriesTypes.LINE ? `${layerChartType}_stacked` : SeriesTypes.LINE; | ||
} | ||
if (series.stacked === 'percent') { | ||
return layerChartType !== SeriesTypes.LINE | ||
? `${layerChartType}_percentage_stacked` | ||
: SeriesTypes.LINE; | ||
} | ||
|
||
return layerChartType; | ||
}; |
67 changes: 67 additions & 0 deletions
67
...s/vis_types/timeseries/public/convert_to_lens/lib/configurations/xy/configuration.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { createPanel } from '../../__mocks__'; | ||
import { getConfigurationForTopN, getConfigurationForTimeseries } from './configuration'; | ||
|
||
describe('getConfigurationForTimeseries', () => { | ||
test('should return correct configuration for timeseries', () => { | ||
expect(getConfigurationForTimeseries(createPanel(), [])).toEqual({ | ||
layers: [], | ||
fillOpacity: 0.5, | ||
legend: { | ||
isVisible: false, | ||
showSingleSeries: false, | ||
position: 'right', | ||
shouldTruncate: false, | ||
maxLines: 1, | ||
}, | ||
gridlinesVisibilitySettings: { | ||
x: false, | ||
yLeft: false, | ||
yRight: false, | ||
}, | ||
yLeftExtent: { mode: 'full' }, | ||
yRightExtent: { mode: 'full' }, | ||
yLeftScale: 'linear', | ||
yRightScale: 'linear', | ||
}); | ||
}); | ||
}); | ||
|
||
describe('getConfigurationForTopN', () => { | ||
test('should return correct configuration for top n', () => { | ||
expect(getConfigurationForTopN(createPanel(), [])).toEqual({ | ||
layers: [], | ||
fillOpacity: 0.5, | ||
legend: { | ||
isVisible: false, | ||
showSingleSeries: false, | ||
position: 'right', | ||
shouldTruncate: false, | ||
maxLines: 1, | ||
}, | ||
gridlinesVisibilitySettings: { | ||
x: false, | ||
yLeft: false, | ||
yRight: false, | ||
}, | ||
tickLabelsVisibilitySettings: { | ||
x: true, | ||
yLeft: false, | ||
yRight: false, | ||
}, | ||
axisTitlesVisibilitySettings: { | ||
x: false, | ||
yLeft: false, | ||
yRight: false, | ||
}, | ||
valueLabels: 'show', | ||
}); | ||
}); | ||
}); |
70 changes: 70 additions & 0 deletions
70
...lugins/vis_types/timeseries/public/convert_to_lens/lib/configurations/xy/configuration.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { Position } from '@elastic/charts'; | ||
import { XYConfiguration, XYLayerConfig } from '@kbn/visualizations-plugin/common'; | ||
import { Panel } from '../../../../../common/types'; | ||
import { getYExtents } from './extents'; | ||
|
||
export const getConfigurationForTimeseries = ( | ||
model: Panel, | ||
layers: XYLayerConfig[] | ||
): XYConfiguration => { | ||
const extents = getYExtents(model); | ||
return { | ||
layers, | ||
fillOpacity: Number(model.series[0].fill) ?? 0.3, | ||
legend: { | ||
isVisible: Boolean(model.show_legend), | ||
showSingleSeries: Boolean(model.show_legend), | ||
position: (model.legend_position as Position) ?? Position.Right, | ||
shouldTruncate: Boolean(model.truncate_legend), | ||
maxLines: model.max_lines_legend ?? 1, | ||
}, | ||
gridlinesVisibilitySettings: { | ||
x: Boolean(model.show_grid), | ||
yLeft: Boolean(model.show_grid), | ||
yRight: Boolean(model.show_grid), | ||
}, | ||
yLeftExtent: extents.yLeftExtent, | ||
yRightExtent: extents.yRightExtent, | ||
yLeftScale: model.axis_scale === 'log' ? 'log' : 'linear', | ||
yRightScale: model.axis_scale === 'log' ? 'log' : 'linear', | ||
}; | ||
}; | ||
|
||
export const getConfigurationForTopN = ( | ||
model: Panel, | ||
layers: XYLayerConfig[] | ||
): XYConfiguration => ({ | ||
layers, | ||
fillOpacity: Number(model.series[0].fill) ?? 0.3, | ||
legend: { | ||
isVisible: Boolean(model.show_legend), | ||
showSingleSeries: Boolean(model.show_legend), | ||
position: (model.legend_position as Position) ?? Position.Right, | ||
shouldTruncate: Boolean(model.truncate_legend), | ||
maxLines: model.max_lines_legend ?? 1, | ||
}, | ||
gridlinesVisibilitySettings: { | ||
x: false, | ||
yLeft: false, | ||
yRight: false, | ||
}, | ||
tickLabelsVisibilitySettings: { | ||
x: true, | ||
yLeft: false, | ||
yRight: false, | ||
}, | ||
axisTitlesVisibilitySettings: { | ||
x: false, | ||
yLeft: false, | ||
yRight: false, | ||
}, | ||
valueLabels: 'show', | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.