Skip to content

Commit 0b117e5

Browse files
Siwei Zhangbhufmann
authored andcommitted
Introduce generic xy endpoint
Introduce generic xy endpoint to support non-time x-axis for XY view. Signed-off-by: Siwei Zhang <[email protected]>
1 parent 1bc642d commit 0b117e5

File tree

11 files changed

+677
-10
lines changed

11 files changed

+677
-10
lines changed
Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
1+
{
2+
"model": {
3+
"title": "Function Density View",
4+
"series": [
5+
{
6+
"seriesId": 3,
7+
"seriesName": "15652",
8+
"xValues": [
9+
[
10+
0,
11+
604229397
12+
],
13+
[
14+
604229398,
15+
1208458795
16+
],
17+
[
18+
1208458796,
19+
1812688193
20+
],
21+
[
22+
1812688194,
23+
2416917590
24+
],
25+
[
26+
2416917591,
27+
3021146988
28+
]
29+
],
30+
"yValues": [
31+
3.0,
32+
0.0,
33+
0.0,
34+
0.0,
35+
1.0
36+
],
37+
"style": {
38+
"parentKey": null,
39+
"values": {
40+
"series-type": "bar"
41+
}
42+
},
43+
"xValuesDescription": {
44+
"dataType": "DURATION",
45+
"unit": "ns",
46+
"axisDomain": {
47+
"type": "range",
48+
"start": 0,
49+
"end": 3021146988
50+
},
51+
"label": "Execution Time"
52+
},
53+
"yValuesDescription": {
54+
"dataType": "NUMBER",
55+
"unit": "",
56+
"axisDomain": null,
57+
"label": "Number of Executions"
58+
}
59+
},
60+
{
61+
"seriesId": 4,
62+
"seriesName": "15653",
63+
"xValues": [
64+
[
65+
0,
66+
604229397
67+
],
68+
[
69+
604229398,
70+
1208458795
71+
],
72+
[
73+
1208458796,
74+
1812688193
75+
],
76+
[
77+
1812688194,
78+
2416917590
79+
],
80+
[
81+
2416917591,
82+
3021146988
83+
]
84+
],
85+
"yValues": [
86+
3.0,
87+
0.0,
88+
0.0,
89+
0.0,
90+
1.0
91+
],
92+
"style": {
93+
"parentKey": null,
94+
"values": {
95+
"series-type": "bar"
96+
}
97+
},
98+
"xValuesDescription": {
99+
"dataType": "DURATION",
100+
"unit": "ns",
101+
"axisDomain": {
102+
"type": "range",
103+
"start": 0,
104+
"end": 3021146988
105+
},
106+
"label": "Execution Time"
107+
},
108+
"yValuesDescription": {
109+
"dataType": "NUMBER",
110+
"unit": "",
111+
"axisDomain": null,
112+
"label": "Number of Executions"
113+
}
114+
},
115+
{
116+
"seriesId": 2,
117+
"seriesName": "15646",
118+
"xValues": [
119+
[
120+
0,
121+
604229397
122+
],
123+
[
124+
604229398,
125+
1208458795
126+
],
127+
[
128+
1208458796,
129+
1812688193
130+
],
131+
[
132+
1812688194,
133+
2416917590
134+
],
135+
[
136+
2416917591,
137+
3021146988
138+
]
139+
],
140+
"yValues": [
141+
3.0,
142+
0.0,
143+
0.0,
144+
0.0,
145+
1.0
146+
],
147+
"style": {
148+
"parentKey": null,
149+
"values": {
150+
"series-type": "bar"
151+
}
152+
},
153+
"xValuesDescription": {
154+
"dataType": "DURATION",
155+
"unit": "ns",
156+
"axisDomain": {
157+
"type": "range",
158+
"start": 0,
159+
"end": 3021146988
160+
},
161+
"label": "Execution Time"
162+
},
163+
"yValuesDescription": {
164+
"dataType": "NUMBER",
165+
"unit": "",
166+
"axisDomain": null,
167+
"label": "Number of Executions"
168+
}
169+
},
170+
{
171+
"seriesId": 1,
172+
"seriesName": "15647",
173+
"xValues": [
174+
[
175+
0,
176+
604229397
177+
],
178+
[
179+
604229398,
180+
1208458795
181+
],
182+
[
183+
1208458796,
184+
1812688193
185+
],
186+
[
187+
1812688194,
188+
2416917590
189+
],
190+
[
191+
2416917591,
192+
3021146988
193+
]
194+
],
195+
"yValues": [
196+
3.0,
197+
0.0,
198+
0.0,
199+
0.0,
200+
1.0
201+
],
202+
"style": {
203+
"parentKey": null,
204+
"values": {
205+
"series-type": "bar"
206+
}
207+
},
208+
"xValuesDescription": {
209+
"dataType": "DURATION",
210+
"unit": "ns",
211+
"axisDomain": {
212+
"type": "range",
213+
"start": 0,
214+
"end": 3021146988
215+
},
216+
"label": "Execution Time"
217+
},
218+
"yValuesDescription": {
219+
"dataType": "NUMBER",
220+
"unit": "",
221+
"axisDomain": null,
222+
"label": "Number of Executions"
223+
}
224+
}
225+
]
226+
},
227+
"statusMessage": "Completed",
228+
"status": "COMPLETED"
229+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"model": {
3+
"title": "Function Density View",
4+
"series": [
5+
{
6+
"seriesId": 3,
7+
"seriesName": "15652",
8+
"xValues": [
9+
"red",
10+
"blue",
11+
"green",
12+
"yellow",
13+
"black"
14+
],
15+
"yValues": [
16+
3.0,
17+
0.0,
18+
0.0,
19+
0.0,
20+
1.0
21+
],
22+
"style": {
23+
"parentKey": null,
24+
"values": {
25+
"series-type": "bar"
26+
}
27+
},
28+
"xValuesDescription": {
29+
"dataType": "STRING",
30+
"unit": "",
31+
"axisDomain": {
32+
"type": "categorical",
33+
"categories": [
34+
"red",
35+
"blue",
36+
"green",
37+
"yellow",
38+
"black"
39+
]
40+
},
41+
"label": "Execution Time"
42+
},
43+
"yValuesDescription": {
44+
"dataType": "NUMBER",
45+
"unit": "",
46+
"axisDomain": null,
47+
"label": "Number of Executions"
48+
}
49+
}
50+
]
51+
},
52+
"statusMessage": "Completed",
53+
"status": "COMPLETED"
54+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"model": {
3+
"autoExpandLevel": -1,
4+
"entries": [
5+
{
6+
"id": 0,
7+
"parentId": -1,
8+
"style": null,
9+
"labels": [
10+
"ls_ust"
11+
],
12+
"hasData": true
13+
},
14+
{
15+
"id": 1,
16+
"parentId": 0,
17+
"style": null,
18+
"labels": [
19+
"15647"
20+
],
21+
"hasData": true
22+
},
23+
{
24+
"id": 2,
25+
"parentId": 0,
26+
"style": null,
27+
"labels": [
28+
"15646"
29+
],
30+
"hasData": true
31+
},
32+
{
33+
"id": 3,
34+
"parentId": 0,
35+
"style": null,
36+
"labels": [
37+
"15652"
38+
],
39+
"hasData": true
40+
},
41+
{
42+
"id": 4,
43+
"parentId": 0,
44+
"style": null,
45+
"labels": [
46+
"15653"
47+
],
48+
"hasData": true
49+
}
50+
],
51+
"headers": []
52+
},
53+
"statusMessage": "Completed",
54+
"status": "COMPLETED"
55+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { createNormalizer, toBigInt } from '../protocol/serialization';
2+
3+
/**
4+
* Represent a categorical axis domain.
5+
*
6+
* Example categories: ["blue", "green", "yellow"]
7+
*/
8+
export interface AxisDomainCategorical {
9+
type: 'categorical'; categories: string[];
10+
}
11+
12+
/**
13+
* Represent a ranged axis domain.
14+
*/
15+
export interface AxisDomainRange {
16+
type: 'range'; start: bigint; end: bigint;
17+
}
18+
19+
/**
20+
* Represent an axis domain, which can be either ranged or categorical.
21+
*/
22+
export type AxisDomain = AxisDomainCategorical | AxisDomainRange;
23+
24+
export function isAxisDomainRange(ad: AxisDomain | undefined | null): ad is AxisDomainRange {
25+
return !!ad && ad.type === 'range';
26+
}
27+
28+
export function isAxisDomainCategorical(ad: AxisDomain | undefined | null): ad is AxisDomainCategorical {
29+
return !!ad && ad.type === 'categorical';
30+
}
31+
32+
export const AxisDomainRange = createNormalizer<AxisDomainRange>({
33+
start: toBigInt,
34+
end: toBigInt,
35+
});
36+
37+
export const AxisDomainCategorical = (v: unknown): AxisDomainCategorical => {
38+
const x = v as any;
39+
return { type: 'categorical', categories: Array.isArray(x?.categories) ? x.categories as string[] : [] };
40+
};
41+
42+
export const AxisDomain = (v: unknown): AxisDomain => {
43+
const x = v as any;
44+
if (!x || typeof x !== 'object') throw new Error('AxisDomain: invalid value');
45+
return x.type === 'range'
46+
? AxisDomainRange(x)
47+
: x.type === 'categorical'
48+
? AxisDomainCategorical(x)
49+
: (x as AxisDomain);
50+
};

0 commit comments

Comments
 (0)