poe-svelte-ui-lib 1.31.1 → 1.31.3
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/Graph/Graph.svelte
CHANGED
|
@@ -301,26 +301,35 @@
|
|
|
301
301
|
drawAllGraphs()
|
|
302
302
|
}
|
|
303
303
|
|
|
304
|
+
/* Прозрачность линий сетки — общая с PeriodChart (border-(--faint-color)/40) */
|
|
305
|
+
const GRID_ALPHA = 0.4
|
|
306
|
+
|
|
304
307
|
const drawAllGraphs = () => {
|
|
305
308
|
if (!ctx) return
|
|
306
309
|
ctx.clearRect(0, 0, width, height)
|
|
307
310
|
|
|
308
311
|
const { padding, graphWidth, graphHeight, minX, timeSpan, yMin, yMax, getX, getY } = computeGeometry()
|
|
309
312
|
|
|
310
|
-
/* Сетка
|
|
311
|
-
|
|
312
|
-
ctx.
|
|
313
|
-
ctx.
|
|
313
|
+
/* Сетка в стиле PeriodChart: пунктир цветом --faint-color темы, подписи тем же цветом без прозрачности */
|
|
314
|
+
const gridColor = getComputedStyle(canvas).getPropertyValue("--faint-color").trim() || "#8b93a1"
|
|
315
|
+
ctx.strokeStyle = gridColor
|
|
316
|
+
ctx.fillStyle = gridColor
|
|
317
|
+
ctx.lineWidth = 1
|
|
318
|
+
ctx.setLineDash([3, 3])
|
|
314
319
|
ctx.font = "10px monospace"
|
|
320
|
+
|
|
321
|
+
/* Сетка X */
|
|
315
322
|
ctx.textAlign = "center"
|
|
316
323
|
|
|
317
324
|
for (let i = 0; i <= 10; i++) {
|
|
318
325
|
const t = minX + (i / 10) * timeSpan
|
|
319
326
|
const x = getX(t)
|
|
327
|
+
ctx.globalAlpha = GRID_ALPHA
|
|
320
328
|
ctx.beginPath()
|
|
321
329
|
ctx.moveTo(x, padding.top)
|
|
322
330
|
ctx.lineTo(x, height - padding.bottom)
|
|
323
331
|
ctx.stroke()
|
|
332
|
+
ctx.globalAlpha = 1
|
|
324
333
|
ctx.textBaseline = "top"
|
|
325
334
|
ctx.fillText(formatAxisLabel(t, timeSpan), x, height - padding.bottom + 2)
|
|
326
335
|
}
|
|
@@ -332,12 +341,15 @@
|
|
|
332
341
|
for (let i = 0; i <= ySteps; i++) {
|
|
333
342
|
const yVal = yMax - (i * (yMax - yMin)) / ySteps
|
|
334
343
|
const y = getY(yVal)
|
|
344
|
+
ctx.globalAlpha = GRID_ALPHA
|
|
335
345
|
ctx.beginPath()
|
|
336
346
|
ctx.moveTo(padding.left, y)
|
|
337
347
|
ctx.lineTo(width - padding.right, y)
|
|
338
348
|
ctx.stroke()
|
|
349
|
+
ctx.globalAlpha = 1
|
|
339
350
|
ctx.fillText(yVal.toFixed(1), padding.left - 5, y)
|
|
340
351
|
}
|
|
352
|
+
ctx.setLineDash([])
|
|
341
353
|
|
|
342
354
|
/* Отрисовка графиков */
|
|
343
355
|
ctx.lineWidth = 2
|
|
@@ -80,23 +80,25 @@
|
|
|
80
80
|
<h5 class={twMerge("w-full text-[13px] font-semibold text-(--muted-color)", label.class)}>{label.name}</h5>
|
|
81
81
|
{/if}
|
|
82
82
|
|
|
83
|
-
<!-- Сегментированный переключатель
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
83
|
+
<!-- Сегментированный переключатель уровней: при одном уровне переключать нечего -->
|
|
84
|
+
{#if levels.length > 1}
|
|
85
|
+
<div class="flex w-full items-center gap-0.5 rounded-[10px] bg-(--container-color) p-[3px]">
|
|
86
|
+
{#each levels as level, index (level.name)}
|
|
87
|
+
<button
|
|
88
|
+
type="button"
|
|
89
|
+
class={twMerge(
|
|
90
|
+
"flex-1 cursor-pointer rounded-[7px] px-3 py-1.5 text-[13px] transition-colors duration-150",
|
|
91
|
+
index === currentLevelIndex
|
|
92
|
+
? "bg-(--back-color) font-semibold text-(--font-color) shadow-(--elevation-1)"
|
|
93
|
+
: "font-medium text-(--muted-color) hover:text-(--font-color)",
|
|
94
|
+
)}
|
|
95
|
+
onclick={() => selectLevel(index)}
|
|
96
|
+
>
|
|
97
|
+
{level.name}
|
|
98
|
+
</button>
|
|
99
|
+
{/each}
|
|
100
|
+
</div>
|
|
101
|
+
{/if}
|
|
100
102
|
|
|
101
103
|
<!-- Столбчатый график -->
|
|
102
104
|
<div class="relative flex w-full flex-col gap-1.5 rounded-[12px] border border-(--hairline-color) bg-(--back-color) p-3.5">
|
|
@@ -117,9 +119,7 @@
|
|
|
117
119
|
<div class="relative flex h-40 w-full items-end gap-1">
|
|
118
120
|
{#each axis.ticks as tick}
|
|
119
121
|
<div
|
|
120
|
-
class="pointer-events-none absolute inset-x-0 border-t {tick === 0
|
|
121
|
-
? 'border-(--hairline-color)'
|
|
122
|
-
: 'border-dashed border-(--hairline-color)/60'}"
|
|
122
|
+
class="pointer-events-none absolute inset-x-0 border-t {tick === 0 ? 'border-(--faint-color)/60' : 'border-dashed border-(--faint-color)/40'}"
|
|
123
123
|
style="bottom: {(tick / axis.top) * 100}%"
|
|
124
124
|
></div>
|
|
125
125
|
{/each}
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
| Название | Тип | По умолчанию | Описание |
|
|
14
14
|
| ------------------- | --------------------------------------------------- | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
15
15
|
| `id` | `string` | `crypto.randomUUID()` | Уникальный идентификатор компонента |
|
|
16
|
-
| `wrapperClass` | `string` | `""`
|
|
16
|
+
| `wrapperClass` | `string` | `""` | CSS-классы обёртки — через `bg-*` задаёт цвет переключателя и столбиков (по умолчанию нейтрально, без декоративной заливки) |
|
|
17
17
|
| `label` | `{ name?: string; class?: string }` | `{ name: "", class: "" }` | Заголовок над графиком |
|
|
18
|
-
| `levels` | `IPeriodChartLevel[]` | 4 демо-уровня со случайными данными | Уровни детализации, порядок = порядок вкладок переключателя; открывается всегда на первом (индекс 0)
|
|
18
|
+
| `levels` | `IPeriodChartLevel[]` | 4 демо-уровня со случайными данными | Уровни детализации, порядок = порядок вкладок переключателя; открывается всегда на первом (индекс 0); при одном уровне переключатель не показывается |
|
|
19
19
|
| `levels[].name` | `string` | `-` | Подпись вкладки, напр. `"Час"` |
|
|
20
20
|
| `levels[].variable` | `string` | `undefined` | Имя переменной устройства, откуда берутся `data` этого уровня, напр. `"PWR.EHour"` — используется конструктором для подписки, сам компонент по нему ничего не запрашивает |
|
|
21
21
|
| `levels[].data` | `number[]` | `-` | Значения — длина массива = число столбиков, ничем не ограничена |
|