Repository navigation
Expand file tree
/
Copy pathplugins.html
More file actions
1368 lines (1292 loc) · 92.4 KB
/
Copy pathplugins.html
File metadata and controls
1368 lines (1292 loc) · 92.4 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
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html lang="en" data-theme="dark">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>WickChart — Plugins</title>
<meta name="description" content="The wickchart plugin family: drawings, sessions, replay, animate, compare, navigator, alerts+, layouts, signals, tape, grid, paper, narrator, coview and scenario — each a zero-dependency opt-in package, documented with a live playground." />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet" />
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='1' y='1' width='22' height='22' rx='6' fill='%236366f1'/%3E%3Crect x='6' y='9' width='3.4' height='7' rx='1' fill='white'/%3E%3Crect x='14.5' y='7' width='3.4' height='5' rx='1' fill='white' opacity='.6'/%3E%3C/svg%3E" />
<!-- the narrator and briefing packages import their analyzers from
wickchart/core (and each other) via bare specifiers; this maps them
for the in-repo playgrounds (npm/bundler users get them from
node_modules instead) -->
<script type="importmap">
{ "imports": {
"wickchart/core": "./src/core.js",
"wickchart-signals/core": "./plugins/signals/core.mjs",
"wickchart-narrator/core": "./plugins/narrator/core.mjs"
} }
</script>
<script type="module" src="./src/wick-feed.js"></script>
<style>
:root {
--bg: #0d1117; --bg2: #11141c; --panel: #151a23; --panel2: #1a2130;
--border: rgba(230,237,243,.09); --border2: rgba(230,237,243,.16);
--text: #e6edf3; --muted: #8b949e; --muted2: #6e7681;
--accent: #6366f1; --accent2: #22d3ee; --up: #16c784; --down: #ea3943;
--code-bg: #0b0f16;
--font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
--mono: ui-monospace, 'SFMono-Regular', 'Cascadia Code', Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; }
body {
margin: 0; background: var(--bg); color: var(--text);
font: 400 14.5px/1.65 var(--font); -webkit-font-smoothing: antialiased;
}
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
font: 500 .86em var(--mono); background: var(--panel2);
border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px;
}
h1, h2, h3, h4 { line-height: 1.3; font-weight: 700; }
h2 { font-size: 21px; margin: 0 0 14px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
h3 { font-size: 15.5px; margin: 26px 0 8px; }
p { margin: 10px 0; } ul, ol { margin: 8px 0; padding-left: 22px; }
li { margin: 3px 0; }
.topbar {
position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 14px;
padding: 10px 22px; background: color-mix(in srgb, var(--bg) 86%, transparent);
backdrop-filter: blur(12px); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 15.5px; }
.brand b { background: linear-gradient(90deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-tag { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; }
.topbar nav { margin-left: auto; display: flex; gap: 16px; }
.topbar nav a { color: var(--muted); font-size: 13px; font-weight: 600; }
.topbar nav a:hover { color: var(--accent2); text-decoration: none; }
.layout { display: flex; align-items: flex-start; max-width: 1280px; margin: 0 auto; }
.side {
position: sticky; top: 53px; width: 250px; flex: 0 0 250px; height: calc(100vh - 53px);
overflow-y: auto; padding: 20px 12px 30px 20px; border-right: 1px solid var(--border);
scrollbar-width: thin;
}
.side input {
width: 100%; padding: 7px 10px; font: 500 12.5px var(--font); color: var(--text);
background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; outline: none;
}
.side input:focus { border-color: var(--accent); }
.toc { margin: 14px 0 0; padding: 0; list-style: none; }
.toc a {
display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
padding: 5px 10px; border-left: 2px solid transparent;
color: var(--muted); font-size: 13px; font-weight: 500; border-radius: 0 6px 6px 0;
}
.toc a:hover { color: var(--text); background: var(--panel2); text-decoration: none; }
.toc a.active { color: var(--accent2); border-left-color: var(--accent2); background: var(--panel2); }
.toc a.hidden { display: none; }
.toc .pkg {
font: 600 9.5px var(--mono); color: var(--muted2); white-space: nowrap;
}
main { flex: 1 1 auto; min-width: 0; padding: 26px 34px 90px; max-width: 900px; }
section { margin: 0 0 54px; scroll-margin-top: 76px; }
section > h2 > .anchor { color: var(--muted2); font-size: .8em; margin-left: 8px; opacity: 0; }
section > h2:hover > .anchor { opacity: 1; }
section > h2 > .size {
float: right; font: 600 10.5px var(--mono); color: var(--muted);
border: 1px solid var(--border); border-radius: 999px; padding: 2px 9px; margin-top: 4px;
}
table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 13px; }
th, td { text-align: left; padding: 7px 10px; border: 1px solid var(--border); vertical-align: top; }
th { background: var(--panel); font-weight: 700; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
td code { white-space: nowrap; }
.codewrap { position: relative; margin: 12px 0; }
pre.code {
margin: 0; padding: 13px 15px; overflow-x: auto; border-radius: 10px;
background: var(--code-bg); border: 1px solid var(--border);
font: 400 12.5px/1.6 var(--mono); color: #c9d1d9; scrollbar-width: thin;
}
pre.code .cmt { color: #6e7681; }
pre.code .tag { color: #7ee787; }
pre.code .attr { color: #79c0ff; }
pre.code .str { color: #a5d6ff; }
.copy-btn {
position: absolute; top: 7px; right: 7px; padding: 3px 10px; font: 600 11px var(--font);
color: var(--muted); background: var(--panel2); border: 1px solid var(--border);
border-radius: 6px; cursor: pointer; opacity: 0; transition: opacity 120ms ease;
}
.codewrap:hover .copy-btn { opacity: 1; }
.copy-btn:hover { color: var(--text); border-color: var(--border2); }
.copy-btn.done { color: var(--up); }
.demo-card {
margin: 16px 0; border: 1px solid var(--border); border-radius: 12px;
background: var(--bg2); overflow: hidden;
}
.demo-head {
display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
padding: 9px 14px; border-bottom: 1px solid var(--border); background: var(--panel);
}
.demo-head .t { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.demo-head .spacer { flex: 1; }
.demo-card wick-chart { display: block; height: 280px; }
.demo-card .foot {
padding: 8px 14px; font-size: 12px; color: var(--muted);
border-top: 1px solid var(--border); font-family: var(--mono); min-height: 20px;
}
button {
appearance: none; display: inline-flex; align-items: center; gap: 6px;
font: 600 12.5px var(--font); color: var(--text);
background: var(--panel2); border: 1px solid var(--border); border-radius: 8px;
padding: 6px 12px; min-height: 30px; cursor: pointer;
}
button:hover { border-color: var(--border2); }
button.primary { background: linear-gradient(90deg, var(--accent), #4f46e5); border-color: transparent; }
button.on { color: var(--accent2); border-color: var(--accent2); }
.seg { display: inline-flex; background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 2px; gap: 2px; }
.seg button { border: none; background: transparent; border-radius: 6px; padding: 4px 10px; min-height: 26px; }
.seg button.active { background: var(--bg); color: var(--accent2); }
input[type="text"] {
font: 500 12.5px var(--mono); color: var(--text); background: var(--code-bg);
border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; outline: none;
}
.pill {
display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .05em;
border-radius: 999px; padding: 2px 9px; border: 1px solid var(--border); color: var(--muted);
}
.pill.new { color: #0d1117; background: var(--accent2); border-color: transparent; }
.note {
border-left: 3px solid var(--accent); background: var(--panel);
padding: 9px 14px; border-radius: 0 8px 8px 0; margin: 12px 0; font-size: 13.5px; color: var(--muted);
}
.note b { color: var(--text); }
@media (max-width: 980px) {
/* see docs.html: without align-items: stretch the stacked <main> sizes
to its content, and the phone renders the whole page zoomed out */
.layout { flex-direction: column; align-items: stretch; }
.side { position: static; width: 100%; flex: none; height: auto; border-right: none; border-bottom: 1px solid var(--border); }
main { padding: 22px 18px 70px; max-width: none; min-width: 0; }
table { display: block; width: max-content; max-width: 100%; overflow-x: auto; }
.topbar { flex-wrap: wrap; row-gap: 4px; }
/* the demo cards clip their overflow, so a segmented control wider than
the phone loses its last buttons outright — wrap them instead */
.seg { flex-wrap: wrap; }
/* nav links were 21px tall — comfortably under a fingertip */
.topbar nav a { display: inline-flex; align-items: center; min-height: 36px; }
}
</style>
</head>
<body>
<header class="topbar">
<span class="brand">Wick<b>Chart</b></span>
<span class="brand-tag">plugins</span>
<nav>
<a href="./">Home</a>
<a href="./docs.html">Docs</a>
<a href="./demo/">Demo</a>
<a href="https://github.com/benyblack/wickchart">GitHub</a>
<a href="https://www.npmjs.com/package/wickchart">npm</a>
</nav>
</header>
<div class="layout">
<aside class="side">
<input id="toc-filter" type="text" placeholder="Filter plugins…" aria-label="Filter plugin sections" />
<ul class="toc" id="toc">
<li><a href="#start">Overview</a></li>
<li><a href="#draw">draw — drawing tools<span class="pkg">draw</span></a></li>
<li><a href="#sessions">sessions — market shading<span class="pkg">sessions</span></a></li>
<li><a href="#replay">replay — bar replay<span class="pkg">replay</span></a></li>
<li><a href="#animate">animate — live-price easing<span class="pkg">animate</span></a></li>
<li><a href="#compare">compare — overlays<span class="pkg">compare</span></a></li>
<li><a href="#navigator">navigator — range strip<span class="pkg">navigator</span></a></li>
<li><a href="#alerts">alerts+ — persistence<span class="pkg">alerts-plus</span></a></li>
<li><a href="#layouts">layouts — snapshots<span class="pkg">layouts</span></a></li>
<li><a href="#signals">signals — patterns<span class="pkg">signals</span></a></li>
<li><a href="#tape">tape — time & sales<span class="pkg">tape</span></a></li>
<li><a href="#grid">grid — multi-chart sync<span class="pkg">grid</span></a></li>
<li><a href="#paper">paper — paper trading<span class="pkg">paper</span></a></li>
<li><a href="#narrator">narrator — guided playback<span class="pkg">narrator</span></a></li>
<li><a href="#coview">coview — co-viewing<span class="pkg">coview</span></a></li>
<li><a href="#scenario">scenario — planning<span class="pkg">scenario</span></a></li>
<li><a href="#ai">ai — agent surface<span class="pkg">ai</span></a></li>
<li><a href="#briefing">briefing — explain the chart<span class="pkg">briefing</span></a></li>
</ul>
</aside>
<main>
<section id="start">
<h2>The plugin family <a class="anchor" href="#start">#</a> <span class="pill new">17 packages</span></h2>
<p>Everything here is an <b>opt-in package</b>, not core bytes: each plugin is a separate npm package, built only on wickchart's public <a href="./docs.html#plugins">layer API</a> and kept small by its own CI gzip budget — zero dependencies, except <a href="#briefing">briefing</a>, which deliberately composes two of its siblings. The core chart stays lean — you pay bytes only for what you attach, and everything detaches cleanly.</p>
<p>Every plugin follows the same shape: <code>attach</code> → configure → <code>detach</code>. Install any of them next to the chart:</p>
<div class="codewrap"><pre class="code"><span class="tag">npm</span> install wickchart wickchart-sessions <span class="cmt">// …or wickchart-draw, wickchart-tape, …</span>
<span class="tag">import</span> <span class="str">'wickchart'</span>; <span class="cmt">// the chart itself</span>
<span class="tag">import</span> { attachSessions } <span class="tag">from</span> <span class="str">'wickchart-sessions'</span>;
<span class="tag">const</span> sessions = <span class="attr">attachSessions</span>(chart, { preset: <span class="str">'crypto'</span> });</pre></div>
<p>…or straight from the CDN, no install: <code>import { attachTape } from 'https://unpkg.com/wickchart-tape'</code>.</p>
<table>
<tr><th>Package</th><th>One-liner</th><th>Size</th><th>Peer</th></tr>
<tr><td><a href="#draw">wickchart-draw</a></td><td>drawing tools — trendlines, levels, rects, fibs, text; JSON in/out</td><td>~8 KB</td><td>≥ 1.4</td></tr>
<tr><td><a href="#sessions">wickchart-sessions</a></td><td>market-session shading, DST-correct, presets or custom windows</td><td>6.3 KB</td><td>≥ 1.4</td></tr>
<tr><td><a href="#replay">wickchart-replay</a></td><td>bar replay — step/seek/play with the future hidden</td><td>3.1 KB</td><td>≥ 1.4</td></tr>
<tr><td><a href="#animate">wickchart-animate</a></td><td>live-price easing — ticks glide to their new close</td><td>2.3 KB</td><td>≥ 2.3</td></tr>
<tr><td><a href="#compare">wickchart-compare</a></td><td>normalized multi-symbol overlays with live legend chips</td><td>4.4 KB</td><td>≥ 1.4</td></tr>
<tr><td><a href="#navigator">wickchart-navigator</a></td><td>range navigator docked below the chart</td><td>3.2 KB</td><td>≥ 1.6</td></tr>
<tr><td><a href="#alerts">wickchart-alerts-plus</a></td><td>alert persistence, sound, desktop notifications, webhooks</td><td>2.7 KB</td><td>≥ 1.4</td></tr>
<tr><td><a href="#layouts">wickchart-layouts</a></td><td>named workspace snapshots — save/load/export full chart state</td><td>2.3 KB</td><td>≥ 1.4</td></tr>
<tr><td><a href="#signals">wickchart-signals</a></td><td>engulfing / pin bar / inside-bar badges with hover explanations</td><td>3.6 KB</td><td>≥ 1.4</td></tr>
<tr><td><a href="#tape">wickchart-tape</a></td><td>time & sales — live prints docked below the chart, trades→bars</td><td>4.6 KB</td><td>≥ 1.6</td></tr>
<tr><td><a href="#narrator">wickchart-narrator</a></td><td>guided playback — narrated timeline, bar-walk, sonification, story tours</td><td>8.6 KB</td><td>≥ 1.4</td></tr>
<tr><td><a href="#coview">wickchart-coview</a></td><td>cross-tab co-viewing — presence bands, shared crosshair, open protocol</td><td>5.0 KB</td><td>≥ 1.4</td></tr>
<tr><td><a href="#scenario">wickchart-scenario</a></td><td>planning — σ-cone projections, ghost paths, R-multiple risk plans</td><td>2.1 KB</td><td>≥ 1.4</td></tr>
<tr><td><a href="#ai">wickchart-ai</a></td><td>the chart as an LLM tool surface — manifest, prompt, validated ops</td><td>2.2 KB</td><td>≥ 1.4</td></tr>
<tr><td><a href="#briefing">wickchart-briefing</a></td><td>one command that explains the chart — the window as a markdown briefing</td><td>3.4 KB</td><td>≥ 1.4</td></tr>
</table>
<div class="note"><b>Dock note:</b> the navigator and the tape both dock through the 1.6 <code>insetBottom</code> hook and share the single strip at the bottom of the canvas — attach one or the other. Every playground below is live: click around.</div>
</section>
<section id="draw">
<h2>wickchart-draw <a class="anchor" href="#draw">#</a> <span class="size">~8 KB gz</span></h2>
<p>Drawing tools as a layer: <b>trendline / ray / infinite line</b>, <b>horizontal level</b>, <b>rectangle</b>, <b>fibonacci retracement</b> and <b>text notes</b> with an inline editor. Drawings are plain <code>{ time, price }</code> data — they ride zoom & pan, survive data reloads and serialize to JSON. Anchors magnet-snap to bar times and OHLC prices.</p>
<div class="codewrap"><pre class="code"><span class="tag">import</span> { attachDrawings } <span class="tag">from</span> <span class="str">'wickchart-draw'</span>;
<span class="tag">const</span> draw = <span class="attr">attachDrawings</span>(chart, { magnet: <span class="tag">true</span>, color: <span class="str">'#4c8dff'</span>, width: <span class="str">1.5</span> });
draw.<span class="attr">setTool</span>(<span class="str">'trendline'</span>); <span class="cmt">// arm a tool — dragging draws instead of panning</span>
draw.<span class="attr">setTool</span>(<span class="tag">null</span>); <span class="cmt">// select mode: click to select, drag to move/re-anchor</span>
draw.<span class="attr">getDrawings</span>(); <span class="cmt">// → JSON array (save it!); draw.setDrawings(saved)</span>
draw.<span class="attr">undo</span>(); draw.<span class="attr">clear</span>(); draw.<span class="attr">deleteSelected</span>();
draw.<span class="attr">setShare</span>(<span class="str">'team-room'</span>); <span class="cmt">// sync drawings across tabs (BroadcastChannel)</span>
chart.<span class="attr">addEventListener</span>(<span class="str">'wick:drawings'</span>, (e) => save(e.detail.drawings)); <span class="cmt">// { drawings, action }</span>
chart.<span class="attr">addEventListener</span>(<span class="str">'wick:drawselect'</span>, (e) => …); <span class="cmt">// { id }</span></pre></div>
<div class="demo-card">
<div class="demo-head">
<span class="t">Playground</span><span class="spacer"></span>
<span class="seg" id="draw-seg"></span>
<span id="draw-tools"></span>
</div>
<wick-feed for="ex-draw" demo="BTC" tf="1h" limit="400"></wick-feed>
<wick-chart id="ex-draw" label="BTC · 1h · drawings"></wick-chart>
<div class="foot" id="draw-foot">arm a tool and drag on the chart — anchors magnet-snap to bars & OHLC</div>
</div>
<div class="note">Delete/Backspace removes the selected drawing. The full tour — editor behavior, sharing across tabs, locked/hidden flags — lives in the <a href="./docs.html#drawing">Drawings chapter of the docs</a>.</div>
</section>
<section id="sessions">
<h2>wickchart-sessions <a class="anchor" href="#sessions">#</a> <span class="size">6.3 KB gz</span></h2>
<p>Translucent session bands under the price action: <b>crypto</b> (Asia / London / New York, UTC), <b>forex</b> (Tokyo / London / New York, UTC), <b>NYSE</b> and <b>CME</b> (real America/New_York / America/Chicago walls, DST-correct) — or fully custom windows. Optional closed-weekend tint and labels on each band. A passive crosshair bridge reports which session you're in; the layer never claims a pointer gesture.</p>
<div class="codewrap"><pre class="code"><span class="tag">import</span> { attachSessions } <span class="tag">from</span> <span class="str">'wickchart-sessions'</span>;
<span class="tag">const</span> s = <span class="attr">attachSessions</span>(chart, { preset: <span class="str">'nyse'</span> });
s.<span class="attr">setPreset</span>(<span class="str">'crypto'</span>); <span class="cmt">// 'crypto' | 'forex' | 'nyse' | 'cme'</span>
s.<span class="attr">setSessions</span>([{ name: <span class="str">'Lunch'</span>, days: <span class="str">[1,2,3,4,5]</span>, start: <span class="str">'12:00'</span>, end: <span class="str">'13:00'</span>, tz: <span class="str">'UTC'</span> }]);
s.<span class="attr">setLabels</span>(<span class="tag">false</span>); s.<span class="attr">setWeekends</span>(<span class="tag">false</span>); s.<span class="attr">setOpacity</span>(<span class="str">0.08</span>);
s.<span class="attr">detach</span>();
chart.<span class="attr">addEventListener</span>(<span class="str">'wick:sessions'</span>, (e) => …); <span class="cmt">// { hover: name | null }</span></pre></div>
<table>
<tr><th>Option / method</th><th>What it does</th></tr>
<tr><td><code>preset</code></td><td>crypto · forex · nyse · cme — nyse/cme use IANA timezones with exact DST math</td></tr>
<tr><td><code>setSessions(list)</code></td><td>custom bands <code>{ name, days, start, end, tz }</code> — <code>'24:00'</code> ends at midnight; times 'HH:MM'</td></tr>
<tr><td><code>setLabels / setWeekends / setOpacity</code></td><td>band labels on/off, closed-weekend tint on/off, band alpha (default 0.06)</td></tr>
</table>
<div class="demo-card">
<div class="demo-head">
<span class="t">Playground</span><span class="spacer"></span>
<span class="seg" id="sess-seg"></span>
</div>
<wick-feed for="ex-sess" demo="BTC" tf="1h" limit="400"></wick-feed>
<wick-chart id="ex-sess" label="BTC · 1h · sessions"></wick-chart>
<div class="foot" id="sess-foot">pick a preset — hourly data shows the intraday bands best</div>
</div>
</section>
<section id="replay">
<h2>wickchart-replay <a class="anchor" href="#replay">#</a> <span class="size">3.1 KB gz</span></h2>
<p>Bar replay on the public data API (<code>setData</code> + <code>update</code>) — the core stays replay-free. Start from any anchor (bar index, timestamp or date string — default ~70% of the dataset), then step or play while the future stays hidden. A badge shows the mode and position; loop mode wraps back to the anchor. If the dataset moves underneath (a live feed appends), replay aborts cleanly instead of corrupting state.</p>
<div class="codewrap"><pre class="code"><span class="tag">import</span> { attachReplay } <span class="tag">from</span> <span class="str">'wickchart-replay'</span>;
<span class="tag">const</span> r = <span class="attr">attachReplay</span>(chart, { speed: <span class="str">4</span> }); <span class="cmt">// bars per second, 0.5..60</span>
r.<span class="attr">start</span>(<span class="str">'2026-03-04'</span>); <span class="cmt">// index | ms | seconds | date string; omit → ~70%</span>
r.<span class="attr">step</span>(); r.<span class="attr">play</span>(); r.<span class="attr">pause</span>(); r.<span class="attr">stop</span>();
r.<span class="attr">setSpeed</span>(<span class="str">15</span>); r.<span class="attr">setLoop</span>(<span class="tag">true</span>); r.<span class="attr">seek</span>(<span class="str">250</span>);
r.<span class="attr">active</span>; r.<span class="attr">playing</span>; r.<span class="attr">index</span>; r.<span class="attr">total</span>; r.<span class="attr">remaining</span>; r.<span class="attr">detach</span>();
chart.<span class="attr">addEventListener</span>(<span class="str">'wick:replay'</span>, (e) => …); <span class="cmt">// { index, total, … }</span></pre></div>
<div class="demo-card">
<div class="demo-head">
<span class="t">Playground</span><span class="spacer"></span>
<span id="rep-btns"></span>
<span class="spacer"></span>
<span class="seg" id="rep-seg"></span>
</div>
<wick-feed for="ex-rep" demo="BTC" tf="1h" limit="400" live="false"></wick-feed>
<wick-chart id="ex-rep" label="BTC · 1h · replay"></wick-chart>
<div class="foot" id="rep-foot">start hides the last ~30% — step through it or press play (feed paused: replay aborts if the dataset moves underneath)</div>
</div>
</section>
<section id="animate">
<h2>wickchart-animate <a class="anchor" href="#animate">#</a> <span class="size">2.3 KB gz</span></h2>
<p>Live-price easing: ticks on the forming bar glide to their new close over a short ease instead of teleporting. The engine wraps <code>update()</code> on the instance, so every tick source — app code, <code><wick-feed></code>, paper — is eased without wiring, and it is display-path only (no drawing, no new core surface). Eased frames rewrite the forming bar's close, which the body, last-price line, axis label, legend and stats all derive from; the final frame always writes the true bar, a new bar flushes the previous bar's true value, backfills pass through un-eased, retargets mid-ease continue from the display value without jumping, and <code>prefers-reduced-motion</code> is a hard passthrough.</p>
<div class="codewrap"><pre class="code"><span class="tag">import</span> { attachAnimate } <span class="tag">from</span> <span class="str">'wickchart-animate'</span>;
<span class="tag">const</span> anim = <span class="attr">attachAnimate</span>(chart, { duration: <span class="str">180</span> }); <span class="cmt">// ms; 0 disables, max 1500</span>
<span class="cmt">// easing: 'ease-out' (default) | 'linear' | fn(t) — volume: true eases the histogram too</span>
anim.<span class="attr">detach</span>();</pre></div>
<div class="note"><b>Caveat:</b> eased frames are live ticks to the chart, so alert predicates and online indicator recompute see interpolated closes — the linear path between two real closes, at most <code>duration</code> of firing-time skew. Escape hatches: <code>duration: 0</code> or <code>detach()</code>. Peer dependency: wickchart ≥ 2.3.</div>
</section>
<section id="compare">
<h2>wickchart-compare <a class="anchor" href="#compare">#</a> <span class="size">4.4 KB gz</span></h2>
<p>Normalized multi-symbol overlays: up to six series, each drawn against its own invisible scale so the price axis is never distorted. Rebase to the <b>first visible close</b> (<code>'first'</code>) or re-rebase live while panning (<code>'visible'</code>); derived <b>ratio</b> and <b>diff</b> series compute A/B on the fly. Legend chips show each symbol's live percent change.</p>
<div class="codewrap"><pre class="code"><span class="tag">import</span> { attachCompare } <span class="tag">from</span> <span class="str">'wickchart-compare'</span>;
<span class="tag">const</span> cmp = <span class="attr">attachCompare</span>(chart);
cmp.<span class="attr">setSeries</span>([
{ label: <span class="str">'ETH'</span>, data: ethBars }, <span class="cmt">// explicit series</span>
{ label: <span class="str">'ETH/SOL'</span>, op: <span class="str">'ratio'</span>, a: <span class="str">'ETH'</span>, b: <span class="str">'SOL'</span> }, <span class="cmt">// derived from labeled ones</span>
]);
cmp.<span class="attr">setRebase</span>(<span class="str">'visible'</span>); <span class="cmt">// 'first' (default) | 'visible' — re-rebase while panning</span>
cmp.<span class="attr">clear</span>(); cmp.<span class="attr">detach</span>();</pre></div>
<div class="demo-card">
<div class="demo-head">
<span class="t">Playground</span><span class="spacer"></span>
<span class="seg" id="cmp-seg"></span>
<span class="spacer"></span>
<span class="seg" id="cmp-rebase"></span>
</div>
<wick-feed for="ex-cmp" demo="BTC" tf="1h" limit="400"></wick-feed>
<wick-chart id="ex-cmp" label="BTC · 1h · compare"></wick-chart>
<div class="foot" id="cmp-foot">overlay synthetic ETH / SOL against this chart — legend chips track the move</div>
</div>
</section>
<section id="navigator">
<h2>wickchart-navigator <a class="anchor" href="#navigator">#</a> <span class="size">3.2 KB gz</span></h2>
<p>The most-missed TradingView affordance: a silhouette of the whole dataset docks at the bottom of the canvas (through the 1.6 <code>insetBottom</code> hook — the chart shrinks above it) with a draggable viewport window. Drag the window to pan, grab an edge to resize, click outside it to jump. Panning/zooming the chart moves the window and vice versa — both stay in sync live.</p>
<div class="codewrap"><pre class="code"><span class="tag">import</span> { attachNavigator } <span class="tag">from</span> <span class="str">'wickchart-navigator'</span>;
<span class="tag">const</span> nav = <span class="attr">attachNavigator</span>(chart, { height: <span class="str">46</span> }); <span class="cmt">// 24..120 px</span>
nav.<span class="attr">height</span>; nav.<span class="attr">detach</span>();</pre></div>
<div class="demo-card">
<div class="demo-head">
<span class="t">Playground</span><span class="spacer"></span>
<span id="nav-btns"></span>
</div>
<wick-feed for="ex-nav" demo="BTC" tf="1h" limit="400"></wick-feed>
<wick-chart id="ex-nav" label="BTC · 1h · navigator"></wick-chart>
<div class="foot" id="nav-foot">drag the window, grab an edge, or click outside it — the chart follows</div>
</div>
<div class="note">Peer: <b>wickchart ≥ 1.6</b> (the <code>insetBottom</code> dock hook). Shares the bottom strip with wickchart-tape — attach one or the other.</div>
</section>
<section id="alerts">
<h2>wickchart-alerts-plus <a class="anchor" href="#alerts">#</a> <span class="size">2.7 KB gz</span></h2>
<p>The pro tier for alerts. Core alerts are runtime-only by design; this plugin mirrors them into any storage (localStorage by default) at save points — adds, removes, fires, <code>sync()</code>, <code>detach()</code> — and re-arms them on reload. When a tab is hidden the browser notification covers it; a two-tone WebAudio beep and a webhook POST ride along.</p>
<div class="codewrap"><pre class="code"><span class="tag">import</span> { attachAlertsPlus } <span class="tag">from</span> <span class="str">'wickchart-alerts-plus'</span>;
<span class="tag">const</span> ap = <span class="attr">attachAlertsPlus</span>(chart, {
key: <span class="str">'my-alerts'</span>, <span class="cmt">// storage key (localStorage by default)</span>
notify: <span class="tag">true</span>, sound: <span class="tag">true</span>, <span class="cmt">// hidden-tab Notification + WebAudio beep</span>
webhook: <span class="str">'https://…'</span>, <span class="cmt">// POST { id, price, when, time, bar, key }</span>
});
ap.<span class="attr">add</span>({ price: <span class="str">100</span>, direction: <span class="str">'above'</span> }); <span class="cmt">// → chart.addAlert + persisted</span>
ap.<span class="attr">add</span>({ when: <span class="str">'rsi(close,14) < 30'</span> }); <span class="cmt">// scripted alerts too</span>
ap.<span class="attr">remove</span>(id); ap.<span class="attr">clear</span>(); ap.<span class="attr">list</span>(); ap.<span class="attr">sync</span>();
ap.<span class="attr">requestNotify</span>(); <span class="cmt">// ask once for the notification permission</span>
ap.<span class="attr">detach</span>();</pre></div>
<div class="demo-card">
<div class="demo-head">
<span class="t">Playground</span><span class="spacer"></span>
<span id="alr-btns"></span>
</div>
<wick-feed for="ex-alr" demo="BTC" tf="1h" limit="400"></wick-feed>
<wick-chart id="ex-alr" label="BTC · 1h · alerts+"></wick-chart>
<div class="foot" id="alr-foot">add a few alerts, then reload the page — they re-arm themselves</div>
</div>
<div class="note">This playground persists under the key <code>wick-docs-alerts</code> — reload and they come back. Notifications/sound are off here to keep the docs quiet; the demo page shows them on.</div>
</section>
<section id="layouts">
<h2>wickchart-layouts <a class="anchor" href="#layouts">#</a> <span class="size">2.3 KB gz</span></h2>
<p>Named workspace snapshots: save the whole setup — type, indicators, theme, view, positions, alerts (plus the drawing list when wickchart-draw is attached) — under a name, and restore it later. Deterministic newest-first ordering via a persisted monotonic sequence; cap of 20 layouts with oldest-eviction; export/import as JSON for sharing. In-memory by default, any storage via <code>key</code>.</p>
<div class="codewrap"><pre class="code"><span class="tag">import</span> { attachLayouts } <span class="tag">from</span> <span class="str">'wickchart-layouts'</span>;
<span class="tag">const</span> layouts = <span class="attr">attachLayouts</span>(chart, { drawings: draw, key: <span class="str">'my-layouts'</span> });
layouts.<span class="attr">save</span>(<span class="str">'swing setup'</span>);
layouts.<span class="attr">load</span>(<span class="str">'swing setup'</span>);
layouts.<span class="attr">rename</span>(<span class="str">'swing setup'</span>, <span class="str">'main'</span>); layouts.<span class="attr">delete</span>(<span class="str">'main'</span>);
layouts.<span class="attr">list</span>(); <span class="cmt">// → [{ name, at, drawingCount }] newest first</span>
layouts.<span class="attr">export</span>(); layouts.<span class="attr">import</span>(json);
layouts.<span class="attr">detach</span>();
chart.<span class="attr">addEventListener</span>(<span class="str">'wick:layouts'</span>, (e) => …); <span class="cmt">// { action, name }</span></pre></div>
<div class="demo-card">
<div class="demo-head">
<span class="t">Playground</span><span class="spacer"></span>
<span id="lay-btns"></span>
</div>
<wick-feed for="ex-lay" demo="BTC" tf="1h" limit="400"></wick-feed>
<wick-chart id="ex-lay" label="BTC · 1h · layouts"></wick-chart>
<div class="foot" id="lay-foot">change something — type, an indicator, the theme — then save & reload it</div>
</div>
</section>
<section id="signals">
<h2>wickchart-signals <a class="anchor" href="#signals">#</a> <span class="size">3.6 KB gz</span></h2>
<p>Candlestick pattern badges: <b>engulfing</b> (<code>E</code>), <b>pin bars</b> (<code>P</code> — hammer / shooting star) and <b>inside bars</b> (<code>IB</code>) drawn as direction-colored chips above/below the bar. Hover a badged bar and the plugin draws the explanation and fires <code>wick:signals</code> — the same passive crosshair bridge as sessions, so gestures stay native. Detection is O(n) and cached per dataset + kind subset.</p>
<div class="codewrap"><pre class="code"><span class="tag">import</span> { attachSignals } <span class="tag">from</span> <span class="str">'wickchart-signals'</span>;
<span class="tag">const</span> sig = <span class="attr">attachSignals</span>(chart, { kinds: [] }); <span class="cmt">// start off — arm from your UI</span>
sig.<span class="attr">setKinds</span>([<span class="str">'engulfing'</span>, <span class="str">'pinbar'</span>]); <span class="cmt">// subset; [] = off; omit = all three</span>
sig.<span class="attr">setLabels</span>(<span class="tag">false</span>); <span class="cmt">// hover explanations off</span>
sig.<span class="attr">count</span>; sig.<span class="attr">kinds</span>; sig.<span class="attr">detach</span>();
chart.<span class="attr">addEventListener</span>(<span class="str">'wick:signals'</span>, (e) => …); <span class="cmt">// { index, time, signals, label }</span></pre></div>
<div class="demo-card">
<div class="demo-head">
<span class="t">Playground</span><span class="spacer"></span>
<span class="seg" id="sig-seg"></span>
</div>
<wick-feed for="ex-sig" demo="BTC" tf="1h" limit="400"></wick-feed>
<wick-chart id="ex-sig" label="BTC · 1h · signals"></wick-chart>
<div class="foot" id="sig-foot">off by default — arm kinds, then hover a badge for the explanation</div>
</div>
</section>
<section id="tape">
<h2>wickchart-tape <a class="anchor" href="#tape">#</a> <span class="size">4.6 KB gz</span></h2>
<p>Time & sales: a live trade-print strip docked at the bottom of the canvas — <code>time · price · size</code> rows colored by side, proportional size bars, oversized prints (<code>bigSize</code>) highlighting their row. Prints carry an optional side; without one the classic <b>tick rule</b> fills it in (uptick → buy, downtick → sell), carried across pushes. The same stream drives the chart: <code>chart.setData(tape.toBars(60000))</code>.</p>
<div class="codewrap"><pre class="code"><span class="tag">import</span> { attachTape } <span class="tag">from</span> <span class="str">'wickchart-tape'</span>;
<span class="tag">const</span> tape = <span class="attr">attachTape</span>(chart, { rows: <span class="str">7</span>, bigSize: <span class="str">50</span> });
socket.<span class="attr">onmessage</span> = (m) => tape.<span class="attr">push</span>(m.trades); <span class="cmt">// single print or batch</span>
tape.<span class="attr">set</span>(backfill); <span class="cmt">// history backfill (resets the tick rule)</span>
tape.<span class="attr">setRows</span>(<span class="str">4</span>); <span class="cmt">// 3..8 — resizes the dock live</span>
tape.<span class="attr">hide</span>(); tape.<span class="attr">show</span>(); <span class="cmt">// hiding frees the docked space entirely</span>
tape.<span class="attr">trades</span>; <span class="cmt">// normalized prints, newest last (cap 500)</span>
tape.<span class="attr">toBars</span>(<span class="str">60000</span>); <span class="cmt">// prints → OHLCV bars, chart-ready</span>
tape.<span class="attr">clear</span>(); tape.<span class="attr">detach</span>();
chart.<span class="attr">addEventListener</span>(<span class="str">'wick:tape'</span>, (e) => …); <span class="cmt">// { action, added?, total }</span></pre></div>
<div class="demo-card">
<div class="demo-head">
<span class="t">Playground</span><span class="spacer"></span>
<span id="tape-btns"></span>
<span class="spacer"></span>
<span class="seg" id="tape-rows"></span>
</div>
<wick-feed for="ex-tape" demo="BTC" tf="1h" limit="400"></wick-feed>
<wick-chart id="ex-tape" label="BTC · 1h · tape"></wick-chart>
<div class="foot" id="tape-foot">attach to start a synthetic print stream — feed real ones via tape.push()</div>
</div>
<div class="note">Peer: <b>wickchart ≥ 1.6</b>. Shares the bottom dock with the navigator. The pure model (normalization, tick rule, <code>tradesToBars</code>, formatting) is a separate import: <code>wickchart-tape/core</code>.</div>
</section>
<section id="grid">
<h2>wickchart-grid <a class="anchor" href="#grid">#</a> <span class="size">4.4 KB gz</span></h2>
<p>Multi-chart layout + sync: one element lays N charts out in a CSS grid and keeps their <b>visible ranges and crosshairs in step</b> — pan or zoom any chart and the others follow; hover one and a dashed ghost crosshair mirrors onto the rest. Everything rides the core's public <code>wick:range</code> / <code>wick:crosshair</code> events, <code>setVisibleRange()</code> and the layer API; the fan-out swallows its own echoes and breaks clamp feedback loops, so sparse charts converge instead of ping-ponging.</p>
<div class="codewrap"><pre class="code"><span class="tag"><wick-grid</span> <span class="attr">cols</span>=<span class="str">"2"</span> <span class="attr">sync</span>=<span class="str">"range crosshair"</span> <span class="attr">style</span>=<span class="str">"height: 640px"</span><span class="tag">></span>
<span class="tag"><wick-chart</span> <span class="attr">label</span>=<span class="str">"BTC · 1h"</span> <span class="attr">indicators</span>=<span class="str">"sma:20"</span><span class="tag">></wick-chart></span>
<span class="tag"><wick-chart</span> <span class="attr">label</span>=<span class="str">"BTC · 15m"</span> <span class="attr">indicators</span>=<span class="str">"rsi:14"</span><span class="tag">></wick-chart></span>
<span class="tag"></wick-grid></span>
<span class="cmt">// or programmatically, on charts you already lay out:</span>
<span class="tag">import</span> { attachGrid } <span class="tag">from</span> <span class="str">'wickchart-grid'</span>;
<span class="tag">const</span> grid = <span class="attr">attachGrid</span>([a, b, c], { <span class="attr">sync</span>: <span class="str">'range time'</span> });
grid.<span class="attr">detach</span>(); <span class="cmt">// unsync, ghost layers removed</span></pre></div>
<p>Attributes: <code>cols</code> (default 2, clamped 1..8), <code>gap</code> (px, default 10), <code>sync</code> — a list of <code>range</code> (shared visible window), <code>crosshair</code> (time + price ghost lines), <code>time</code> (vertical line only — for grids whose price scales are not comparable), <code>both</code>; default <code>range crosshair</code>. The host needs a height: grid rows size from it.</p>
<div class="demo-card">
<div class="demo-head">
<span class="t">Playground</span><span class="spacer"></span>
<span class="seg" id="grid-sync"></span>
</div>
<wick-feed for="ex-g1" demo="BTC" tf="1h" limit="400"></wick-feed>
<wick-feed for="ex-g2" demo="ETH" tf="15m" limit="400"></wick-feed>
<wick-grid id="ex-grid" cols="2" gap="8" style="height: 380px">
<wick-chart id="ex-g1" label="BTC · 1h"></wick-chart>
<wick-chart id="ex-g2" label="ETH · 15m" type="line"></wick-chart>
</wick-grid>
<div class="foot" id="grid-foot">pan or hover one chart — the other follows (time-only sync by default: BTC and ETH prices aren't comparable)</div>
</div>
<div class="note">Peer: <b>wickchart ≥ 1.4</b>. The pure fan-out model (echo suppression, clamp-cycle breaking, the ghost crosshair layer) is a separate import: <code>wickchart-grid/core</code>.</div>
</section>
<section id="paper">
<h2>wickchart-paper <a class="anchor" href="#paper">#</a> <span class="size">6.2 KB gz</span></h2>
<p>Paper trading on top of <a href="#replay">wickchart-replay</a>: place orders while the tape plays forward and watch them fill at honest prices — a market order placed while paused fills at the <b>next bar's open</b> (you can never trade a close you already saw), limits fill at the limit unless the open gaps through them. The session's equity curve docks under the chart (fills as dots, starting-cash baseline, max drawdown), and the open position mirrors onto the core positions API as an entry line with live P&L. Seeking back resets the session.</p>
<div class="codewrap"><pre class="code"><span class="tag">import</span> { attachReplay } <span class="tag">from</span> <span class="str">'wickchart-replay'</span>;
<span class="tag">import</span> { attachPaper } <span class="tag">from</span> <span class="str">'wickchart-paper'</span>;
<span class="tag">const</span> replay = <span class="attr">attachReplay</span>(chart);
<span class="tag">const</span> paper = <span class="attr">attachPaper</span>(chart, { <span class="attr">cash</span>: <span class="num">10000</span>, <span class="attr">fee</span>: <span class="num">0.0004</span> });
replay.<span class="attr">start</span>(); <span class="cmt">// ~70% into the data, future hidden</span>
paper.<span class="attr">buy</span>(<span class="num">1</span>); <span class="cmt">// queued — fills at the NEXT bar's open</span>
paper.<span class="attr">flatten</span>(); <span class="cmt">// market-close the whole position</span>
paper.<span class="attr">stats</span>; <span class="cmt">// equity, realized, trades, winRate, maxDD</span></pre></div>
<p>Signed quantities net and flip (sell 5 against a long of 2 closes it and opens a short of 3); adds average the entry; fees come off cash per fill. Events on the chart: <code>wick:paper</code> (<code>order / fill / close / cancel / reset</code>). The engine is pure data in / data out — <code>wickchart-paper/core</code> — usable for backtests with no DOM at all.</p>
<div class="demo-card">
<div class="demo-head">
<span class="t">Playground</span>
<span id="paper-btns"></span><span class="spacer"></span>
<span class="seg" id="paper-ctl"></span>
</div>
<wick-feed for="ex-paper" demo="BTC" tf="1h" limit="400"></wick-feed>
<wick-chart id="ex-paper" label="BTC · 1h · paper"></wick-chart>
<div class="foot" id="paper-foot">start the tape, then long / short / flatten — fills land on the equity strip below the axis</div>
</div>
<div class="note">Peer: <b>wickchart ≥ 1.4</b>, pairs with <b>wickchart-replay</b>. Shares the bottom dock with the navigator and tape (attach one at a time for a clean strip).</div>
</section>
<section id="narrator">
<h2>wickchart-narrator <a class="anchor" href="#narrator">#</a> <span class="size">8.6 KB gz</span></h2>
<p>Guided playback: the chart as a story. <b>narrate()</b> turns a window into an ordered timeline — pivot highs/lows, volume spikes, gaps, RSI divergences and derived legs ("+12.4% over 38 bars"). <b>walk()</b> slides the viewport through history while <code>wick:walk</code> events announce each step's events; <b>playRange()</b> and the <code>sonify</code> attribute make the same data audible (a pitch sweep of the visible bars, one blip per crosshair bar); <b>captureScene() / playStory()</b> record chart state as scenes and replay them as a narrated tour — camera eases, indicators flip, scenarios set and clear. Any user input interrupts playback.</p>
<div class="codewrap"><pre class="code"><span class="tag">import</span> { attachNarrator } <span class="tag">from</span> <span class="str">'wickchart-narrator'</span>;
<span class="tag">const</span> narrator = <span class="attr">attachNarrator</span>(chart); <span class="cmt">// methods land on the instance</span>
chart.<span class="attr">narrate</span>({ from, to }); <span class="cmt">// the event timeline</span>
chart.<span class="attr">walk</span>({ from: <span class="str">0</span>, speed: <span class="str">120</span> }); <span class="cmt">// narrated viewport replay</span>
chart.<span class="attr">stopWalk</span>(); <span class="cmt">// any pointer/wheel/key input stops it too</span>
chart.<span class="attr">playRange</span>(); <span class="cmt">// ~4s pitch sweep (needs a click first)</span>
<span class="tag">const</span> tour = [
chart.<span class="attr">captureScene</span>(<span class="str">'Overview'</span>, <span class="str">'The full picture'</span>),
{ <span class="attr">title</span>: <span class="str">'The breakout'</span>, <span class="attr">range</span>: { from, to }, <span class="attr">indicators</span>: <span class="str">'sma:20'</span> },
];
chart.<span class="attr">playStory</span>(tour, { <span class="attr">loop</span>: <span class="str">true</span> }); <span class="cmt">// wick:story narrates each scene</span>
narrator.<span class="attr">detach</span>();
chart.<span class="attr">addEventListener</span>(<span class="str">'wick:walk'</span>, (e) => …); <span class="cmt">// { phase: step|end|stop, index, events }</span></pre></div>
<p>Scenes are plain data — title, note, a time <code>range</code>, <code>indicators</code>, series <code>type</code>, <code>overlays</code>, <code>scenario</code>/<code>riskPlan</code> (or <code>null</code> to clear) and a <code>dwell</code> — capped at 20, junk dropped, dwell clamped to 500–30000 ms; <code>playStory(story, { dwell, panMs, loop })</code> eases the camera between them and <code>stopStory()</code> / <code>getStory()</code> control the tour. Events: <code>wick:walk</code> <code>{ phase: 'step'|'end'|'stop', index, events, from, to }</code> and <code>wick:story</code> <code>{ phase: 'scene'|'end'|'stop', index, total, scene, title, note }</code>. Timeline entries carry <code>{ i, time, type, side, note, legPct?, legBars? }</code>, sorted and capped at 60; <code>walk({ from, to, speed, step })</code> any user input interrupts. The walk is a local replay of real history, not a projection — see <a href="#scenario">scenario</a> for what-ifs; during a walk the chart broadcasts its moving viewport over <a href="#coview">co-view</a>, so peers watch the tour with you. First package of the 2.0 split: attaching shadows the core's own identical methods until 2.0 removes them.</p>
<div class="demo-card">
<div class="demo-head">
<span class="t">Playground</span><span class="spacer"></span>
<span id="nar-btns"></span>
</div>
<wick-feed for="ex-nar" demo="BTC" tf="1h" limit="400"></wick-feed>
<wick-chart id="ex-nar" label="BTC · 1h · narrator"></wick-chart>
<div class="foot" id="nar-foot">walk replays history with live captions — the tour eases through three scenes; touching the chart interrupts either</div>
</div>
<div class="note">Peer: <b>wickchart ≥ 1.4</b> (the one family member that imports <code>wickchart/core</code> — from a CDN, map that specifier with an import map). Part of the <a href="https://github.com/benyblack/wickchart/blob/main/ROADMAP-V2.md">2.0 plan</a>.</div>
</section>
<section id="coview">
<h2>wickchart-coview <a class="anchor" href="#coview">#</a> <span class="size">5.0 KB gz</span></h2>
<p>Cross-tab co-viewing: charts that share a room name (<code>co-view="btc-warroom"</code>) keep each other briefed. Every pan/zoom broadcasts the visible window (throttled to ~8/s, heartbeat every 4 s), each chart renders the others' viewports as <b>labeled bands</b> along the top of the plot, and the <b>crosshair is shared live</b> — a dashed ghost mirrors the pointer of the tab you are pairing with. Closed tabs say goodbye; crashed tabs fade via the 12 s presence TTL.</p>
<div class="codewrap"><pre class="code"><span class="tag"><wick-chart</span> <span class="attr">co-view</span>=<span class="str">"btc-warroom"</span> <span class="attr">co-view-name</span>=<span class="str">"Maya"</span><span class="tag">></wick-chart></span>
<span class="tag">import</span> { attachCoview } <span class="tag">from</span> <span class="str">'wickchart-coview'</span>;
<span class="tag">const</span> coview = <span class="attr">attachCoview</span>(chart);
chart.<span class="attr">getPeers</span>(); <span class="cmt">// [{ id, name: 'Maya', range: {from,to}, at }]</span>
chart.<span class="attr">addEventListener</span>(<span class="str">'wick:peers'</span>, (e) => …); <span class="cmt">// { peers, joined, left }</span>
coview.<span class="attr">detach</span>();
<span class="cmt">// the protocol is public — anything that can postMessage can join:</span>
<span class="cmt">// channel "wick-co-view:<room>", messages { v: 1, peer, type: view|cross|bye }</span></pre></div>
<p>Membership events fire on join and leave only — not on every move. Wrong-version, self-echoed and unknown messages are ignored by construction. Transport is same-origin <code>BroadcastChannel</code> — tabs, windows, and multiple charts on one page; presence never leaves the browser. To sync across the network, forward the core's public <code>wick:range</code> events through your own WebSocket and replay them — the plugin ships no network code. The presence tracker and the protocol envelope are pure and DOM-free: <code>wickchart-coview/core</code> (<code>PresenceTracker</code>, <code>coWrap</code>/<code>coUnwrap</code>) — reusable over WebSockets. Second package of the 2.0 split; attaching shadows the core's identical machinery until 2.0 removes it.</p>
<div class="demo-card">
<div class="demo-head">
<span class="t">Playground</span><span class="spacer"></span>
<span id="cv-btns"></span>
</div>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 8px">
<wick-feed for="ex-cv1" demo="BTC" tf="1h" limit="400"></wick-feed>
<wick-feed for="ex-cv2" demo="ETH" tf="1h" limit="400"></wick-feed>
<wick-chart id="ex-cv1" label="BTC · 1h · coview"></wick-chart>
<wick-chart id="ex-cv2" label="ETH · 1h · coview"></wick-chart>
</div>
<div class="foot" id="cv-foot">pair the charts — each shows the other's viewport as a band; hovering one drives the dashed ghost on the other</div>
</div>
<div class="note">Peer: <b>wickchart ≥ 1.4</b>. Self-contained — imports nothing from wickchart. Works across tabs of the same browser (BroadcastChannel); rooms are per-origin. Part of the <a href="https://github.com/benyblack/wickchart/blob/main/ROADMAP-V2.md">2.0 plan</a>.</div>
</section>
<section id="scenario">
<h2>wickchart-scenario <a class="anchor" href="#scenario">#</a> <span class="size">2.1 KB gz</span></h2>
<p>Planning surfaces drawn straight onto the chart. <b>Scenario projections</b>: a ghost path of future prices plus σ-bands — a volatility cone widening with √h from realized volatility — with future space reserved on the right so the projection stays visible. <b>Risk plans</b>: an R-multiple grid anchored at entry/stop (1R = |entry − stop|, direction derived), reward lines at kR with risk/reward zones shaded, so sizing and take-profit choices read directly off the chart.</p>
<div class="codewrap"><pre class="code"><span class="tag">import</span> { attachScenario } <span class="tag">from</span> <span class="str">'wickchart-scenario'</span>;
<span class="tag">const</span> scenario = <span class="attr">attachScenario</span>(chart); <span class="cmt">// methods land on the instance</span>
chart.<span class="attr">setScenario</span>({ <span class="attr">path</span>: [<span class="str">64000</span>, <span class="str">65500</span>, <span class="str">68000</span>], <span class="attr">label</span>: <span class="str">'bull case'</span> });
chart.<span class="attr">setScenario</span>({ <span class="attr">horizon</span>: <span class="str">48</span> }); <span class="cmt">// cone-only projection</span>
chart.<span class="attr">scenario</span>; <span class="cmt">// a copy of the active one</span>
chart.<span class="attr">setRiskPlan</span>({ <span class="attr">entry</span>: <span class="str">64500</span>, <span class="attr">stop</span>: <span class="str">63800</span>, <span class="attr">multiples</span>: [<span class="str">1</span>, <span class="str">2</span>, <span class="str">3</span>] });
chart.<span class="attr">setRiskPlan</span>({ <span class="attr">entry</span>: <span class="str">64500</span>, <span class="attr">stop</span>: <span class="str">63800</span>, <span class="attr">targets</span>: [<span class="str">65900</span>, <span class="str">67300</span>] }); <span class="cmt">// prices → kR</span>
chart.<span class="attr">riskPlan</span>; <span class="cmt">// { entry, stop, risk, direction, levels }</span>
chart.<span class="attr">clearScenario</span>(); chart.<span class="attr">clearRiskPlan</span>();
scenario.<span class="attr">detach</span>();</pre></div>
<p>Invalid specs are dropped, never thrown — and <b>clear</b> what was there before (replace semantics). Both are analysis data, excluded from <code>getState()</code>. The pure surface (validators, the √h cone math, realized volatility) is a separate import: <code>wickchart-scenario/core</code>. Third package of the 2.0 split — the smallest attach layer of the family: four setters writing the state seams the element's renderer, cone cache and future-space reservation already read.</p>
<div class="demo-card">
<div class="demo-head">
<span class="t">Playground</span><span class="spacer"></span>
<span id="sc-btns"></span><span class="spacer"></span>
<span id="sc-risk-btns"></span>
</div>
<wick-feed for="ex-sc" demo="BTC" tf="1h" limit="400"></wick-feed>
<wick-chart id="ex-sc" label="BTC · 1h · scenario"></wick-chart>
<div class="foot" id="sc-foot">project a path or a σ-cone into the future space; the risk plan anchors at the last close — combine both</div>
</div>
<div class="note">Peer: <b>wickchart ≥ 1.4</b>, imports the shared validators/cone math from <code>wickchart/core</code> (CDN users: import map). Part of the <a href="https://github.com/benyblack/wickchart/blob/main/ROADMAP-V2.md">2.0 plan</a>.</div>
</section>
<section id="ai">
<h2>wickchart-ai <a class="anchor" href="#ai">#</a> <span class="size">2.2 KB gz</span></h2>
<p>The chart as an <b>LLM tool surface</b> — and nothing that touches the network. <code>aiTools()</code> is a self-describing tool manifest (get_data_window, set_indicators, set_overlays, add_alert, set_view, set_type, …); <code>aiPrompt()</code> is the matching system prompt; <code>aiContext()</code> grounds the model in the live state plus the visible-window summary; <code>applyAI(ops)</code> runs model answers through a <b>validated dispatcher</b> — ops are whitelisted, args checked, and a bad op resolves <code>{ok:false, error}</code> instead of throwing so the agent can self-correct. <code>ask(instruction, {run})</code> wires it end to end with your model call.</p>
<div class="codewrap"><pre class="code"><span class="tag">import</span> { attachAI } <span class="tag">from</span> <span class="str">'wickchart-ai'</span>;
<span class="tag">const</span> ai = <span class="attr">attachAI</span>(chart); <span class="cmt">// methods land on the instance</span>
<span class="tag">const</span> { results } = <span class="attr">await</span> chart.<span class="attr">ask</span>(<span class="str">'add RSI and mark the demand zone'</span>, {
<span class="attr">run</span>: <span class="tag">async</span> (payload) => (<span class="tag">await</span> callMyLLM(payload)).ops, <span class="cmt">// your model, your keys</span>
});
<span class="cmt">// or two-step: build the payload, ship it anywhere, apply the answer</span>
<span class="tag">const</span> { payload } = <span class="attr">await</span> chart.<span class="attr">ask</span>(<span class="str">'switch to a line chart'</span>);
chart.<span class="attr">applyAI</span>([{ <span class="attr">tool</span>: <span class="str">'set_type'</span>, <span class="attr">args</span>: { <span class="attr">type</span>: <span class="str">'line'</span> } }]);
ai.<span class="attr">detach</span>();</pre></div>
<p>The chart itself never touches the network — <code>run</code> is yours, so keys and endpoints stay in your code. <code>getDataWindow()</code> stays in core by design (a data API, not an LLM API); <code>ask()</code> composes it. The manifest + prompt + dispatcher are pure: <code>wickchart-ai/core</code>. Fourth and final package of the 2.0 split — attaching shadows the core's identical methods until 2.0 removes them.</p>
<div class="demo-card">
<div class="demo-head">
<span class="t">Playground</span><span class="spacer"></span>
<span style="font-size:12px;color:var(--muted)">offline demo agent — no LLM, no network</span>
<span id="ai-btns"></span>
</div>
<div style="display:flex; gap:8px; padding:10px 14px; border-bottom:1px solid var(--border); background: var(--panel); flex-wrap:wrap;">
<input type="text" id="ag-instruction" style="flex:1 1 280px" spellcheck="false"
value="show RSI and MACD, mark the demand zone, and alert on volume spikes" aria-label="Instruction for the demo agent" />
<button class="primary" id="ag-run">Run agent → applyAI()</button>
</div>
<wick-feed for="ex-ai" demo="BTC" tf="1h" limit="400"></wick-feed>
<wick-chart id="ex-ai" label="BTC · 1h · ai"></wick-chart>
<pre id="ag-out" style="display:none; margin:0; padding:10px 14px; font-size:11.5px; line-height:1.55; overflow:auto; max-height:220px; border-top:1px solid var(--border); background:var(--code-bg, #0b0f16)"></pre>
<div class="foot" id="ai-foot">the demo agent parses keywords into ops and applies them through the validated dispatcher — wire a real model via chart.ask(instruction, { run })</div>
</div>
<div class="note">Peer: <b>wickchart ≥ 1.4</b>, imports the manifest/prompt/dispatcher from <code>wickchart/core</code> (CDN users: import map). Part of the <a href="https://github.com/benyblack/wickchart/blob/main/ROADMAP-V2.md">2.0 plan</a>.</div>
</section>
<section id="briefing">
<h2>wickchart-briefing <a class="anchor" href="#briefing">#</a> <span class="size">3.4 KB gz</span> <span class="pill new">NEW</span></h2>
<p><b>One command that explains the chart.</b> The visible window becomes a structured markdown briefing — the tape summary (trend, volatility regime, notable events), the candlestick signal census, the smart annotations and the narrate timeline — a ready-to-paste document instead of a screenshot. Pure composition: the sections <i>are</i> <code>windowSummary</code>, <code>detectSignals</code>, <code>detectAnnotations</code> and <code>narrateWindow</code>, so the briefing can never disagree with the chart it describes. Computed locally; nothing leaves the page until you copy it somewhere.</p>
<div class="codewrap"><pre class="code"><span class="tag">import</span> { attachBriefing } <span class="tag">from</span> <span class="str">'wickchart-briefing'</span>;
<span class="attr">attachBriefing</span>(chart);
<span class="tag">const</span> b = chart.<span class="attr">briefing</span>(); <span class="cmt">// the model — null before data lands</span>
b.<span class="attr">markdown</span>; <span class="cmt">// the document (plus structured fields)</span>
<span class="tag">await</span> chart.<span class="attr">copyBriefing</span>(); <span class="cmt">// …straight to the clipboard</span></pre></div>
<p>The attach installs <code>chart.briefing()</code> / <code>chart.copyBriefing()</code> on the instance (shadowing nothing; <code>detach()</code> removes them). It covers the <b>visible range</b> — pan and zoom first, the briefing follows the view — falling back to the full dataset. Output is deterministic: UTC-stable timestamps and an injectable clock, so the same window briefs byte-identically.</p>
<div class="note">Dependencies: <b>wickchart-signals</b> + <b>wickchart-narrator</b> — the census and the timeline are theirs, not copies (CDN users: import map). The pure model is <code>wickchart-briefing/core</code> — no chart, no DOM, usable from a worker or a backtest.</div>
<div class="demo-card">
<div class="demo-head"><span class="t">Playground</span><span class="spacer"></span><span id="br-btns"></span></div>
<wick-feed for="ex-br" demo="BTC" tf="1h" limit="400"></wick-feed>
<wick-chart id="ex-br" label="BTC · 1h" indicators="sma:20 volume"></wick-chart>
<pre id="br-out" style="display:none; margin:0; padding:10px 14px; font-size:11.5px; line-height:1.55; overflow:auto; max-height:260px; border-top:1px solid var(--border); background:var(--code-bg, #0b0f16); white-space:pre-wrap"></pre>
<div class="foot" id="br-foot">brief the visible window — pan/zoom first, the briefing follows the view</div>
</div>
</section>
</main>
</div>
<script type="module">
import { attachDrawings } from './plugins/draw/draw.mjs';
import { attachSessions } from './plugins/sessions/sessions.mjs';
import { attachReplay } from './plugins/replay/replay.mjs';
import { attachCompare } from './plugins/compare/compare.mjs';
import { attachNavigator } from './plugins/navigator/navigator.mjs';
import { attachAlertsPlus } from './plugins/alerts-plus/alerts-plus.mjs';
import { attachLayouts } from './plugins/layouts/layouts.mjs';
import { attachSignals } from './plugins/signals/signals.mjs';
import { attachTape } from './plugins/tape/tape.mjs';
import './plugins/grid/grid.mjs';
import { attachPaper } from './plugins/paper/paper.mjs';
import { attachNarrator } from './plugins/narrator/narrator.mjs';
import { attachCoview } from './plugins/coview/coview.mjs';
import { attachScenario } from './plugins/scenario/scenario.mjs';
import { attachAI } from './plugins/ai/ai.mjs';
import { attachBriefing } from './plugins/briefing/briefing.mjs';
const $ = (id) => document.getElementById(id);
/* ---------- code copy buttons ---------- */
for (const pre of document.querySelectorAll('pre.code')) {
const wrap = document.createElement('div');
wrap.className = 'codewrap';
pre.parentNode.insertBefore(wrap, pre);
wrap.appendChild(pre);
const btn = document.createElement('button');
btn.className = 'copy-btn';
btn.type = 'button';
btn.textContent = 'Copy';
btn.addEventListener('click', async () => {
try {
await navigator.clipboard.writeText(pre.textContent);
} catch (_) {
const ta = document.createElement('textarea');
ta.value = pre.textContent;
document.body.appendChild(ta);
ta.select();
document.execCommand('copy');
ta.remove();
}
btn.textContent = 'Copied';
btn.classList.add('done');
setTimeout(() => { btn.textContent = 'Copy'; btn.classList.remove('done'); }, 1400);
});
wrap.appendChild(btn);
}
/* ---------- sidebar: scrollspy + filter ---------- */
const links = [...document.querySelectorAll('#toc a')];
const sections = links
.map((a) => ({ a, sec: document.querySelector(a.getAttribute('href')) }))
.filter((x) => x.sec);
const onScroll = () => {
const y = window.scrollY + 120;
let cur = sections[0];
for (const s of sections) if (s.sec.offsetTop <= y) cur = s;
links.forEach((a) => a.classList.toggle('active', a === cur.a));
};
window.addEventListener('scroll', onScroll, { passive: true });
onScroll();
$('toc-filter').addEventListener('input', (e) => {
const q = e.target.value.trim().toLowerCase();
for (const { a, sec } of sections) {
const hit = !q || sec.textContent.toLowerCase().includes(q) || a.textContent.toLowerCase().includes(q);
a.classList.toggle('hidden', !hit);
}
});
/* ---------- helpers ---------- */
const seg = (el, options, initial, onPick) => {
for (const [val, label] of options) {
const b = document.createElement('button');
b.type = 'button';
b.textContent = label;
b.className = val === initial ? 'active' : '';
b.addEventListener('click', () => {
el.querySelectorAll('button').forEach((x) => x.classList.remove('active'));
b.classList.add('active');
onPick(val);
});
el.appendChild(b);
}
};
const mkBtn = (parent, label, title, fn) => {
const b = document.createElement('button');
b.type = 'button';
b.textContent = label;
if (title) b.title = title;
b.addEventListener('click', fn);
parent.appendChild(b);
return b;
};
const TF = 3600e3;
// base-seeded random walk on the same hourly grid as the demo feed —
// used by the compare playground as sibling symbols
const genSeries = (base, n = 300) => {
const t0 = Math.floor(Date.now() / TF) * TF - (n - 1) * TF;
const out = [];
let prevClose = base;
for (let i = 0; i < n; i++) {
const open = prevClose;
const drift = (Math.random() - 0.5) * open * 0.012;
const close = Math.max(1, open + drift);
out.push({
time: t0 + i * TF, open, close,
high: Math.max(open, close) * (1 + Math.random() * 0.004),
low: Math.min(open, close) * (1 - Math.random() * 0.004),
volume: 40 + Math.random() * 160,
});
prevClose = close;
}
return out;
};
/* ---------- draw playground ---------- */
{
const c = $('ex-draw'), foot = $('draw-foot');
const draw = attachDrawings(c, { magnet: true });
let magnet = true;
seg($('draw-seg'), [
['select', 'Select'], ['trendline', 'Trendline'], ['hline', 'Level'],
['rect', 'Rect'], ['fib', 'Fib'], ['text', 'Text'],
], 'select', (v) => {
draw.setTool(v === 'select' ? null : v);
foot.textContent =
v === 'select' ? 'select mode — click a drawing to move/re-anchor'
: v === 'hline' || v === 'text' ? v + ' armed — click to place'
: v + ' armed — drag on the chart';
});
mkBtn($('draw-tools'), 'Magnet', 'toggle magnet snapping', (e) => {
magnet = !magnet;
draw.setMagnet(magnet);
e.currentTarget.classList.toggle('on', magnet);
foot.textContent = magnet ? 'magnet on — anchors snap to bars & OHLC' : 'magnet off — free placement';
}).classList.add('on');
mkBtn($('draw-tools'), 'Undo', 'undo the last drawing', () => draw.undo());
// Del/Backspace is the desktop route; a touchscreen has neither, so
// without a button a drawing made on a phone can never be removed.
const del = mkBtn($('draw-tools'), 'Delete', 'delete the selected drawing (or press Del)', () => {
if (!draw.deleteSelected()) foot.textContent = 'select a drawing first — tap it in select mode';
});
del.disabled = true;
mkBtn($('draw-tools'), 'Clear', 'remove all drawings', () => draw.clear());
c.addEventListener('wick:drawselect', (e) => (del.disabled = !e.detail.id));
c.addEventListener('wick:drawings', (e) => {
del.disabled = !draw.selectedId;
const n = e.detail.drawings.length;
foot.textContent = `${n} drawing${n === 1 ? '' : 's'} — ${e.detail.action}`;
});
}
/* ---------- sessions playground ---------- */
{
const c = $('ex-sess'), foot = $('sess-foot');
let plugin = null;
seg($('sess-seg'), [['off', 'off'], ['crypto', 'crypto'], ['forex', 'forex'], ['nyse', 'NYSE'], ['cme', 'CME']], 'crypto', (v) => {
if (plugin) { plugin.detach(); plugin = null; }
if (v !== 'off') {
plugin = attachSessions(c, { preset: v });
foot.textContent = v + ' preset — hover a band and the foot names it';
} else foot.textContent = 'off';
});
c.addEventListener('wick:sessions', (e) => {
if (e.detail.hover) foot.textContent = 'crosshair in: ' + e.detail.hover;
});
// default selection renders once the feed has data
const kick = () => {
if (c.data && c.data.length) { plugin = attachSessions(c, { preset: 'crypto' }); }
else setTimeout(kick, 400);
};
setTimeout(kick, 500);
}
/* ---------- replay playground ---------- */
{
const c = $('ex-rep'), foot = $('rep-foot');
const r = attachReplay(c);
const playBtn = mkBtn($('rep-btns'), '▶ Start', 'start / pause the replay', () => {
if (!r.active) {
r.start();
r.play();
} else if (r.playing) {
r.pause();
} else {
r.play();
}
playBtn.textContent = r.playing ? '⏸ Pause' : '▶ Play';
foot.textContent = `replay ${r.index}/${r.total} — ${r.remaining} bars hidden`;
});
mkBtn($('rep-btns'), 'Step →', 'reveal one bar', () => { r.step(); foot.textContent = `replay ${r.index}/${r.total} — ${r.remaining} bars hidden`; });
mkBtn($('rep-btns'), '⏹ Exit', 'exit replay and restore the full dataset', () => {
r.stop();
playBtn.textContent = '▶ Start';
foot.textContent = 'exited — full dataset restored';
});
seg($('rep-seg'), [['1', '1×'], ['4', '4×'], ['15', '15×']], '4', (v) => { r.setSpeed(+v); foot.textContent = 'speed ' + v + ' bars/sec'; });
c.addEventListener('wick:replay', (e) => {
if (!r.active) return;
playBtn.textContent = r.playing ? '⏸ Pause' : '▶ Play';
foot.textContent = `replay ${e.detail.index}/${e.detail.total}`;
});
}
/* ---------- compare playground ---------- */
{
const c = $('ex-cmp'), foot = $('cmp-foot');
const cmp = attachCompare(c);
const cache = new Map();
const series = (sym) => {
if (!cache.has(sym)) cache.set(sym, genSeries(sym === 'ETH' ? 2400 : 95));
return cache.get(sym);
};
seg($('cmp-seg'), [['off', 'off'], ['eth', 'ETH'], ['eth+sol', 'ETH+SOL']], 'off', (v) => {
if (v === 'off') { cmp.clear(); foot.textContent = 'off'; return; }
const list = v.split('+').map((s) => ({ label: s.toUpperCase(), data: series(s) }));
cmp.setSeries(list);
foot.textContent = list.map((s) => s.label).join(' + ') + ' overlaid, rebased to ' + cmp.rebase;
});
seg($('cmp-rebase'), [['first', 'rebase: first'], ['visible', 'rebase: visible']], 'first', (v) => {
cmp.setRebase(v);
foot.textContent = 'rebase ' + v + (v === 'visible' ? ' — pan and watch the chips re-anchor' : '');
});
}
/* ---------- navigator playground ---------- */
{
const c = $('ex-nav'), foot = $('nav-foot');
let nav = null;
const btn = mkBtn($('nav-btns'), 'Attach', 'attach the range navigator', () => {
if (nav) {
nav.detach();
nav = null;
btn.textContent = 'Attach';
btn.classList.remove('on');
foot.textContent = 'detached — the dock space is released';
} else {
nav = attachNavigator(c);
btn.textContent = 'Detach';
btn.classList.add('on');
foot.textContent = 'attached — drag the window, grab an edge, click to jump';
}
});
}
/* ---------- alerts+ playground ---------- */
{
const c = $('ex-alr'), foot = $('alr-foot');
const ap = attachAlertsPlus(c, { key: 'wick-docs-alerts' });
let n = 0;
const restored = ap.list().length;
if (restored) foot.textContent = `restored ${restored} persisted alert${restored === 1 ? '' : 's'} from storage`;
mkBtn($('alr-btns'), '+ Alert +1%', 'add a price alert 1% above the last close (persisted)', () => {
const d = c.data;
if (!d || !d.length) return;
ap.add({ id: 'docs-a' + ++n, price: d[d.length - 1].close * 1.01, direction: 'above' });
foot.textContent = `alert armed — ${ap.list().length} persisted (reload the page)`;
});
mkBtn($('alr-btns'), 'Clear', 'remove every persisted alert', () => {
ap.clear();
foot.textContent = 'cleared — storage emptied';
});
c.addEventListener('wick:alert', (e) => {
foot.textContent = `wick:alert → ${e.detail.id} crossed ${e.detail.price?.toFixed(2)}`;
});
}
/* ---------- layouts playground ---------- */
{
const c = $('ex-lay'), foot = $('lay-foot');
const layouts = attachLayouts(c);
mkBtn($('lay-btns'), 'Save view…', 'save the current setup under a name', () => {
const name = prompt('Save the current setup as:', 'docs-' + (layouts.list()[0]?.name || 'main'));
if (name == null) return;
layouts.save(name);
foot.textContent = `saved "${name}" — ${layouts.list().length} layout(s) in memory`;
});
mkBtn($('lay-btns'), 'Load', 'load the most recent snapshot', () => {
const first = layouts.list()[0];
if (!first) { foot.textContent = 'nothing saved yet'; return; }
layouts.load(first.name);
foot.textContent = `loaded "${first.name}"`;
});
mkBtn($('lay-btns'), 'Export', 'JSON of every snapshot — copy it anywhere', async () => {
const json = layouts.export();
try { await navigator.clipboard.writeText(json); foot.textContent = 'export → ' + json.length + ' chars of JSON, copied to clipboard'; }
catch (_) { foot.textContent = 'export → ' + json.length + ' chars of JSON'; }
});
}
/* ---------- signals playground ---------- */
{
const c = $('ex-sig'), foot = $('sig-foot');
const sig = attachSignals(c, { kinds: [] });
seg($('sig-seg'), [['off', 'off'], ['all', 'all kinds'], ['ep', 'E + P']], 'off', (v) => {
sig.setKinds(v === 'all' ? ['engulfing', 'pinbar', 'inside'] : v === 'ep' ? ['engulfing', 'pinbar'] : []);
if (v === 'off') { foot.textContent = 'off'; return; }
// detection runs on the next render — read the count after a frame
requestAnimationFrame(() => {
foot.textContent = `${sig.count} signals detected — hover a badge for the explanation`;
});
});
c.addEventListener('wick:signals', (e) => {
if (e.detail.label) foot.textContent = 'under crosshair: ' + e.detail.label;
});
}
/* ---------- tape playground ---------- */
{
const c = $('ex-tape'), foot = $('tape-foot');
let tape = null;
let timer = 0;
const tick = () => {
const d = c.data;