Skip to content

Commit

Permalink
Refactored native histogram query UI
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Rabenhorst <sebastian.rabenhorst@shopify.com>
  • Loading branch information
rabenhorst committed Apr 19, 2023
1 parent f3e2798 commit cba7ebf
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
24 changes: 12 additions & 12 deletions pkg/ui/bindata.go

Large diffs are not rendered by default.

9 changes: 3 additions & 6 deletions pkg/ui/react-app/src/pages/graph/DataTable.tsx
Expand Up @@ -3,7 +3,7 @@ import React, { FC, ReactNode } from 'react';
import { UncontrolledAlert, Table } from 'reactstrap';

import SeriesName from './SeriesName';
import { Metric, Histogram } from '../../types/types';
import { Metric, Histogram, SampleValue, SampleHistogram } from '../../types/types';

import moment from 'moment';

Expand Down Expand Up @@ -40,9 +40,6 @@ interface RangeSamples {
histograms?: SampleHistogram[];
}

type SampleValue = [number, string];
type SampleHistogram = [number, Histogram];

const limitSeries = <S extends InstantSample | RangeSamples>(series: S[]): S[] => {
const maxSeries = 10000;

Expand Down Expand Up @@ -83,7 +80,7 @@ const DataTable: FC<QueryResult> = ({ data }) => {
break;
case 'matrix':
rows = (limitSeries(data.result) as RangeSamples[]).map((s, index) => {
const valueText = s.values
const valuesAndTimes = s.values
? s.values
.map((v) => {
return v[1] + ' @' + v[0];
Expand All @@ -107,7 +104,7 @@ const DataTable: FC<QueryResult> = ({ data }) => {
<SeriesName labels={s.metric} format={doFormat} />
</td>
<td>
{valueText} {histogramsAndTimes}
{valuesAndTimes} {histogramsAndTimes}
</td>
</tr>
);
Expand Down
4 changes: 2 additions & 2 deletions pkg/ui/react-app/src/pages/graph/Graph.tsx
Expand Up @@ -3,7 +3,7 @@ import React, { PureComponent } from 'react';
import ReactResizeDetector from 'react-resize-detector';

import { Legend } from './Legend';
import { Metric, QueryParams, Histogram } from '../../types/types';
import { Metric, QueryParams, SampleValue, SampleHistogram } from '../../types/types';
import { isPresent } from '../../utils';
import { normalizeData, getOptions, toHoverColor } from './GraphHelpers';

Expand All @@ -16,7 +16,7 @@ require('jquery.flot.tooltip');
export interface GraphProps {
data: {
resultType: string;
result: Array<{ metric: Metric; values: [number, string][]; histograms?: [number, Histogram][] }>;
result: Array<{ metric: Metric; values: SampleValue[]; histograms?: SampleHistogram[] }>;
};
stacked: boolean;
useLocalTime: boolean;
Expand Down
3 changes: 3 additions & 0 deletions pkg/ui/react-app/src/types/types.ts
Expand Up @@ -10,6 +10,9 @@ export interface Histogram {
buckets?: [number, string, string, string][];
}

export type SampleValue = [number, string];
export type SampleHistogram = [number, Histogram];

export interface QueryParams {
startTime: number;
endTime: number;
Expand Down

0 comments on commit cba7ebf

Please sign in to comment.