@hybridcore/ui 1.5.80 → 1.5.82
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/{AxisRendererY-CFo972D5.js → AxisRendererY-kADUad00.js} +2464 -3363
- package/dist/ColumnSeries-BTcqshjB.js +399 -0
- package/dist/DateAxis-CMum47iz.js +924 -0
- package/dist/LineSeries-CfcpoYla.js +549 -0
- package/dist/components/charts/candlestick/logic.js +133 -526
- package/dist/components/charts/highlighting-line-data/logic.js +152 -695
- package/dist/components/metric-card/MetricChart.js +525 -0
- package/dist/components/metric-card/index.js +88 -45
- package/dist/components/metric-card/logic.js +82 -37
- package/dist/components/metric-card/styled.js +109 -90
- package/dist/components/paginated-list/styled.js +3 -3
- package/dist/main.d.ts +33 -14
- package/package.json +1 -1
|
@@ -0,0 +1,525 @@
|
|
|
1
|
+
import { jsx as k } from "react/jsx-runtime";
|
|
2
|
+
import { h as S, m as F, i as p, j as v, k as L, l as X, V as z, b as Y, A as j, X as E, c as G, g as O, d as Z, f as w } from "../../AxisRendererY-kADUad00.js";
|
|
3
|
+
import { useRef as q, useLayoutEffect as V } from "react";
|
|
4
|
+
import { C as B } from "../../ColumnSeries-BTcqshjB.js";
|
|
5
|
+
import { L as W } from "../../LineSeries-CfcpoYla.js";
|
|
6
|
+
class P extends S {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments), Object.defineProperty(this, "_frequency", {
|
|
9
|
+
enumerable: !0,
|
|
10
|
+
configurable: !0,
|
|
11
|
+
writable: !0,
|
|
12
|
+
value: 1
|
|
13
|
+
}), Object.defineProperty(this, "_itemMap", {
|
|
14
|
+
enumerable: !0,
|
|
15
|
+
configurable: !0,
|
|
16
|
+
writable: !0,
|
|
17
|
+
value: {}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
_afterNew() {
|
|
21
|
+
this._settings.themeTags = F(this._settings.themeTags, ["axis"]), this.fields.push("category", "id", "cellSize"), this.setPrivateRaw("name", "category"), this.addTag("category"), super._afterNew();
|
|
22
|
+
}
|
|
23
|
+
_afterDataChange() {
|
|
24
|
+
super._afterDataChange();
|
|
25
|
+
const t = this.dataItems.length;
|
|
26
|
+
t > 0 && this.setPrivateRaw("maxZoomFactor", t), this.setPrivateRaw("startIndex", Math.min(this.getPrivate("startIndex", 0), t)), this.setPrivateRaw("endIndex", Math.min(this.getPrivate("endIndex", t), 1));
|
|
27
|
+
}
|
|
28
|
+
_prepareChildren() {
|
|
29
|
+
super._prepareChildren();
|
|
30
|
+
const t = this.dataItems.length;
|
|
31
|
+
let e = 0;
|
|
32
|
+
this._valuesDirty && (this._itemMap = {}, p(this.dataItems, (r) => {
|
|
33
|
+
r.setRaw("index", e), this._itemMap[r.get("category")] = r, e++;
|
|
34
|
+
}), this.setPrivateRaw("maxZoomFactor", t));
|
|
35
|
+
let a = this.get("start", 0), i = this.get("end", 1), s = this._getIndices(a, i);
|
|
36
|
+
this.setPrivateRaw("startIndex", s.startIndex), this.setPrivateRaw("endIndex", s.endIndex), (this._sizeDirty || this._valuesDirty || this.isDirty("start") || this.isDirty("end") || this.isPrivateDirty("endIndex") || this.isPrivateDirty("startIndex") || this.isPrivateDirty("width") || this.isPrivateDirty("height")) && this.dataItems.length > 0 && (this._handleRangeChange(), this._prepareAxisItems(), this._updateAxisRanges());
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* @ignore
|
|
40
|
+
*/
|
|
41
|
+
adjustZoom() {
|
|
42
|
+
const t = this.dataItems.length;
|
|
43
|
+
if (t > 1) {
|
|
44
|
+
let e = this.get("maxZoomCount", this.dataItems.length), a = this.get("minZoomCount", 1), i = 0, s = this.getPrivate("startIndex", 0), r = this.getPrivate("endIndex", 0);
|
|
45
|
+
const d = this._sAnimation, o = this._eAnimation;
|
|
46
|
+
let l = this.get("start", 0), n = !1;
|
|
47
|
+
d && !d.stopped && (l = Number(d.to), n = !0);
|
|
48
|
+
let m = this.get("end", 1);
|
|
49
|
+
if (o && !o.stopped && (m = Number(o.to), n = !0), n) {
|
|
50
|
+
const h = this._getIndices(l, m);
|
|
51
|
+
s = h.startIndex, r = h.endIndex;
|
|
52
|
+
}
|
|
53
|
+
for (let h = s; h < r; h++) {
|
|
54
|
+
const g = this.dataItems[h];
|
|
55
|
+
i += g.get("finalCellSize", 1);
|
|
56
|
+
}
|
|
57
|
+
if (i <= a) {
|
|
58
|
+
let h = 0;
|
|
59
|
+
for (let g = s; g < t; g++) {
|
|
60
|
+
const f = this.dataItems[g];
|
|
61
|
+
if (h += f.get("finalCellSize", 1), r = g + 1, h >= a)
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
if (h < a)
|
|
65
|
+
for (let g = s - 1; g >= 0; g--) {
|
|
66
|
+
const f = this.dataItems[g];
|
|
67
|
+
if (h += f.get("finalCellSize", 1), s = g, h >= a)
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
this.zoomToIndexes(s, r);
|
|
71
|
+
} else if (i >= e) {
|
|
72
|
+
let h = i;
|
|
73
|
+
for (let g = r - 1; g >= s; g--) {
|
|
74
|
+
const f = this.dataItems[g];
|
|
75
|
+
if (h -= f.get("finalCellSize", 1), h <= e) {
|
|
76
|
+
r = g + 1;
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
this.zoomToIndexes(s, r);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
_handleRangeChange() {
|
|
85
|
+
p(this.series, (t) => {
|
|
86
|
+
let e = this.dataItems[this.startIndex()].get("category"), a = this.dataItems[this.endIndex() - 1].get("category"), i = t.get("baseAxis"), s = t.get("xAxis"), r = t.get("yAxis");
|
|
87
|
+
if (s instanceof P && r instanceof P)
|
|
88
|
+
t._markDirtyAxes();
|
|
89
|
+
else if (i === this) {
|
|
90
|
+
let d, o, l = r;
|
|
91
|
+
if (s === i ? (t.get("categoryXField") && (d = "categoryX"), t.get("openCategoryXField") && (o = "openCategoryX")) : r === i && (t.get("categoryYField") && (d = "categoryY"), t.get("openCategoryYField") && (o = "openCategoryY"), l = s), l instanceof z && (d || o)) {
|
|
92
|
+
let h = function(u, y, c, _, N, R) {
|
|
93
|
+
let x, C = y.categoryToIndex(N);
|
|
94
|
+
for (; !x && C >= 0 && C < y.dataItems.length; ) {
|
|
95
|
+
let D = y.dataItems[C].get("category");
|
|
96
|
+
if (R == "previous")
|
|
97
|
+
for (let I = u.dataItems.length - 1; I >= 0; I--) {
|
|
98
|
+
let b = u.dataItems[I];
|
|
99
|
+
if (c && b.get(c) === D) {
|
|
100
|
+
x = b;
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
if (_ && b.get(_) === D) {
|
|
104
|
+
x = b;
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
else
|
|
109
|
+
for (let I = 0, b = u.dataItems.length; I < b; I++) {
|
|
110
|
+
let M = u.dataItems[I];
|
|
111
|
+
if (c && M.get(c) === D) {
|
|
112
|
+
x = M;
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
if (_ && M.get(_) === D) {
|
|
116
|
+
x = M;
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
x || (C += R === "previous" ? -1 : 1);
|
|
121
|
+
}
|
|
122
|
+
return x;
|
|
123
|
+
}, n, m;
|
|
124
|
+
n = h(t, this, d, o, e, "next"), m = h(t, this, d, o, a, "previous");
|
|
125
|
+
let g = 0, f = t.dataItems.length;
|
|
126
|
+
n && (g = t.dataItems.indexOf(n)), m && (f = t.dataItems.indexOf(m) + 1), t.setPrivate("startIndex", g), t.setPrivate("endIndex", f);
|
|
127
|
+
let T = !1;
|
|
128
|
+
for (let u = g; u < f; u++) {
|
|
129
|
+
const y = t.dataItems[u];
|
|
130
|
+
if (p(t.__valueXShowFields, (c) => {
|
|
131
|
+
y.get(c) != null && (T = !0);
|
|
132
|
+
}), p(t.__valueYShowFields, (c) => {
|
|
133
|
+
y.get(c) != null && (T = !0);
|
|
134
|
+
}), T)
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
t.setPrivate("outOfSelection", !T);
|
|
138
|
+
}
|
|
139
|
+
t._markDirtyAxes();
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
_prepareAxisItems() {
|
|
144
|
+
var t;
|
|
145
|
+
const e = this.get("renderer"), a = this.dataItems.length;
|
|
146
|
+
let i = this.startIndex();
|
|
147
|
+
i > 0 && i--;
|
|
148
|
+
let s = this.endIndex();
|
|
149
|
+
s < a && s++;
|
|
150
|
+
const r = e.get("minorLabelsEnabled"), d = e.get("minorGridEnabled", r);
|
|
151
|
+
let o = e.axisLength() / Math.max(e.get("minGridDistance"), 1), l = Math.max(1, Math.min(a, Math.ceil((s - i) / o)));
|
|
152
|
+
i = Math.floor(i / l) * l, this._frequency = l;
|
|
153
|
+
for (let m = 0; m < a; m++)
|
|
154
|
+
this._toggleDataItem(this.dataItems[m], !1);
|
|
155
|
+
let n = this.dataItems[i].get("index", 0);
|
|
156
|
+
for (let m = i; m < s; m = m + l) {
|
|
157
|
+
let h = this.dataItems[m];
|
|
158
|
+
this._createAssets(h, []), this._toggleDataItem(h, !0);
|
|
159
|
+
let g = l;
|
|
160
|
+
d && (g = 1), this._prepareDataItem(h, n, g), n++;
|
|
161
|
+
}
|
|
162
|
+
if (e.get("minorGridEnabled"))
|
|
163
|
+
for (let m = i; m < s; m++) {
|
|
164
|
+
let h = this.dataItems[m];
|
|
165
|
+
m % l != 0 && (this._createAssets(h, ["minor"], !0), this._toggleDataItem(h, !0), this._prepareDataItem(h, 0, 1), r || (t = h.get("label")) === null || t === void 0 || t.setPrivate("visible", !1));
|
|
166
|
+
}
|
|
167
|
+
this._updateGhost();
|
|
168
|
+
}
|
|
169
|
+
_prepareDataItem(t, e, a) {
|
|
170
|
+
let i = this.get("renderer"), s = t.get("categoryLocation", 0), r = t.get("endCategoryLocation", 1), d = t.get("index");
|
|
171
|
+
v(d) || (d = this.categoryToIndex(t.get("category")));
|
|
172
|
+
let o = this.indexToPosition(d, s), l = t.get("endCategory"), n;
|
|
173
|
+
l ? (n = this.categoryToIndex(l), v(n) || (n = d)) : n = d;
|
|
174
|
+
let m = this.indexToPosition(n, r), h, g;
|
|
175
|
+
if (t.get("isRange")) {
|
|
176
|
+
if (h = n, !v(d)) {
|
|
177
|
+
this._toggleDataItem(t, !1);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
} else
|
|
181
|
+
h = d + this._frequency - 1;
|
|
182
|
+
g = this.indexToPosition(h, r), i.updateLabel(t.get("label"), o, m, a), i.updateGrid(t.get("grid"), o, m), i.updateTick(t.get("tick"), o, m, a), i.updateFill(t.get("axisFill"), o, g), this._processBullet(t), i.updateBullet(t.get("bullet"), o, m);
|
|
183
|
+
const f = this.get("fillRule");
|
|
184
|
+
f && f(t, e);
|
|
185
|
+
}
|
|
186
|
+
startIndex() {
|
|
187
|
+
let t = this.dataItems.length;
|
|
188
|
+
return Math.min(Math.max(this.getPrivate("startIndex", 0), 0), t - 1);
|
|
189
|
+
}
|
|
190
|
+
endIndex() {
|
|
191
|
+
let t = this.dataItems.length;
|
|
192
|
+
return Math.max(1, Math.min(this.getPrivate("endIndex", t), t));
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* @ignore
|
|
196
|
+
*/
|
|
197
|
+
baseValue() {
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* @ignore
|
|
201
|
+
*/
|
|
202
|
+
basePosition() {
|
|
203
|
+
return 0;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Returns X coordinate in pixels corresponding to specific category index.
|
|
207
|
+
*
|
|
208
|
+
* @param value Index
|
|
209
|
+
* @return X coordinate
|
|
210
|
+
*/
|
|
211
|
+
getX(t) {
|
|
212
|
+
let e = this._itemMap[t];
|
|
213
|
+
return e ? this._settings.renderer.positionToCoordinate(this.indexToPosition(e.get("index", 0))) : NaN;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Returns Y coordinate in pixels corresponding to specific category index.
|
|
217
|
+
*
|
|
218
|
+
* @param value Index
|
|
219
|
+
* @return Y coordinate
|
|
220
|
+
*/
|
|
221
|
+
getY(t) {
|
|
222
|
+
let e = this._itemMap[t];
|
|
223
|
+
return e ? this._settings.renderer.positionToCoordinate(this.indexToPosition(e.get("index", 0))) : NaN;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* @ignore
|
|
227
|
+
*/
|
|
228
|
+
getDataItemPositionX(t, e, a, i) {
|
|
229
|
+
const s = t.get(e), r = this._itemMap[s];
|
|
230
|
+
return r ? this.indexToPosition(r.get("index", 0), a) : NaN;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* @ignore
|
|
234
|
+
*/
|
|
235
|
+
getDataItemCoordinateX(t, e, a, i) {
|
|
236
|
+
return this._settings.renderer.positionToCoordinate(this.getDataItemPositionX(t, e, a, i));
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* @ignore
|
|
240
|
+
*/
|
|
241
|
+
getDataItemPositionY(t, e, a, i) {
|
|
242
|
+
const s = t.get(e), r = this._itemMap[s];
|
|
243
|
+
return r ? this.indexToPosition(r.get("index", 0), a) : NaN;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* @ignore
|
|
247
|
+
*/
|
|
248
|
+
getDataItemCoordinateY(t, e, a, i) {
|
|
249
|
+
return this._settings.renderer.positionToCoordinate(this.getDataItemPositionY(t, e, a, i));
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Converts category index to a relative position.
|
|
253
|
+
*
|
|
254
|
+
* `location` indicates relative position within category: 0 - start, 1 - end.
|
|
255
|
+
*
|
|
256
|
+
* If not set, will use middle (0.5) of the category.
|
|
257
|
+
*
|
|
258
|
+
* @param index Index
|
|
259
|
+
* @param location Location
|
|
260
|
+
* @return Index
|
|
261
|
+
*/
|
|
262
|
+
indexToPosition(t, e, a) {
|
|
263
|
+
let i = this.dataItems.length, s = 0;
|
|
264
|
+
if (i == 0 || (t >= i && (t = i - 1, e = 1), v(e) || (e = 0.5), !v(t)))
|
|
265
|
+
return 0;
|
|
266
|
+
let r = this.get("startLocation", 0), d = this.get("endLocation", 1);
|
|
267
|
+
if (!this.get("cellSizeField"))
|
|
268
|
+
i -= r, i -= 1 - d, s = (t + e - r) / i;
|
|
269
|
+
else {
|
|
270
|
+
let o = a ? "finalCellSize" : "cellSize";
|
|
271
|
+
const l = this.dataItems;
|
|
272
|
+
let n = 0;
|
|
273
|
+
p(this.dataItems, (g) => {
|
|
274
|
+
n += g.get(o, 1);
|
|
275
|
+
}), n -= r * l[0].get(o, 1), n -= (1 - d) * l[l.length - 1].get(o, 1);
|
|
276
|
+
let m = 0;
|
|
277
|
+
for (let g = 0; g < t; g++)
|
|
278
|
+
m += l[g].get(o, 1);
|
|
279
|
+
let h = l[t].get(o, 1);
|
|
280
|
+
s = (m + e * h - r * l[0].get(o, 1)) / n;
|
|
281
|
+
}
|
|
282
|
+
if (!a) {
|
|
283
|
+
let o = this.dataItems[t];
|
|
284
|
+
o && (s += o.get("deltaPosition", 0));
|
|
285
|
+
}
|
|
286
|
+
return s;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Returns a position of a category.
|
|
290
|
+
*
|
|
291
|
+
* @param category Category to look up
|
|
292
|
+
* @return Position
|
|
293
|
+
*/
|
|
294
|
+
categoryToPosition(t) {
|
|
295
|
+
let e = this._itemMap[t];
|
|
296
|
+
return e ? this.indexToPosition(e.get("index")) : NaN;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Returns an index of a category.
|
|
300
|
+
*
|
|
301
|
+
* @param category Category to look up
|
|
302
|
+
* @return Index
|
|
303
|
+
*/
|
|
304
|
+
categoryToIndex(t) {
|
|
305
|
+
let e = this._itemMap[t];
|
|
306
|
+
return e ? e.get("index") : NaN;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* @ignore
|
|
310
|
+
*/
|
|
311
|
+
dataItemToPosition(t) {
|
|
312
|
+
return this.indexToPosition(t.get("index"));
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* @ignore
|
|
316
|
+
*/
|
|
317
|
+
roundAxisPosition(t, e) {
|
|
318
|
+
return t += (0.5 - e) / this.dataItems.length, this.indexToPosition(this.axisPositionToIndex(t), e);
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Returns an index of the category that corresponds to specific pixel
|
|
322
|
+
* position within axis.
|
|
323
|
+
*
|
|
324
|
+
* @param position Position (px)
|
|
325
|
+
* @return Category index
|
|
326
|
+
*/
|
|
327
|
+
axisPositionToIndex(t) {
|
|
328
|
+
let e = this.dataItems.length;
|
|
329
|
+
if (e === 0)
|
|
330
|
+
return 0;
|
|
331
|
+
if (this.get("cellSizeField")) {
|
|
332
|
+
let a = 0, i = [];
|
|
333
|
+
p(this.dataItems, (l) => {
|
|
334
|
+
const n = l.get("cellSize", 1);
|
|
335
|
+
i.push(n), a += n;
|
|
336
|
+
});
|
|
337
|
+
let s = this.get("startLocation", 0), r = this.get("endLocation", 1);
|
|
338
|
+
a -= s, a -= 1 - r;
|
|
339
|
+
let d = t * a + s, o = 0;
|
|
340
|
+
for (let l = 0; l < e; l++) {
|
|
341
|
+
const n = i[l];
|
|
342
|
+
if (d < o + n)
|
|
343
|
+
return l;
|
|
344
|
+
o += n;
|
|
345
|
+
}
|
|
346
|
+
return e - 1;
|
|
347
|
+
} else
|
|
348
|
+
return L(Math.floor(t * e), 0, e - 1);
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Returns text to be used in an axis tooltip for specific relative position.
|
|
352
|
+
*
|
|
353
|
+
* @param position Position
|
|
354
|
+
* @return Tooltip text
|
|
355
|
+
*/
|
|
356
|
+
getTooltipText(t, e) {
|
|
357
|
+
const a = this.dataItems[this.axisPositionToIndex(t)];
|
|
358
|
+
if (a) {
|
|
359
|
+
const i = a.get("label");
|
|
360
|
+
if (i)
|
|
361
|
+
return X(i, this.get("tooltipText", ""));
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
_updateTooltipText(t, e) {
|
|
365
|
+
t._setDataItem(this.dataItems[this.axisPositionToIndex(e)]), t.label.text.markDirtyText();
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Returns a data item from series that is closest to the `position`.
|
|
369
|
+
*
|
|
370
|
+
* @param series Series
|
|
371
|
+
* @param position Relative position
|
|
372
|
+
* @return Data item
|
|
373
|
+
*/
|
|
374
|
+
getSeriesItem(t, e) {
|
|
375
|
+
if (this.dataItems.length > 0) {
|
|
376
|
+
let a = this.getPrivate("name") + this.get("renderer").getPrivate("letter"), i = this.axisPositionToIndex(e), s = t.dataItems[i], r = this.dataItems[i], d = r.get("category");
|
|
377
|
+
if (s && r && s.get(a) === d)
|
|
378
|
+
return s;
|
|
379
|
+
for (let o = 0, l = t.dataItems.length; o < l; o++) {
|
|
380
|
+
let n = t.dataItems[o];
|
|
381
|
+
if (n.get(a) === d)
|
|
382
|
+
return n;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
_getIndices(t, e) {
|
|
387
|
+
let a = this.dataItems.length, i = 0, s = a, r = "cellSize";
|
|
388
|
+
if (this.get("cellSizeField")) {
|
|
389
|
+
let d = 0;
|
|
390
|
+
const o = this.dataItems;
|
|
391
|
+
if (o.length == 0)
|
|
392
|
+
return { startIndex: 0, endIndex: 0 };
|
|
393
|
+
p(o, (n) => {
|
|
394
|
+
d += n.get(r, 1);
|
|
395
|
+
}), d -= this.get("startLocation", 0) * o[0].get(r, 1), d -= (1 - this.get("endLocation", 1)) * o[o.length - 1].get(r, 1);
|
|
396
|
+
let l = 0;
|
|
397
|
+
for (let n = 0; n < a; n++)
|
|
398
|
+
if (l += this.dataItems[n].get(r, 1), Math.round(l) > Math.round(t * d)) {
|
|
399
|
+
i = n;
|
|
400
|
+
break;
|
|
401
|
+
}
|
|
402
|
+
for (let n = i + 1; n < a; n++)
|
|
403
|
+
if (l += this.dataItems[n].get(r, 1), Math.round(l) >= Math.round(e * d)) {
|
|
404
|
+
s = n + 1;
|
|
405
|
+
break;
|
|
406
|
+
}
|
|
407
|
+
i = Math.max(i, 0), s = Math.min(s, a);
|
|
408
|
+
} else
|
|
409
|
+
i = Math.max(Math.round(this.get("start", 0) * a), 0), s = Math.min(Math.round(this.get("end", 1) * a), a);
|
|
410
|
+
return { startIndex: i, endIndex: s };
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Zooms the axis to specific `start` and `end` indexes.
|
|
414
|
+
*
|
|
415
|
+
* Optional `duration` specifies duration of zoom animation in milliseconds.
|
|
416
|
+
*
|
|
417
|
+
* @param start Start index
|
|
418
|
+
* @param end End index
|
|
419
|
+
* @param duration Duration in milliseconds
|
|
420
|
+
*/
|
|
421
|
+
zoomToIndexes(t, e, a) {
|
|
422
|
+
let i = this.dataItems.length;
|
|
423
|
+
this.get("cellSizeField") ? (t = Math.min(Math.max(t, 0), i), e = Math.max(Math.min(e, i), 1), this.setPrivateRaw("startIndex", t), this.setPrivateRaw("endIndex", e), this.zoom(this.indexToPosition(t, 0, !0), this.indexToPosition(e, 0, !0), a)) : this.zoom(t / i, e / i, a);
|
|
424
|
+
}
|
|
425
|
+
zoomToCategories(t, e, a) {
|
|
426
|
+
this.zoomToIndexes(this.categoryToIndex(t), this.categoryToIndex(e) + 1, a);
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Returns position span between start and end of a single cell in axis.
|
|
430
|
+
*
|
|
431
|
+
* @since 5.2.30
|
|
432
|
+
* @return Position
|
|
433
|
+
*/
|
|
434
|
+
getCellWidthPosition() {
|
|
435
|
+
return this._frequency / this.dataItems.length / (this.get("end", 1) - this.get("start", 0));
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* @ignore
|
|
439
|
+
*/
|
|
440
|
+
nextPosition(t) {
|
|
441
|
+
t == null && (t = 1), this.get("renderer").getPrivate("letter") == "Y" && (t *= -1);
|
|
442
|
+
const e = this.getPrivate("tooltipPosition", 0), a = L(this.axisPositionToIndex(e) + t, 0, this.dataItems.length - 1);
|
|
443
|
+
return this.toGlobalPosition(this.indexToPosition(a));
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
Object.defineProperty(P, "className", {
|
|
447
|
+
enumerable: !0,
|
|
448
|
+
configurable: !0,
|
|
449
|
+
writable: !0,
|
|
450
|
+
value: "CategoryAxis"
|
|
451
|
+
});
|
|
452
|
+
Object.defineProperty(P, "classNames", {
|
|
453
|
+
enumerable: !0,
|
|
454
|
+
configurable: !0,
|
|
455
|
+
writable: !0,
|
|
456
|
+
value: S.classNames.concat([P.className])
|
|
457
|
+
});
|
|
458
|
+
const $ = ({ data: A, type: t, color: e }) => {
|
|
459
|
+
const a = q(null);
|
|
460
|
+
return V(() => {
|
|
461
|
+
if (!a.current) return;
|
|
462
|
+
const i = Y.new(a.current);
|
|
463
|
+
i.setThemes([j.new(i)]);
|
|
464
|
+
const s = i.container.children.push(
|
|
465
|
+
E.new(i, {
|
|
466
|
+
panX: !1,
|
|
467
|
+
panY: !1,
|
|
468
|
+
wheelX: "none",
|
|
469
|
+
wheelY: "none",
|
|
470
|
+
paddingLeft: 0,
|
|
471
|
+
paddingRight: 0,
|
|
472
|
+
paddingTop: 0,
|
|
473
|
+
paddingBottom: 0
|
|
474
|
+
})
|
|
475
|
+
), r = s.xAxes.push(
|
|
476
|
+
P.new(i, {
|
|
477
|
+
categoryField: "t",
|
|
478
|
+
renderer: G.new(i, {
|
|
479
|
+
minGridDistance: 10
|
|
480
|
+
}),
|
|
481
|
+
tooltip: O.new(i, {})
|
|
482
|
+
})
|
|
483
|
+
), d = r.get("renderer");
|
|
484
|
+
d.grid.template.set("visible", !1), d.labels.template.set("visible", !1), r.data.setAll(A);
|
|
485
|
+
const o = s.yAxes.push(
|
|
486
|
+
z.new(i, {
|
|
487
|
+
renderer: Z.new(i, {})
|
|
488
|
+
})
|
|
489
|
+
), l = o.get("renderer");
|
|
490
|
+
l.grid.template.set("visible", !1), l.labels.template.set("visible", !1);
|
|
491
|
+
let n;
|
|
492
|
+
return t === "column" ? (n = s.series.push(
|
|
493
|
+
B.new(i, {
|
|
494
|
+
name: "Series",
|
|
495
|
+
xAxis: r,
|
|
496
|
+
yAxis: o,
|
|
497
|
+
valueYField: "v",
|
|
498
|
+
categoryXField: "t",
|
|
499
|
+
fill: w(e),
|
|
500
|
+
stroke: w(e)
|
|
501
|
+
})
|
|
502
|
+
), n.columns.template.setAll({
|
|
503
|
+
cornerRadiusTL: 2,
|
|
504
|
+
cornerRadiusTR: 2,
|
|
505
|
+
strokeOpacity: 0
|
|
506
|
+
})) : (n = s.series.push(
|
|
507
|
+
W.new(i, {
|
|
508
|
+
name: "Series",
|
|
509
|
+
xAxis: r,
|
|
510
|
+
yAxis: o,
|
|
511
|
+
valueYField: "v",
|
|
512
|
+
categoryXField: "t",
|
|
513
|
+
fill: w(e),
|
|
514
|
+
stroke: w(e)
|
|
515
|
+
})
|
|
516
|
+
), n.strokes.template.setAll({
|
|
517
|
+
strokeWidth: 2
|
|
518
|
+
})), n.data.setAll(A), n.appear(1e3), s.appear(1e3, 100), () => {
|
|
519
|
+
i.dispose();
|
|
520
|
+
};
|
|
521
|
+
}, [A, t, e]), /* @__PURE__ */ k("div", { ref: a, style: { width: "100%", height: "100%" } });
|
|
522
|
+
};
|
|
523
|
+
export {
|
|
524
|
+
$ as MetricChart
|
|
525
|
+
};
|
|
@@ -1,54 +1,97 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Stack as
|
|
3
|
-
import * as
|
|
4
|
-
import { useMetricCardLogic as
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { jsx as e, jsxs as t } from "react/jsx-runtime";
|
|
2
|
+
import { useTheme as R, Stack as o, Skeleton as l } from "@mui/material";
|
|
3
|
+
import * as k from "react";
|
|
4
|
+
import { useMetricCardLogic as L } from "./logic.js";
|
|
5
|
+
import { MetricChart as V } from "./MetricChart.js";
|
|
6
|
+
import { MetricCardRoot as v, MetricCardCornerIconContainer as A, MetricCardIconContainer as I, MetricCardContent as D, MetricCardLabel as P, MetricCardValue as W, MetricCardTrendContainer as q, MetricCardDescription as B, MetricCardChartContainer as E } from "./styled.js";
|
|
7
|
+
const N = k.forwardRef(
|
|
8
|
+
(S, s) => {
|
|
8
9
|
const {
|
|
9
|
-
label:
|
|
10
|
-
value:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
10
|
+
label: y,
|
|
11
|
+
value: d,
|
|
12
|
+
calculatedValue: b,
|
|
13
|
+
calculatedChange: h,
|
|
14
|
+
description: m,
|
|
15
|
+
variant: c,
|
|
16
|
+
loading: T,
|
|
17
|
+
showChange: p,
|
|
18
|
+
showTrend: C,
|
|
19
|
+
Icon: i,
|
|
20
|
+
iconPosition: f,
|
|
21
|
+
showChart: x,
|
|
22
|
+
chartType: g,
|
|
23
|
+
sx: w,
|
|
24
|
+
other: u,
|
|
25
|
+
ownerState: r,
|
|
26
|
+
TrendIcon: z,
|
|
27
|
+
showCornerIcon: j,
|
|
28
|
+
showSideIcon: M
|
|
29
|
+
} = L(S), n = R();
|
|
30
|
+
let a = n.palette.text.secondary;
|
|
31
|
+
return c === "primary" && (a = n.palette.primary.main), c === "success" && (a = n.palette.success.main), c === "warning" && (a = n.palette.warning.main), c === "danger" && (a = n.palette.error.main), T ? /* @__PURE__ */ e(v, { ref: s, ownerState: r, sx: w, ...u, children: /* @__PURE__ */ t(o, { spacing: 1, children: [
|
|
32
|
+
/* @__PURE__ */ e(l, { variant: "text", width: "60%" }),
|
|
33
|
+
/* @__PURE__ */ e(l, { variant: "rectangular", height: 40, width: "40%" }),
|
|
34
|
+
/* @__PURE__ */ e(l, { variant: "text", width: "80%" }),
|
|
35
|
+
x && /* @__PURE__ */ e(
|
|
36
|
+
l,
|
|
37
|
+
{
|
|
38
|
+
variant: "rectangular",
|
|
39
|
+
height: 40,
|
|
40
|
+
width: "100%",
|
|
41
|
+
sx: { mt: 2 }
|
|
42
|
+
}
|
|
43
|
+
)
|
|
44
|
+
] }) }) : /* @__PURE__ */ t(v, { ref: s, ownerState: r, sx: w, ...u, children: [
|
|
45
|
+
j && i && /* @__PURE__ */ e(A, { ownerState: r, children: /* @__PURE__ */ e(i, { sx: { fontSize: 24 } }) }),
|
|
46
|
+
/* @__PURE__ */ t(
|
|
47
|
+
o,
|
|
26
48
|
{
|
|
27
49
|
direction: "row",
|
|
28
50
|
justifyContent: "space-between",
|
|
29
51
|
alignItems: "flex-start",
|
|
52
|
+
sx: { flex: 1 },
|
|
30
53
|
children: [
|
|
31
|
-
|
|
32
|
-
/* @__PURE__ */
|
|
33
|
-
/* @__PURE__ */
|
|
34
|
-
/* @__PURE__ */
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
54
|
+
M && i && f === "left" && /* @__PURE__ */ e(I, { ownerState: r, children: /* @__PURE__ */ e(i, { sx: { fontSize: 24 } }) }),
|
|
55
|
+
/* @__PURE__ */ t(D, { ownerState: r, children: [
|
|
56
|
+
/* @__PURE__ */ e(P, { variant: "subtitle2", ownerState: r, children: y }),
|
|
57
|
+
/* @__PURE__ */ t(
|
|
58
|
+
o,
|
|
59
|
+
{
|
|
60
|
+
direction: "row",
|
|
61
|
+
alignItems: "baseline",
|
|
62
|
+
spacing: 1,
|
|
63
|
+
flexWrap: "wrap",
|
|
64
|
+
children: [
|
|
65
|
+
/* @__PURE__ */ e(W, { variant: "h4", ownerState: r, children: b }),
|
|
66
|
+
(p || C) && h !== "—" && /* @__PURE__ */ t(q, { ownerState: r, children: [
|
|
67
|
+
C && /* @__PURE__ */ e(z, { sx: { fontSize: 16 } }),
|
|
68
|
+
p && h
|
|
69
|
+
] })
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
)
|
|
50
73
|
] }),
|
|
51
|
-
|
|
74
|
+
M && i && f === "right" && /* @__PURE__ */ e(I, { ownerState: r, children: /* @__PURE__ */ e(i, { sx: { fontSize: 24 } }) })
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
),
|
|
78
|
+
/* @__PURE__ */ t(
|
|
79
|
+
o,
|
|
80
|
+
{
|
|
81
|
+
direction: { xs: "column-reverse", sm: "column" },
|
|
82
|
+
spacing: 1,
|
|
83
|
+
sx: { width: "100%", mt: 2 },
|
|
84
|
+
children: [
|
|
85
|
+
m && /* @__PURE__ */ e(
|
|
86
|
+
B,
|
|
87
|
+
{
|
|
88
|
+
variant: "caption",
|
|
89
|
+
ownerState: r,
|
|
90
|
+
sx: { textAlign: { xs: "center", sm: "left" } },
|
|
91
|
+
children: m
|
|
92
|
+
}
|
|
93
|
+
),
|
|
94
|
+
x && g && d.length >= 2 && /* @__PURE__ */ e(E, { ownerState: r, children: /* @__PURE__ */ e(V, { type: g, data: d, color: a }) })
|
|
52
95
|
]
|
|
53
96
|
}
|
|
54
97
|
)
|
|
@@ -56,5 +99,5 @@ const k = g.forwardRef(
|
|
|
56
99
|
}
|
|
57
100
|
);
|
|
58
101
|
export {
|
|
59
|
-
|
|
102
|
+
N as MetricCard
|
|
60
103
|
};
|