@perses-dev/status-history-chart-plugin 0.6.0 → 0.7.0
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.
- package/__mf/js/{456.ee65e816.js → 456.dc9b62af.js} +1 -1
- package/__mf/js/{StatusHistoryChart.3532083a.js → StatusHistoryChart.0afd1ff7.js} +5 -5
- package/__mf/js/async/125.bf16be8f.js +1 -0
- package/__mf/js/async/{22.b2b97531.js → 22.8056fc40.js} +1 -1
- package/__mf/js/async/{977.1462b2d4.js → 491.dd94c4b9.js} +5 -5
- package/__mf/js/async/{610.37fe76b5.js → 610.89fadbc8.js} +1 -1
- package/__mf/js/async/750.36e74bac.js +2 -0
- package/__mf/js/async/__federation_expose_StatusHistoryChart.96028d95.js +23 -0
- package/__mf/js/main.676de733.js +1 -0
- package/lib/StatusHistoryChartBase.d.ts +27 -0
- package/lib/StatusHistoryChartBase.d.ts.map +1 -0
- package/lib/StatusHistoryChartBase.js +130 -0
- package/lib/StatusHistoryChartBase.js.map +1 -0
- package/lib/StatusHistoryPanel.d.ts.map +1 -1
- package/lib/StatusHistoryPanel.js +3 -2
- package/lib/StatusHistoryPanel.js.map +1 -1
- package/lib/StatusHistoryTooltip.d.ts +13 -0
- package/lib/StatusHistoryTooltip.d.ts.map +1 -0
- package/lib/StatusHistoryTooltip.js +47 -0
- package/lib/StatusHistoryTooltip.js.map +1 -0
- package/lib/cjs/StatusHistoryChartBase.js +138 -0
- package/lib/cjs/StatusHistoryPanel.js +2 -1
- package/lib/cjs/StatusHistoryTooltip.js +55 -0
- package/lib/cjs/index.js +12 -0
- package/lib/cjs/utils/get-color.js +125 -0
- package/lib/cjs/utils/get-formatted-axis-label.js +48 -0
- package/lib/cjs/utils/get-tooltip-position.js +35 -0
- package/lib/cjs/utils/index.js +34 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +12 -0
- package/lib/index.js.map +1 -1
- package/lib/utils/get-color.d.ts +6 -0
- package/lib/utils/get-color.d.ts.map +1 -0
- package/lib/utils/get-color.js +100 -0
- package/lib/utils/get-color.js.map +1 -0
- package/lib/utils/get-formatted-axis-label.d.ts +2 -0
- package/lib/utils/get-formatted-axis-label.d.ts.map +1 -0
- package/lib/utils/get-formatted-axis-label.js +41 -0
- package/lib/utils/get-formatted-axis-label.js.map +1 -0
- package/lib/utils/get-tooltip-position.d.ts +3 -0
- package/lib/utils/get-tooltip-position.d.ts.map +1 -0
- package/lib/utils/get-tooltip-position.js +27 -0
- package/lib/utils/get-tooltip-position.js.map +1 -0
- package/lib/utils/index.d.ts +6 -0
- package/lib/utils/index.d.ts.map +1 -0
- package/lib/utils/index.js +19 -0
- package/lib/utils/index.js.map +1 -0
- package/mf-manifest.json +12 -10
- package/mf-stats.json +16 -11
- package/package.json +1 -1
- package/__mf/js/async/996.06dcce9b.js +0 -2
- package/__mf/js/async/__federation_expose_StatusHistoryChart.7de772fb.js +0 -1
- package/__mf/js/main.2afb03fb.js +0 -1
- /package/__mf/js/async/{977.1462b2d4.js.LICENSE.txt → 491.dd94c4b9.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{996.06dcce9b.js.LICENSE.txt → 750.36e74bac.js.LICENSE.txt} +0 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// Copyright 2024 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
function _export(target, all) {
|
|
18
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: all[name]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
FALLBACK_COLOR: function() {
|
|
25
|
+
return FALLBACK_COLOR;
|
|
26
|
+
},
|
|
27
|
+
getColorForValue: function() {
|
|
28
|
+
return getColorForValue;
|
|
29
|
+
},
|
|
30
|
+
getColorsForValues: function() {
|
|
31
|
+
return getColorsForValues;
|
|
32
|
+
},
|
|
33
|
+
hexToHSL: function() {
|
|
34
|
+
return hexToHSL;
|
|
35
|
+
},
|
|
36
|
+
hslToHex: function() {
|
|
37
|
+
return hslToHex;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
const FALLBACK_COLOR = '#1f77b4';
|
|
41
|
+
function getColorForValue(value, baseColor) {
|
|
42
|
+
// Validate base color
|
|
43
|
+
if (!baseColor.match(/^#[0-9A-Fa-f]{6}$/)) {
|
|
44
|
+
baseColor = FALLBACK_COLOR;
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
const [baseH, baseS, baseL] = hexToHSL(baseColor);
|
|
48
|
+
// Ensure numeric values are valid
|
|
49
|
+
if (isNaN(baseH) || isNaN(baseS) || isNaN(baseL)) {
|
|
50
|
+
throw new Error('Invalid HSL values');
|
|
51
|
+
}
|
|
52
|
+
// Create deterministic hash
|
|
53
|
+
const hash = String(value).split('').reduce((acc, char)=>acc + char.charCodeAt(0), 0);
|
|
54
|
+
const hueStep = 60;
|
|
55
|
+
const lightnessVariation = 15;
|
|
56
|
+
const hueOffset = hash % 6 * hueStep; // 6 segments of 60° each
|
|
57
|
+
const newH = (baseH + hueOffset) % 360;
|
|
58
|
+
const newL = baseL + (hash % 2 ? lightnessVariation : -lightnessVariation);
|
|
59
|
+
// Keep saturation high for better distinction
|
|
60
|
+
const newS = Math.min(baseS + 10, 90);
|
|
61
|
+
const color = hslToHex(Math.abs(newH), Math.min(Math.max(newS, 50), 90), Math.min(Math.max(newL, 30), 70) // Keep lightness 30-70%
|
|
62
|
+
);
|
|
63
|
+
// Validate generated color
|
|
64
|
+
if (!color.match(/^#[0-9A-Fa-f]{6}$/)) {
|
|
65
|
+
throw new Error('Invalid generated color');
|
|
66
|
+
}
|
|
67
|
+
return color;
|
|
68
|
+
} catch {
|
|
69
|
+
return FALLBACK_COLOR;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function getColorsForValues(uniqueValues, themeColors) {
|
|
73
|
+
// If we have enough theme colors, use them
|
|
74
|
+
if (themeColors.length >= uniqueValues.length) {
|
|
75
|
+
return themeColors.slice(0, uniqueValues.length);
|
|
76
|
+
}
|
|
77
|
+
// Use theme colors first, then generate additional ones
|
|
78
|
+
return uniqueValues.map((value, index)=>{
|
|
79
|
+
if (index < themeColors.length) {
|
|
80
|
+
return themeColors[index] || FALLBACK_COLOR;
|
|
81
|
+
}
|
|
82
|
+
return getColorForValue(value, themeColors[0] || FALLBACK_COLOR);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function hexToHSL(hex) {
|
|
86
|
+
const r = parseInt(hex.slice(1, 3), 16) / 255;
|
|
87
|
+
const g = parseInt(hex.slice(3, 5), 16) / 255;
|
|
88
|
+
const b = parseInt(hex.slice(5, 7), 16) / 255;
|
|
89
|
+
const max = Math.max(r, g, b);
|
|
90
|
+
const min = Math.min(r, g, b);
|
|
91
|
+
let h = 0;
|
|
92
|
+
let s = 0;
|
|
93
|
+
const l = (max + min) / 2;
|
|
94
|
+
if (max !== min) {
|
|
95
|
+
const d = max - min;
|
|
96
|
+
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
97
|
+
switch(max){
|
|
98
|
+
case r:
|
|
99
|
+
h = (g - b) / d + (g < b ? 6 : 0);
|
|
100
|
+
break;
|
|
101
|
+
case g:
|
|
102
|
+
h = (b - r) / d + 2;
|
|
103
|
+
break;
|
|
104
|
+
case b:
|
|
105
|
+
h = (r - g) / d + 4;
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
h /= 6;
|
|
109
|
+
}
|
|
110
|
+
return [
|
|
111
|
+
h * 360,
|
|
112
|
+
s * 100,
|
|
113
|
+
l * 100
|
|
114
|
+
];
|
|
115
|
+
}
|
|
116
|
+
function hslToHex(h, s, l) {
|
|
117
|
+
l /= 100;
|
|
118
|
+
const a = s * Math.min(l, 1 - l) / 100;
|
|
119
|
+
const f = (n)=>{
|
|
120
|
+
const k = (n + h / 30) % 12;
|
|
121
|
+
const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
|
|
122
|
+
return Math.round(255 * color).toString(16).padStart(2, '0');
|
|
123
|
+
};
|
|
124
|
+
return `#${f(0)}${f(8)}${f(4)}`;
|
|
125
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Copyright 2024 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "getFormattedStatusHistoryAxisLabel", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return getFormattedStatusHistoryAxisLabel;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _components = require("@perses-dev/components");
|
|
24
|
+
function getFormattedStatusHistoryAxisLabel(rangeMs, timezone) {
|
|
25
|
+
return function(value) {
|
|
26
|
+
const dayMs = 86400000;
|
|
27
|
+
const monthMs = 2629440000;
|
|
28
|
+
const yearMs = 31536000000;
|
|
29
|
+
const timeStamp = new Date(Number(value));
|
|
30
|
+
// more than 5 years
|
|
31
|
+
if (rangeMs > yearMs * 5) {
|
|
32
|
+
return (0, _components.formatWithTimeZone)(timeStamp, 'yyy', timezone);
|
|
33
|
+
}
|
|
34
|
+
// more than 2 years
|
|
35
|
+
if (rangeMs > yearMs * 2) {
|
|
36
|
+
return (0, _components.formatWithTimeZone)(timeStamp, 'MMM yyy', timezone);
|
|
37
|
+
}
|
|
38
|
+
// between 5 days to 6 months
|
|
39
|
+
if (rangeMs > dayMs * 10 && rangeMs < monthMs * 6) {
|
|
40
|
+
return (0, _components.formatWithTimeZone)(timeStamp, 'dd.MM', timezone); // 12-01
|
|
41
|
+
}
|
|
42
|
+
// between 2 and 10 days
|
|
43
|
+
if (rangeMs > dayMs * 2 && rangeMs <= dayMs * 10) {
|
|
44
|
+
return (0, _components.formatWithTimeZone)(timeStamp, 'dd.MM HH:mm', timezone); // 12-01; // 12-01 12:30
|
|
45
|
+
}
|
|
46
|
+
return (0, _components.formatWithTimeZone)(timeStamp, 'HH:mm', timezone);
|
|
47
|
+
};
|
|
48
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Copyright 2024 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "getTooltipPosition", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return getTooltipPosition;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const getTooltipPosition = (...data)=>{
|
|
24
|
+
const point = data[0];
|
|
25
|
+
const size = data[4];
|
|
26
|
+
// calculate the position to avoid overflow
|
|
27
|
+
const [x, y] = point;
|
|
28
|
+
const { contentSize, viewSize } = size;
|
|
29
|
+
const posX = x + contentSize[0] > viewSize[0] ? x - contentSize[0] : x;
|
|
30
|
+
const posY = y + contentSize[1] > viewSize[1] ? y - contentSize[1] : y;
|
|
31
|
+
return [
|
|
32
|
+
posX,
|
|
33
|
+
posY
|
|
34
|
+
];
|
|
35
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
_export_star(require("./data-transform"), exports);
|
|
18
|
+
_export_star(require("./get-color"), exports);
|
|
19
|
+
_export_star(require("./get-formatted-axis-label"), exports);
|
|
20
|
+
_export_star(require("./get-timescale"), exports);
|
|
21
|
+
_export_star(require("./get-tooltip-position"), exports);
|
|
22
|
+
function _export_star(from, to) {
|
|
23
|
+
Object.keys(from).forEach(function(k) {
|
|
24
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
25
|
+
Object.defineProperty(to, k, {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function() {
|
|
28
|
+
return from[k];
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
return from;
|
|
34
|
+
}
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2CAA2C,CAAC;AAC1D,cAAc,sBAAsB,CAAC;AACrC,cAAc,mCAAmC,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
// Copyright 2025 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
1
13
|
export { getPluginModule } from './getPluginModule';
|
|
2
14
|
export * from './status-history-model';
|
|
3
15
|
export * from './StatusHistoryChart';
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// Copyright 2025 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\nexport { getPluginModule } from './getPluginModule';\nexport * from './status-history-model';\nexport * from './StatusHistoryChart';\nexport * from './StatusHistoryChartOptionsEditorSettings';\nexport * from './StatusHistoryPanel';\nexport * from './StatusHistoryValueMappingEditor';\n"],"names":["getPluginModule"],"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;AAEjC,SAASA,eAAe,QAAQ,oBAAoB;AACpD,cAAc,yBAAyB;AACvC,cAAc,uBAAuB;AACrC,cAAc,4CAA4C;AAC1D,cAAc,uBAAuB;AACrC,cAAc,oCAAoC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const FALLBACK_COLOR = "#1f77b4";
|
|
2
|
+
export declare function getColorForValue(value: number | string, baseColor: string): string;
|
|
3
|
+
export declare function getColorsForValues(uniqueValues: Array<number | string>, themeColors: string[]): string[];
|
|
4
|
+
export declare function hexToHSL(hex: string): [number, number, number];
|
|
5
|
+
export declare function hslToHex(h: number, s: number, l: number): string;
|
|
6
|
+
//# sourceMappingURL=get-color.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-color.d.ts","sourceRoot":"","sources":["../../../src/utils/get-color.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,cAAc,YAAY,CAAC;AAExC,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CA2ClF;AAED,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAaxG;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CA8B9D;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAWhE"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// Copyright 2024 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
export const FALLBACK_COLOR = '#1f77b4';
|
|
14
|
+
export function getColorForValue(value, baseColor) {
|
|
15
|
+
// Validate base color
|
|
16
|
+
if (!baseColor.match(/^#[0-9A-Fa-f]{6}$/)) {
|
|
17
|
+
baseColor = FALLBACK_COLOR;
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
const [baseH, baseS, baseL] = hexToHSL(baseColor);
|
|
21
|
+
// Ensure numeric values are valid
|
|
22
|
+
if (isNaN(baseH) || isNaN(baseS) || isNaN(baseL)) {
|
|
23
|
+
throw new Error('Invalid HSL values');
|
|
24
|
+
}
|
|
25
|
+
// Create deterministic hash
|
|
26
|
+
const hash = String(value).split('').reduce((acc, char)=>acc + char.charCodeAt(0), 0);
|
|
27
|
+
const hueStep = 60;
|
|
28
|
+
const lightnessVariation = 15;
|
|
29
|
+
const hueOffset = hash % 6 * hueStep; // 6 segments of 60° each
|
|
30
|
+
const newH = (baseH + hueOffset) % 360;
|
|
31
|
+
const newL = baseL + (hash % 2 ? lightnessVariation : -lightnessVariation);
|
|
32
|
+
// Keep saturation high for better distinction
|
|
33
|
+
const newS = Math.min(baseS + 10, 90);
|
|
34
|
+
const color = hslToHex(Math.abs(newH), Math.min(Math.max(newS, 50), 90), Math.min(Math.max(newL, 30), 70) // Keep lightness 30-70%
|
|
35
|
+
);
|
|
36
|
+
// Validate generated color
|
|
37
|
+
if (!color.match(/^#[0-9A-Fa-f]{6}$/)) {
|
|
38
|
+
throw new Error('Invalid generated color');
|
|
39
|
+
}
|
|
40
|
+
return color;
|
|
41
|
+
} catch {
|
|
42
|
+
return FALLBACK_COLOR;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export function getColorsForValues(uniqueValues, themeColors) {
|
|
46
|
+
// If we have enough theme colors, use them
|
|
47
|
+
if (themeColors.length >= uniqueValues.length) {
|
|
48
|
+
return themeColors.slice(0, uniqueValues.length);
|
|
49
|
+
}
|
|
50
|
+
// Use theme colors first, then generate additional ones
|
|
51
|
+
return uniqueValues.map((value, index)=>{
|
|
52
|
+
if (index < themeColors.length) {
|
|
53
|
+
return themeColors[index] || FALLBACK_COLOR;
|
|
54
|
+
}
|
|
55
|
+
return getColorForValue(value, themeColors[0] || FALLBACK_COLOR);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
export function hexToHSL(hex) {
|
|
59
|
+
const r = parseInt(hex.slice(1, 3), 16) / 255;
|
|
60
|
+
const g = parseInt(hex.slice(3, 5), 16) / 255;
|
|
61
|
+
const b = parseInt(hex.slice(5, 7), 16) / 255;
|
|
62
|
+
const max = Math.max(r, g, b);
|
|
63
|
+
const min = Math.min(r, g, b);
|
|
64
|
+
let h = 0;
|
|
65
|
+
let s = 0;
|
|
66
|
+
const l = (max + min) / 2;
|
|
67
|
+
if (max !== min) {
|
|
68
|
+
const d = max - min;
|
|
69
|
+
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
70
|
+
switch(max){
|
|
71
|
+
case r:
|
|
72
|
+
h = (g - b) / d + (g < b ? 6 : 0);
|
|
73
|
+
break;
|
|
74
|
+
case g:
|
|
75
|
+
h = (b - r) / d + 2;
|
|
76
|
+
break;
|
|
77
|
+
case b:
|
|
78
|
+
h = (r - g) / d + 4;
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
h /= 6;
|
|
82
|
+
}
|
|
83
|
+
return [
|
|
84
|
+
h * 360,
|
|
85
|
+
s * 100,
|
|
86
|
+
l * 100
|
|
87
|
+
];
|
|
88
|
+
}
|
|
89
|
+
export function hslToHex(h, s, l) {
|
|
90
|
+
l /= 100;
|
|
91
|
+
const a = s * Math.min(l, 1 - l) / 100;
|
|
92
|
+
const f = (n)=>{
|
|
93
|
+
const k = (n + h / 30) % 12;
|
|
94
|
+
const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
|
|
95
|
+
return Math.round(255 * color).toString(16).padStart(2, '0');
|
|
96
|
+
};
|
|
97
|
+
return `#${f(0)}${f(8)}${f(4)}`;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
//# sourceMappingURL=get-color.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/get-color.ts"],"sourcesContent":["// Copyright 2024 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\nexport const FALLBACK_COLOR = '#1f77b4';\n\nexport function getColorForValue(value: number | string, baseColor: string): string {\n // Validate base color\n if (!baseColor.match(/^#[0-9A-Fa-f]{6}$/)) {\n baseColor = FALLBACK_COLOR;\n }\n\n try {\n const [baseH, baseS, baseL] = hexToHSL(baseColor);\n\n // Ensure numeric values are valid\n if (isNaN(baseH) || isNaN(baseS) || isNaN(baseL)) {\n throw new Error('Invalid HSL values');\n }\n\n // Create deterministic hash\n const hash = String(value)\n .split('')\n .reduce((acc, char) => acc + char.charCodeAt(0), 0);\n\n const hueStep = 60;\n const lightnessVariation = 15;\n\n const hueOffset = (hash % 6) * hueStep; // 6 segments of 60° each\n const newH = (baseH + hueOffset) % 360;\n const newL = baseL + (hash % 2 ? lightnessVariation : -lightnessVariation);\n\n // Keep saturation high for better distinction\n const newS = Math.min(baseS + 10, 90);\n const color = hslToHex(\n Math.abs(newH),\n Math.min(Math.max(newS, 50), 90), // Keep saturation 50-90%\n Math.min(Math.max(newL, 30), 70) // Keep lightness 30-70%\n );\n\n // Validate generated color\n if (!color.match(/^#[0-9A-Fa-f]{6}$/)) {\n throw new Error('Invalid generated color');\n }\n\n return color;\n } catch {\n return FALLBACK_COLOR;\n }\n}\n\nexport function getColorsForValues(uniqueValues: Array<number | string>, themeColors: string[]): string[] {\n // If we have enough theme colors, use them\n if (themeColors.length >= uniqueValues.length) {\n return themeColors.slice(0, uniqueValues.length);\n }\n\n // Use theme colors first, then generate additional ones\n return uniqueValues.map((value, index) => {\n if (index < themeColors.length) {\n return themeColors[index] || FALLBACK_COLOR;\n }\n return getColorForValue(value, themeColors[0] || FALLBACK_COLOR);\n });\n}\n\nexport function hexToHSL(hex: string): [number, number, number] {\n const r = parseInt(hex.slice(1, 3), 16) / 255;\n const g = parseInt(hex.slice(3, 5), 16) / 255;\n const b = parseInt(hex.slice(5, 7), 16) / 255;\n\n const max = Math.max(r, g, b);\n const min = Math.min(r, g, b);\n let h = 0;\n let s = 0;\n const l = (max + min) / 2;\n\n if (max !== min) {\n const d = max - min;\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n\n switch (max) {\n case r:\n h = (g - b) / d + (g < b ? 6 : 0);\n break;\n case g:\n h = (b - r) / d + 2;\n break;\n case b:\n h = (r - g) / d + 4;\n break;\n }\n h /= 6;\n }\n\n return [h * 360, s * 100, l * 100];\n}\n\nexport function hslToHex(h: number, s: number, l: number): string {\n l /= 100;\n const a = (s * Math.min(l, 1 - l)) / 100;\n const f = (n: number): string => {\n const k = (n + h / 30) % 12;\n const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);\n return Math.round(255 * color)\n .toString(16)\n .padStart(2, '0');\n };\n return `#${f(0)}${f(8)}${f(4)}`;\n}\n"],"names":["FALLBACK_COLOR","getColorForValue","value","baseColor","match","baseH","baseS","baseL","hexToHSL","isNaN","Error","hash","String","split","reduce","acc","char","charCodeAt","hueStep","lightnessVariation","hueOffset","newH","newL","newS","Math","min","color","hslToHex","abs","max","getColorsForValues","uniqueValues","themeColors","length","slice","map","index","hex","r","parseInt","g","b","h","s","l","d","a","f","n","k","round","toString","padStart"],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-formatted-axis-label.d.ts","sourceRoot":"","sources":["../../../src/utils/get-formatted-axis-label.ts"],"names":[],"mappings":"AAgBA,wBAAgB,kCAAkC,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,IACjE,OAAO,MAAM,KAAG,MAAM,CA6BxC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Copyright 2024 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { formatWithTimeZone } from '@perses-dev/components';
|
|
14
|
+
// https://echarts.apache.org/en/option.html#xAxis.axisLabel.formatter
|
|
15
|
+
export function getFormattedStatusHistoryAxisLabel(rangeMs, timezone) {
|
|
16
|
+
return function(value) {
|
|
17
|
+
const dayMs = 86400000;
|
|
18
|
+
const monthMs = 2629440000;
|
|
19
|
+
const yearMs = 31536000000;
|
|
20
|
+
const timeStamp = new Date(Number(value));
|
|
21
|
+
// more than 5 years
|
|
22
|
+
if (rangeMs > yearMs * 5) {
|
|
23
|
+
return formatWithTimeZone(timeStamp, 'yyy', timezone);
|
|
24
|
+
}
|
|
25
|
+
// more than 2 years
|
|
26
|
+
if (rangeMs > yearMs * 2) {
|
|
27
|
+
return formatWithTimeZone(timeStamp, 'MMM yyy', timezone);
|
|
28
|
+
}
|
|
29
|
+
// between 5 days to 6 months
|
|
30
|
+
if (rangeMs > dayMs * 10 && rangeMs < monthMs * 6) {
|
|
31
|
+
return formatWithTimeZone(timeStamp, 'dd.MM', timezone); // 12-01
|
|
32
|
+
}
|
|
33
|
+
// between 2 and 10 days
|
|
34
|
+
if (rangeMs > dayMs * 2 && rangeMs <= dayMs * 10) {
|
|
35
|
+
return formatWithTimeZone(timeStamp, 'dd.MM HH:mm', timezone); // 12-01; // 12-01 12:30
|
|
36
|
+
}
|
|
37
|
+
return formatWithTimeZone(timeStamp, 'HH:mm', timezone);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=get-formatted-axis-label.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/get-formatted-axis-label.ts"],"sourcesContent":["// Copyright 2024 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 { formatWithTimeZone } from '@perses-dev/components';\n\n// https://echarts.apache.org/en/option.html#xAxis.axisLabel.formatter\nexport function getFormattedStatusHistoryAxisLabel(rangeMs: number, timezone: string) {\n return function (value: number): string {\n const dayMs = 86400000;\n const monthMs = 2629440000;\n const yearMs = 31536000000;\n\n const timeStamp = new Date(Number(value));\n\n // more than 5 years\n if (rangeMs > yearMs * 5) {\n return formatWithTimeZone(timeStamp, 'yyy', timezone);\n }\n\n // more than 2 years\n if (rangeMs > yearMs * 2) {\n return formatWithTimeZone(timeStamp, 'MMM yyy', timezone);\n }\n\n // between 5 days to 6 months\n if (rangeMs > dayMs * 10 && rangeMs < monthMs * 6) {\n return formatWithTimeZone(timeStamp, 'dd.MM', timezone); // 12-01\n }\n\n // between 2 and 10 days\n if (rangeMs > dayMs * 2 && rangeMs <= dayMs * 10) {\n return formatWithTimeZone(timeStamp, 'dd.MM HH:mm', timezone); // 12-01; // 12-01 12:30\n }\n\n return formatWithTimeZone(timeStamp, 'HH:mm', timezone);\n };\n}\n"],"names":["formatWithTimeZone","getFormattedStatusHistoryAxisLabel","rangeMs","timezone","value","dayMs","monthMs","yearMs","timeStamp","Date","Number"],"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;AAEjC,SAASA,kBAAkB,QAAQ,yBAAyB;AAE5D,sEAAsE;AACtE,OAAO,SAASC,mCAAmCC,OAAe,EAAEC,QAAgB;IAClF,OAAO,SAAUC,KAAa;QAC5B,MAAMC,QAAQ;QACd,MAAMC,UAAU;QAChB,MAAMC,SAAS;QAEf,MAAMC,YAAY,IAAIC,KAAKC,OAAON;QAElC,oBAAoB;QACpB,IAAIF,UAAUK,SAAS,GAAG;YACxB,OAAOP,mBAAmBQ,WAAW,OAAOL;QAC9C;QAEA,oBAAoB;QACpB,IAAID,UAAUK,SAAS,GAAG;YACxB,OAAOP,mBAAmBQ,WAAW,WAAWL;QAClD;QAEA,6BAA6B;QAC7B,IAAID,UAAUG,QAAQ,MAAMH,UAAUI,UAAU,GAAG;YACjD,OAAON,mBAAmBQ,WAAW,SAASL,WAAW,QAAQ;QACnE;QAEA,wBAAwB;QACxB,IAAID,UAAUG,QAAQ,KAAKH,WAAWG,QAAQ,IAAI;YAChD,OAAOL,mBAAmBQ,WAAW,eAAeL,WAAW,wBAAwB;QACzF;QAEA,OAAOH,mBAAmBQ,WAAW,SAASL;IAChD;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-tooltip-position.d.ts","sourceRoot":"","sources":["../../../src/utils/get-tooltip-position.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEjD,eAAO,MAAM,kBAAkB,EAAE,sBAAsB,CAAC,UAAU,CAYjE,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Copyright 2024 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
export const getTooltipPosition = (...data)=>{
|
|
14
|
+
const point = data[0];
|
|
15
|
+
const size = data[4];
|
|
16
|
+
// calculate the position to avoid overflow
|
|
17
|
+
const [x, y] = point;
|
|
18
|
+
const { contentSize, viewSize } = size;
|
|
19
|
+
const posX = x + contentSize[0] > viewSize[0] ? x - contentSize[0] : x;
|
|
20
|
+
const posY = y + contentSize[1] > viewSize[1] ? y - contentSize[1] : y;
|
|
21
|
+
return [
|
|
22
|
+
posX,
|
|
23
|
+
posY
|
|
24
|
+
];
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=get-tooltip-position.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/get-tooltip-position.ts"],"sourcesContent":["// Copyright 2024 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 { TooltipComponentOption } from 'echarts';\n\nexport const getTooltipPosition: TooltipComponentOption['position'] = (...data) => {\n const point = data[0];\n const size = data[4];\n\n // calculate the position to avoid overflow\n const [x, y] = point;\n const { contentSize, viewSize } = size;\n\n const posX = x + contentSize[0] > viewSize[0] ? x - contentSize[0] : x;\n const posY = y + contentSize[1] > viewSize[1] ? y - contentSize[1] : y;\n\n return [posX, posY];\n};\n"],"names":["getTooltipPosition","data","point","size","x","y","contentSize","viewSize","posX","posY"],"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;AAIjC,OAAO,MAAMA,qBAAyD,CAAC,GAAGC;IACxE,MAAMC,QAAQD,IAAI,CAAC,EAAE;IACrB,MAAME,OAAOF,IAAI,CAAC,EAAE;IAEpB,2CAA2C;IAC3C,MAAM,CAACG,GAAGC,EAAE,GAAGH;IACf,MAAM,EAAEI,WAAW,EAAEC,QAAQ,EAAE,GAAGJ;IAElC,MAAMK,OAAOJ,IAAIE,WAAW,CAAC,EAAE,GAAGC,QAAQ,CAAC,EAAE,GAAGH,IAAIE,WAAW,CAAC,EAAE,GAAGF;IACrE,MAAMK,OAAOJ,IAAIC,WAAW,CAAC,EAAE,GAAGC,QAAQ,CAAC,EAAE,GAAGF,IAAIC,WAAW,CAAC,EAAE,GAAGD;IAErE,OAAO;QAACG;QAAMC;KAAK;AACrB,EAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAaA,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
export * from './data-transform';
|
|
14
|
+
export * from './get-color';
|
|
15
|
+
export * from './get-formatted-axis-label';
|
|
16
|
+
export * from './get-timescale';
|
|
17
|
+
export * from './get-tooltip-position';
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/index.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\nexport * from './data-transform';\nexport * from './get-color';\nexport * from './get-formatted-axis-label';\nexport * from './get-timescale';\nexport * from './get-tooltip-position';\n"],"names":[],"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;AAEjC,cAAc,mBAAmB;AACjC,cAAc,cAAc;AAC5B,cAAc,6BAA6B;AAC3C,cAAc,kBAAkB;AAChC,cAAc,yBAAyB"}
|
package/mf-manifest.json
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
"name": "StatusHistoryChart",
|
|
6
6
|
"type": "app",
|
|
7
7
|
"buildInfo": {
|
|
8
|
-
"buildVersion": "0.
|
|
8
|
+
"buildVersion": "0.7.0",
|
|
9
9
|
"buildName": "@perses-dev/status-history-chart-plugin"
|
|
10
10
|
},
|
|
11
11
|
"remoteEntry": {
|
|
12
|
-
"name": "__mf/js/StatusHistoryChart.
|
|
12
|
+
"name": "__mf/js/StatusHistoryChart.0afd1ff7.js",
|
|
13
13
|
"path": "",
|
|
14
14
|
"type": "global"
|
|
15
15
|
},
|
|
@@ -137,12 +137,13 @@
|
|
|
137
137
|
"__mf/js/async/740.6b036ded.js",
|
|
138
138
|
"__mf/js/async/238.e1063a95.js",
|
|
139
139
|
"__mf/js/async/75.2cda0740.js",
|
|
140
|
-
"__mf/js/async/
|
|
140
|
+
"__mf/js/async/750.36e74bac.js",
|
|
141
|
+
"__mf/js/async/125.bf16be8f.js",
|
|
141
142
|
"__mf/js/async/822.c6b015c5.js",
|
|
142
143
|
"__mf/js/async/539.e7706a03.js",
|
|
143
144
|
"__mf/js/async/738.a0be8511.js",
|
|
144
145
|
"__mf/js/async/232.cccd71f6.js",
|
|
145
|
-
"__mf/js/async/610.
|
|
146
|
+
"__mf/js/async/610.89fadbc8.js",
|
|
146
147
|
"__mf/js/async/981.caaa6409.js"
|
|
147
148
|
],
|
|
148
149
|
"sync": [
|
|
@@ -207,7 +208,7 @@
|
|
|
207
208
|
"js": {
|
|
208
209
|
"async": [],
|
|
209
210
|
"sync": [
|
|
210
|
-
"__mf/js/async/610.
|
|
211
|
+
"__mf/js/async/610.89fadbc8.js"
|
|
211
212
|
]
|
|
212
213
|
},
|
|
213
214
|
"css": {
|
|
@@ -327,28 +328,29 @@
|
|
|
327
328
|
"assets": {
|
|
328
329
|
"js": {
|
|
329
330
|
"sync": [
|
|
331
|
+
"__mf/js/async/750.36e74bac.js",
|
|
330
332
|
"__mf/js/async/539.e7706a03.js",
|
|
331
|
-
"__mf/js/async/
|
|
332
|
-
"__mf/js/async/__federation_expose_StatusHistoryChart.
|
|
333
|
+
"__mf/js/async/491.dd94c4b9.js",
|
|
334
|
+
"__mf/js/async/__federation_expose_StatusHistoryChart.96028d95.js"
|
|
333
335
|
],
|
|
334
336
|
"async": [
|
|
335
337
|
"__mf/js/async/964.03c8778c.js",
|
|
336
338
|
"__mf/js/async/960.587af91a.js",
|
|
337
339
|
"__mf/js/async/770.ddaea8f9.js",
|
|
338
340
|
"__mf/js/async/lib-router.c90fcaed.js",
|
|
339
|
-
"__mf/js/async/22.
|
|
341
|
+
"__mf/js/async/22.8056fc40.js",
|
|
340
342
|
"__mf/js/async/13.714dc818.js",
|
|
341
343
|
"__mf/js/async/488.f3f63548.js",
|
|
342
344
|
"__mf/js/async/238.e1063a95.js",
|
|
343
345
|
"__mf/js/async/224.d1554d4a.js",
|
|
344
|
-
"__mf/js/async/
|
|
346
|
+
"__mf/js/async/125.bf16be8f.js",
|
|
345
347
|
"__mf/js/async/822.c6b015c5.js",
|
|
346
348
|
"__mf/js/async/292.6a606f52.js",
|
|
347
349
|
"__mf/js/async/738.a0be8511.js",
|
|
348
350
|
"__mf/js/async/173.23a9af58.js",
|
|
349
351
|
"__mf/js/async/232.cccd71f6.js",
|
|
350
352
|
"__mf/js/async/75.2cda0740.js",
|
|
351
|
-
"__mf/js/async/610.
|
|
353
|
+
"__mf/js/async/610.89fadbc8.js",
|
|
352
354
|
"__mf/js/async/740.6b036ded.js",
|
|
353
355
|
"__mf/js/async/981.caaa6409.js"
|
|
354
356
|
]
|