-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NP] Inline buildPointSeriesData and buildHierarchicalData dependenci…
…es (#61575) (#63145) * Move buildHierarchicalData to vislib * Move shortened version of buildPointSeriesData to Discover * Move buildPointSeriesData to vis_type_vislib * Convert unit tests to jest * Remove ui/agg_response * Convert point_series files to TS * Update TS in unit tests * Convert buildHierarchicalData to TS * Convert buildPointSeriesData to TS in Discover * Clean TS in Discover * Update TS for buildHierarchicalData * Update buildHierarchicalData unit tests * Clean up TS in point_series * Add unit tests fro response_handler.js * Simplify point_series for Discover * Return array for data * Add check for empty row * Simplify point_series for Discover * Return all points * Specify TS * Refactoring * Simplifying * improve types * Update _get_point.test.ts Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: Joe Reuter <johannes.reuter@elastic.co> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: Joe Reuter <johannes.reuter@elastic.co>
- Loading branch information
1 parent
ae4b098
commit 7b0c852
Showing
41 changed files
with
1,328 additions
and
1,040 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
File renamed without changes.
111 changes: 111 additions & 0 deletions
111
src/legacy/core_plugins/kibana/public/discover/np_ready/angular/helpers/point_series.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,111 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { uniq } from 'lodash'; | ||
import { Duration, Moment } from 'moment'; | ||
import { Unit } from '@elastic/datemath'; | ||
|
||
import { SerializedFieldFormat } from '../../../../../../../../plugins/expressions/common/types'; | ||
|
||
export interface Column { | ||
id: string; | ||
name: string; | ||
} | ||
|
||
export interface Row { | ||
[key: string]: number | 'NaN'; | ||
} | ||
|
||
export interface Table { | ||
columns: Column[]; | ||
rows: Row[]; | ||
} | ||
|
||
interface HistogramParams { | ||
date: true; | ||
interval: Duration; | ||
intervalESValue: number; | ||
intervalESUnit: Unit; | ||
format: string; | ||
bounds: { | ||
min: Moment; | ||
max: Moment; | ||
}; | ||
} | ||
export interface Dimension { | ||
accessor: 0 | 1; | ||
format: SerializedFieldFormat<{ pattern: string }>; | ||
} | ||
|
||
export interface Dimensions { | ||
x: Dimension & { params: HistogramParams }; | ||
y: Dimension; | ||
} | ||
|
||
interface Ordered { | ||
date: true; | ||
interval: Duration; | ||
intervalESUnit: string; | ||
intervalESValue: number; | ||
min: Moment; | ||
max: Moment; | ||
} | ||
export interface Chart { | ||
values: Array<{ | ||
x: number; | ||
y: number; | ||
}>; | ||
xAxisOrderedValues: number[]; | ||
xAxisFormat: Dimension['format']; | ||
xAxisLabel: Column['name']; | ||
yAxisLabel?: Column['name']; | ||
ordered: Ordered; | ||
} | ||
|
||
export const buildPointSeriesData = (table: Table, dimensions: Dimensions) => { | ||
const { x, y } = dimensions; | ||
const xAccessor = table.columns[x.accessor].id; | ||
const yAccessor = table.columns[y.accessor].id; | ||
const chart = {} as Chart; | ||
|
||
chart.xAxisOrderedValues = uniq(table.rows.map(r => r[xAccessor] as number)); | ||
chart.xAxisFormat = x.format; | ||
chart.xAxisLabel = table.columns[x.accessor].name; | ||
|
||
const { intervalESUnit, intervalESValue, interval, bounds } = x.params; | ||
chart.ordered = { | ||
date: true, | ||
interval, | ||
intervalESUnit, | ||
intervalESValue, | ||
min: bounds.min, | ||
max: bounds.max, | ||
}; | ||
|
||
chart.yAxisLabel = table.columns[y.accessor].name; | ||
|
||
chart.values = table.rows | ||
.filter(row => row && row[yAccessor] !== 'NaN') | ||
.map(row => ({ | ||
x: row[xAccessor] as number, | ||
y: row[yAccessor] as number, | ||
})); | ||
|
||
return chart; | ||
}; |
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
137 changes: 0 additions & 137 deletions
137
src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/response_handlers.js
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.