@tradeglotnpm/charts 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,19 @@
1
+ Glot Charts
2
+ Copyright 2026 TradeGlot
3
+
4
+ This product includes software developed by TradeGlot (https://tradeglot.com).
5
+
6
+ Licensed under the Apache License 2.0; see LICENSE.
7
+
8
+ Attribution notice: When you use Glot Charts in a product that is available to end
9
+ users, you must keep the Glot Charts attribution logo enabled on the chart
10
+ (attributionLogo: true, the default), or display the text "Charts by Glot Charts
11
+ (TradeGlot)" together with a link to https://tradeglot.com on a page of your website
12
+ or application that is publicly available to your users. See docs/attribution.md.
13
+
14
+ Trademarks: "Glot", "TradeGlot" and the TradeGlot logos are trademarks of TradeGlot.
15
+ No license in this repository grants any right to use them; see TRADEMARKS.md.
16
+
17
+ TradingView and Pine Script are trademarks of TradingView, Inc. MetaTrader, MQL4 and
18
+ MQL5 are trademarks of MetaQuotes Ltd. TradeGlot is not affiliated with, endorsed by
19
+ or sponsored by these companies. They are named only to describe compatibility.
package/README.md CHANGED
@@ -1,3 +1,50 @@
1
- # Temporary Holding Version
1
+ # @tradeglotnpm/charts
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Open-source financial charts for the web: candles, indicator lines, shape marks, fills and trade marks on Canvas 2D, with crosshair, pan and zoom. No run-time dependencies; about 6 KB gzip. Up is blue and down is orange by default.
4
+
5
+ > 0.1 is a preview: the API may change before 1.0.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @tradeglotnpm/charts
11
+ ```
12
+
13
+ Or with a script tag (global `GlotCharts`):
14
+
15
+ ```html
16
+ <script src="https://cdn.jsdelivr.net/npm/@tradeglotnpm/charts@0.1/dist/glot-charts.min.js"></script>
17
+ ```
18
+
19
+ ## Quick start
20
+
21
+ ```ts
22
+ import { createChart } from "@tradeglotnpm/charts";
23
+
24
+ const chart = createChart(document.getElementById("chart")!, { theme: "dark" }); // give #chart a height
25
+ chart.setData({
26
+ bars: [{ time: Date.UTC(2026, 0, 5), open: 4101.2, high: 4110.8, low: 4098.5, close: 4108.3 }],
27
+ });
28
+ chart.update({
29
+ time: Date.UTC(2026, 0, 5, 1),
30
+ open: 4108.3,
31
+ high: 4116.9,
32
+ low: 4105.0,
33
+ close: 4116.4,
34
+ });
35
+ ```
36
+
37
+ `time` is Unix time in milliseconds, UTC.
38
+
39
+ ## Documentation
40
+
41
+ - [Getting started](https://github.com/tradeglot/glot-charts/blob/main/docs/getting-started.md)
42
+ - [API reference](https://github.com/tradeglot/glot-charts/blob/main/docs/api.md)
43
+ - [Examples: plain HTML, React, Vue](https://github.com/tradeglot/glot-charts/tree/main/examples)
44
+ - [Changelog](https://github.com/tradeglot/glot-charts/blob/main/CHANGELOG.md)
45
+
46
+ ## License and attribution
47
+
48
+ Apache 2.0 with an attribution notice (see `NOTICE`). The chart shows a small Glot Charts logo by default; you may turn it off if you credit Glot Charts with a link on a public page of your product ([details](https://github.com/tradeglot/glot-charts/blob/main/docs/attribution.md)).
49
+
50
+ Charts show past prices. Trading involves risk of loss.
@@ -0,0 +1,6 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="96" height="20" viewBox="0 0 96 20" role="img" aria-label="Glot Charts">
2
+ <rect x="2" y="2" width="16" height="16" rx="4" fill="#6D5BFF"/>
3
+ <path d="M7 6.5L4.8 10 7 13.5M13 6.5L15.2 10 13 13.5" fill="none" stroke="#FFFFFF" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/>
4
+ <rect x="8.6" y="7" width="2.8" height="6" rx="0.8" fill="#FFFFFF"/>
5
+ <text x="23" y="14.5" font-family="Space Grotesk, Arial, sans-serif" font-size="12" font-weight="600" fill="#5A5F7A">Glot Charts</text>
6
+ </svg>
@@ -0,0 +1,3 @@
1
+ /** Default attribution image, shipped with the package in `assets/`. */
2
+ export declare const ATTRIBUTION_SRC: string;
3
+ export declare const ATTRIBUTION_HREF = "https://tradeglot.com/";
@@ -0,0 +1,41 @@
1
+ import { type ThemeOption } from "./theme.js";
2
+ import type { Bar, ChartData, ChartOptions } from "./types.js";
3
+ export declare class GlotChart {
4
+ private opts;
5
+ readonly el: HTMLDivElement;
6
+ private canvas;
7
+ private legend;
8
+ private labelEl;
9
+ private data;
10
+ private view;
11
+ private frame;
12
+ private drag;
13
+ private moved;
14
+ private raf;
15
+ private resize;
16
+ constructor(host: HTMLElement, opts?: ChartOptions);
17
+ setData(data: ChartData, keepView?: boolean): void;
18
+ /**
19
+ * Adds or changes the newest bar, for live data. A bar with the same time as the last bar
20
+ * replaces it; a later bar is appended. Indicator values for the new bar can follow through
21
+ * `setData`. Throws on a bar older than the last one.
22
+ */
23
+ update(bar: Bar): void;
24
+ /** Switches between the built-in themes or your own colors. */
25
+ setTheme(theme: ThemeOption): void;
26
+ /** The data the chart currently draws. */
27
+ getData(): ChartData;
28
+ /** Highlights one bar (debugger cursor) and scrolls it into view. */
29
+ mark(bar: number | null): void;
30
+ /** Re-reads the theme colors (after a theme switch). */
31
+ refresh(): void;
32
+ dispose(): void;
33
+ private ariaLabel;
34
+ private bind;
35
+ private hover;
36
+ private renderLegend;
37
+ private schedule;
38
+ private draw;
39
+ }
40
+ /** Creates a chart inside `host` (it fills the host, so give the host a size). */
41
+ export declare function createChart(host: HTMLElement, options?: ChartOptions): GlotChart;
package/dist/csv.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import type { Bar } from "./types.js";
2
+ export declare function barsFromCsv(text: string): Bar[];
package/dist/draw.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ import { type Viewport } from "./scale.js";
2
+ import type { ChartTheme } from "./theme.js";
3
+ import type { ChartData } from "./types.js";
4
+ export declare const AXIS_W = 72;
5
+ export declare const AXIS_H = 24;
6
+ export interface Frame {
7
+ width: number;
8
+ height: number;
9
+ /** Bar under the pointer, for the crosshair and legend. */
10
+ hover: number | null;
11
+ /** Bar highlighted by the debugger (part 4) or a click. */
12
+ marked: number | null;
13
+ }
14
+ export declare function drawFrame(ctx: CanvasRenderingContext2D, d: ChartData, v: Viewport, th: ChartTheme, f: Frame): void;
15
+ /** Index of the bar with time <= t (bars sorted by time). */
16
+ export declare function bisect(bars: {
17
+ time: number;
18
+ }[], t: number): number;
@@ -0,0 +1,6 @@
1
+ /*! Glot Charts 0.1.0 | Apache-2.0 with NOTICE | https://github.com/tradeglot/glot-charts */
2
+ var oe=Object.defineProperty;var ae=(e,t,n)=>t in e?oe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var g=(e,t,n)=>ae(e,typeof t!="symbol"?t+"":t,n);function U(e,t,n){let i=Math.ceil(t/n.barWidth)+1,r=Math.min(e-1,Math.floor(n.end));return[Math.max(0,r-i+1),r]}function N(e,t,n){return t-(n.end-e+.5)*n.barWidth}function P(e,t,n){return Math.round(n.end+.5-(t-e)/n.barWidth)}function L(e,t=.05){let n=1/0,i=-1/0;for(let o of e)o===null||!Number.isFinite(o)||(o<n&&(n=o),o>i&&(i=o));if(n===1/0)return[0,1];if(n===i)return[n-1,i+1];let r=(i-n)*t;return[n-r,i+r]}function W(e,t){let n=e/Math.max(1,t),i=10**Math.floor(Math.log10(n)),r=n/i;return(r<1.5?1:r<3?2:r<7?5:10)*i}function H(e){return Math.max(0,Math.min(8,-Math.floor(Math.log10(e)+1e-9)))}function I(e,t){let n=Math.abs(e).toFixed(t),[i="0",r]=n.split("."),o=i.replace(/\B(?=(\d{3})+(?!\d))/g,",");return(e<0?"\u2212":"")+o+(r?"."+r:"")}function B(e,t){if(!e)return null;switch(e){case"up":return t.up;case"down":return t.down;case"accent":return t.accent;case"neutral":return t.muted;default:return e}}function x(e,t,n,i,r,o,l,u){e.lineWidth=1.5;for(let h=Math.max(r,1);h<=o;h++){let m=t.values[h-1],a=t.values[h];m==null||a===null||a===void 0||(e.strokeStyle=B(t.colors?.[h],i)??n,e.beginPath(),e.moveTo(l(h-1),u(m)),e.lineTo(l(h),u(a)),e.stroke())}e.lineWidth=1}function J(e,t,n,i,r,o,l,u){let h=n.find(a=>a.name===t.a)?.values,m=n.find(a=>a.name===t.b)?.values;if(!(!h||!m))for(let a=Math.max(r,1);a<=o;a++){let d=[h[a-1],h[a],m[a],m[a-1]],c=B(t.colors[a],i);if(!c||d.some(b=>b==null))continue;let[M,S,y,E]=d;e.fillStyle=c,e.beginPath(),e.moveTo(l(a-1),u(M)),e.lineTo(l(a),u(S)),e.lineTo(l(a),u(y)),e.lineTo(l(a-1),u(E)),e.closePath(),e.fill()}}function Q(e,t,n,i,r,o,l,u,h){for(let a=r;a<=o;a++){if(!t.values[a])continue;let d=n[a],c=l(a),M=t.at==="below_bar"?u(d.low)+12+2:t.at==="top"?12:t.at==="bottom"?h-12:u(d.high)-12-2,S=B(t.colors?.[a],i)??i.accent;if(e.fillStyle=e.strokeStyle=S,se(e,t.shape,c,M,6),t.text){e.font=`11px ${i.font}`,e.textAlign="center";let y=t.at==="below_bar"||t.at==="bottom";e.fillText(t.text,c,y?M+12+4:M-12-4),e.textAlign="start"}}}function se(e,t,n,i,r){switch(e.beginPath(),t){case"triangle_up":case"arrow_up":case"label_up":A(e,[n,i-r,n+r,i+r,n-r,i+r]);break;case"triangle_down":case"arrow_down":case"label_down":A(e,[n,i+r,n+r,i-r,n-r,i-r]);break;case"square":e.rect(n-r*.8,i-r*.8,r*1.6,r*1.6);break;case"diamond":A(e,[n,i-r,n+r,i,n,i+r,n-r,i]);break;case"cross":case"x_cross":{let o=t==="cross"?0:Math.PI/4;e.lineWidth=2;for(let l of[o,o+Math.PI/2])e.moveTo(n-r*Math.cos(l),i-r*Math.sin(l)),e.lineTo(n+r*Math.cos(l),i+r*Math.sin(l));e.stroke(),e.lineWidth=1;return}case"flag":A(e,[n-r*.6,i-r,n+r,i-r*.4,n-r*.6,i+r*.2]);break;default:e.arc(n,i,r*.7,0,Math.PI*2)}e.fill()}function A(e,t){e.moveTo(t[0],t[1]);for(let n=2;n<t.length;n+=2)e.lineTo(t[n],t[n+1]);e.closePath()}var T=72,D=24;function Y(e,t,n,i,r){let o=r.width-T,l=t.series??[],u=l.filter(s=>!s.overlay),h=(r.height-D)*(u.length?.72:1),m=h,a=r.height-D-h;if(e.clearRect(0,0,r.width,r.height),e.fillStyle=i.bg,e.fillRect(0,0,r.width,r.height),t.bars.length===0)return;let[d,c]=U(t.bars.length,o,n),M=t.bars.slice(d,c+1),S=l.filter(s=>s.overlay),[y,E]=L([...M.flatMap(s=>[s.low,s.high]),...S.flatMap(s=>s.values.slice(d,c+1))]),b=s=>(E-s)/(E-y)*(h-8)+4,f=s=>N(s,o,n),F=W(E-y,Math.max(2,Math.floor(h/60))),V=H(F);e.font=`12px ${i.mono}`,e.textBaseline="middle";for(let s=Math.ceil(y/F)*F;s<=E;s+=F)R(e,i.grid,0,b(s),o,b(s)),e.fillStyle=i.muted,e.fillText(I(s,V),o+6,b(s));r.marked!==null&&r.marked>=d&&r.marked<=c&&(e.fillStyle=i.grid,e.fillRect(f(r.marked)-n.barWidth/2,0,n.barWidth,r.height-D));let j=Math.max(1,n.barWidth*.7);for(let s=d;s<=c;s++){let p=t.bars[s],v=p.close>=p.open;e.strokeStyle=e.fillStyle=v?i.up:i.down;let w=Math.round(f(s))+.5;R(e,e.strokeStyle,w,b(p.high),w,b(p.low));let C=b(Math.max(p.open,p.close));e.fillRect(w-j/2,C,j,Math.max(1,b(Math.min(p.open,p.close))-C))}for(let s of t.fills??[])J(e,s,l,i,d,c,f,b);S.forEach((s,p)=>{let v=i.series[p%i.series.length];s.colors?.some(w=>w)?x(e,s,v,i,d,c,f,b):X(e,v,s.values,d,c,f,b,p>=i.series.length)});for(let s of t.shapes??[])Q(e,s,t.bars,i,d,c,f,b,h);let z=s=>q(t.bars,s);for(let s of t.trades??[]){let p=z(s.entryTime),v=z(s.exitTime),w=s.side==="buy"?i.up:i.down;p>=d&&p<=c&&me(e,w,f(p),b(s.entryPrice),s.side==="buy"),v>=d&&v<=c&&de(e,w,f(v),b(s.exitPrice))}if(u.length){R(e,i.grid,0,m,r.width,m);let[s,p]=L(u.flatMap(C=>C.values.slice(d,c+1))),v=C=>m+4+(p-C)/(p-s)*(a-8);u.forEach((C,ie)=>{let $=i.series[ie%i.series.length];C.colors?.some(re=>re)?x(e,C,$,i,d,c,f,v):X(e,$,C.values,d,c,f,v,!1)});let w=H(W(p-s,2));e.fillStyle=i.muted,e.fillText(I(p,w),o+6,m+10),e.fillText(I(s,w),o+6,m+a-10)}le(e,t,n,i,r,d,c),he(e,t,i,r,f,b,h,V)}function le(e,t,n,i,r,o,l){let u=r.width-T,h=r.height-D;R(e,i.grid,0,h,r.width,h),e.fillStyle=i.muted,e.font=`12px ${i.font}`;let m=Math.max(1,Math.ceil(110/n.barWidth));for(let a=o-o%m;a<=l;a+=m){if(a<o)continue;let d=new Date(t.bars[a].time).toISOString();e.fillText(`${d.slice(5,10)} ${d.slice(11,16)}`,N(a,u,n)-30,h+12)}e.fillText("UTC",u+6,h+12)}function he(e,t,n,i,r,o,l,u){if(i.hover===null||!t.bars[i.hover])return;let h=t.bars[i.hover];e.setLineDash([4,4]),R(e,n.muted,Math.round(r(i.hover))+.5,0,Math.round(r(i.hover))+.5,i.height-D),e.setLineDash([]);let m=o(h.close);m>=0&&m<=l&&(e.fillStyle=n.grid,e.fillRect(i.width-T,m-9,T,18),e.fillStyle=n.text,e.font=`12px ${n.mono}`,e.fillText(I(h.close,u+1),i.width-T+6,m))}function X(e,t,n,i,r,o,l,u){e.strokeStyle=t,e.lineWidth=1.5,e.setLineDash(u?[6,3]:[]),e.beginPath();let h=!1;for(let m=i;m<=r;m++){let a=n[m];if(a==null||!Number.isFinite(a)){h=!1;continue}h?e.lineTo(o(m),l(a)):e.moveTo(o(m),l(a)),h=!0}e.stroke(),e.setLineDash([]),e.lineWidth=1}function R(e,t,n,i,r,o){e.strokeStyle=t,e.beginPath(),e.moveTo(n,i),e.lineTo(r,o),e.stroke()}function me(e,t,n,i,r){let l=r?i+10:i-10;e.fillStyle=t,e.beginPath(),e.moveTo(n,r?l-6:l+6),e.lineTo(n-6,r?l+6:l-6),e.lineTo(n+6,r?l+6:l-6),e.fill()}function de(e,t,n,i){e.strokeStyle=t,e.lineWidth=2,e.beginPath(),e.arc(n,i,4,0,Math.PI*2),e.stroke(),e.lineWidth=1}function q(e,t){let n=0,i=e.length-1;for(;n<i;){let r=n+i+1>>1;e[r].time<=t?n=r:i=r-1}return n}var O="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI5NiIgaGVpZ2h0PSIyMCIgdmlld0JveD0iMCAwIDk2IDIwIiByb2xlPSJpbWciIGFyaWEtbGFiZWw9Ikdsb3QgQ2hhcnRzIj4KPHJlY3QgeD0iMiIgeT0iMiIgd2lkdGg9IjE2IiBoZWlnaHQ9IjE2IiByeD0iNCIgZmlsbD0iIzZENUJGRiIvPgo8cGF0aCBkPSJNNyA2LjVMNC44IDEwIDcgMTMuNU0xMyA2LjVMMTUuMiAxMCAxMyAxMy41IiBmaWxsPSJub25lIiBzdHJva2U9IiNGRkZGRkYiIHN0cm9rZS13aWR0aD0iMS40IiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz4KPHJlY3QgeD0iOC42IiB5PSI3IiB3aWR0aD0iMi44IiBoZWlnaHQ9IjYiIHJ4PSIwLjgiIGZpbGw9IiNGRkZGRkYiLz4KPHRleHQgeD0iMjMiIHk9IjE0LjUiIGZvbnQtZmFtaWx5PSJTcGFjZSBHcm90ZXNrLCBBcmlhbCwgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIxMiIgZm9udC13ZWlnaHQ9IjYwMCIgZmlsbD0iIzVBNUY3QSI+R2xvdCBDaGFydHM8L3RleHQ+Cjwvc3ZnPgo=",Z="https://tradeglot.com/";var ue=`
3
+ :where(.glot-chart-legend){position:absolute;left:8px;top:6px;right:80px;font:12px var(--glot-chart-mono);color:var(--glot-chart-text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;pointer-events:none}
4
+ :where(.glot-chart-label){position:absolute;right:80px;bottom:30px;font:600 12px var(--glot-chart-font);color:var(--glot-chart-muted);border:1px solid var(--glot-chart-grid);border-radius:999px;padding:2px 10px;pointer-events:none}
5
+ `;function K(e){if(e.querySelector("style[data-glot-charts]"))return;let t=e.createElement("style");t.dataset.glotCharts="",t.textContent=ue,e.head.append(t)}function ee(e,t){e.style.setProperty("--glot-chart-text",t.text),e.style.setProperty("--glot-chart-muted",t.muted),e.style.setProperty("--glot-chart-grid",t.grid),e.style.setProperty("--glot-chart-font",t.font),e.style.setProperty("--glot-chart-mono",t.mono)}var te='"Be Vietnam Pro", "Inter", sans-serif',ne='"JetBrains Mono", Menlo, monospace',_={dark:{bg:"#0E0F1A",text:"#ECEEF8",muted:"#A3A8C3",grid:"#2A2E48",up:"#3D8BFF",down:"#FF7A3D",accent:"#A99FFF",font:te,mono:ne,series:["#A99FFF","#ECEEF8","#A3A8C3"]},light:{bg:"#F6F6FB",text:"#14152B",muted:"#5A5F7A",grid:"#DCDDEA",up:"#2266DE",down:"#BA481A",accent:"#5B4BE0",font:te,mono:ne,series:["#5B4BE0","#14152B","#5A5F7A"]}};function G(e,t="dark"){let n=typeof t=="string"?_[t]:{..._.dark,...t},i=getComputedStyle(e),r=(m,a)=>i.getPropertyValue(m).trim()||a,o=r("--tg-text-accent",n.accent),l=r("--tg-text",n.text),u=r("--tg-muted",n.muted),h=i.getPropertyValue("--tg-text-accent").trim()!=="";return{bg:r("--tg-bg",n.bg),text:l,muted:u,grid:r("--tg-border",n.grid),up:r("--tg-chart-candle-up",n.up),down:r("--tg-chart-candle-down",n.down),accent:o,font:r("--tg-font-ui",n.font),mono:r("--tg-font-mono",n.mono),series:h?[o,l,u]:n.series}}var ce=2,pe=40,k=class{constructor(t,n={}){this.opts=n;g(this,"el");g(this,"canvas");g(this,"legend");g(this,"labelEl");g(this,"data",{bars:[]});g(this,"view",{end:0,barWidth:8});g(this,"frame",{width:0,height:0,hover:null,marked:null});g(this,"drag",null);g(this,"moved",!1);g(this,"raf",0);g(this,"resize");if(this.el=document.createElement("div"),this.el.className="glot-chart",this.el.style.cssText="position:relative;width:100%;height:100%;overflow:hidden;touch-action:none",this.canvas=document.createElement("canvas"),this.canvas.style.cssText="position:absolute;inset:0;width:100%;height:100%;cursor:crosshair",this.canvas.setAttribute("role","img"),this.legend=document.createElement("div"),this.legend.className="glot-chart-legend",this.labelEl=document.createElement("span"),this.labelEl.className="glot-chart-label",this.el.append(this.canvas,this.legend,this.labelEl),n.attributionLogo!==!1){let i=document.createElement("a");i.className="glot-chart-attribution",i.href=n.attributionHref??Z,i.target="_blank",i.rel="noopener",i.title="Charts by Glot Charts (TradeGlot)",i.style.cssText="position:absolute;left:8px;bottom:28px;height:18px;opacity:0.7";let r=document.createElement("img");r.src=n.attributionSrc??O,r.alt="Glot Charts",r.height=18,r.style.cssText="height:18px;display:block",i.append(r),this.el.append(i)}K(t.ownerDocument),t.append(this.el),this.bind(),this.resize=new ResizeObserver(()=>this.schedule()),this.resize.observe(this.el)}setData(t,n=!1){let i=this.view.end>=this.data.bars.length-1;this.data=t,(!n||i)&&(this.view.end=Math.max(0,t.bars.length-1)),this.labelEl.textContent=t.label??"",this.labelEl.hidden=!t.label,this.canvas.setAttribute("aria-label",this.ariaLabel()),this.schedule()}update(t){let n=this.data.bars,i=n[n.length-1],r=this.view.end>=n.length-1;if(i&&t.time<i.time)throw new RangeError(`update: bar time ${t.time} is older than the last bar ${i.time}`);i&&t.time===i.time?n[n.length-1]=t:(n.push(t),r&&(this.view.end=n.length-1)),this.canvas.setAttribute("aria-label",this.ariaLabel()),this.schedule()}setTheme(t){this.opts={...this.opts,theme:t},this.schedule()}getData(){return this.data}mark(t){if(this.frame.marked=t,t!==null){let n=(this.frame.width-T)/this.view.barWidth;(t>this.view.end||t<this.view.end-n+1)&&(this.view.end=Math.min(this.data.bars.length-1,t+Math.floor(n/2)))}this.schedule()}refresh(){this.schedule()}dispose(){this.resize.disconnect(),cancelAnimationFrame(this.raf),this.el.remove()}ariaLabel(){let t=this.data.label;return`${this.data.bars.length} bars${t?`, ${t}`:""}`}bind(){let t=this.canvas;t.addEventListener("wheel",n=>{n.preventDefault();let i=n.deltaY>0?.85:1.15;this.view.barWidth=Math.min(pe,Math.max(ce,this.view.barWidth*i)),this.schedule()},{passive:!1}),t.addEventListener("pointerdown",n=>{this.drag={x:n.clientX,end:this.view.end},this.moved=!1,t.setPointerCapture(n.pointerId)}),t.addEventListener("pointermove",n=>{let i=t.getBoundingClientRect();if(this.drag){let r=n.clientX-this.drag.x;Math.abs(r)>3&&(this.moved=!0);let o=this.data.bars.length;this.view.end=Math.min(o-1+20,Math.max(0,this.drag.end-r/this.view.barWidth))}this.hover(P(n.clientX-i.left,i.width-T,this.view))}),t.addEventListener("pointerup",n=>{let i=t.getBoundingClientRect();if(this.drag&&!this.moved){let r=P(n.clientX-i.left,i.width-T,this.view);r>=0&&r<this.data.bars.length&&this.opts.onBarClick?.(r)}this.drag=null}),t.addEventListener("pointerleave",()=>this.hover(null))}hover(t){let n=t!==null&&t>=0&&t<this.data.bars.length?t:null;this.frame.hover=n,this.renderLegend(n??this.frame.marked??this.data.bars.length-1),this.schedule()}renderLegend(t){let n=this.data.bars[t];if(!n){this.legend.textContent="";return}let i=o=>I(o,2),r=[`O ${i(n.open)} H ${i(n.high)} L ${i(n.low)} C ${i(n.close)}`];for(let o of this.data.series??[]){let l=o.values[t];r.push(`${o.name} ${l==null?"na":i(l)}`)}this.legend.textContent=r.join(" ")}schedule(){cancelAnimationFrame(this.raf),this.raf=requestAnimationFrame(()=>this.draw())}draw(){let t=window.devicePixelRatio||1,n=this.el.clientWidth,i=this.el.clientHeight;if(n===0||i===0)return;(this.canvas.width!==Math.round(n*t)||this.canvas.height!==Math.round(i*t))&&(this.canvas.width=Math.round(n*t),this.canvas.height=Math.round(i*t));let r=this.canvas.getContext("2d");if(!r)return;r.setTransform(t,0,0,t,0,0),this.frame.width=n,this.frame.height=i,this.frame.hover===null&&this.renderLegend(this.frame.marked??this.data.bars.length-1);let o=G(this.el,this.opts.theme);ee(this.el,o),Y(r,this.data,this.view,o,this.frame)}};function be(e,t={}){return new k(e,t)}var ge="0.1.0";function fe(e){let t=e.split(`
6
+ `).filter(a=>a.trim()),n=(t.shift()??"").split(",").map(a=>a.trim().toLowerCase()),i=a=>n.indexOf(a),[r,o,l,u,h]=["time","open","high","low","close"].map(i);if([r,o,l,u,h].some(a=>a===void 0||a<0))return[];let m=[];for(let a of t){let d=a.split(","),c={time:Number(d[r]),open:Number(d[o]),high:Number(d[l]),low:Number(d[u]),close:Number(d[h])};Object.values(c).every(Number.isFinite)&&m.push(c)}return m}export{Z as ATTRIBUTION_HREF,O as ATTRIBUTION_SRC,k as GlotChart,_ as THEMES,ge as VERSION,P as barAt,fe as barsFromCsv,q as bisect,be as createChart,H as decimalsFor,L as extent,I as formatNumber,W as niceStep,G as readTheme,B as resolveColor,U as visibleRange,N as xOf};
@@ -0,0 +1,6 @@
1
+ /*! Glot Charts 0.1.0 | Apache-2.0 with NOTICE | https://github.com/tradeglot/glot-charts */
2
+ "use strict";var GlotCharts=(()=>{var k=Object.defineProperty;var he=Object.getOwnPropertyDescriptor;var me=Object.getOwnPropertyNames;var de=Object.prototype.hasOwnProperty;var ue=(e,t,n)=>t in e?k(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ce=(e,t)=>{for(var n in t)k(e,n,{get:t[n],enumerable:!0})},pe=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of me(t))!de.call(e,r)&&r!==n&&k(e,r,{get:()=>t[r],enumerable:!(i=he(t,r))||i.enumerable});return e};var be=e=>pe(k({},"__esModule",{value:!0}),e);var g=(e,t,n)=>ue(e,typeof t!="symbol"?t+"":t,n);var Ie={};ce(Ie,{ATTRIBUTION_HREF:()=>Z,ATTRIBUTION_SRC:()=>O,GlotChart:()=>A,THEMES:()=>_,VERSION:()=>oe,barAt:()=>P,barsFromCsv:()=>ae,bisect:()=>z,createChart:()=>re,decimalsFor:()=>H,extent:()=>L,formatNumber:()=>M,niceStep:()=>W,readTheme:()=>G,resolveColor:()=>D,visibleRange:()=>V,xOf:()=>N});function V(e,t,n){let i=Math.ceil(t/n.barWidth)+1,r=Math.min(e-1,Math.floor(n.end));return[Math.max(0,r-i+1),r]}function N(e,t,n){return t-(n.end-e+.5)*n.barWidth}function P(e,t,n){return Math.round(n.end+.5-(t-e)/n.barWidth)}function L(e,t=.05){let n=1/0,i=-1/0;for(let o of e)o===null||!Number.isFinite(o)||(o<n&&(n=o),o>i&&(i=o));if(n===1/0)return[0,1];if(n===i)return[n-1,i+1];let r=(i-n)*t;return[n-r,i+r]}function W(e,t){let n=e/Math.max(1,t),i=10**Math.floor(Math.log10(n)),r=n/i;return(r<1.5?1:r<3?2:r<7?5:10)*i}function H(e){return Math.max(0,Math.min(8,-Math.floor(Math.log10(e)+1e-9)))}function M(e,t){let n=Math.abs(e).toFixed(t),[i="0",r]=n.split("."),o=i.replace(/\B(?=(\d{3})+(?!\d))/g,",");return(e<0?"\u2212":"")+o+(r?"."+r:"")}function D(e,t){if(!e)return null;switch(e){case"up":return t.up;case"down":return t.down;case"accent":return t.accent;case"neutral":return t.muted;default:return e}}function j(e,t,n,i,r,o,l,u){e.lineWidth=1.5;for(let h=Math.max(r,1);h<=o;h++){let m=t.values[h-1],a=t.values[h];m==null||a===null||a===void 0||(e.strokeStyle=D(t.colors?.[h],i)??n,e.beginPath(),e.moveTo(l(h-1),u(m)),e.lineTo(l(h),u(a)),e.stroke())}e.lineWidth=1}function X(e,t,n,i,r,o,l,u){let h=n.find(a=>a.name===t.a)?.values,m=n.find(a=>a.name===t.b)?.values;if(!(!h||!m))for(let a=Math.max(r,1);a<=o;a++){let d=[h[a-1],h[a],m[a],m[a-1]],c=D(t.colors[a],i);if(!c||d.some(b=>b==null))continue;let[y,S,I,E]=d;e.fillStyle=c,e.beginPath(),e.moveTo(l(a-1),u(y)),e.lineTo(l(a),u(S)),e.lineTo(l(a),u(I)),e.lineTo(l(a-1),u(E)),e.closePath(),e.fill()}}function Y(e,t,n,i,r,o,l,u,h){for(let a=r;a<=o;a++){if(!t.values[a])continue;let d=n[a],c=l(a),y=t.at==="below_bar"?u(d.low)+12+2:t.at==="top"?12:t.at==="bottom"?h-12:u(d.high)-12-2,S=D(t.colors?.[a],i)??i.accent;if(e.fillStyle=e.strokeStyle=S,ge(e,t.shape,c,y,6),t.text){e.font=`11px ${i.font}`,e.textAlign="center";let I=t.at==="below_bar"||t.at==="bottom";e.fillText(t.text,c,I?y+12+4:y-12-4),e.textAlign="start"}}}function ge(e,t,n,i,r){switch(e.beginPath(),t){case"triangle_up":case"arrow_up":case"label_up":x(e,[n,i-r,n+r,i+r,n-r,i+r]);break;case"triangle_down":case"arrow_down":case"label_down":x(e,[n,i+r,n+r,i-r,n-r,i-r]);break;case"square":e.rect(n-r*.8,i-r*.8,r*1.6,r*1.6);break;case"diamond":x(e,[n,i-r,n+r,i,n,i+r,n-r,i]);break;case"cross":case"x_cross":{let o=t==="cross"?0:Math.PI/4;e.lineWidth=2;for(let l of[o,o+Math.PI/2])e.moveTo(n-r*Math.cos(l),i-r*Math.sin(l)),e.lineTo(n+r*Math.cos(l),i+r*Math.sin(l));e.stroke(),e.lineWidth=1;return}case"flag":x(e,[n-r*.6,i-r,n+r,i-r*.4,n-r*.6,i+r*.2]);break;default:e.arc(n,i,r*.7,0,Math.PI*2)}e.fill()}function x(e,t){e.moveTo(t[0],t[1]);for(let n=2;n<t.length;n+=2)e.lineTo(t[n],t[n+1]);e.closePath()}var T=72,R=24;function K(e,t,n,i,r){let o=r.width-T,l=t.series??[],u=l.filter(s=>!s.overlay),h=(r.height-R)*(u.length?.72:1),m=h,a=r.height-R-h;if(e.clearRect(0,0,r.width,r.height),e.fillStyle=i.bg,e.fillRect(0,0,r.width,r.height),t.bars.length===0)return;let[d,c]=V(t.bars.length,o,n),y=t.bars.slice(d,c+1),S=l.filter(s=>s.overlay),[I,E]=L([...y.flatMap(s=>[s.low,s.high]),...S.flatMap(s=>s.values.slice(d,c+1))]),b=s=>(E-s)/(E-I)*(h-8)+4,f=s=>N(s,o,n),B=W(E-I,Math.max(2,Math.floor(h/60))),$=H(B);e.font=`12px ${i.mono}`,e.textBaseline="middle";for(let s=Math.ceil(I/B)*B;s<=E;s+=B)F(e,i.grid,0,b(s),o,b(s)),e.fillStyle=i.muted,e.fillText(M(s,$),o+6,b(s));r.marked!==null&&r.marked>=d&&r.marked<=c&&(e.fillStyle=i.grid,e.fillRect(f(r.marked)-n.barWidth/2,0,n.barWidth,r.height-R));let U=Math.max(1,n.barWidth*.7);for(let s=d;s<=c;s++){let p=t.bars[s],v=p.close>=p.open;e.strokeStyle=e.fillStyle=v?i.up:i.down;let w=Math.round(f(s))+.5;F(e,e.strokeStyle,w,b(p.high),w,b(p.low));let C=b(Math.max(p.open,p.close));e.fillRect(w-U/2,C,U,Math.max(1,b(Math.min(p.open,p.close))-C))}for(let s of t.fills??[])X(e,s,l,i,d,c,f,b);S.forEach((s,p)=>{let v=i.series[p%i.series.length];s.colors?.some(w=>w)?j(e,s,v,i,d,c,f,b):q(e,v,s.values,d,c,f,b,p>=i.series.length)});for(let s of t.shapes??[])Y(e,s,t.bars,i,d,c,f,b,h);let J=s=>z(t.bars,s);for(let s of t.trades??[]){let p=J(s.entryTime),v=J(s.exitTime),w=s.side==="buy"?i.up:i.down;p>=d&&p<=c&&we(e,w,f(p),b(s.entryPrice),s.side==="buy"),v>=d&&v<=c&&Ce(e,w,f(v),b(s.exitPrice))}if(u.length){F(e,i.grid,0,m,r.width,m);let[s,p]=L(u.flatMap(C=>C.values.slice(d,c+1))),v=C=>m+4+(p-C)/(p-s)*(a-8);u.forEach((C,se)=>{let Q=i.series[se%i.series.length];C.colors?.some(le=>le)?j(e,C,Q,i,d,c,f,v):q(e,Q,C.values,d,c,f,v,!1)});let w=H(W(p-s,2));e.fillStyle=i.muted,e.fillText(M(p,w),o+6,m+10),e.fillText(M(s,w),o+6,m+a-10)}fe(e,t,n,i,r,d,c),ve(e,t,i,r,f,b,h,$)}function fe(e,t,n,i,r,o,l){let u=r.width-T,h=r.height-R;F(e,i.grid,0,h,r.width,h),e.fillStyle=i.muted,e.font=`12px ${i.font}`;let m=Math.max(1,Math.ceil(110/n.barWidth));for(let a=o-o%m;a<=l;a+=m){if(a<o)continue;let d=new Date(t.bars[a].time).toISOString();e.fillText(`${d.slice(5,10)} ${d.slice(11,16)}`,N(a,u,n)-30,h+12)}e.fillText("UTC",u+6,h+12)}function ve(e,t,n,i,r,o,l,u){if(i.hover===null||!t.bars[i.hover])return;let h=t.bars[i.hover];e.setLineDash([4,4]),F(e,n.muted,Math.round(r(i.hover))+.5,0,Math.round(r(i.hover))+.5,i.height-R),e.setLineDash([]);let m=o(h.close);m>=0&&m<=l&&(e.fillStyle=n.grid,e.fillRect(i.width-T,m-9,T,18),e.fillStyle=n.text,e.font=`12px ${n.mono}`,e.fillText(M(h.close,u+1),i.width-T+6,m))}function q(e,t,n,i,r,o,l,u){e.strokeStyle=t,e.lineWidth=1.5,e.setLineDash(u?[6,3]:[]),e.beginPath();let h=!1;for(let m=i;m<=r;m++){let a=n[m];if(a==null||!Number.isFinite(a)){h=!1;continue}h?e.lineTo(o(m),l(a)):e.moveTo(o(m),l(a)),h=!0}e.stroke(),e.setLineDash([]),e.lineWidth=1}function F(e,t,n,i,r,o){e.strokeStyle=t,e.beginPath(),e.moveTo(n,i),e.lineTo(r,o),e.stroke()}function we(e,t,n,i,r){let l=r?i+10:i-10;e.fillStyle=t,e.beginPath(),e.moveTo(n,r?l-6:l+6),e.lineTo(n-6,r?l+6:l-6),e.lineTo(n+6,r?l+6:l-6),e.fill()}function Ce(e,t,n,i){e.strokeStyle=t,e.lineWidth=2,e.beginPath(),e.arc(n,i,4,0,Math.PI*2),e.stroke(),e.lineWidth=1}function z(e,t){let n=0,i=e.length-1;for(;n<i;){let r=n+i+1>>1;e[r].time<=t?n=r:i=r-1}return n}var O="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI5NiIgaGVpZ2h0PSIyMCIgdmlld0JveD0iMCAwIDk2IDIwIiByb2xlPSJpbWciIGFyaWEtbGFiZWw9Ikdsb3QgQ2hhcnRzIj4KPHJlY3QgeD0iMiIgeT0iMiIgd2lkdGg9IjE2IiBoZWlnaHQ9IjE2IiByeD0iNCIgZmlsbD0iIzZENUJGRiIvPgo8cGF0aCBkPSJNNyA2LjVMNC44IDEwIDcgMTMuNU0xMyA2LjVMMTUuMiAxMCAxMyAxMy41IiBmaWxsPSJub25lIiBzdHJva2U9IiNGRkZGRkYiIHN0cm9rZS13aWR0aD0iMS40IiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz4KPHJlY3QgeD0iOC42IiB5PSI3IiB3aWR0aD0iMi44IiBoZWlnaHQ9IjYiIHJ4PSIwLjgiIGZpbGw9IiNGRkZGRkYiLz4KPHRleHQgeD0iMjMiIHk9IjE0LjUiIGZvbnQtZmFtaWx5PSJTcGFjZSBHcm90ZXNrLCBBcmlhbCwgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIxMiIgZm9udC13ZWlnaHQ9IjYwMCIgZmlsbD0iIzVBNUY3QSI+R2xvdCBDaGFydHM8L3RleHQ+Cjwvc3ZnPgo=",Z="https://tradeglot.com/";var Te=`
3
+ :where(.glot-chart-legend){position:absolute;left:8px;top:6px;right:80px;font:12px var(--glot-chart-mono);color:var(--glot-chart-text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;pointer-events:none}
4
+ :where(.glot-chart-label){position:absolute;right:80px;bottom:30px;font:600 12px var(--glot-chart-font);color:var(--glot-chart-muted);border:1px solid var(--glot-chart-grid);border-radius:999px;padding:2px 10px;pointer-events:none}
5
+ `;function ee(e){if(e.querySelector("style[data-glot-charts]"))return;let t=e.createElement("style");t.dataset.glotCharts="",t.textContent=Te,e.head.append(t)}function te(e,t){e.style.setProperty("--glot-chart-text",t.text),e.style.setProperty("--glot-chart-muted",t.muted),e.style.setProperty("--glot-chart-grid",t.grid),e.style.setProperty("--glot-chart-font",t.font),e.style.setProperty("--glot-chart-mono",t.mono)}var ne='"Be Vietnam Pro", "Inter", sans-serif',ie='"JetBrains Mono", Menlo, monospace',_={dark:{bg:"#0E0F1A",text:"#ECEEF8",muted:"#A3A8C3",grid:"#2A2E48",up:"#3D8BFF",down:"#FF7A3D",accent:"#A99FFF",font:ne,mono:ie,series:["#A99FFF","#ECEEF8","#A3A8C3"]},light:{bg:"#F6F6FB",text:"#14152B",muted:"#5A5F7A",grid:"#DCDDEA",up:"#2266DE",down:"#BA481A",accent:"#5B4BE0",font:ne,mono:ie,series:["#5B4BE0","#14152B","#5A5F7A"]}};function G(e,t="dark"){let n=typeof t=="string"?_[t]:{..._.dark,...t},i=getComputedStyle(e),r=(m,a)=>i.getPropertyValue(m).trim()||a,o=r("--tg-text-accent",n.accent),l=r("--tg-text",n.text),u=r("--tg-muted",n.muted),h=i.getPropertyValue("--tg-text-accent").trim()!=="";return{bg:r("--tg-bg",n.bg),text:l,muted:u,grid:r("--tg-border",n.grid),up:r("--tg-chart-candle-up",n.up),down:r("--tg-chart-candle-down",n.down),accent:o,font:r("--tg-font-ui",n.font),mono:r("--tg-font-mono",n.mono),series:h?[o,l,u]:n.series}}var Me=2,ye=40,A=class{constructor(t,n={}){this.opts=n;g(this,"el");g(this,"canvas");g(this,"legend");g(this,"labelEl");g(this,"data",{bars:[]});g(this,"view",{end:0,barWidth:8});g(this,"frame",{width:0,height:0,hover:null,marked:null});g(this,"drag",null);g(this,"moved",!1);g(this,"raf",0);g(this,"resize");if(this.el=document.createElement("div"),this.el.className="glot-chart",this.el.style.cssText="position:relative;width:100%;height:100%;overflow:hidden;touch-action:none",this.canvas=document.createElement("canvas"),this.canvas.style.cssText="position:absolute;inset:0;width:100%;height:100%;cursor:crosshair",this.canvas.setAttribute("role","img"),this.legend=document.createElement("div"),this.legend.className="glot-chart-legend",this.labelEl=document.createElement("span"),this.labelEl.className="glot-chart-label",this.el.append(this.canvas,this.legend,this.labelEl),n.attributionLogo!==!1){let i=document.createElement("a");i.className="glot-chart-attribution",i.href=n.attributionHref??Z,i.target="_blank",i.rel="noopener",i.title="Charts by Glot Charts (TradeGlot)",i.style.cssText="position:absolute;left:8px;bottom:28px;height:18px;opacity:0.7";let r=document.createElement("img");r.src=n.attributionSrc??O,r.alt="Glot Charts",r.height=18,r.style.cssText="height:18px;display:block",i.append(r),this.el.append(i)}ee(t.ownerDocument),t.append(this.el),this.bind(),this.resize=new ResizeObserver(()=>this.schedule()),this.resize.observe(this.el)}setData(t,n=!1){let i=this.view.end>=this.data.bars.length-1;this.data=t,(!n||i)&&(this.view.end=Math.max(0,t.bars.length-1)),this.labelEl.textContent=t.label??"",this.labelEl.hidden=!t.label,this.canvas.setAttribute("aria-label",this.ariaLabel()),this.schedule()}update(t){let n=this.data.bars,i=n[n.length-1],r=this.view.end>=n.length-1;if(i&&t.time<i.time)throw new RangeError(`update: bar time ${t.time} is older than the last bar ${i.time}`);i&&t.time===i.time?n[n.length-1]=t:(n.push(t),r&&(this.view.end=n.length-1)),this.canvas.setAttribute("aria-label",this.ariaLabel()),this.schedule()}setTheme(t){this.opts={...this.opts,theme:t},this.schedule()}getData(){return this.data}mark(t){if(this.frame.marked=t,t!==null){let n=(this.frame.width-T)/this.view.barWidth;(t>this.view.end||t<this.view.end-n+1)&&(this.view.end=Math.min(this.data.bars.length-1,t+Math.floor(n/2)))}this.schedule()}refresh(){this.schedule()}dispose(){this.resize.disconnect(),cancelAnimationFrame(this.raf),this.el.remove()}ariaLabel(){let t=this.data.label;return`${this.data.bars.length} bars${t?`, ${t}`:""}`}bind(){let t=this.canvas;t.addEventListener("wheel",n=>{n.preventDefault();let i=n.deltaY>0?.85:1.15;this.view.barWidth=Math.min(ye,Math.max(Me,this.view.barWidth*i)),this.schedule()},{passive:!1}),t.addEventListener("pointerdown",n=>{this.drag={x:n.clientX,end:this.view.end},this.moved=!1,t.setPointerCapture(n.pointerId)}),t.addEventListener("pointermove",n=>{let i=t.getBoundingClientRect();if(this.drag){let r=n.clientX-this.drag.x;Math.abs(r)>3&&(this.moved=!0);let o=this.data.bars.length;this.view.end=Math.min(o-1+20,Math.max(0,this.drag.end-r/this.view.barWidth))}this.hover(P(n.clientX-i.left,i.width-T,this.view))}),t.addEventListener("pointerup",n=>{let i=t.getBoundingClientRect();if(this.drag&&!this.moved){let r=P(n.clientX-i.left,i.width-T,this.view);r>=0&&r<this.data.bars.length&&this.opts.onBarClick?.(r)}this.drag=null}),t.addEventListener("pointerleave",()=>this.hover(null))}hover(t){let n=t!==null&&t>=0&&t<this.data.bars.length?t:null;this.frame.hover=n,this.renderLegend(n??this.frame.marked??this.data.bars.length-1),this.schedule()}renderLegend(t){let n=this.data.bars[t];if(!n){this.legend.textContent="";return}let i=o=>M(o,2),r=[`O ${i(n.open)} H ${i(n.high)} L ${i(n.low)} C ${i(n.close)}`];for(let o of this.data.series??[]){let l=o.values[t];r.push(`${o.name} ${l==null?"na":i(l)}`)}this.legend.textContent=r.join(" ")}schedule(){cancelAnimationFrame(this.raf),this.raf=requestAnimationFrame(()=>this.draw())}draw(){let t=window.devicePixelRatio||1,n=this.el.clientWidth,i=this.el.clientHeight;if(n===0||i===0)return;(this.canvas.width!==Math.round(n*t)||this.canvas.height!==Math.round(i*t))&&(this.canvas.width=Math.round(n*t),this.canvas.height=Math.round(i*t));let r=this.canvas.getContext("2d");if(!r)return;r.setTransform(t,0,0,t,0,0),this.frame.width=n,this.frame.height=i,this.frame.hover===null&&this.renderLegend(this.frame.marked??this.data.bars.length-1);let o=G(this.el,this.opts.theme);te(this.el,o),K(r,this.data,this.view,o,this.frame)}};function re(e,t={}){return new A(e,t)}var oe="0.1.0";function ae(e){let t=e.split(`
6
+ `).filter(a=>a.trim()),n=(t.shift()??"").split(",").map(a=>a.trim().toLowerCase()),i=a=>n.indexOf(a),[r,o,l,u,h]=["time","open","high","low","close"].map(i);if([r,o,l,u,h].some(a=>a===void 0||a<0))return[];let m=[];for(let a of t){let d=a.split(","),c={time:Number(d[r]),open:Number(d[o]),high:Number(d[l]),low:Number(d[u]),close:Number(d[h])};Object.values(c).every(Number.isFinite)&&m.push(c)}return m}return be(Ie);})();
@@ -0,0 +1,9 @@
1
+ export { GlotChart, createChart } from "./chart.js";
2
+ export { ATTRIBUTION_HREF, ATTRIBUTION_SRC } from "./attribution.js";
3
+ export { VERSION } from "./version.js";
4
+ export { THEMES, readTheme, type ChartTheme, type ThemeOption } from "./theme.js";
5
+ export { barsFromCsv } from "./csv.js";
6
+ export { bisect } from "./draw.js";
7
+ export * from "./scale.js";
8
+ export { resolveColor } from "./marks.js";
9
+ export type { Bar, ChartData, ChartOptions, FillSeries, LineSeries, ProgramColor, ShapeSeries, TradeMark, } from "./types.js";
package/dist/index.js ADDED
@@ -0,0 +1,648 @@
1
+ /*! Glot Charts 0.1.0 | Apache-2.0 with NOTICE | https://github.com/tradeglot/glot-charts */
2
+ var __defProp = Object.defineProperty;
3
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+
6
+ // src/scale.ts
7
+ function visibleRange(n, width, v) {
8
+ const count = Math.ceil(width / v.barWidth) + 1;
9
+ const last = Math.min(n - 1, Math.floor(v.end));
10
+ const first = Math.max(0, last - count + 1);
11
+ return [first, last];
12
+ }
13
+ function xOf(i, width, v) {
14
+ return width - (v.end - i + 0.5) * v.barWidth;
15
+ }
16
+ function barAt(x, width, v) {
17
+ return Math.round(v.end + 0.5 - (width - x) / v.barWidth);
18
+ }
19
+ function extent(values, pad = 0.05) {
20
+ let lo = Infinity;
21
+ let hi = -Infinity;
22
+ for (const x of values) {
23
+ if (x === null || !Number.isFinite(x)) continue;
24
+ if (x < lo) lo = x;
25
+ if (x > hi) hi = x;
26
+ }
27
+ if (lo === Infinity) return [0, 1];
28
+ if (lo === hi) return [lo - 1, hi + 1];
29
+ const p = (hi - lo) * pad;
30
+ return [lo - p, hi + p];
31
+ }
32
+ function niceStep(range, ticks) {
33
+ const raw = range / Math.max(1, ticks);
34
+ const mag = 10 ** Math.floor(Math.log10(raw));
35
+ const norm = raw / mag;
36
+ const nice = norm < 1.5 ? 1 : norm < 3 ? 2 : norm < 7 ? 5 : 10;
37
+ return nice * mag;
38
+ }
39
+ function decimalsFor(step) {
40
+ return Math.max(0, Math.min(8, -Math.floor(Math.log10(step) + 1e-9)));
41
+ }
42
+ function formatNumber(v, decimals) {
43
+ const s = Math.abs(v).toFixed(decimals);
44
+ const [i = "0", f] = s.split(".");
45
+ const g = i.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
46
+ return (v < 0 ? "\u2212" : "") + g + (f ? "." + f : "");
47
+ }
48
+
49
+ // src/marks.ts
50
+ function resolveColor(c, th) {
51
+ if (!c) return null;
52
+ switch (c) {
53
+ case "up":
54
+ return th.up;
55
+ case "down":
56
+ return th.down;
57
+ case "accent":
58
+ return th.accent;
59
+ case "neutral":
60
+ return th.muted;
61
+ default:
62
+ return c;
63
+ }
64
+ }
65
+ function coloredLine(ctx, s, fallback, th, a, b, x, y) {
66
+ ctx.lineWidth = 1.5;
67
+ for (let i = Math.max(a, 1); i <= b; i++) {
68
+ const p = s.values[i - 1];
69
+ const q = s.values[i];
70
+ if (p === null || p === void 0 || q === null || q === void 0) continue;
71
+ ctx.strokeStyle = resolveColor(s.colors?.[i], th) ?? fallback;
72
+ ctx.beginPath();
73
+ ctx.moveTo(x(i - 1), y(p));
74
+ ctx.lineTo(x(i), y(q));
75
+ ctx.stroke();
76
+ }
77
+ ctx.lineWidth = 1;
78
+ }
79
+ function drawFill(ctx, f, lines, th, a, b, x, y) {
80
+ const la = lines.find((l) => l.name === f.a)?.values;
81
+ const lb = lines.find((l) => l.name === f.b)?.values;
82
+ if (!la || !lb) return;
83
+ for (let i = Math.max(a, 1); i <= b; i++) {
84
+ const v = [la[i - 1], la[i], lb[i], lb[i - 1]];
85
+ const color = resolveColor(f.colors[i], th);
86
+ if (!color || v.some((n) => n === null || n === void 0)) continue;
87
+ const [a0, a1, b1, b0] = v;
88
+ ctx.fillStyle = color;
89
+ ctx.beginPath();
90
+ ctx.moveTo(x(i - 1), y(a0));
91
+ ctx.lineTo(x(i), y(a1));
92
+ ctx.lineTo(x(i), y(b1));
93
+ ctx.lineTo(x(i - 1), y(b0));
94
+ ctx.closePath();
95
+ ctx.fill();
96
+ }
97
+ }
98
+ function drawShapes(ctx, s, bars, th, a, b, x, y, paneH) {
99
+ const r = 6;
100
+ for (let i = a; i <= b; i++) {
101
+ if (!s.values[i]) continue;
102
+ const bar = bars[i];
103
+ const cx = x(i);
104
+ const cy = s.at === "below_bar" ? y(bar.low) + 2 * r + 2 : s.at === "top" ? 2 * r : s.at === "bottom" ? paneH - 2 * r : y(bar.high) - 2 * r - 2;
105
+ const color = resolveColor(s.colors?.[i], th) ?? th.accent;
106
+ ctx.fillStyle = ctx.strokeStyle = color;
107
+ shape(ctx, s.shape, cx, cy, r);
108
+ if (s.text) {
109
+ ctx.font = `11px ${th.font}`;
110
+ ctx.textAlign = "center";
111
+ const below = s.at === "below_bar" || s.at === "bottom";
112
+ ctx.fillText(s.text, cx, below ? cy + 2 * r + 4 : cy - 2 * r - 4);
113
+ ctx.textAlign = "start";
114
+ }
115
+ }
116
+ }
117
+ function shape(ctx, kind, cx, cy, r) {
118
+ ctx.beginPath();
119
+ switch (kind) {
120
+ case "triangle_up":
121
+ case "arrow_up":
122
+ case "label_up":
123
+ poly(ctx, [cx, cy - r, cx + r, cy + r, cx - r, cy + r]);
124
+ break;
125
+ case "triangle_down":
126
+ case "arrow_down":
127
+ case "label_down":
128
+ poly(ctx, [cx, cy + r, cx + r, cy - r, cx - r, cy - r]);
129
+ break;
130
+ case "square":
131
+ ctx.rect(cx - r * 0.8, cy - r * 0.8, r * 1.6, r * 1.6);
132
+ break;
133
+ case "diamond":
134
+ poly(ctx, [cx, cy - r, cx + r, cy, cx, cy + r, cx - r, cy]);
135
+ break;
136
+ case "cross":
137
+ case "x_cross": {
138
+ const d = kind === "cross" ? 0 : Math.PI / 4;
139
+ ctx.lineWidth = 2;
140
+ for (const t of [d, d + Math.PI / 2]) {
141
+ ctx.moveTo(cx - r * Math.cos(t), cy - r * Math.sin(t));
142
+ ctx.lineTo(cx + r * Math.cos(t), cy + r * Math.sin(t));
143
+ }
144
+ ctx.stroke();
145
+ ctx.lineWidth = 1;
146
+ return;
147
+ }
148
+ case "flag":
149
+ poly(ctx, [cx - r * 0.6, cy - r, cx + r, cy - r * 0.4, cx - r * 0.6, cy + r * 0.2]);
150
+ break;
151
+ default:
152
+ ctx.arc(cx, cy, r * 0.7, 0, Math.PI * 2);
153
+ }
154
+ ctx.fill();
155
+ }
156
+ function poly(ctx, pts) {
157
+ ctx.moveTo(pts[0], pts[1]);
158
+ for (let k = 2; k < pts.length; k += 2) ctx.lineTo(pts[k], pts[k + 1]);
159
+ ctx.closePath();
160
+ }
161
+
162
+ // src/draw.ts
163
+ var AXIS_W = 72;
164
+ var AXIS_H = 24;
165
+ function drawFrame(ctx, d, v, th, f) {
166
+ const plotW = f.width - AXIS_W;
167
+ const series = d.series ?? [];
168
+ const lower = series.filter((s) => !s.overlay);
169
+ const mainH = (f.height - AXIS_H) * (lower.length ? 0.72 : 1);
170
+ const lowerTop = mainH;
171
+ const lowerH = f.height - AXIS_H - mainH;
172
+ ctx.clearRect(0, 0, f.width, f.height);
173
+ ctx.fillStyle = th.bg;
174
+ ctx.fillRect(0, 0, f.width, f.height);
175
+ if (d.bars.length === 0) return;
176
+ const [a, b] = visibleRange(d.bars.length, plotW, v);
177
+ const vis = d.bars.slice(a, b + 1);
178
+ const overlays = series.filter((s) => s.overlay);
179
+ const [lo, hi] = extent([
180
+ ...vis.flatMap((x2) => [x2.low, x2.high]),
181
+ ...overlays.flatMap((s) => s.values.slice(a, b + 1))
182
+ ]);
183
+ const y = (p) => (hi - p) / (hi - lo) * (mainH - 8) + 4;
184
+ const x = (i) => xOf(i, plotW, v);
185
+ const step = niceStep(hi - lo, Math.max(2, Math.floor(mainH / 60)));
186
+ const dec = decimalsFor(step);
187
+ ctx.font = `12px ${th.mono}`;
188
+ ctx.textBaseline = "middle";
189
+ for (let p = Math.ceil(lo / step) * step; p <= hi; p += step) {
190
+ line(ctx, th.grid, 0, y(p), plotW, y(p));
191
+ ctx.fillStyle = th.muted;
192
+ ctx.fillText(formatNumber(p, dec), plotW + 6, y(p));
193
+ }
194
+ if (f.marked !== null && f.marked >= a && f.marked <= b) {
195
+ ctx.fillStyle = th.grid;
196
+ ctx.fillRect(x(f.marked) - v.barWidth / 2, 0, v.barWidth, f.height - AXIS_H);
197
+ }
198
+ const bw = Math.max(1, v.barWidth * 0.7);
199
+ for (let i = a; i <= b; i++) {
200
+ const bar = d.bars[i];
201
+ const up = bar.close >= bar.open;
202
+ ctx.strokeStyle = ctx.fillStyle = up ? th.up : th.down;
203
+ const cx = Math.round(x(i)) + 0.5;
204
+ line(ctx, ctx.strokeStyle, cx, y(bar.high), cx, y(bar.low));
205
+ const top = y(Math.max(bar.open, bar.close));
206
+ ctx.fillRect(cx - bw / 2, top, bw, Math.max(1, y(Math.min(bar.open, bar.close)) - top));
207
+ }
208
+ for (const fl of d.fills ?? []) drawFill(ctx, fl, series, th, a, b, x, y);
209
+ overlays.forEach((s, k) => {
210
+ const color = th.series[k % th.series.length];
211
+ if (s.colors?.some((c) => c)) coloredLine(ctx, s, color, th, a, b, x, y);
212
+ else polyline(ctx, color, s.values, a, b, x, y, k >= th.series.length);
213
+ });
214
+ for (const sh of d.shapes ?? []) drawShapes(ctx, sh, d.bars, th, a, b, x, y, mainH);
215
+ const index = (t) => bisect(d.bars, t);
216
+ for (const t of d.trades ?? []) {
217
+ const ie = index(t.entryTime);
218
+ const ix = index(t.exitTime);
219
+ const color = t.side === "buy" ? th.up : th.down;
220
+ if (ie >= a && ie <= b) triangle(ctx, color, x(ie), y(t.entryPrice), t.side === "buy");
221
+ if (ix >= a && ix <= b) ring(ctx, color, x(ix), y(t.exitPrice));
222
+ }
223
+ if (lower.length) {
224
+ line(ctx, th.grid, 0, lowerTop, f.width, lowerTop);
225
+ const [llo, lhi] = extent(lower.flatMap((s) => s.values.slice(a, b + 1)));
226
+ const ly = (p) => lowerTop + 4 + (lhi - p) / (lhi - llo) * (lowerH - 8);
227
+ lower.forEach((s, k) => {
228
+ const color = th.series[k % th.series.length];
229
+ if (s.colors?.some((c) => c)) coloredLine(ctx, s, color, th, a, b, x, ly);
230
+ else polyline(ctx, color, s.values, a, b, x, ly, false);
231
+ });
232
+ const ld = decimalsFor(niceStep(lhi - llo, 2));
233
+ ctx.fillStyle = th.muted;
234
+ ctx.fillText(formatNumber(lhi, ld), plotW + 6, lowerTop + 10);
235
+ ctx.fillText(formatNumber(llo, ld), plotW + 6, lowerTop + lowerH - 10);
236
+ }
237
+ drawTimeAxis(ctx, d, v, th, f, a, b);
238
+ drawCrosshair(ctx, d, th, f, x, y, mainH, dec);
239
+ }
240
+ function drawTimeAxis(ctx, d, v, th, f, a, b) {
241
+ const plotW = f.width - AXIS_W;
242
+ const top = f.height - AXIS_H;
243
+ line(ctx, th.grid, 0, top, f.width, top);
244
+ ctx.fillStyle = th.muted;
245
+ ctx.font = `12px ${th.font}`;
246
+ const every = Math.max(1, Math.ceil(110 / v.barWidth));
247
+ for (let i = a - a % every; i <= b; i += every) {
248
+ if (i < a) continue;
249
+ const t = new Date(d.bars[i].time).toISOString();
250
+ ctx.fillText(`${t.slice(5, 10)} ${t.slice(11, 16)}`, xOf(i, plotW, v) - 30, top + 12);
251
+ }
252
+ ctx.fillText("UTC", plotW + 6, top + 12);
253
+ }
254
+ function drawCrosshair(ctx, d, th, f, x, y, mainH, dec) {
255
+ if (f.hover === null || !d.bars[f.hover]) return;
256
+ const bar = d.bars[f.hover];
257
+ ctx.setLineDash([4, 4]);
258
+ line(
259
+ ctx,
260
+ th.muted,
261
+ Math.round(x(f.hover)) + 0.5,
262
+ 0,
263
+ Math.round(x(f.hover)) + 0.5,
264
+ f.height - AXIS_H
265
+ );
266
+ ctx.setLineDash([]);
267
+ const yc = y(bar.close);
268
+ if (yc >= 0 && yc <= mainH) {
269
+ ctx.fillStyle = th.grid;
270
+ ctx.fillRect(f.width - AXIS_W, yc - 9, AXIS_W, 18);
271
+ ctx.fillStyle = th.text;
272
+ ctx.font = `12px ${th.mono}`;
273
+ ctx.fillText(formatNumber(bar.close, dec + 1), f.width - AXIS_W + 6, yc);
274
+ }
275
+ }
276
+ function polyline(ctx, color, vals, a, b, x, y, dashed) {
277
+ ctx.strokeStyle = color;
278
+ ctx.lineWidth = 1.5;
279
+ ctx.setLineDash(dashed ? [6, 3] : []);
280
+ ctx.beginPath();
281
+ let pen = false;
282
+ for (let i = a; i <= b; i++) {
283
+ const val = vals[i];
284
+ if (val === null || val === void 0 || !Number.isFinite(val)) {
285
+ pen = false;
286
+ continue;
287
+ }
288
+ if (pen) ctx.lineTo(x(i), y(val));
289
+ else ctx.moveTo(x(i), y(val));
290
+ pen = true;
291
+ }
292
+ ctx.stroke();
293
+ ctx.setLineDash([]);
294
+ ctx.lineWidth = 1;
295
+ }
296
+ function line(ctx, color, x1, y1, x2, y2) {
297
+ ctx.strokeStyle = color;
298
+ ctx.beginPath();
299
+ ctx.moveTo(x1, y1);
300
+ ctx.lineTo(x2, y2);
301
+ ctx.stroke();
302
+ }
303
+ function triangle(ctx, color, cx, cy, up) {
304
+ const s = 6;
305
+ const yy = up ? cy + 10 : cy - 10;
306
+ ctx.fillStyle = color;
307
+ ctx.beginPath();
308
+ ctx.moveTo(cx, up ? yy - s : yy + s);
309
+ ctx.lineTo(cx - s, up ? yy + s : yy - s);
310
+ ctx.lineTo(cx + s, up ? yy + s : yy - s);
311
+ ctx.fill();
312
+ }
313
+ function ring(ctx, color, cx, cy) {
314
+ ctx.strokeStyle = color;
315
+ ctx.lineWidth = 2;
316
+ ctx.beginPath();
317
+ ctx.arc(cx, cy, 4, 0, Math.PI * 2);
318
+ ctx.stroke();
319
+ ctx.lineWidth = 1;
320
+ }
321
+ function bisect(bars, t) {
322
+ let lo = 0;
323
+ let hi = bars.length - 1;
324
+ while (lo < hi) {
325
+ const mid = lo + hi + 1 >> 1;
326
+ if (bars[mid].time <= t) lo = mid;
327
+ else hi = mid - 1;
328
+ }
329
+ return lo;
330
+ }
331
+
332
+ // src/attribution.ts
333
+ var ATTRIBUTION_SRC = new URL("../assets/glot-charts-attribution.svg", import.meta.url).href;
334
+ var ATTRIBUTION_HREF = "https://tradeglot.com/";
335
+
336
+ // src/styles.ts
337
+ var CSS = `
338
+ :where(.glot-chart-legend){position:absolute;left:8px;top:6px;right:80px;font:12px var(--glot-chart-mono);color:var(--glot-chart-text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;pointer-events:none}
339
+ :where(.glot-chart-label){position:absolute;right:80px;bottom:30px;font:600 12px var(--glot-chart-font);color:var(--glot-chart-muted);border:1px solid var(--glot-chart-grid);border-radius:999px;padding:2px 10px;pointer-events:none}
340
+ `;
341
+ function injectStyles(doc) {
342
+ if (doc.querySelector("style[data-glot-charts]")) return;
343
+ const style = doc.createElement("style");
344
+ style.dataset.glotCharts = "";
345
+ style.textContent = CSS;
346
+ doc.head.append(style);
347
+ }
348
+ function applyThemeVars(el, th) {
349
+ el.style.setProperty("--glot-chart-text", th.text);
350
+ el.style.setProperty("--glot-chart-muted", th.muted);
351
+ el.style.setProperty("--glot-chart-grid", th.grid);
352
+ el.style.setProperty("--glot-chart-font", th.font);
353
+ el.style.setProperty("--glot-chart-mono", th.mono);
354
+ }
355
+
356
+ // src/theme.ts
357
+ var FONT_UI = '"Be Vietnam Pro", "Inter", sans-serif';
358
+ var FONT_MONO = '"JetBrains Mono", Menlo, monospace';
359
+ var THEMES = {
360
+ dark: {
361
+ bg: "#0E0F1A",
362
+ text: "#ECEEF8",
363
+ muted: "#A3A8C3",
364
+ grid: "#2A2E48",
365
+ up: "#3D8BFF",
366
+ down: "#FF7A3D",
367
+ accent: "#A99FFF",
368
+ font: FONT_UI,
369
+ mono: FONT_MONO,
370
+ series: ["#A99FFF", "#ECEEF8", "#A3A8C3"]
371
+ },
372
+ light: {
373
+ bg: "#F6F6FB",
374
+ text: "#14152B",
375
+ muted: "#5A5F7A",
376
+ grid: "#DCDDEA",
377
+ up: "#2266DE",
378
+ down: "#BA481A",
379
+ accent: "#5B4BE0",
380
+ font: FONT_UI,
381
+ mono: FONT_MONO,
382
+ series: ["#5B4BE0", "#14152B", "#5A5F7A"]
383
+ }
384
+ };
385
+ function readTheme(el, option = "dark") {
386
+ const base = typeof option === "string" ? THEMES[option] : { ...THEMES.dark, ...option };
387
+ const css = getComputedStyle(el);
388
+ const v = (name, fallback) => css.getPropertyValue(name).trim() || fallback;
389
+ const accent = v("--tg-text-accent", base.accent);
390
+ const text = v("--tg-text", base.text);
391
+ const muted = v("--tg-muted", base.muted);
392
+ const fromCss = css.getPropertyValue("--tg-text-accent").trim() !== "";
393
+ return {
394
+ bg: v("--tg-bg", base.bg),
395
+ text,
396
+ muted,
397
+ grid: v("--tg-border", base.grid),
398
+ up: v("--tg-chart-candle-up", base.up),
399
+ down: v("--tg-chart-candle-down", base.down),
400
+ accent,
401
+ font: v("--tg-font-ui", base.font),
402
+ mono: v("--tg-font-mono", base.mono),
403
+ // Lines: accent, then text, then muted.
404
+ series: fromCss ? [accent, text, muted] : base.series
405
+ };
406
+ }
407
+
408
+ // src/chart.ts
409
+ var MIN_BAR = 2;
410
+ var MAX_BAR = 40;
411
+ var GlotChart = class {
412
+ constructor(host, opts = {}) {
413
+ this.opts = opts;
414
+ __publicField(this, "el");
415
+ __publicField(this, "canvas");
416
+ __publicField(this, "legend");
417
+ __publicField(this, "labelEl");
418
+ __publicField(this, "data", { bars: [] });
419
+ __publicField(this, "view", { end: 0, barWidth: 8 });
420
+ __publicField(this, "frame", { width: 0, height: 0, hover: null, marked: null });
421
+ __publicField(this, "drag", null);
422
+ __publicField(this, "moved", false);
423
+ __publicField(this, "raf", 0);
424
+ __publicField(this, "resize");
425
+ this.el = document.createElement("div");
426
+ this.el.className = "glot-chart";
427
+ this.el.style.cssText = "position:relative;width:100%;height:100%;overflow:hidden;touch-action:none";
428
+ this.canvas = document.createElement("canvas");
429
+ this.canvas.style.cssText = "position:absolute;inset:0;width:100%;height:100%;cursor:crosshair";
430
+ this.canvas.setAttribute("role", "img");
431
+ this.legend = document.createElement("div");
432
+ this.legend.className = "glot-chart-legend";
433
+ this.labelEl = document.createElement("span");
434
+ this.labelEl.className = "glot-chart-label";
435
+ this.el.append(this.canvas, this.legend, this.labelEl);
436
+ if (opts.attributionLogo !== false) {
437
+ const link = document.createElement("a");
438
+ link.className = "glot-chart-attribution";
439
+ link.href = opts.attributionHref ?? ATTRIBUTION_HREF;
440
+ link.target = "_blank";
441
+ link.rel = "noopener";
442
+ link.title = "Charts by Glot Charts (TradeGlot)";
443
+ link.style.cssText = "position:absolute;left:8px;bottom:28px;height:18px;opacity:0.7";
444
+ const logo = document.createElement("img");
445
+ logo.src = opts.attributionSrc ?? ATTRIBUTION_SRC;
446
+ logo.alt = "Glot Charts";
447
+ logo.height = 18;
448
+ logo.style.cssText = "height:18px;display:block";
449
+ link.append(logo);
450
+ this.el.append(link);
451
+ }
452
+ injectStyles(host.ownerDocument);
453
+ host.append(this.el);
454
+ this.bind();
455
+ this.resize = new ResizeObserver(() => this.schedule());
456
+ this.resize.observe(this.el);
457
+ }
458
+ setData(data, keepView = false) {
459
+ const wasAtEnd = this.view.end >= this.data.bars.length - 1;
460
+ this.data = data;
461
+ if (!keepView || wasAtEnd) this.view.end = Math.max(0, data.bars.length - 1);
462
+ this.labelEl.textContent = data.label ?? "";
463
+ this.labelEl.hidden = !data.label;
464
+ this.canvas.setAttribute("aria-label", this.ariaLabel());
465
+ this.schedule();
466
+ }
467
+ /**
468
+ * Adds or changes the newest bar, for live data. A bar with the same time as the last bar
469
+ * replaces it; a later bar is appended. Indicator values for the new bar can follow through
470
+ * `setData`. Throws on a bar older than the last one.
471
+ */
472
+ update(bar) {
473
+ const bars = this.data.bars;
474
+ const last = bars[bars.length - 1];
475
+ const atEnd = this.view.end >= bars.length - 1;
476
+ if (last && bar.time < last.time) {
477
+ throw new RangeError(`update: bar time ${bar.time} is older than the last bar ${last.time}`);
478
+ }
479
+ if (last && bar.time === last.time) bars[bars.length - 1] = bar;
480
+ else {
481
+ bars.push(bar);
482
+ if (atEnd) this.view.end = bars.length - 1;
483
+ }
484
+ this.canvas.setAttribute("aria-label", this.ariaLabel());
485
+ this.schedule();
486
+ }
487
+ /** Switches between the built-in themes or your own colors. */
488
+ setTheme(theme) {
489
+ this.opts = { ...this.opts, theme };
490
+ this.schedule();
491
+ }
492
+ /** The data the chart currently draws. */
493
+ getData() {
494
+ return this.data;
495
+ }
496
+ /** Highlights one bar (debugger cursor) and scrolls it into view. */
497
+ mark(bar) {
498
+ this.frame.marked = bar;
499
+ if (bar !== null) {
500
+ const visible = (this.frame.width - AXIS_W) / this.view.barWidth;
501
+ if (bar > this.view.end || bar < this.view.end - visible + 1) {
502
+ this.view.end = Math.min(this.data.bars.length - 1, bar + Math.floor(visible / 2));
503
+ }
504
+ }
505
+ this.schedule();
506
+ }
507
+ /** Re-reads the theme colors (after a theme switch). */
508
+ refresh() {
509
+ this.schedule();
510
+ }
511
+ dispose() {
512
+ this.resize.disconnect();
513
+ cancelAnimationFrame(this.raf);
514
+ this.el.remove();
515
+ }
516
+ ariaLabel() {
517
+ const label = this.data.label;
518
+ return `${this.data.bars.length} bars${label ? `, ${label}` : ""}`;
519
+ }
520
+ bind() {
521
+ const c = this.canvas;
522
+ c.addEventListener(
523
+ "wheel",
524
+ (e) => {
525
+ e.preventDefault();
526
+ const factor = e.deltaY > 0 ? 0.85 : 1.15;
527
+ this.view.barWidth = Math.min(MAX_BAR, Math.max(MIN_BAR, this.view.barWidth * factor));
528
+ this.schedule();
529
+ },
530
+ { passive: false }
531
+ );
532
+ c.addEventListener("pointerdown", (e) => {
533
+ this.drag = { x: e.clientX, end: this.view.end };
534
+ this.moved = false;
535
+ c.setPointerCapture(e.pointerId);
536
+ });
537
+ c.addEventListener("pointermove", (e) => {
538
+ const r = c.getBoundingClientRect();
539
+ if (this.drag) {
540
+ const dx = e.clientX - this.drag.x;
541
+ if (Math.abs(dx) > 3) this.moved = true;
542
+ const n = this.data.bars.length;
543
+ this.view.end = Math.min(n - 1 + 20, Math.max(0, this.drag.end - dx / this.view.barWidth));
544
+ }
545
+ this.hover(barAt(e.clientX - r.left, r.width - AXIS_W, this.view));
546
+ });
547
+ c.addEventListener("pointerup", (e) => {
548
+ const r = c.getBoundingClientRect();
549
+ if (this.drag && !this.moved) {
550
+ const bar = barAt(e.clientX - r.left, r.width - AXIS_W, this.view);
551
+ if (bar >= 0 && bar < this.data.bars.length) this.opts.onBarClick?.(bar);
552
+ }
553
+ this.drag = null;
554
+ });
555
+ c.addEventListener("pointerleave", () => this.hover(null));
556
+ }
557
+ hover(bar) {
558
+ const valid = bar !== null && bar >= 0 && bar < this.data.bars.length ? bar : null;
559
+ this.frame.hover = valid;
560
+ this.renderLegend(valid ?? this.frame.marked ?? this.data.bars.length - 1);
561
+ this.schedule();
562
+ }
563
+ renderLegend(i) {
564
+ const b = this.data.bars[i];
565
+ if (!b) {
566
+ this.legend.textContent = "";
567
+ return;
568
+ }
569
+ const f = (v) => formatNumber(v, 2);
570
+ const parts = [`O ${f(b.open)} H ${f(b.high)} L ${f(b.low)} C ${f(b.close)}`];
571
+ for (const s of this.data.series ?? []) {
572
+ const v = s.values[i];
573
+ parts.push(`${s.name} ${v === null || v === void 0 ? "na" : f(v)}`);
574
+ }
575
+ this.legend.textContent = parts.join(" ");
576
+ }
577
+ schedule() {
578
+ cancelAnimationFrame(this.raf);
579
+ this.raf = requestAnimationFrame(() => this.draw());
580
+ }
581
+ draw() {
582
+ const dpr = window.devicePixelRatio || 1;
583
+ const w = this.el.clientWidth;
584
+ const h = this.el.clientHeight;
585
+ if (w === 0 || h === 0) return;
586
+ if (this.canvas.width !== Math.round(w * dpr) || this.canvas.height !== Math.round(h * dpr)) {
587
+ this.canvas.width = Math.round(w * dpr);
588
+ this.canvas.height = Math.round(h * dpr);
589
+ }
590
+ const ctx = this.canvas.getContext("2d");
591
+ if (!ctx) return;
592
+ ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
593
+ this.frame.width = w;
594
+ this.frame.height = h;
595
+ if (this.frame.hover === null)
596
+ this.renderLegend(this.frame.marked ?? this.data.bars.length - 1);
597
+ const theme = readTheme(this.el, this.opts.theme);
598
+ applyThemeVars(this.el, theme);
599
+ drawFrame(ctx, this.data, this.view, theme, this.frame);
600
+ }
601
+ };
602
+ function createChart(host, options = {}) {
603
+ return new GlotChart(host, options);
604
+ }
605
+
606
+ // src/version.ts
607
+ var VERSION = "0.1.0";
608
+
609
+ // src/csv.ts
610
+ function barsFromCsv(text) {
611
+ const lines = text.split("\n").filter((l2) => l2.trim());
612
+ const head = (lines.shift() ?? "").split(",").map((h2) => h2.trim().toLowerCase());
613
+ const col = (n) => head.indexOf(n);
614
+ const [t, o, h, l, c] = ["time", "open", "high", "low", "close"].map(col);
615
+ if ([t, o, h, l, c].some((i) => i === void 0 || i < 0)) return [];
616
+ const out = [];
617
+ for (const line2 of lines) {
618
+ const cells = line2.split(",");
619
+ const bar = {
620
+ time: Number(cells[t]),
621
+ open: Number(cells[o]),
622
+ high: Number(cells[h]),
623
+ low: Number(cells[l]),
624
+ close: Number(cells[c])
625
+ };
626
+ if (Object.values(bar).every(Number.isFinite)) out.push(bar);
627
+ }
628
+ return out;
629
+ }
630
+ export {
631
+ ATTRIBUTION_HREF,
632
+ ATTRIBUTION_SRC,
633
+ GlotChart,
634
+ THEMES,
635
+ VERSION,
636
+ barAt,
637
+ barsFromCsv,
638
+ bisect,
639
+ createChart,
640
+ decimalsFor,
641
+ extent,
642
+ formatNumber,
643
+ niceStep,
644
+ readTheme,
645
+ resolveColor,
646
+ visibleRange,
647
+ xOf
648
+ };
@@ -0,0 +1,15 @@
1
+ import type { ChartTheme } from "./theme.js";
2
+ import type { FillSeries, LineSeries, ShapeSeries } from "./types.js";
3
+ type Scale = (v: number) => number;
4
+ /** A program color as a canvas color; theme names map to the brand tokens. */
5
+ export declare function resolveColor(c: string | null | undefined, th: ChartTheme): string | null;
6
+ /** A line whose segment into bar i takes bar i's color (Pine and Glot behavior). */
7
+ export declare function coloredLine(ctx: CanvasRenderingContext2D, s: LineSeries, fallback: string, th: ChartTheme, a: number, b: number, x: Scale, y: Scale): void;
8
+ /** Fills between two lines, one quad per bar step, colored by the later bar. */
9
+ export declare function drawFill(ctx: CanvasRenderingContext2D, f: FillSeries, lines: LineSeries[], th: ChartTheme, a: number, b: number, x: Scale, y: Scale): void;
10
+ /** Marks of one `plotshape` on bars where it is true. */
11
+ export declare function drawShapes(ctx: CanvasRenderingContext2D, s: ShapeSeries, bars: {
12
+ high: number;
13
+ low: number;
14
+ }[], th: ChartTheme, a: number, b: number, x: Scale, y: Scale, paneH: number): void;
15
+ export {};
@@ -0,0 +1,17 @@
1
+ export interface Viewport {
2
+ /** Index of the right-most visible bar (may be fractional while panning). */
3
+ end: number;
4
+ /** Pixels per bar. */
5
+ barWidth: number;
6
+ }
7
+ export declare function visibleRange(n: number, width: number, v: Viewport): [number, number];
8
+ /** Bar index to x of the bar's center. */
9
+ export declare function xOf(i: number, width: number, v: Viewport): number;
10
+ export declare function barAt(x: number, width: number, v: Viewport): number;
11
+ export declare function extent(values: Iterable<number | null>, pad?: number): [number, number];
12
+ /** "Nice" tick step for a range, so labels land on round numbers. */
13
+ export declare function niceStep(range: number, ticks: number): number;
14
+ /** Decimals needed to show a tick step without trailing noise. */
15
+ export declare function decimalsFor(step: number): number;
16
+ /** International number format with a fixed number of decimals (4,116.40). */
17
+ export declare function formatNumber(v: number, decimals: number): string;
@@ -0,0 +1,3 @@
1
+ import type { ChartTheme } from "./theme.js";
2
+ export declare function injectStyles(doc: Document): void;
3
+ export declare function applyThemeVars(el: HTMLElement, th: ChartTheme): void;
@@ -0,0 +1,18 @@
1
+ export interface ChartTheme {
2
+ bg: string;
3
+ text: string;
4
+ muted: string;
5
+ grid: string;
6
+ up: string;
7
+ down: string;
8
+ accent: string;
9
+ font: string;
10
+ mono: string;
11
+ series: string[];
12
+ }
13
+ /** Built-in themes. Up is blue and down is orange; gold and teal are never used (they mark
14
+ * real money and paper trading in TradeGlot products). */
15
+ export declare const THEMES: Record<"dark" | "light", ChartTheme>;
16
+ export type ThemeOption = "dark" | "light" | Partial<ChartTheme>;
17
+ /** Resolves the theme: CSS variables on the host win, then the option, then the dark theme. */
18
+ export declare function readTheme(el: Element, option?: ThemeOption): ChartTheme;
@@ -0,0 +1,73 @@
1
+ import type { ThemeOption } from "./theme.js";
2
+ export interface Bar {
3
+ time: number;
4
+ open: number;
5
+ high: number;
6
+ low: number;
7
+ close: number;
8
+ }
9
+ export interface LineSeries {
10
+ name: string;
11
+ /** One value per bar; null where the series is `na`. */
12
+ values: (number | null)[];
13
+ /** Overlay on price (true) or in the lower pane (false). */
14
+ overlay: boolean;
15
+ /** The program's `color =` per bar (see `ProgramColor`); null keeps the theme color. */
16
+ colors?: (string | null)[];
17
+ }
18
+ /**
19
+ * A color the program chose: `#RRGGBB`, `#RRGGBBAA`, a CSS color name, or a theme name
20
+ * (`up`, `down`, `accent`, `neutral`). Program colors are the author's content and are drawn as
21
+ * written; the chart's own chrome keeps the brand tokens.
22
+ */
23
+ export type ProgramColor = string;
24
+ /** `plotshape`: a mark on each bar where `values[i]` is true. */
25
+ export interface ShapeSeries {
26
+ name: string;
27
+ values: boolean[];
28
+ /** `triangle_up`, `triangle_down`, `arrow_up`, `arrow_down`, `circle`, `square`, `diamond`,
29
+ * `cross`, `x_cross`, `label_up`, `label_down`, `flag`. */
30
+ shape: string;
31
+ /** `above_bar`, `below_bar`, `top` or `bottom`. */
32
+ at: string;
33
+ text?: string;
34
+ colors?: (ProgramColor | null)[];
35
+ }
36
+ /** `fill`: the area between two line series (by name), colored per bar. */
37
+ export interface FillSeries {
38
+ name: string;
39
+ a: string;
40
+ b: string;
41
+ colors: (ProgramColor | null)[];
42
+ }
43
+ export interface TradeMark {
44
+ side: "buy" | "sell";
45
+ entryTime: number;
46
+ entryPrice: number;
47
+ exitTime: number;
48
+ exitPrice: number;
49
+ }
50
+ export interface ChartData {
51
+ bars: Bar[];
52
+ /** Indicator lines (default none). */
53
+ series?: LineSeries[];
54
+ /** Trade marks (default none). */
55
+ trades?: TradeMark[];
56
+ shapes?: ShapeSeries[];
57
+ fills?: FillSeries[];
58
+ /** Shown top-left, for example "Sample data". */
59
+ label?: string;
60
+ }
61
+ export interface ChartOptions {
62
+ /** Glot Charts attribution logo, on by default. Turning it off requires the credit and link
63
+ * described in NOTICE and docs/attribution.md. */
64
+ attributionLogo?: boolean;
65
+ /** Where the attribution logo links (default https://tradeglot.com/). */
66
+ attributionHref?: string;
67
+ /** "dark" (default), "light" or your own colors. TradeGlot CSS variables on the page win. */
68
+ theme?: ThemeOption;
69
+ /** Called with the bar index under a click. */
70
+ onBarClick?: (bar: number) => void;
71
+ /** URL of the attribution image (default: the SVG shipped in `assets/`). */
72
+ attributionSrc?: string;
73
+ }
@@ -0,0 +1 @@
1
+ export declare const VERSION: string;
package/package.json CHANGED
@@ -1,6 +1,65 @@
1
1
  {
2
2
  "name": "@tradeglotnpm/charts",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Open-source financial chart library for the web: candles, indicator lines, marks and trades on Canvas 2D, with no run-time dependencies",
5
+ "license": "Apache-2.0",
6
+ "author": "TradeGlot",
7
+ "homepage": "https://github.com/tradeglot/glot-charts#readme",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/tradeglot/glot-charts.git",
11
+ "directory": "packages/charts"
12
+ },
13
+ "bugs": "https://github.com/tradeglot/glot-charts/issues",
14
+ "keywords": [
15
+ "chart",
16
+ "charts",
17
+ "financial-charts",
18
+ "candlestick",
19
+ "ohlc",
20
+ "trading",
21
+ "canvas",
22
+ "technical-analysis",
23
+ "glot"
24
+ ],
25
+ "type": "module",
26
+ "sideEffects": false,
27
+ "main": "./dist/index.js",
28
+ "module": "./dist/index.js",
29
+ "types": "./dist/index.d.ts",
30
+ "unpkg": "./dist/glot-charts.min.js",
31
+ "jsdelivr": "./dist/glot-charts.min.js",
32
+ "exports": {
33
+ ".": {
34
+ "types": "./dist/index.d.ts",
35
+ "import": "./dist/index.js",
36
+ "default": "./dist/index.js"
37
+ },
38
+ "./glot-charts.min.js": "./dist/glot-charts.min.js",
39
+ "./glot-charts.esm.min.js": "./dist/glot-charts.esm.min.js",
40
+ "./assets/*": "./assets/*",
41
+ "./package.json": "./package.json"
42
+ },
43
+ "files": [
44
+ "dist",
45
+ "assets",
46
+ "NOTICE",
47
+ "LICENSE",
48
+ "README.md"
49
+ ],
50
+ "publishConfig": {
51
+ "access": "public",
52
+ "provenance": true
53
+ },
54
+ "scripts": {
55
+ "build": "node scripts/build.mjs",
56
+ "check-dist": "node scripts/check-dist.mjs",
57
+ "prepack": "node scripts/build.mjs && node scripts/check-dist.mjs && cp ../../LICENSE ../../NOTICE .",
58
+ "typecheck": "tsc -p .",
59
+ "test": "vitest run --reporter=dot"
60
+ },
61
+ "devDependencies": {
62
+ "esbuild": "0.25.10",
63
+ "happy-dom": "^20.0.0"
64
+ }
65
+ }