@perses-dev/core 0.51.0-rc.0 → 0.51.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -29,25 +29,10 @@ _export(exports, {
|
|
|
29
29
|
},
|
|
30
30
|
getTimeSeriesValues: function() {
|
|
31
31
|
return getTimeSeriesValues;
|
|
32
|
-
},
|
|
33
|
-
getXValues: function() {
|
|
34
|
-
return getXValues;
|
|
35
|
-
},
|
|
36
|
-
getYValues: function() {
|
|
37
|
-
return getYValues;
|
|
38
32
|
}
|
|
39
33
|
});
|
|
40
34
|
const _mathjs = require("./mathjs");
|
|
41
35
|
const MIN_STEP_INTERVAL_MS = 10;
|
|
42
|
-
function getXValues(timeScale) {
|
|
43
|
-
const xValues = [];
|
|
44
|
-
let timestamp = timeScale.startMs;
|
|
45
|
-
while(timestamp <= timeScale.endMs){
|
|
46
|
-
xValues.push(timestamp);
|
|
47
|
-
timestamp += timeScale.stepMs;
|
|
48
|
-
}
|
|
49
|
-
return xValues;
|
|
50
|
-
}
|
|
51
36
|
function getTimeSeriesValues(series, timeScale) {
|
|
52
37
|
let timestamp = timeScale.startMs;
|
|
53
38
|
const values = series.values;
|
|
@@ -78,26 +63,6 @@ function getTimeSeriesValues(series, timeScale) {
|
|
|
78
63
|
}
|
|
79
64
|
return processedValues;
|
|
80
65
|
}
|
|
81
|
-
function getYValues(series, timeScale) {
|
|
82
|
-
let timestamp = timeScale.startMs;
|
|
83
|
-
const yValues = [];
|
|
84
|
-
for (const valueTuple of series.values){
|
|
85
|
-
// Fill in values up to the current series value timestamp with nulls
|
|
86
|
-
while(timestamp < valueTuple[0]){
|
|
87
|
-
yValues.push(null);
|
|
88
|
-
timestamp += timeScale.stepMs;
|
|
89
|
-
}
|
|
90
|
-
// Now add the current value since timestamp should match
|
|
91
|
-
yValues.push(valueTuple[1]);
|
|
92
|
-
timestamp += timeScale.stepMs;
|
|
93
|
-
}
|
|
94
|
-
// Add null values at the end of the series if necessary
|
|
95
|
-
while(timestamp <= timeScale.endMs){
|
|
96
|
-
yValues.push(null);
|
|
97
|
-
timestamp += timeScale.stepMs;
|
|
98
|
-
}
|
|
99
|
-
return yValues;
|
|
100
|
-
}
|
|
101
66
|
function getCommonTimeScale(seriesData) {
|
|
102
67
|
let timeRange = undefined;
|
|
103
68
|
const steps = [];
|
|
@@ -1,23 +1,11 @@
|
|
|
1
1
|
import { TimeScale, TimeSeries, TimeSeriesData, TimeSeriesValueTuple } from '../model';
|
|
2
2
|
export declare const MIN_STEP_INTERVAL_MS = 10;
|
|
3
|
-
/**
|
|
4
|
-
* Given a common time scale (see `getCommonTimeScale`), generates an array of
|
|
5
|
-
* timestamp values in ms for the x axis of a graph.
|
|
6
|
-
*/
|
|
7
|
-
export declare function getXValues(timeScale: TimeScale): number[];
|
|
8
3
|
/**
|
|
9
4
|
* Given a TimeSeries from a query and a common time scale (see `getCommonTimeScale`),
|
|
10
5
|
* processes the time series values, filling in any timestamps that are missing
|
|
11
6
|
* from the time series data with `null` values.
|
|
12
7
|
*/
|
|
13
8
|
export declare function getTimeSeriesValues(series: TimeSeries, timeScale: TimeScale): TimeSeriesValueTuple[];
|
|
14
|
-
/**
|
|
15
|
-
* [DEPRECATED] Used for legacy LineChart 'category' axis approach.
|
|
16
|
-
* Given a TimeSeries from a query and a common time scale (see `getCommonTimeScale`),
|
|
17
|
-
* gets the values for the y axis of a graph, filling in any timestamps that are
|
|
18
|
-
* missing from the time series data with `null` values.
|
|
19
|
-
*/
|
|
20
|
-
export declare function getYValues(series: TimeSeries, timeScale: TimeScale): Array<number | null>;
|
|
21
9
|
/**
|
|
22
10
|
* Given a list of running queries, calculates a common time scale for use on
|
|
23
11
|
* the x axis (i.e. start/end dates and a step that is divisible into all of
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time-series-data.d.ts","sourceRoot":"","sources":["../../src/utils/time-series-data.ts"],"names":[],"mappings":"AAaA,OAAO,EAAqB,SAAS,EAAE,UAAU,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAG1G,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC
|
|
1
|
+
{"version":3,"file":"time-series-data.d.ts","sourceRoot":"","sources":["../../src/utils/time-series-data.ts"],"names":[],"mappings":"AAaA,OAAO,EAAqB,SAAS,EAAE,UAAU,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAG1G,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,GAAG,oBAAoB,EAAE,CAyBpG;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,KAAK,CAAC,cAAc,GAAG,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,SAAS,CAAC,GACzE,SAAS,GAAG,SAAS,CAgFvB"}
|
|
@@ -12,18 +12,6 @@
|
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { gcd } from './mathjs';
|
|
14
14
|
export const MIN_STEP_INTERVAL_MS = 10;
|
|
15
|
-
/**
|
|
16
|
-
* Given a common time scale (see `getCommonTimeScale`), generates an array of
|
|
17
|
-
* timestamp values in ms for the x axis of a graph.
|
|
18
|
-
*/ export function getXValues(timeScale) {
|
|
19
|
-
const xValues = [];
|
|
20
|
-
let timestamp = timeScale.startMs;
|
|
21
|
-
while(timestamp <= timeScale.endMs){
|
|
22
|
-
xValues.push(timestamp);
|
|
23
|
-
timestamp += timeScale.stepMs;
|
|
24
|
-
}
|
|
25
|
-
return xValues;
|
|
26
|
-
}
|
|
27
15
|
/**
|
|
28
16
|
* Given a TimeSeries from a query and a common time scale (see `getCommonTimeScale`),
|
|
29
17
|
* processes the time series values, filling in any timestamps that are missing
|
|
@@ -58,31 +46,6 @@ export const MIN_STEP_INTERVAL_MS = 10;
|
|
|
58
46
|
}
|
|
59
47
|
return processedValues;
|
|
60
48
|
}
|
|
61
|
-
/**
|
|
62
|
-
* [DEPRECATED] Used for legacy LineChart 'category' axis approach.
|
|
63
|
-
* Given a TimeSeries from a query and a common time scale (see `getCommonTimeScale`),
|
|
64
|
-
* gets the values for the y axis of a graph, filling in any timestamps that are
|
|
65
|
-
* missing from the time series data with `null` values.
|
|
66
|
-
*/ export function getYValues(series, timeScale) {
|
|
67
|
-
let timestamp = timeScale.startMs;
|
|
68
|
-
const yValues = [];
|
|
69
|
-
for (const valueTuple of series.values){
|
|
70
|
-
// Fill in values up to the current series value timestamp with nulls
|
|
71
|
-
while(timestamp < valueTuple[0]){
|
|
72
|
-
yValues.push(null);
|
|
73
|
-
timestamp += timeScale.stepMs;
|
|
74
|
-
}
|
|
75
|
-
// Now add the current value since timestamp should match
|
|
76
|
-
yValues.push(valueTuple[1]);
|
|
77
|
-
timestamp += timeScale.stepMs;
|
|
78
|
-
}
|
|
79
|
-
// Add null values at the end of the series if necessary
|
|
80
|
-
while(timestamp <= timeScale.endMs){
|
|
81
|
-
yValues.push(null);
|
|
82
|
-
timestamp += timeScale.stepMs;
|
|
83
|
-
}
|
|
84
|
-
return yValues;
|
|
85
|
-
}
|
|
86
49
|
/**
|
|
87
50
|
* Given a list of running queries, calculates a common time scale for use on
|
|
88
51
|
* the x axis (i.e. start/end dates and a step that is divisible into all of
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/time-series-data.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { AbsoluteTimeRange, TimeScale, TimeSeries, TimeSeriesData, TimeSeriesValueTuple } from '../model';\nimport { gcd } from './mathjs';\n\nexport const MIN_STEP_INTERVAL_MS = 10;\n\n/**\n * Given a
|
|
1
|
+
{"version":3,"sources":["../../src/utils/time-series-data.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { AbsoluteTimeRange, TimeScale, TimeSeries, TimeSeriesData, TimeSeriesValueTuple } from '../model';\nimport { gcd } from './mathjs';\n\nexport const MIN_STEP_INTERVAL_MS = 10;\n\n/**\n * Given a TimeSeries from a query and a common time scale (see `getCommonTimeScale`),\n * processes the time series values, filling in any timestamps that are missing\n * from the time series data with `null` values.\n */\nexport function getTimeSeriesValues(series: TimeSeries, timeScale: TimeScale): TimeSeriesValueTuple[] {\n let timestamp = timeScale.startMs;\n\n const values = series.values;\n const processedValues: TimeSeriesValueTuple[] = [];\n\n for (const valueTuple of values) {\n // Fill in values up to the current series value timestamp with nulls\n while (timestamp < valueTuple[0]) {\n processedValues.push([timestamp, null]);\n timestamp += timeScale.stepMs;\n }\n\n // Now add the current value since timestamp should match\n processedValues.push([timestamp, valueTuple[1]]);\n timestamp += timeScale.stepMs;\n }\n\n // Add null values at the end of the series if necessary\n while (timestamp <= timeScale.endMs) {\n processedValues.push([timestamp, null]);\n timestamp += timeScale.stepMs;\n }\n\n return processedValues;\n}\n\n/**\n * Given a list of running queries, calculates a common time scale for use on\n * the x axis (i.e. start/end dates and a step that is divisible into all of\n * the queries' steps).\n */\nexport function getCommonTimeScale(\n seriesData: Array<TimeSeriesData | Pick<TimeSeries, 'values'> | undefined>\n): TimeScale | undefined {\n let timeRange: AbsoluteTimeRange | undefined = undefined;\n const steps: number[] = [];\n\n for (const data of seriesData) {\n if (data && 'timeRange' in data) {\n if (data === undefined || data.timeRange === undefined || data.stepMs === undefined) continue;\n\n // Keep track of query steps so we can calculate a common one for the graph\n steps.push(data.stepMs);\n\n // If we don't have an overall time range yet, just start with this one\n if (timeRange === undefined) {\n timeRange = data.timeRange;\n continue;\n }\n\n // Otherwise, see if this query has a start or end outside of the current\n // time range\n if (data.timeRange.start < timeRange.start) {\n timeRange.start = data.timeRange.start;\n }\n if (data.timeRange.end > timeRange.end) {\n timeRange.end = data.timeRange.end;\n }\n } else if (data && 'values' in data) {\n for (let i = 0; i < data.values.length; i++) {\n const values = data.values[i];\n if (values === undefined) {\n continue;\n }\n\n const [timestamp] = values;\n const start = new Date(timestamp);\n const end = new Date(timestamp);\n\n if (timeRange === undefined) {\n timeRange = {\n start,\n end,\n };\n continue;\n }\n\n if (start < timeRange.start) {\n timeRange.start = start;\n }\n\n if (end > timeRange.end) {\n timeRange.end = end;\n }\n }\n\n if (timeRange === undefined) return undefined;\n\n const startMs = timeRange.start.valueOf();\n const endMs = timeRange.end.valueOf();\n const rangeMs = endMs - startMs;\n\n return { startMs, endMs, rangeMs, stepMs: MIN_STEP_INTERVAL_MS };\n }\n }\n\n if (timeRange === undefined) return undefined;\n\n // Use the greatest common divisor of all step values as the overall step\n // for the x axis (or if only one query, just use that query's step value)\n let stepMs: number;\n if (steps.length === 1) {\n stepMs = steps[0] as number;\n } else {\n const calculatedStepMs = gcd(...steps);\n stepMs = calculatedStepMs < MIN_STEP_INTERVAL_MS ? MIN_STEP_INTERVAL_MS : calculatedStepMs;\n }\n\n const startMs = timeRange.start.valueOf();\n const endMs = timeRange.end.valueOf();\n const rangeMs = endMs - startMs;\n\n return { startMs, endMs, stepMs, rangeMs };\n}\n"],"names":["gcd","MIN_STEP_INTERVAL_MS","getTimeSeriesValues","series","timeScale","timestamp","startMs","values","processedValues","valueTuple","push","stepMs","endMs","getCommonTimeScale","seriesData","timeRange","undefined","steps","data","start","end","i","length","Date","valueOf","rangeMs","calculatedStepMs"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,GAAG,QAAQ,WAAW;AAE/B,OAAO,MAAMC,uBAAuB,GAAG;AAEvC;;;;CAIC,GACD,OAAO,SAASC,oBAAoBC,MAAkB,EAAEC,SAAoB;IAC1E,IAAIC,YAAYD,UAAUE,OAAO;IAEjC,MAAMC,SAASJ,OAAOI,MAAM;IAC5B,MAAMC,kBAA0C,EAAE;IAElD,KAAK,MAAMC,cAAcF,OAAQ;QAC/B,qEAAqE;QACrE,MAAOF,YAAYI,UAAU,CAAC,EAAE,CAAE;YAChCD,gBAAgBE,IAAI,CAAC;gBAACL;gBAAW;aAAK;YACtCA,aAAaD,UAAUO,MAAM;QAC/B;QAEA,yDAAyD;QACzDH,gBAAgBE,IAAI,CAAC;YAACL;YAAWI,UAAU,CAAC,EAAE;SAAC;QAC/CJ,aAAaD,UAAUO,MAAM;IAC/B;IAEA,wDAAwD;IACxD,MAAON,aAAaD,UAAUQ,KAAK,CAAE;QACnCJ,gBAAgBE,IAAI,CAAC;YAACL;YAAW;SAAK;QACtCA,aAAaD,UAAUO,MAAM;IAC/B;IAEA,OAAOH;AACT;AAEA;;;;CAIC,GACD,OAAO,SAASK,mBACdC,UAA0E;IAE1E,IAAIC,YAA2CC;IAC/C,MAAMC,QAAkB,EAAE;IAE1B,KAAK,MAAMC,QAAQJ,WAAY;QAC7B,IAAII,QAAQ,eAAeA,MAAM;YAC/B,IAAIA,SAASF,aAAaE,KAAKH,SAAS,KAAKC,aAAaE,KAAKP,MAAM,KAAKK,WAAW;YAErF,2EAA2E;YAC3EC,MAAMP,IAAI,CAACQ,KAAKP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