@hybridcore/ui 1.5.79 → 1.5.82

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,249 @@
1
+ import { R as M, L, T as k, m as T, i as V, b as G, A as S, X as j, c as z, g as O, V as R, d as N, f as _, p as E } from "../../../AxisRendererY-kADUad00.js";
2
+ import { useThemeProps as H } from "@mui/material";
3
+ import { useRef as A, useLayoutEffect as W, useEffect as U } from "react";
4
+ import { X as Z, D as q } from "../../../DateAxis-CMum47iz.js";
5
+ import { C as F } from "../../../ColumnSeries-BTcqshjB.js";
6
+ class D extends M {
7
+ _beforeChanged() {
8
+ super._beforeChanged(), (this.isDirty("lowX0") || this.isDirty("lowY0") || this.isDirty("lowX1") || this.isDirty("lowY1") || this.isDirty("highX0") || this.isDirty("highX1") || this.isDirty("highY0") || this.isDirty("highY1")) && (this._clear = !0);
9
+ }
10
+ _draw() {
11
+ super._draw();
12
+ const e = this._display;
13
+ e.moveTo(this.get("lowX0", 0), this.get("lowY0", 0)), e.lineTo(this.get("lowX1", 0), this.get("lowY1", 0)), e.moveTo(this.get("highX0", 0), this.get("highY0", 0)), e.lineTo(this.get("highX1", 0), this.get("highY1", 0));
14
+ }
15
+ }
16
+ Object.defineProperty(D, "className", {
17
+ enumerable: !0,
18
+ configurable: !0,
19
+ writable: !0,
20
+ value: "Candlestick"
21
+ });
22
+ Object.defineProperty(D, "classNames", {
23
+ enumerable: !0,
24
+ configurable: !0,
25
+ writable: !0,
26
+ value: M.classNames.concat([D.className])
27
+ });
28
+ class C extends F {
29
+ constructor() {
30
+ super(...arguments), Object.defineProperty(this, "columns", {
31
+ enumerable: !0,
32
+ configurable: !0,
33
+ writable: !0,
34
+ value: this.addDisposer(new L(k.new({
35
+ themeTags: ["autocolor"]
36
+ }), () => D._new(this._root, {
37
+ themeTags: T(this.columns.template.get("themeTags", []), ["candlestick", "series", "column"])
38
+ }, [this.columns.template])))
39
+ });
40
+ }
41
+ /**
42
+ * @ignore
43
+ */
44
+ makeColumn(e, t) {
45
+ const h = t.make();
46
+ return this.get("turboMode") ? h.virtualParent = this.chart : this.mainContainer.children.push(h), h._setDataItem(e), t.push(h), h;
47
+ }
48
+ _updateGraphics(e, t, h) {
49
+ super._updateGraphics(e, t, h);
50
+ const m = this.getRaw("xAxis"), d = this.getRaw("yAxis");
51
+ let Y = this.get("vcy", 1), n = this.get("vcx", 1), c, x, u, l, g, p, w, a, o = this.get("locationX", e.get("locationX", 0.5)), r = this.get("locationY", e.get("locationY", 0.5)), s = this.get("openLocationX", e.get("openLocationX", o)), i = this.get("openLocationY", e.get("openLocationY", r)), b;
52
+ if (h == 0) {
53
+ let y = d.getDataItemPositionY(e, this._yOpenField, 1, Y), f = d.getDataItemPositionY(e, this._yField, 1, Y);
54
+ l = d.getDataItemPositionY(e, this._yLowField, 1, Y), a = d.getDataItemPositionY(e, this._yHighField, 1, Y), w = Math.max(y, f), u = Math.min(y, f);
55
+ let X = this._aLocationX0 + s - 0.5, v = this._aLocationX1 + o - 0.5;
56
+ c = m.getDataItemPositionX(e, this._xField, X + (v - X) / 2, n), x = c, g = c, p = c, b = "vertical";
57
+ } else {
58
+ let y = m.getDataItemPositionX(e, this._xOpenField, 1, n), f = m.getDataItemPositionX(e, this._xField, 1, n);
59
+ x = m.getDataItemPositionX(e, this._xLowField, 1, n), p = m.getDataItemPositionX(e, this._xHighField, 1, n), g = Math.max(y, f), c = Math.min(y, f);
60
+ let X = this._aLocationY0 + i - 0.5, v = this._aLocationY1 + r - 0.5;
61
+ u = d.getDataItemPositionY(e, this._yField, X + (v - X) / 2, Y), l = u, w = u, a = u, b = "horizontal";
62
+ }
63
+ this._updateCandleGraphics(e, c, x, u, l, g, p, w, a, b);
64
+ }
65
+ _updateCandleGraphics(e, t, h, m, d, Y, n, c, x, u) {
66
+ let l = e.get("graphics");
67
+ if (l) {
68
+ let g = this.getPoint(t, m), p = this.getPoint(h, d), w = this.getPoint(Y, c), a = this.getPoint(n, x);
69
+ if (this.get("turboMode")) {
70
+ const o = this.allColumnsData[this.allColumnsData.length - 1];
71
+ o.lowX0 = g.x, o.lowY0 = g.y, o.lowX1 = p.x, o.lowY1 = p.y, o.highX0 = w.x, o.highY0 = w.y, o.highX1 = a.x, o.highY1 = a.y;
72
+ } else {
73
+ let o = l.x(), r = l.y();
74
+ l.set("lowX0", g.x - o), l.set("lowY0", g.y - r), l.set("lowX1", p.x - o), l.set("lowY1", p.y - r), l.set("highX0", w.x - o), l.set("highY0", w.y - r), l.set("highX1", a.x - o), l.set("highY1", a.y - r), l.set("orientation", u);
75
+ let s = e.get("rangeGraphics");
76
+ s && V(s, (i) => {
77
+ i.set("lowX0", g.x - o), i.set("lowY0", g.y - r), i.set("lowX1", p.x - o), i.set("lowY1", p.y - r), i.set("highX0", w.x - o), i.set("highY0", w.y - r), i.set("highX1", a.x - o), i.set("highY1", a.y - r), i.set("orientation", u);
78
+ });
79
+ }
80
+ }
81
+ }
82
+ _afterColumnsDraw() {
83
+ this.get("turboMode") && this.allColumns.set("draw", (e) => {
84
+ e.clear(), V(this.allColumnsData, (t) => {
85
+ e.beginPath();
86
+ const h = t.width, m = t.height, d = t.x, Y = t.y, n = t.stroke, c = t.fill, x = t.strokeWidth, u = t.strokeOpacity, l = t.fillOpacity, g = t.lowX0, p = t.lowY0, w = t.lowX1, a = t.lowY1, o = t.highX0, r = t.highY0, s = t.highX1, i = t.highY1;
87
+ e.beginFill(c, l), e.beginPath(), e.lineStyle(x, n, u), e.drawRect(d, Y, h, m), e.moveTo(g, p), e.lineTo(w, a), e.moveTo(o, r), e.lineTo(s, i), e.endStroke(), e.endFill();
88
+ });
89
+ });
90
+ }
91
+ _processAxisRange(e) {
92
+ super._processAxisRange(e), e.columns = new L(k.new({}), () => D._new(this._root, {
93
+ themeTags: T(e.columns.template.get("themeTags", []), ["candlestick", "series", "column"])
94
+ }, [this.columns.template, e.columns.template]));
95
+ }
96
+ }
97
+ Object.defineProperty(C, "className", {
98
+ enumerable: !0,
99
+ configurable: !0,
100
+ writable: !0,
101
+ value: "CandlestickSeries"
102
+ });
103
+ Object.defineProperty(C, "classNames", {
104
+ enumerable: !0,
105
+ configurable: !0,
106
+ writable: !0,
107
+ value: F.classNames.concat([C.className])
108
+ });
109
+ const $ = (P) => {
110
+ const e = H({
111
+ props: P,
112
+ name: "MuiCandlestickChart"
113
+ }), {
114
+ data: t,
115
+ seriesName: h,
116
+ height: m = "500px",
117
+ width: d = "100%",
118
+ chartId: Y = "candlestick-chart",
119
+ showVolume: n = !1,
120
+ risingColor: c = "#00b050",
121
+ fallingColor: x = "#ff3b30",
122
+ loading: u = !1,
123
+ emptyMessage: l = "No data available",
124
+ sx: g,
125
+ ...p
126
+ } = e, w = {
127
+ ...e,
128
+ height: m,
129
+ width: d,
130
+ chartId: Y,
131
+ showVolume: n,
132
+ risingColor: c,
133
+ fallingColor: x,
134
+ loading: u,
135
+ emptyMessage: l
136
+ }, a = A(null), o = A(null), r = A(null);
137
+ return W(() => {
138
+ if (!r.current) return;
139
+ const s = G.new(r.current);
140
+ o.current = s, s.setThemes([S.new(s)]);
141
+ const i = s.container.children.push(
142
+ j.new(s, {
143
+ panX: !0,
144
+ panY: !0,
145
+ wheelX: "panX",
146
+ wheelY: "zoomX",
147
+ pinchZoomX: !0,
148
+ layout: s.verticalLayout
149
+ })
150
+ );
151
+ a.current = i, i.set(
152
+ "cursor",
153
+ Z.new(s, {
154
+ behavior: "zoomX"
155
+ })
156
+ ).lineY.set("visible", !1);
157
+ const b = i.xAxes.push(
158
+ q.new(s, {
159
+ maxDeviation: 0.3,
160
+ groupData: !0,
161
+ baseInterval: { timeUnit: "day", count: 1 },
162
+ renderer: z.new(s, {
163
+ minorGridEnabled: !0
164
+ }),
165
+ tooltip: O.new(s, {})
166
+ })
167
+ ), y = i.yAxes.push(
168
+ R.new(s, {
169
+ renderer: N.new(s, {})
170
+ })
171
+ ), f = i.series.push(
172
+ C.new(s, {
173
+ name: h || "Price",
174
+ xAxis: b,
175
+ yAxis: y,
176
+ valueXField: "date",
177
+ openValueYField: "open",
178
+ highValueYField: "high",
179
+ lowValueYField: "low",
180
+ valueYField: "close",
181
+ tooltip: O.new(s, {
182
+ labelText: `
183
+ Open: {openValueY}
184
+ High: {highValueY}
185
+ Low: {lowValueY}
186
+ Close: {valueY}
187
+ Change: {valueY - openValueY > 0 ? "+" : ""}{((valueY - openValueY)/openValueY*100).toFixed(2)}%
188
+ `
189
+ })
190
+ })
191
+ );
192
+ f.columns.template.states.create("riseFromPrevious", {
193
+ fill: _(c),
194
+ stroke: _(c)
195
+ }), f.columns.template.states.create("dropFromPrevious", {
196
+ fill: _(x),
197
+ stroke: _(x)
198
+ });
199
+ let X = null, v = null;
200
+ return n && (v = i.yAxes.push(
201
+ R.new(s, {
202
+ renderer: N.new(s, {
203
+ opposite: !0
204
+ }),
205
+ numberFormat: "#a"
206
+ })
207
+ ), X = i.series.push(
208
+ F.new(s, {
209
+ name: "Volume",
210
+ xAxis: b,
211
+ yAxis: v,
212
+ valueYField: "volume",
213
+ valueXField: "date",
214
+ fill: _("#2962ff"),
215
+ stroke: _("#2962ff"),
216
+ opacity: 0.6
217
+ })
218
+ ), X.columns.template.setAll({
219
+ width: E(80)
220
+ })), f.data.setAll(t), n && X && X.data.setAll(t), i.appear(1e3), f.appear(1e3), () => {
221
+ s.dispose();
222
+ };
223
+ }, []), U(() => {
224
+ if (a.current && o.current) {
225
+ const s = a.current.series.getIndex(
226
+ 0
227
+ ), i = n ? a.current.series.getIndex(1) : null;
228
+ s == null || s.data.setAll(t), i == null || i.data.setAll(t);
229
+ }
230
+ }, [t, n]), {
231
+ chartDivRef: r,
232
+ data: t,
233
+ seriesName: h,
234
+ height: m,
235
+ width: d,
236
+ chartId: Y,
237
+ showVolume: n,
238
+ risingColor: c,
239
+ fallingColor: x,
240
+ loading: u,
241
+ emptyMessage: l,
242
+ sx: g,
243
+ other: p,
244
+ ownerState: w
245
+ };
246
+ };
247
+ export {
248
+ $ as useCandlestickChartLogic
249
+ };
@@ -0,0 +1,12 @@
1
+ import { styled as i } from "@mui/material";
2
+ const h = i("div", {
3
+ name: "MuiCandlestickChart",
4
+ slot: "Root"
5
+ })(({ ownerState: t }) => ({
6
+ position: "relative",
7
+ width: t.width,
8
+ height: t.height
9
+ }));
10
+ export {
11
+ h as CandlestickChartRoot
12
+ };