@ceeblue/web-utils 3.2.0 → 3.2.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.
- package/dist/web-utils.d.ts +8 -0
- package/dist/web-utils.js +22 -9
- package/dist/web-utils.js.map +1 -1
- package/dist/web-utils.min.js +1 -1
- package/dist/web-utils.min.js.map +1 -1
- package/package.json +1 -1
package/dist/web-utils.d.ts
CHANGED
|
@@ -1144,6 +1144,14 @@ declare class UIMetrics {
|
|
|
1144
1144
|
* set the metric unit-step in pixels
|
|
1145
1145
|
*/
|
|
1146
1146
|
set stepSize(value: number);
|
|
1147
|
+
/**
|
|
1148
|
+
* Return the space width available to display average metric
|
|
1149
|
+
*/
|
|
1150
|
+
get averageDisplayWidth(): number;
|
|
1151
|
+
/**
|
|
1152
|
+
* Return the count of displayable metrics regarding the space available on the screen
|
|
1153
|
+
*/
|
|
1154
|
+
get displayableCount(): number;
|
|
1147
1155
|
private _ui;
|
|
1148
1156
|
private _html?;
|
|
1149
1157
|
private _lineHeight;
|
package/dist/web-utils.js
CHANGED
|
@@ -2253,6 +2253,20 @@ class UIMetrics {
|
|
|
2253
2253
|
set stepSize(value) {
|
|
2254
2254
|
this._stepSize = value;
|
|
2255
2255
|
}
|
|
2256
|
+
/**
|
|
2257
|
+
* Return the space width available to display average metric
|
|
2258
|
+
*/
|
|
2259
|
+
get averageDisplayWidth() {
|
|
2260
|
+
// 7 chars (1 char width ≈ fontSize/2)
|
|
2261
|
+
return (this._legendFontSize / 2) * 7;
|
|
2262
|
+
}
|
|
2263
|
+
/**
|
|
2264
|
+
* Return the count of displayable metrics regarding the space available on the screen
|
|
2265
|
+
*/
|
|
2266
|
+
get displayableCount() {
|
|
2267
|
+
const width = this._ui.clientWidth - this.averageDisplayWidth;
|
|
2268
|
+
return Math.ceil((width - this._labelWidth) / this._stepSize);
|
|
2269
|
+
}
|
|
2256
2270
|
constructor(ui) {
|
|
2257
2271
|
this._ui = ui;
|
|
2258
2272
|
// default values in pixels
|
|
@@ -2281,21 +2295,20 @@ class UIMetrics {
|
|
|
2281
2295
|
return;
|
|
2282
2296
|
}
|
|
2283
2297
|
this._html = '';
|
|
2284
|
-
const
|
|
2285
|
-
const
|
|
2298
|
+
const averageDisplayWidth = this.averageDisplayWidth;
|
|
2299
|
+
const averageCenter = averageDisplayWidth / 2;
|
|
2300
|
+
const width = this._ui.clientWidth - averageDisplayWidth;
|
|
2286
2301
|
const graphHeight = this._lineHeight - 2 * this._graphMargin;
|
|
2287
2302
|
const graphMiddle = Math.round(this._lineHeight / 2);
|
|
2288
2303
|
const textY = Math.round(this._lineHeight / 2 + this._textMargin);
|
|
2289
2304
|
const titleWidth = this._labelWidth - 2 * this._textMargin;
|
|
2290
|
-
const
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
if (x >= width) {
|
|
2294
|
-
x -= values.splice(0, Math.ceil((x - width) / this._stepSize)).length * this._stepSize;
|
|
2295
|
-
}
|
|
2305
|
+
for (const [key, fullValues] of stats) {
|
|
2306
|
+
const displayableCount = Math.ceil((width - this._labelWidth) / this._stepSize);
|
|
2307
|
+
const values = fullValues.slice(Math.max(0, fullValues.length - displayableCount));
|
|
2296
2308
|
if (!values.length) {
|
|
2297
2309
|
continue;
|
|
2298
2310
|
}
|
|
2311
|
+
let x = this._labelWidth + values.length * this._stepSize;
|
|
2299
2312
|
/*
|
|
2300
2313
|
<svg class="list-group-item p-0" style="height: 40px;" xmlns="http://www.w3.org/2000/svg">
|
|
2301
2314
|
<text x="5" y="22">M text</text>
|
|
@@ -2403,4 +2416,4 @@ class UIMetrics {
|
|
|
2403
2416
|
* This file is part of https://github.com/CeeblueTV/web-utils which is released under GNU Affero General Public License.
|
|
2404
2417
|
* See file LICENSE or go to https://spdx.org/licenses/AGPL-3.0-or-later.html for full license details.
|
|
2405
2418
|
*/
|
|
2406
|
-
const VERSION = '3.2.
|
|
2419
|
+
const VERSION = '3.2.1';export{BinaryReader,BinaryWriter,BitReader,ByteRate,Connect,EpochTime,EventEmitter,FixMap,Log,LogLevel,Loggable,NetAddress,Numbers,Queue,SDP,UIMetrics,Util,VERSION,WebSocketReliable,log};//# sourceMappingURL=web-utils.js.map
|