Skip to content

Commit

Permalink
feat!: remove aggregates from dataStreams
Browse files Browse the repository at this point in the history
  • Loading branch information
corteggiano committed May 30, 2023
1 parent cad38d1 commit 76563af
Show file tree
Hide file tree
Showing 71 changed files with 173 additions and 453 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ const timelineParams: Partial<SearchQueryParams> = {
id: 'test',
color: 'black',
name: 'test stream',
data: [],
aggregates: { [MINUTE_IN_MS]: [TEST_DATA_POINT_STANDARD] },
data: [TEST_DATA_POINT_STANDARD],
resolution: MINUTE_IN_MS,
aggregationType: AggregateType.AVERAGE,
dataType: DataType.NUMBER,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
NUMBER_INFO_2,
START_DATE,
} from '../../../../src/testing/__mocks__/mockWidgetProperties';
import { AggregateType } from '../../../../src/utils/dataTypes';

it('renders no tooltip when only info is empty', () => {
visitDynamicWidget(cy, {
Expand Down Expand Up @@ -57,13 +58,14 @@ it('renders no tooltip when there is no data for the requested resolution', () =

it('renders tooltip rows in order of values magnitude', () => {
const resolution = MINUTE_IN_MS;
const aggregationType = AggregateType.AVERAGE;
visitDynamicWidget(cy, {
componentTag: 'iot-app-kit-vis-bar-chart',
viewportStart: new Date(START_DATE.getTime() - MINUTE_IN_MS),
viewportEnd: new Date(START_DATE.getTime() + 10 * MINUTE_IN_MS),
dataStreams: [
{ ...NUMBER_STREAM_1, data: [], aggregates: { [resolution]: NUMBER_STREAM_1.data }, resolution },
{ ...NUMBER_STREAM_2, data: [], aggregates: { [resolution]: NUMBER_STREAM_2.data }, resolution },
{ ...NUMBER_STREAM_1, data: NUMBER_STREAM_1.data, resolution, aggregationType },
{ ...NUMBER_STREAM_2, data: NUMBER_STREAM_2.data, resolution, aggregationType },
],
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,12 @@ const AGGREGATED_DATA_STREAM = {
...DATA_STREAM_2,
resolution: DAY_IN_MS,
aggregationType: AggregateType.AVERAGE,
aggregates: {
[DAY_IN_MS]: [
{
x: (START.getTime() + END.getTime()) / 2,
y: 100,
},
],
},
data: [
{
x: (START.getTime() + END.getTime()) / 2,
y: 100,
},
],
};

it('displays each aggregation description within tooltip', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { DataStream } from '../../utils/dataTypes';

export const STROKE_WIDTH = 1.5;

export const getDataStreamForEventing = (dataStreams: DataStream[]): Omit<DataStream, 'data' | 'aggregates'>[] =>
export const getDataStreamForEventing = (dataStreams: DataStream[]): Omit<DataStream, 'data'>[] =>
dataStreams.map(dataStream => ({
id: dataStream.id,
name: dataStream.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const updateGeometry = (
dataStreams: DataStream<Primitive>[],
toClipSpace: (time: number) => number
) => {
const streamVertexSets = dataStreams.filter(isNumberDataStream).map(stream => vertices(stream, stream.resolution));
const streamVertexSets = dataStreams.filter(isNumberDataStream).map(stream => vertices(stream));
const allVertices = streamVertexSets.flat();
const { position, pointColor } = geometry.attributes;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@ export const DATA_STREAMS: DataStream[] = [
resolution: 1000,
id: '1',
aggregationType: AggregateType.AVERAGE,
aggregates: {
1000: [
{ x: new Date(1995, 0, 1).getTime(), y: 0 },
{ x: new Date(2000, 0, 2).getTime(), y: 10 },
{ x: new Date(2010, 0, 3).getTime(), y: 20 },
{ x: new Date(2020, 0, 4).getTime(), y: 50 },
],
},
data: [],
data: [
{ x: new Date(1995, 0, 1).getTime(), y: 0 },
{ x: new Date(2000, 0, 2).getTime(), y: 10 },
{ x: new Date(2010, 0, 3).getTime(), y: 20 },
{ x: new Date(2020, 0, 4).getTime(), y: 50 },
],
dataType: DataType.NUMBER,
},
];
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { LinearRegressionResult, Trend, TrendResult } from './types';
import { getVisibleData } from '../dataFilters';
import { getDataPoints } from '../../../../utils/getDataPoints';
import { DataStream, Timestamp, ViewPortConfig } from '../../../../utils/dataTypes';
import { TREND_TYPE } from '../../../../utils/dataConstants';

Expand Down Expand Up @@ -71,7 +70,7 @@ export const getAllTrendResults = (
const trendResults: TrendResult[] = [];
dataStreams.forEach(stream => {
const { id } = stream;
const dataPoints = getDataPoints(stream, stream.resolution);
const dataPoints = stream.data;

// only compute a trend line if there are at least two visible and/or boundary data points, the reason being that
// a trend line based on a single point of data has no informational value and may actually be misleading
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export interface ChartConfig extends BaseConfig {
}

export type WidgetConfigurationUpdate = Omit<ChartConfig, 'viewport' | 'messageOverrides'> & {
dataStreams: Omit<DataStream, 'data' | 'aggregates'>[];
dataStreams: Omit<DataStream, 'data'>[];
widgetId: string;
};

Expand Down
Loading

0 comments on commit 76563af

Please sign in to comment.