-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
494 lines (431 loc) · 22.7 KB
/
index.html
File metadata and controls
494 lines (431 loc) · 22.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Scaling: UNS vs. Middleware — Tobias Eberlein</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Outfit:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&display=swap');
:root{
--bg:#080a10;--s1:#0e1118;--s2:#151a24;--s3:#1c2230;
--border:#252d3e;--bhi:#3a4866;
--text:#b8bfcc;--dim:#5e6880;--bright:#dfe3ec;--white:#f0f2f6;
--blue:#3b82f6;--blue2:#60a5fa;--blueBg:rgba(59,130,246,.08);--blueBdr:rgba(59,130,246,.25);
--orange:#f59e0b;--orangeBg:rgba(245,158,11,.08);--orangeBdr:rgba(245,158,11,.25);
--green:#22c55e;--red:#ef4444;--purple:#a855f7;
--serif:'Instrument Serif',Georgia,serif;
--sans:'Outfit',system-ui,sans-serif;
--mono:'JetBrains Mono',monospace;
}
*{margin:0;padding:0;box-sizing:border-box}
body{background:var(--bg);color:var(--text);font-family:var(--sans)}
::selection{background:rgba(59,130,246,.3);color:var(--white)}
.page{max-width:1200px;margin:0 auto;padding:40px 24px 60px}
.hdr{text-align:center;margin-bottom:32px;position:relative}
.hdr .tag{font-family:var(--mono);font-size:10px;font-weight:700;letter-spacing:3px;text-transform:uppercase;color:var(--blue);margin-bottom:8px}
.hdr h1{font-family:var(--serif);font-size:clamp(26px,4vw,38px);color:var(--white);font-weight:400;line-height:1.2;margin-bottom:8px}
.hdr h1 em{font-style:italic;color:var(--blue2)}
.hdr p{font-size:14px;color:var(--dim);max-width:600px;margin:0 auto}
/* Language toggle */
.lang-toggle{position:absolute;top:0;right:0;display:flex;gap:0;background:var(--s1);border:1px solid var(--border);border-radius:6px;overflow:hidden}
.lang-btn{padding:6px 14px;font-family:var(--mono);font-size:10px;font-weight:700;border:none;background:transparent;color:var(--dim);cursor:pointer;transition:all .2s;letter-spacing:1px}
.lang-btn.act{background:var(--blue);color:#fff}
.lang-btn:hover:not(.act){color:var(--bright);background:var(--s2)}
.ctrl{display:flex;align-items:center;justify-content:center;gap:20px;padding:20px 28px;background:var(--s1);border:1px solid var(--border);border-radius:12px;margin-bottom:32px;flex-wrap:wrap}
.ctrl label{font-family:var(--mono);font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:1.5px;color:var(--dim)}
.ctrl input[type=range]{-webkit-appearance:none;width:280px;height:6px;border-radius:3px;background:var(--s3);outline:none}
.ctrl input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;width:22px;height:22px;border-radius:50%;background:var(--blue);cursor:pointer;border:3px solid var(--bg);box-shadow:0 0 12px rgba(59,130,246,.4)}
.ctrl .val{font-family:var(--mono);font-size:28px;font-weight:700;color:var(--white);min-width:50px;text-align:center}
.ctrl .val small{font-size:11px;color:var(--dim);font-weight:400;display:block}
.stats{display:grid;grid-template-columns:repeat(4,1fr);gap:10px;margin-bottom:32px}
.stat{background:var(--s1);border:1px solid var(--border);border-radius:8px;padding:12px 14px;text-align:center}
.stat .sv{font-family:var(--mono);font-size:22px;font-weight:700;color:var(--white)}
.stat .sl{font-size:10px;color:var(--dim);font-weight:600;text-transform:uppercase;letter-spacing:.5px;margin-top:2px}
.stat.hl{border-color:var(--blueBdr);background:var(--blueBg)}
.stat.warn{border-color:var(--orangeBdr);background:var(--orangeBg)}
.grid{display:grid;grid-template-columns:1fr 1fr;gap:20px;margin-bottom:20px}
.panel{background:var(--s1);border:1px solid var(--border);border-radius:10px;padding:18px;overflow:hidden}
.panel.full{grid-column:1/-1}
.panel-tag{font-family:var(--mono);font-size:9px;font-weight:700;text-transform:uppercase;letter-spacing:2px;margin-bottom:10px;display:flex;align-items:center;gap:6px}
.panel-tag .dot{width:7px;height:7px;border-radius:50%;flex-shrink:0}
.topo{display:flex;gap:0;height:360px}
.topo-side{flex:1;position:relative;padding:8px}
.topo-label{font-family:var(--mono);font-size:9px;font-weight:700;text-transform:uppercase;letter-spacing:1.5px;text-align:center;margin-bottom:8px;padding:4px 8px;border-radius:4px}
.topo-label.mw{color:var(--orange);background:rgba(245,158,11,.1)}
.topo-label.uns{color:var(--blue);background:rgba(59,130,246,.1)}
.topo-divider{width:1px;background:var(--border);margin:0 4px;flex-shrink:0}
svg.topo-svg{width:100%;height:300px}
.topo-count{font-family:var(--mono);font-size:11px;text-align:center;margin-top:6px;font-weight:600}
.topo-count span{font-weight:700;font-size:14px}
.topo-count.bad span{color:var(--red)}
.topo-count.good span{color:var(--green)}
.tree-container{height:360px;overflow-y:auto;overflow-x:hidden;position:relative;scrollbar-width:thin;scrollbar-color:var(--border) transparent}
.tree-container::-webkit-scrollbar{width:5px}
.tree-container::-webkit-scrollbar-track{background:transparent}
.tree-container::-webkit-scrollbar-thumb{background:var(--border);border-radius:3px}
.tree-container::-webkit-scrollbar-thumb:hover{background:var(--bhi)}
.tree-node{position:absolute;font-family:var(--mono);font-size:11px;padding:4px 10px;border-radius:4px;white-space:nowrap;transition:all .4s ease;opacity:0;transform:translateX(-10px)}
.tree-node.show{opacity:1;transform:translateX(0)}
.tree-node.root{background:var(--blue);color:#fff;font-weight:700;font-size:12px}
.tree-node.site{background:rgba(59,130,246,.15);color:var(--blue2);border:1px solid var(--blueBdr);font-size:11px}
.tree-node.line{background:rgba(34,197,94,.1);color:var(--green);border:1px solid rgba(34,197,94,.2);font-size:11px}
.tree-node.station{background:var(--s2);color:var(--dim);border:1px solid var(--border);font-size:10px}
.tree-node.ki{background:rgba(168,85,247,.1);color:var(--purple);border:1px solid rgba(168,85,247,.2);font-size:10px}
.chart-wrap{height:280px;position:relative}
canvas{width:100%!important;height:100%!important}
.chart-legend{display:flex;gap:16px;justify-content:center;margin-top:8px;flex-wrap:wrap}
.chart-legend .cl{display:flex;align-items:center;gap:5px;font-size:10px;color:var(--dim)}
.chart-legend .cl .cb{width:10px;height:10px;border-radius:2px}
.foot{text-align:center;padding:24px 0;border-top:1px solid var(--border);margin-top:20px;font-size:12px;color:var(--dim)}
.foot strong{color:var(--text)}
@media(max-width:800px){
.grid{grid-template-columns:1fr}
.stats{grid-template-columns:repeat(2,1fr)}
.topo{flex-direction:column;height:auto}
.topo-divider{width:100%;height:1px;margin:8px 0}
.lang-toggle{position:static;margin:0 auto 12px}
}
</style>
</head>
<body>
<div class="page">
<div class="hdr">
<div class="lang-toggle">
<button class="lang-btn act" data-lang="en" onclick="setLang('en')">EN</button>
<button class="lang-btn" data-lang="de" onclick="setLang('de')">DE</button>
</div>
<div class="tag" data-i="tag">Interactive Visualization</div>
<h1 data-i="title">From One Line to <em>n Lines</em></h1>
<p data-i="subtitle">How complexity, data points and integration effort change — UNS vs. Point-to-Point Middleware compared.</p>
</div>
<div class="ctrl">
<label data-i="sliderLabel">Production Lines</label>
<input type="range" id="slider" min="1" max="10" value="1">
<div class="val"><span id="numLines">1</span><small data-i="linesUnit">Lines</small></div>
</div>
<div class="stats">
<div class="stat hl"><div class="sv" id="stDp">500</div><div class="sl" data-i="statDp">Data Points</div></div>
<div class="stat"><div class="sv" id="stSt">5</div><div class="sl" data-i="statSt">Stations</div></div>
<div class="stat warn"><div class="sv" id="stMw">25</div><div class="sl" data-i="statMw">Middleware Connections</div></div>
<div class="stat hl"><div class="sv" id="stUns">1</div><div class="sl" data-i="statUns">UNS Broker</div></div>
</div>
<div class="grid">
<div class="panel full">
<div class="panel-tag"><span class="dot" style="background:var(--orange)"></span><span data-i="topoTag">Topology Comparison: Point-to-Point Middleware vs. Unified Namespace</span></div>
<div class="topo">
<div class="topo-side">
<div class="topo-label mw" data-i="mwLabel">Point-to-Point Middleware</div>
<svg class="topo-svg" id="svgMw"></svg>
<div class="topo-count bad" id="mwCount"><span data-i="connLabel">Connections</span>: <span id="mwVal">0</span></div>
</div>
<div class="topo-divider"></div>
<div class="topo-side">
<div class="topo-label uns" data-i="unsLabel">Unified Namespace</div>
<svg class="topo-svg" id="svgUns"></svg>
<div class="topo-count good" id="unsCount"><span data-i="connLabel2">Connections</span>: <span id="unsVal">0</span></div>
</div>
</div>
</div>
</div>
<div class="grid">
<div class="panel">
<div class="panel-tag"><span class="dot" style="background:var(--green)"></span><span data-i="treeTag">UNS Topic Tree — Grows With Every Line</span></div>
<div class="tree-container" id="treeContainer"></div>
</div>
<div class="panel">
<div class="panel-tag"><span class="dot" style="background:var(--blue)"></span><span data-i="chartTag">Scaling Comparison</span></div>
<div class="chart-wrap"><canvas id="chart"></canvas></div>
<div class="chart-legend">
<div class="cl"><div class="cb" style="background:var(--red)"></div><span data-i="legMw">Middleware Connections</span></div>
<div class="cl"><div class="cb" style="background:var(--blue)"></div><span data-i="legUns">UNS Connections</span></div>
<div class="cl"><div class="cb" style="background:var(--green)"></div><span data-i="legDp">Data Points (×100)</span></div>
</div>
</div>
</div>
<footer class="foot">© 2026 <strong>Tobias Eberlein</strong> — All rights reserved</footer>
</div>
<script>
// ═══ I18N ═══
const L = {
en: {
tag: "Interactive Visualization",
title: 'From One Line to <em>n Lines</em>',
subtitle: "How complexity, data points and integration effort change — UNS vs. Point-to-Point Middleware compared.",
sliderLabel: "Production Lines", linesUnit: "Lines",
statDp: "Data Points", statSt: "Stations", statMw: "Middleware Connections", statUns: "UNS Broker",
topoTag: "Topology Comparison: Point-to-Point Middleware vs. Unified Namespace",
mwLabel: "Point-to-Point Middleware", unsLabel: "Unified Namespace",
connLabel: "Connections", connLabel2: "Connections",
treeTag: "UNS Topic Tree — Grows With Every Line",
chartTag: "Scaling Comparison",
legMw: "Middleware Connections", legUns: "UNS Connections", legDp: "Data Points (×100)",
consumers: ["Dashboard","ERP","Historian","AI/ML","Analytics"],
more: "more", moreLines: "more lines"
},
de: {
tag: "Interaktive Visualisierung",
title: 'Von einer Linie zu <em>n Linien</em>',
subtitle: "Wie sich Komplexität, Datenpunkte und Integrationsaufwand verändern — UNS vs. Punkt-zu-Punkt-Middleware im Vergleich.",
sliderLabel: "Fertigungslinien", linesUnit: "Linien",
statDp: "Datenpunkte", statSt: "Stationen", statMw: "Middleware-Verbindungen", statUns: "UNS-Broker",
topoTag: "Topologie-Vergleich: Punkt-zu-Punkt-Middleware vs. Unified Namespace",
mwLabel: "Punkt-zu-Punkt-Middleware", unsLabel: "Unified Namespace",
connLabel: "Verbindungen", connLabel2: "Verbindungen",
treeTag: "UNS Topic-Baum — Wächst mit jeder Linie",
chartTag: "Skalierungsvergleich",
legMw: "Middleware-Verbindungen", legUns: "UNS-Verbindungen", legDp: "Datenpunkte (×100)",
consumers: ["Dashboard","ERP","Historian","KI/ML","Analytics"],
more: "mehr", moreLines: "weitere Linien"
}
};
let lang = 'en';
function setLang(l) {
lang = l;
document.querySelectorAll('.lang-btn').forEach(b => b.classList.toggle('act', b.dataset.lang === l));
document.querySelectorAll('[data-i]').forEach(el => {
const key = el.dataset.i;
if (L[l][key]) {
if (key === 'title') el.innerHTML = L[l][key];
else el.textContent = L[l][key];
}
});
update(+slider.value);
}
// ═══ CONFIG ═══
const STA_PER_LINE = 5, DP_PER_STA = 100, NUM_CONSUMERS = 5;
const slider = document.getElementById('slider');
const numLines = document.getElementById('numLines');
// ═══ TOPOLOGY: MIDDLEWARE ═══
function drawMiddleware(n) {
const svg = document.getElementById('svgMw');
const W = svg.clientWidth || 420, H = svg.clientHeight || 300;
svg.innerHTML = '';
svg.setAttribute('viewBox', `0 0 ${W} ${H}`);
const stations = n * STA_PER_LINE;
const srcX = 50, tgtX = W - 50;
const maxVis = Math.min(stations, 25);
const consumers = L[lang].consumers;
const consY = [];
for (let i = 0; i < NUM_CONSUMERS; i++) consY.push(35 + (H - 70) * i / (NUM_CONSUMERS - 1));
// Consumer boxes (right)
consY.forEach((y, i) => {
const r = svgEl('rect', {x:tgtX-34, y:y-9, width:68, height:18, rx:4, fill:'#1c2230', stroke:'#f59e0b', 'stroke-width':'1'});
svg.appendChild(r);
const t = svgEl('text', {x:tgtX, y:y+3, 'text-anchor':'middle', 'font-size':'7.5', 'font-family':'JetBrains Mono', fill:'#f59e0b'});
t.textContent = consumers[i]; svg.appendChild(t);
});
// Station dots + lines
for (let i = 0; i < maxVis; i++) {
const y = 16 + (H - 32) * i / Math.max(maxVis - 1, 1);
const lineIdx = Math.floor(i / STA_PER_LINE);
const lineColors = ['#f59e0b','#fb923c','#ef4444','#e879f9','#a855f7','#06b6d4','#84cc16','#22d3ee','#f472b6','#38bdf8'];
const dotColor = lineColors[lineIdx % lineColors.length];
// Connection lines — THICKER and more visible
consY.forEach(cy => {
const opacity = Math.max(0.08, 0.35 - n * 0.025);
const strokeW = Math.max(0.6, 1.5 - n * 0.08);
const line = svgEl('line', {x1:srcX+6, y1:y, x2:tgtX-38, y2:cy,
stroke:`rgba(239,68,68,${opacity})`, 'stroke-width':strokeW});
svg.appendChild(line);
});
// Station dot
const r = Math.max(3, 5.5 - n * 0.25);
svg.appendChild(svgEl('circle', {cx:srcX, cy:y, r:r, fill:dotColor}));
// Station label (only if few)
if (n <= 2) {
const t = svgEl('text', {x:srcX-r-4, y:y+3, 'text-anchor':'end', 'font-size':'6.5', 'font-family':'JetBrains Mono', fill:dotColor});
t.textContent = `S${(i%STA_PER_LINE)+1}`; svg.appendChild(t);
}
}
if (stations > maxVis) {
const t = svgEl('text', {x:srcX, y:H-4, 'text-anchor':'middle', 'font-size':'9', 'font-family':'JetBrains Mono', fill:'#ef4444', 'font-weight':'600'});
t.textContent = `+${stations - maxVis} ${L[lang].more}`; svg.appendChild(t);
}
document.getElementById('mwVal').textContent = stations * NUM_CONSUMERS;
}
// ═══ TOPOLOGY: UNS ═══
function drawUNS(n) {
const svg = document.getElementById('svgUns');
const W = svg.clientWidth || 420, H = svg.clientHeight || 300;
svg.innerHTML = '';
svg.setAttribute('viewBox', `0 0 ${W} ${H}`);
const cx = W / 2, cy = H / 2;
const stations = n * STA_PER_LINE;
const maxVis = Math.min(stations, 30);
const consumers = L[lang].consumers;
// Glow rings
svg.appendChild(svgEl('circle', {cx, cy, r:32, fill:'none', stroke:'rgba(59,130,246,0.08)', 'stroke-width':'12'}));
svg.appendChild(svgEl('circle', {cx, cy, r:24, fill:'none', stroke:'rgba(59,130,246,0.12)', 'stroke-width':'6'}));
// Station connections — left arc, THICKER
const stR = Math.max(75, 100 - n * 2.5);
const lineColors = ['#22c55e','#3b82f6','#f59e0b','#a855f7','#ec4899','#06b6d4','#f97316','#84cc16','#e879f9','#fb923c'];
for (let i = 0; i < maxVis; i++) {
const angle = Math.PI * 0.65 + Math.PI * 1.3 * i / Math.max(maxVis - 1, 1);
const x = cx + stR * Math.cos(angle);
const y = cy + stR * Math.sin(angle);
const lineIdx = Math.floor(i / STA_PER_LINE);
const col = lineColors[lineIdx % lineColors.length];
// Connection line — thick and visible
svg.appendChild(svgEl('line', {x1:x, y1:y, x2:cx, y2:cy,
stroke:col, 'stroke-opacity':'0.3', 'stroke-width': Math.max(1, 2 - n * 0.1)}));
// Station dot
const r = Math.max(3, 5 - n * 0.2);
svg.appendChild(svgEl('circle', {cx:x, cy:y, r:r, fill:col}));
}
// Central broker
svg.appendChild(svgEl('circle', {cx, cy, r:20, fill:'#0f1a2e', stroke:'#3b82f6', 'stroke-width':'2.5'}));
const bt = svgEl('text', {x:cx, y:cy+3.5, 'text-anchor':'middle', 'font-size':'9', 'font-family':'JetBrains Mono', 'font-weight':'700', fill:'#3b82f6'});
bt.textContent = 'UNS'; svg.appendChild(bt);
// Consumer connections — right arc, THICKER
const cR = 95;
consumers.forEach((label, i) => {
const angle = -Math.PI * 0.35 + Math.PI * 0.7 * i / (consumers.length - 1);
const x = cx + cR * Math.cos(angle);
const y = cy + cR * Math.sin(angle);
svg.appendChild(svgEl('line', {x1:cx, y1:cy, x2:x, y2:y,
stroke:'#3b82f6', 'stroke-opacity':'0.3', 'stroke-width':'1.5'}));
svg.appendChild(svgEl('rect', {x:x-30, y:y-8, width:60, height:16, rx:4, fill:'#151a24', stroke:'#3b82f6', 'stroke-width':'1'}));
const t = svgEl('text', {x, y:y+3, 'text-anchor':'middle', 'font-size':'7', 'font-family':'JetBrains Mono', fill:'#60a5fa'});
t.textContent = label; svg.appendChild(t);
});
// Line legend dots at bottom
if (n > 1) {
const legY = H - 12;
for (let l = 0; l < Math.min(n, 10); l++) {
const lx = cx - (Math.min(n,10) - 1) * 8 + l * 16;
svg.appendChild(svgEl('circle', {cx:lx, cy:legY, r:3.5, fill:lineColors[l]}));
const t = svgEl('text', {x:lx, y:legY+11, 'text-anchor':'middle', 'font-size':'6', 'font-family':'JetBrains Mono', fill:lineColors[l]});
t.textContent = `L${l+1}`; svg.appendChild(t);
}
}
document.getElementById('unsVal').textContent = stations + NUM_CONSUMERS;
}
function svgEl(tag, attrs) {
const el = document.createElementNS('http://www.w3.org/2000/svg', tag);
for (const [k, v] of Object.entries(attrs)) el.setAttribute(k, v);
return el;
}
// ═══ UNS TREE ═══
function drawTree(n) {
const container = document.getElementById('treeContainer');
container.innerHTML = '';
let y = 10;
const indent = 24, lineH = 24;
function add(text, level, cls, delay) {
const el = document.createElement('div');
el.className = `tree-node ${cls}`;
el.textContent = text;
el.style.left = (12 + level * indent) + 'px';
el.style.top = y + 'px';
el.style.transitionDelay = delay + 'ms';
container.appendChild(el);
setTimeout(() => el.classList.add('show'), 10);
y += lineH;
}
add('Company/', 0, 'root', 0);
add('SiteA/', 1, 'site', 40);
const maxL = Math.min(n, 6);
for (let l = 0; l < maxL; l++) {
add(`Line-${l + 1}/`, 2, 'line', 80 + l * 60);
if (n <= 3) {
['S1-Infeed/','S2-Press/','S3-Assembly/','S4-QC/','S5-Packing/'].forEach((s, si) => {
add(s, 3, 'station', 120 + l * 60 + si * 30);
});
if (n >= 2 && l === 0) {
add('AI/', 3, 'ki', 300 + l * 60);
add('PredMaint/ RUL_h → 342', 4, 'ki', 340 + l * 60);
}
} else if (n <= 6) {
add('S1-Infeed/', 3, 'station', 120 + l * 40);
add('S2-Press/', 3, 'station', 150 + l * 40);
add(`... +3 ${lang==='de'?'Stationen':'stations'}`, 3, 'station', 180 + l * 40);
}
}
if (n > 6) add(`... +${n - 6} ${L[lang].moreLines}`, 2, 'line', 400);
if (n >= 2) {
y += 8;
add('OEE/', 2, 'site', 500);
add(`Availability → ${(85 + Math.random() * 5).toFixed(1)}`, 3, 'station', 540);
}
// Set scroll height
const spacer = document.createElement('div');
spacer.style.height = (y + 20) + 'px';
container.appendChild(spacer);
}
// ═══ CHART ═══
let chartCanvas, chartCtx;
function initChart() { chartCanvas = document.getElementById('chart'); chartCtx = chartCanvas.getContext('2d'); }
function drawChart(currentN) {
const canvas = chartCanvas;
const dpr = window.devicePixelRatio || 1;
const rect = canvas.parentElement.getBoundingClientRect();
canvas.width = rect.width * dpr; canvas.height = 280 * dpr;
canvas.style.width = rect.width + 'px'; canvas.style.height = '280px';
const ctx = chartCtx; ctx.scale(dpr, dpr);
const W = rect.width, H = 280;
ctx.clearRect(0, 0, W, H);
const pad = {top:20, right:20, bottom:30, left:50};
const cw = W - pad.left - pad.right, ch = H - pad.top - pad.bottom;
const pts = [];
for (let i = 1; i <= 10; i++) {
const s = i * STA_PER_LINE;
pts.push({x:i, mw: s * NUM_CONSUMERS, uns: s + NUM_CONSUMERS, dp: s * DP_PER_STA / 100});
}
const maxY = Math.max(...pts.map(p => p.mw)) * 1.1;
const px = x => pad.left + (x - 1) / 9 * cw;
const py = y => pad.top + ch - (y / maxY) * ch;
// Grid
ctx.strokeStyle = '#1c2230'; ctx.lineWidth = 0.5;
for (let i = 0; i <= 5; i++) {
const yy = pad.top + ch * i / 5;
ctx.beginPath(); ctx.moveTo(pad.left, yy); ctx.lineTo(W - pad.right, yy); ctx.stroke();
ctx.fillStyle = '#5e6880'; ctx.font = '9px JetBrains Mono'; ctx.textAlign = 'right';
ctx.fillText(Math.round(maxY * (5 - i) / 5), pad.left - 8, yy + 3);
}
// X labels
ctx.textAlign = 'center';
for (let i = 1; i <= 10; i++) {
ctx.fillStyle = i === currentN ? '#f0f2f6' : '#5e6880';
ctx.font = i === currentN ? 'bold 10px JetBrains Mono' : '9px JetBrains Mono';
ctx.fillText(i + 'L', px(i), H - 8);
}
// Highlight column
ctx.fillStyle = 'rgba(59,130,246,0.06)';
ctx.fillRect(px(currentN) - cw / 20, pad.top, cw / 10, ch);
function drawLine(key, color, dash) {
ctx.beginPath(); ctx.strokeStyle = color; ctx.lineWidth = 2.5; ctx.setLineDash(dash || []);
pts.forEach((p, i) => { const x = px(p.x), y = py(p[key]); i === 0 ? ctx.moveTo(x, y) : ctx.lineTo(x, y); });
ctx.stroke(); ctx.setLineDash([]);
// Area fill
ctx.beginPath(); ctx.fillStyle = color.replace(')', ',0.06)').replace('rgb', 'rgba');
pts.forEach((p, i) => { const x = px(p.x), y = py(p[key]); i === 0 ? ctx.moveTo(x, y) : ctx.lineTo(x, y); });
ctx.lineTo(px(10), py(0)); ctx.lineTo(px(1), py(0)); ctx.closePath(); ctx.fill();
const cp = pts[currentN - 1];
ctx.beginPath(); ctx.arc(px(cp.x), py(cp[key]), 6, 0, Math.PI * 2);
ctx.fillStyle = color; ctx.fill();
ctx.beginPath(); ctx.arc(px(cp.x), py(cp[key]), 3.5, 0, Math.PI * 2);
ctx.fillStyle = '#080a10'; ctx.fill();
ctx.fillStyle = color; ctx.font = 'bold 11px JetBrains Mono'; ctx.textAlign = 'left';
ctx.fillText(Math.round(cp[key]), px(cp.x) + 10, py(cp[key]) + 4);
}
drawLine('mw', '#ef4444');
drawLine('uns', '#3b82f6');
drawLine('dp', '#22c55e', [4, 3]);
}
// ═══ UPDATE ═══
function update(n) {
numLines.textContent = n;
const stations = n * STA_PER_LINE;
document.getElementById('stDp').textContent = (stations * DP_PER_STA).toLocaleString(lang === 'de' ? 'de-DE' : 'en-US');
document.getElementById('stSt').textContent = stations;
document.getElementById('stMw').textContent = stations * NUM_CONSUMERS;
document.getElementById('stUns').textContent = stations + NUM_CONSUMERS;
drawMiddleware(n); drawUNS(n); drawTree(n); drawChart(n);
}
slider.addEventListener('input', () => update(+slider.value));
window.addEventListener('resize', () => update(+slider.value));
initChart();
setTimeout(() => update(1), 100);
</script>
</body>
</html>