@graphysdk/geom-candlestick 0.1.0 → 0.1.1-beta.1790850980247
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.
|
@@ -81,10 +81,10 @@ export declare class CandlestickGeom extends Geom<CandlestickGeomParams> {
|
|
|
81
81
|
discreteMainAxis: boolean;
|
|
82
82
|
};
|
|
83
83
|
/**
|
|
84
|
-
* A hovered session is one unit
|
|
85
|
-
*
|
|
84
|
+
* A hovered session is one unit: the rectangle as wide as its body and as tall as its wick, so a press anywhere
|
|
85
|
+
* across the candle is on the session.
|
|
86
86
|
*/
|
|
87
|
-
readonly spatialKind = "
|
|
87
|
+
readonly spatialKind = "rects";
|
|
88
88
|
readonly highlightStrategy: "observation-rerender";
|
|
89
89
|
/**
|
|
90
90
|
* The tooltip shows the session's four prices, as written in the data and formatted like the price axis, each
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let r=require("@graphysdk/react"),v=require("react"),c=require("react/jsx-runtime");var x={direction:"candlestickDirection"},M=(t,e)=>{const o=e==="x"?(0,r.getX)(t):(0,r.getY)(t),i=e==="x"?(0,r.getXMin)(t):(0,r.getYMin)(t),n=e==="x"?(0,r.getXMax)(t):(0,r.getYMax)(t),s=e==="x"?(0,r.getYMin)(t):(0,r.getXMin)(t),l=e==="x"?(0,r.getYMax)(t):(0,r.getXMax)(t),d=(0,r.getScaledAesthetic)(t,"open"),a=(0,r.getScaledAesthetic)(t,"close");return o===null||i===null||n===null||s===null||l===null||d===null||a===null?null:{observation:t,band:o,bodyStart:i,bodyEnd:n,low:s,high:l,open:d,close:a,direction:t[x.direction]==="falling"?"falling":"rising"}},p=(t,e)=>{const o=[];for(const i of t){const n=M(i,e);n!==null&&o.push(n)}return o},A=1,B=1,_=.6,O=["open","high","low","close"],V={alpha:"unitInterval",fillAlpha:"unitInterval",strokeWidth:"pixels"},f={fill:"color",stroke:"color"},E={stroke:"color",alpha:"unitInterval",strokeWidth:"pixels",dashArray:"dashArray"},C=class extends r.Geom{constructor(...t){super(...t),this.type="candlestick",this.defaultParams={},this.derivedVariables=[x.direction],this.aesthetics=[{kind:"visual",name:"color"}],this.positionRoles=[{axis:"x",role:"point",valueKind:"value"},{axis:"y",role:"min",valueKind:"value",aes:"low"},{axis:"y",role:"max",valueKind:"value",aes:"high"},{axis:"y",role:"scalar",valueKind:"value",aes:"open"},{axis:"y",role:"scalar",valueKind:"value",aes:"close"}],this.supportedPositions=["identity"],this.supportedCoordTypes=["cartesian","flip"],this.scaleConstraints={discreteMainAxis:!0},this.spatialKind="rects",this.highlightStrategy="observation-rerender",this.tooltip=O.map(e=>({aes:e})),this.styleTarget=(0,r.defineGeomStyleTarget)({observation:{vocabulary:V,sharedPaint:!1,aesthetics:{},rest:{alpha:1,fillAlpha:1,strokeWidth:A}},parts:{rising:{vocabulary:f,aesthetics:{fill:"color",stroke:"color"},rest:{fill:(0,r.token)("trendPositive"),stroke:(0,r.token)("trendPositive")}},falling:{vocabulary:f,aesthetics:{fill:"color",stroke:"color"},rest:{fill:(0,r.token)("trendNegative"),stroke:(0,r.token)("trendNegative")}},wick:{vocabulary:E,rest:{alpha:1,strokeWidth:B,dashArray:[]}}}}),this.resolveBandFraction=e=>m(e),this.validateMapping=({mapping:e})=>["open","close"].filter(o=>e[o]===void 0).map(o=>({code:"MISSING_AESTHETIC",message:`candlestick geom requires '${o}' to be mapped`})),this.resolveAnchorPosition=(e,{coordSystem:o})=>{const i=(0,r.readMainAxis)(o),n=M(e,i);return n===null?null:i==="x"?{x:n.band,y:n.close}:{x:n.close,y:n.band}}}resolveParams(t){const{width:e,...o}=super.resolveParams(t);if(e===void 0)return o;const i=typeof e=="number"&&Number.isFinite(e)?e:null;if(i!==null&&i>0&&i<=1)return{...o,width:i};const n=i!==null&&i>1?1:void 0;return t.diagnostics?.addWarning({code:"INVALID_GEOM_PARAM",message:`Candlestick width must be a fraction in (0, 1], got ${String(e)}; falling back to ${n??"the default band"}.`,context:{geom:this.type,param:"width",expected:"0 < width <= 1",actual:i??String(e)},suggestion:"Set params.width to a fraction of the session band in (0, 1]."}),{...o,...n!==void 0&&{width:n}}}compile({data:t,mapping:e,params:o}){const i=m(o)/2;return{data:T(t,b(e.open),b(e.close)).addConstantVariable(r.POSITION_VARIABLES.xMin,"numeric",-i).addConstantVariable(r.POSITION_VARIABLES.xMax,"numeric",i),mapping:{y:e.close}}}},m=({width:t})=>t??_,b=t=>t===void 0?null:typeof t=="string"?t:"variable"in t?t.variable:null,T=(t,e,o)=>{if(e===null||o===null||!t.hasVariable(e)||!t.hasVariable(o))return t;const i=t.getValues(e,{type:"numeric"}),n=t.getValues(o,{type:"numeric"}),s=i.map((l,d)=>{const a=n[d];return l===null||a===null||a===void 0?null:a>=l?"rising":"falling"});return t.addVariable(x.direction,"categorical",s)},D=5e-4,S=(t,e)=>{const o=(t.open+t.close)/2,i=Math.max(Math.abs(t.close-t.open),D)/2,n=(0,r.composePoint)(e,{main:t.bodyStart,cross:o-i}),s=(0,r.composePoint)(e,{main:t.bodyEnd,cross:o+i}),[l,d]=w((0,r.toViewBoxX)(n.x),(0,r.toViewBoxX)(s.x)),[a,h]=w((0,r.toViewBoxY)(n.y),(0,r.toViewBoxY)(s.y));return{x:l,y:a,width:d-l,height:h-a}},w=(t,e)=>t<=e?[t,e]:[e,t],W=({layer:t,coordSystem:e,panelRect:o,styleReaders:i})=>{const n=(0,r.readMainAxis)(e),s=p(t.data,n),l=i.part("wick"),d=l===void 0?[]:s.map(h=>{const u=P(h.band,h.low,n,o),g=P(h.band,h.high,n,o),I=l.get("strokeWidth",h.observation)??0;return{kind:"stroke",pathData:`M${u.x},${u.y}L${g.x},${g.y}`,width:I}}),a=s.map(h=>{const u=S(h,n),g=u.x*o.width;return{kind:"region",pathData:`M${g},${u.y*o.height}H${(u.x+u.width)*o.width}V${(u.y+u.height)*o.height}H${g}Z`}});return[...d,...a]},P=(t,e,o,i)=>{const n=(0,r.composePoint)(o,{main:t,cross:e});return(0,r.scalePointToPanel)((0,r.projectPointCartesian)(n.x,n.y),i)},k=t=>{const e=(0,r.createStableKeyGenerator)(t.data,t.mapping,t.id);return o=>e(o.observation)},y=({candles:t,mainAxis:e,styleReaders:o,getKey:i,isHovered:n=!1,shouldAnimateTransitions:s=!1})=>{const l=n?"hovered":void 0,d=o.part("wick");return(0,c.jsxs)(c.Fragment,{children:[d&&t.map(a=>(0,c.jsx)(j,{candle:a,mainAxis:e,readers:d,directionReaders:o.part(a.direction),state:l,shouldAnimateTransitions:s},i(a))),t.map(a=>(0,c.jsx)(Y,{candle:a,mainAxis:e,styleReaders:o,state:l,shouldAnimateTransitions:s},i(a)))]})},j=({candle:t,mainAxis:e,readers:o,directionReaders:i,state:n,shouldAnimateTransitions:s})=>{const l=(0,r.composePoint)(e,{main:t.band,cross:t.low}),d=(0,r.composePoint)(e,{main:t.band,cross:t.high}),a=o.get("strokeWidth",t.observation,n)??0,h=o.get("stroke",t.observation,n)??i?.get("stroke",t.observation,n);return(0,c.jsx)(r.GeomLine,{"data-testid":"candlestick-wick",x1:(0,r.toPercent)((0,r.toViewBoxX)(l.x)),y1:(0,r.toPercent)((0,r.toViewBoxY)(l.y)),x2:(0,r.toPercent)((0,r.toViewBoxX)(d.x)),y2:(0,r.toPercent)((0,r.toViewBoxY)(d.y)),stroke:h===void 0?void 0:(0,r.toPaintColor)(h),strokeOpacity:o.get("alpha",t.observation,n),strokeWidth:a,strokeDasharray:(0,r.toStrokeDasharray)(o.get("dashArray",t.observation,n),a),shouldAnimateTransitions:s})},Y=({candle:t,mainAxis:e,styleReaders:o,state:i,shouldAnimateTransitions:n})=>{const s=S(t,e),l=o.part(t.direction),d=l?.get("fill",t.observation,i),a=l?.get("stroke",t.observation,i);return(0,c.jsx)(r.GeomRect,{"data-testid":"candlestick-body",x:(0,r.toPercent)(s.x),y:(0,r.toPercent)(s.y),width:(0,r.toPercent)(s.width),height:(0,r.toPercent)(s.height),fill:d===void 0?void 0:(0,r.toPaintColor)(d),opacity:o.get("alpha",t.observation,i),fillOpacity:o.get("fillAlpha",t.observation,i),stroke:a===void 0?void 0:(0,r.toPaintColor)(a),strokeWidth:o.get("strokeWidth",t.observation,i),shouldAnimateTransitions:n})},K=({layer:t,sourceLayer:e,mainAxis:o,styleReaders:i})=>(0,c.jsx)(y,{candles:(0,v.useMemo)(()=>p(t.data,o),[t.data,o]),mainAxis:o,styleReaders:i,getKey:(0,v.useMemo)(()=>k(e),[e])}),H=({layer:t,primary:e,siblings:o,mainAxis:i,styleReaders:n})=>(0,c.jsx)("g",{"data-testid":"hovered-candles",children:(0,c.jsx)(y,{candles:p([e,...o].map(s=>s.observation),i),mainAxis:i,styleReaders:n,getKey:(0,v.useMemo)(()=>k(t),[t]),isHovered:!0})}),N=({layer:t,mainAxis:e,styleReaders:o,shouldAnimateTransitions:i,intro:n})=>{const s=(0,c.jsx)(y,{candles:(0,v.useMemo)(()=>p(t.data,e),[t.data,e]),mainAxis:e,styleReaders:o,getKey:(0,v.useMemo)(()=>k(t),[t]),shouldAnimateTransitions:i}),l=X(n);return l===null?s:(0,c.jsx)(r.IntroFade,{intro:l,children:s})},X=t=>t==null?null:{type:"fade",layerId:t.layerId,durationSeconds:t.durationSeconds},$=(0,r.defineGeomRenderer)(new C,{coord:"cartesian",swatchShape:"square",guideMode:"band",render:({layer:t,coordSystem:e,styleReaders:o,shouldAnimateTransitions:i,intro:n})=>(0,c.jsx)(N,{layer:t,mainAxis:(0,r.readMainAxis)(e),styleReaders:o,shouldAnimateTransitions:i,intro:n}),renderHighlight:({layer:t,sourceLayer:e,coordSystem:o,styleReaders:i})=>(0,c.jsx)(K,{layer:t,sourceLayer:e,mainAxis:(0,r.readMainAxis)(o),styleReaders:i}),renderHover:({layer:t,primary:e,group:o,related:i,coordSystem:n,styleReaders:s})=>(0,c.jsx)(H,{layer:t,primary:e,siblings:[...o,...i],mainAxis:(0,r.readMainAxis)(n),styleReaders:s}),renderHoverCompanions:()=>null,getEditOutlineShapes:W});exports.CandlestickGeom=C;exports.candlestick=$;
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Geom as $, GeomLine as N, GeomRect as Y, IntroFade as L, POSITION_VARIABLES as
|
|
2
|
-
import { useMemo as
|
|
1
|
+
import { Geom as $, GeomLine as N, GeomRect as Y, IntroFade as L, POSITION_VARIABLES as S, composePoint as p, createStableKeyGenerator as G, defineGeomRenderer as X, defineGeomStyleTarget as F, getScaledAesthetic as P, getX as R, getXMax as M, getXMin as A, getY as U, getYMax as D, getYMin as E, projectPointCartesian as j, readMainAxis as g, scalePointToPanel as q, toPaintColor as b, toPercent as u, toStrokeDasharray as Z, toViewBoxX as y, toViewBoxY as m, token as k } from "@graphysdk/react";
|
|
2
|
+
import { useMemo as f } from "react";
|
|
3
3
|
import { Fragment as z, jsx as c, jsxs as J } from "react/jsx-runtime";
|
|
4
4
|
var w = { direction: "candlestickDirection" }, K = (t, e) => {
|
|
5
|
-
const r = e === "x" ?
|
|
6
|
-
return r === null ||
|
|
5
|
+
const r = e === "x" ? R(t) : U(t), o = e === "x" ? A(t) : E(t), i = e === "x" ? M(t) : D(t), a = e === "x" ? E(t) : A(t), s = e === "x" ? D(t) : M(t), l = P(t, "open"), n = P(t, "close");
|
|
6
|
+
return r === null || o === null || i === null || a === null || s === null || l === null || n === null ? null : {
|
|
7
7
|
observation: t,
|
|
8
8
|
band: r,
|
|
9
|
-
bodyStart:
|
|
10
|
-
bodyEnd:
|
|
9
|
+
bodyStart: o,
|
|
10
|
+
bodyEnd: i,
|
|
11
11
|
low: a,
|
|
12
12
|
high: s,
|
|
13
13
|
open: l,
|
|
@@ -16,9 +16,9 @@ var w = { direction: "candlestickDirection" }, K = (t, e) => {
|
|
|
16
16
|
};
|
|
17
17
|
}, x = (t, e) => {
|
|
18
18
|
const r = [];
|
|
19
|
-
for (const
|
|
20
|
-
const
|
|
21
|
-
|
|
19
|
+
for (const o of t) {
|
|
20
|
+
const i = K(o, e);
|
|
21
|
+
i !== null && r.push(i);
|
|
22
22
|
}
|
|
23
23
|
return r;
|
|
24
24
|
}, Q = 1, tt = 1, et = 0.6, rt = [
|
|
@@ -26,14 +26,14 @@ var w = { direction: "candlestickDirection" }, K = (t, e) => {
|
|
|
26
26
|
"high",
|
|
27
27
|
"low",
|
|
28
28
|
"close"
|
|
29
|
-
],
|
|
29
|
+
], ot = {
|
|
30
30
|
alpha: "unitInterval",
|
|
31
31
|
fillAlpha: "unitInterval",
|
|
32
32
|
strokeWidth: "pixels"
|
|
33
33
|
}, _ = {
|
|
34
34
|
fill: "color",
|
|
35
35
|
stroke: "color"
|
|
36
|
-
},
|
|
36
|
+
}, it = {
|
|
37
37
|
stroke: "color",
|
|
38
38
|
alpha: "unitInterval",
|
|
39
39
|
strokeWidth: "pixels",
|
|
@@ -73,9 +73,9 @@ var w = { direction: "candlestickDirection" }, K = (t, e) => {
|
|
|
73
73
|
valueKind: "value",
|
|
74
74
|
aes: "close"
|
|
75
75
|
}
|
|
76
|
-
], this.supportedPositions = ["identity"], this.supportedCoordTypes = ["cartesian", "flip"], this.scaleConstraints = { discreteMainAxis: !0 }, this.spatialKind = "
|
|
76
|
+
], this.supportedPositions = ["identity"], this.supportedCoordTypes = ["cartesian", "flip"], this.scaleConstraints = { discreteMainAxis: !0 }, this.spatialKind = "rects", this.highlightStrategy = "observation-rerender", this.tooltip = rt.map((e) => ({ aes: e })), this.styleTarget = F({
|
|
77
77
|
observation: {
|
|
78
|
-
vocabulary:
|
|
78
|
+
vocabulary: ot,
|
|
79
79
|
sharedPaint: !1,
|
|
80
80
|
aesthetics: {},
|
|
81
81
|
rest: {
|
|
@@ -92,8 +92,8 @@ var w = { direction: "candlestickDirection" }, K = (t, e) => {
|
|
|
92
92
|
stroke: "color"
|
|
93
93
|
},
|
|
94
94
|
rest: {
|
|
95
|
-
fill:
|
|
96
|
-
stroke:
|
|
95
|
+
fill: k("trendPositive"),
|
|
96
|
+
stroke: k("trendPositive")
|
|
97
97
|
}
|
|
98
98
|
},
|
|
99
99
|
falling: {
|
|
@@ -103,12 +103,12 @@ var w = { direction: "candlestickDirection" }, K = (t, e) => {
|
|
|
103
103
|
stroke: "color"
|
|
104
104
|
},
|
|
105
105
|
rest: {
|
|
106
|
-
fill:
|
|
107
|
-
stroke:
|
|
106
|
+
fill: k("trendNegative"),
|
|
107
|
+
stroke: k("trendNegative")
|
|
108
108
|
}
|
|
109
109
|
},
|
|
110
110
|
wick: {
|
|
111
|
-
vocabulary:
|
|
111
|
+
vocabulary: it,
|
|
112
112
|
rest: {
|
|
113
113
|
alpha: 1,
|
|
114
114
|
strokeWidth: tt,
|
|
@@ -120,95 +120,95 @@ var w = { direction: "candlestickDirection" }, K = (t, e) => {
|
|
|
120
120
|
code: "MISSING_AESTHETIC",
|
|
121
121
|
message: `candlestick geom requires '${r}' to be mapped`
|
|
122
122
|
})), this.resolveAnchorPosition = (e, { coordSystem: r }) => {
|
|
123
|
-
const
|
|
124
|
-
return
|
|
125
|
-
x:
|
|
126
|
-
y:
|
|
123
|
+
const o = g(r), i = K(e, o);
|
|
124
|
+
return i === null ? null : o === "x" ? {
|
|
125
|
+
x: i.band,
|
|
126
|
+
y: i.close
|
|
127
127
|
} : {
|
|
128
|
-
x:
|
|
129
|
-
y:
|
|
128
|
+
x: i.close,
|
|
129
|
+
y: i.band
|
|
130
130
|
};
|
|
131
131
|
};
|
|
132
132
|
}
|
|
133
133
|
resolveParams(t) {
|
|
134
134
|
const { width: e, ...r } = super.resolveParams(t);
|
|
135
135
|
if (e === void 0) return r;
|
|
136
|
-
const
|
|
137
|
-
if (
|
|
136
|
+
const o = typeof e == "number" && Number.isFinite(e) ? e : null;
|
|
137
|
+
if (o !== null && o > 0 && o <= 1) return {
|
|
138
138
|
...r,
|
|
139
|
-
width:
|
|
139
|
+
width: o
|
|
140
140
|
};
|
|
141
|
-
const
|
|
141
|
+
const i = o !== null && o > 1 ? 1 : void 0;
|
|
142
142
|
return t.diagnostics?.addWarning({
|
|
143
143
|
code: "INVALID_GEOM_PARAM",
|
|
144
|
-
message: `Candlestick width must be a fraction in (0, 1], got ${String(e)}; falling back to ${
|
|
144
|
+
message: `Candlestick width must be a fraction in (0, 1], got ${String(e)}; falling back to ${i ?? "the default band"}.`,
|
|
145
145
|
context: {
|
|
146
146
|
geom: this.type,
|
|
147
147
|
param: "width",
|
|
148
148
|
expected: "0 < width <= 1",
|
|
149
|
-
actual:
|
|
149
|
+
actual: o ?? String(e)
|
|
150
150
|
},
|
|
151
151
|
suggestion: "Set params.width to a fraction of the session band in (0, 1]."
|
|
152
152
|
}), {
|
|
153
153
|
...r,
|
|
154
|
-
...
|
|
154
|
+
...i !== void 0 && { width: i }
|
|
155
155
|
};
|
|
156
156
|
}
|
|
157
157
|
compile({ data: t, mapping: e, params: r }) {
|
|
158
|
-
const
|
|
158
|
+
const o = B(r) / 2;
|
|
159
159
|
return {
|
|
160
|
-
data: nt(t, O(e.open), O(e.close)).addConstantVariable(
|
|
160
|
+
data: nt(t, O(e.open), O(e.close)).addConstantVariable(S.xMin, "numeric", -o).addConstantVariable(S.xMax, "numeric", o),
|
|
161
161
|
mapping: { y: e.close }
|
|
162
162
|
};
|
|
163
163
|
}
|
|
164
164
|
}, B = ({ width: t }) => t ?? et, O = (t) => t === void 0 ? null : typeof t == "string" ? t : "variable" in t ? t.variable : null, nt = (t, e, r) => {
|
|
165
165
|
if (e === null || r === null || !t.hasVariable(e) || !t.hasVariable(r)) return t;
|
|
166
|
-
const
|
|
167
|
-
const n =
|
|
166
|
+
const o = t.getValues(e, { type: "numeric" }), i = t.getValues(r, { type: "numeric" }), a = o.map((s, l) => {
|
|
167
|
+
const n = i[l];
|
|
168
168
|
return s === null || n === null || n === void 0 ? null : n >= s ? "rising" : "falling";
|
|
169
169
|
});
|
|
170
170
|
return t.addVariable(w.direction, "categorical", a);
|
|
171
171
|
}, st = 5e-4, H = (t, e) => {
|
|
172
|
-
const r = (t.open + t.close) / 2,
|
|
172
|
+
const r = (t.open + t.close) / 2, o = Math.max(Math.abs(t.close - t.open), st) / 2, i = p(e, {
|
|
173
173
|
main: t.bodyStart,
|
|
174
|
-
cross: r -
|
|
174
|
+
cross: r - o
|
|
175
175
|
}), a = p(e, {
|
|
176
176
|
main: t.bodyEnd,
|
|
177
|
-
cross: r +
|
|
178
|
-
}), [s, l] = T(y(
|
|
177
|
+
cross: r + o
|
|
178
|
+
}), [s, l] = T(y(i.x), y(a.x)), [n, d] = T(m(i.y), m(a.y));
|
|
179
179
|
return {
|
|
180
180
|
x: s,
|
|
181
181
|
y: n,
|
|
182
182
|
width: l - s,
|
|
183
183
|
height: d - n
|
|
184
184
|
};
|
|
185
|
-
}, T = (t, e) => t <= e ? [t, e] : [e, t], lt = ({ layer: t, coordSystem: e, panelRect: r, styleReaders:
|
|
186
|
-
const
|
|
187
|
-
const h = W(d.band, d.low,
|
|
185
|
+
}, T = (t, e) => t <= e ? [t, e] : [e, t], lt = ({ layer: t, coordSystem: e, panelRect: r, styleReaders: o }) => {
|
|
186
|
+
const i = g(e), a = x(t.data, i), s = o.part("wick"), l = s === void 0 ? [] : a.map((d) => {
|
|
187
|
+
const h = W(d.band, d.low, i, r), v = W(d.band, d.high, i, r), V = s.get("strokeWidth", d.observation) ?? 0;
|
|
188
188
|
return {
|
|
189
189
|
kind: "stroke",
|
|
190
|
-
pathData: `M${h.x},${h.y}L${
|
|
190
|
+
pathData: `M${h.x},${h.y}L${v.x},${v.y}`,
|
|
191
191
|
width: V
|
|
192
192
|
};
|
|
193
193
|
}), n = a.map((d) => {
|
|
194
|
-
const h = H(d,
|
|
194
|
+
const h = H(d, i), v = h.x * r.width;
|
|
195
195
|
return {
|
|
196
196
|
kind: "region",
|
|
197
|
-
pathData: `M${
|
|
197
|
+
pathData: `M${v},${h.y * r.height}H${(h.x + h.width) * r.width}V${(h.y + h.height) * r.height}H${v}Z`
|
|
198
198
|
};
|
|
199
199
|
});
|
|
200
200
|
return [...l, ...n];
|
|
201
|
-
}, W = (t, e, r,
|
|
202
|
-
const
|
|
201
|
+
}, W = (t, e, r, o) => {
|
|
202
|
+
const i = p(r, {
|
|
203
203
|
main: t,
|
|
204
204
|
cross: e
|
|
205
205
|
});
|
|
206
|
-
return q(j(
|
|
206
|
+
return q(j(i.x, i.y), o);
|
|
207
207
|
}, C = (t) => {
|
|
208
208
|
const e = G(t.data, t.mapping, t.id);
|
|
209
209
|
return (r) => e(r.observation);
|
|
210
|
-
}, I = ({ candles: t, mainAxis: e, styleReaders: r, getKey:
|
|
211
|
-
const s =
|
|
210
|
+
}, I = ({ candles: t, mainAxis: e, styleReaders: r, getKey: o, isHovered: i = !1, shouldAnimateTransitions: a = !1 }) => {
|
|
211
|
+
const s = i ? "hovered" : void 0, l = r.part("wick");
|
|
212
212
|
return /* @__PURE__ */ J(z, { children: [l && t.map((n) => /* @__PURE__ */ c(dt, {
|
|
213
213
|
candle: n,
|
|
214
214
|
mainAxis: e,
|
|
@@ -216,21 +216,21 @@ var w = { direction: "candlestickDirection" }, K = (t, e) => {
|
|
|
216
216
|
directionReaders: r.part(n.direction),
|
|
217
217
|
state: s,
|
|
218
218
|
shouldAnimateTransitions: a
|
|
219
|
-
},
|
|
219
|
+
}, o(n))), t.map((n) => /* @__PURE__ */ c(ct, {
|
|
220
220
|
candle: n,
|
|
221
221
|
mainAxis: e,
|
|
222
222
|
styleReaders: r,
|
|
223
223
|
state: s,
|
|
224
224
|
shouldAnimateTransitions: a
|
|
225
|
-
},
|
|
226
|
-
}, dt = ({ candle: t, mainAxis: e, readers: r, directionReaders:
|
|
225
|
+
}, o(n)))] });
|
|
226
|
+
}, dt = ({ candle: t, mainAxis: e, readers: r, directionReaders: o, state: i, shouldAnimateTransitions: a }) => {
|
|
227
227
|
const s = p(e, {
|
|
228
228
|
main: t.band,
|
|
229
229
|
cross: t.low
|
|
230
230
|
}), l = p(e, {
|
|
231
231
|
main: t.band,
|
|
232
232
|
cross: t.high
|
|
233
|
-
}), n = r.get("strokeWidth", t.observation,
|
|
233
|
+
}), n = r.get("strokeWidth", t.observation, i) ?? 0, d = r.get("stroke", t.observation, i) ?? o?.get("stroke", t.observation, i);
|
|
234
234
|
return /* @__PURE__ */ c(N, {
|
|
235
235
|
"data-testid": "candlestick-wick",
|
|
236
236
|
x1: u(y(s.x)),
|
|
@@ -238,13 +238,13 @@ var w = { direction: "candlestickDirection" }, K = (t, e) => {
|
|
|
238
238
|
x2: u(y(l.x)),
|
|
239
239
|
y2: u(m(l.y)),
|
|
240
240
|
stroke: d === void 0 ? void 0 : b(d),
|
|
241
|
-
strokeOpacity: r.get("alpha", t.observation,
|
|
241
|
+
strokeOpacity: r.get("alpha", t.observation, i),
|
|
242
242
|
strokeWidth: n,
|
|
243
|
-
strokeDasharray: Z(r.get("dashArray", t.observation,
|
|
243
|
+
strokeDasharray: Z(r.get("dashArray", t.observation, i), n),
|
|
244
244
|
shouldAnimateTransitions: a
|
|
245
245
|
});
|
|
246
|
-
}, ct = ({ candle: t, mainAxis: e, styleReaders: r, state:
|
|
247
|
-
const a = H(t, e), s = r.part(t.direction), l = s?.get("fill", t.observation,
|
|
246
|
+
}, ct = ({ candle: t, mainAxis: e, styleReaders: r, state: o, shouldAnimateTransitions: i }) => {
|
|
247
|
+
const a = H(t, e), s = r.part(t.direction), l = s?.get("fill", t.observation, o), n = s?.get("stroke", t.observation, o);
|
|
248
248
|
return /* @__PURE__ */ c(Y, {
|
|
249
249
|
"data-testid": "candlestick-body",
|
|
250
250
|
x: u(a.x),
|
|
@@ -252,60 +252,64 @@ var w = { direction: "candlestickDirection" }, K = (t, e) => {
|
|
|
252
252
|
width: u(a.width),
|
|
253
253
|
height: u(a.height),
|
|
254
254
|
fill: l === void 0 ? void 0 : b(l),
|
|
255
|
-
opacity: r.get("alpha", t.observation,
|
|
256
|
-
fillOpacity: r.get("fillAlpha", t.observation,
|
|
255
|
+
opacity: r.get("alpha", t.observation, o),
|
|
256
|
+
fillOpacity: r.get("fillAlpha", t.observation, o),
|
|
257
257
|
stroke: n === void 0 ? void 0 : b(n),
|
|
258
|
-
strokeWidth: r.get("strokeWidth", t.observation,
|
|
259
|
-
shouldAnimateTransitions:
|
|
258
|
+
strokeWidth: r.get("strokeWidth", t.observation, o),
|
|
259
|
+
shouldAnimateTransitions: i
|
|
260
260
|
});
|
|
261
|
-
}, ht = ({ layer: t, sourceLayer: e, mainAxis: r, styleReaders:
|
|
262
|
-
candles:
|
|
261
|
+
}, ht = ({ layer: t, sourceLayer: e, mainAxis: r, styleReaders: o }) => /* @__PURE__ */ c(I, {
|
|
262
|
+
candles: f(() => x(t.data, r), [t.data, r]),
|
|
263
263
|
mainAxis: r,
|
|
264
|
-
styleReaders:
|
|
265
|
-
getKey:
|
|
266
|
-
}), ut = ({ layer: t, primary: e, siblings: r, mainAxis:
|
|
264
|
+
styleReaders: o,
|
|
265
|
+
getKey: f(() => C(e), [e])
|
|
266
|
+
}), ut = ({ layer: t, primary: e, siblings: r, mainAxis: o, styleReaders: i }) => /* @__PURE__ */ c("g", {
|
|
267
267
|
"data-testid": "hovered-candles",
|
|
268
268
|
children: /* @__PURE__ */ c(I, {
|
|
269
|
-
candles: x([e, ...r].map((a) => a.observation),
|
|
270
|
-
mainAxis:
|
|
271
|
-
styleReaders:
|
|
272
|
-
getKey:
|
|
269
|
+
candles: x([e, ...r].map((a) => a.observation), o),
|
|
270
|
+
mainAxis: o,
|
|
271
|
+
styleReaders: i,
|
|
272
|
+
getKey: f(() => C(t), [t]),
|
|
273
273
|
isHovered: !0
|
|
274
274
|
})
|
|
275
|
-
}),
|
|
275
|
+
}), vt = ({ layer: t, mainAxis: e, styleReaders: r, shouldAnimateTransitions: o, intro: i }) => {
|
|
276
276
|
const a = /* @__PURE__ */ c(I, {
|
|
277
|
-
candles:
|
|
277
|
+
candles: f(() => x(t.data, e), [t.data, e]),
|
|
278
278
|
mainAxis: e,
|
|
279
279
|
styleReaders: r,
|
|
280
|
-
getKey:
|
|
281
|
-
shouldAnimateTransitions:
|
|
282
|
-
});
|
|
283
|
-
return
|
|
284
|
-
intro:
|
|
280
|
+
getKey: f(() => C(t), [t]),
|
|
281
|
+
shouldAnimateTransitions: o
|
|
282
|
+
}), s = gt(i);
|
|
283
|
+
return s === null ? a : /* @__PURE__ */ c(L, {
|
|
284
|
+
intro: s,
|
|
285
285
|
children: a
|
|
286
|
-
})
|
|
287
|
-
},
|
|
286
|
+
});
|
|
287
|
+
}, gt = (t) => t == null ? null : {
|
|
288
|
+
type: "fade",
|
|
289
|
+
layerId: t.layerId,
|
|
290
|
+
durationSeconds: t.durationSeconds
|
|
291
|
+
}, yt = X(new at(), {
|
|
288
292
|
coord: "cartesian",
|
|
289
293
|
swatchShape: "square",
|
|
290
294
|
guideMode: "band",
|
|
291
|
-
render: ({ layer: t, coordSystem: e, styleReaders: r, shouldAnimateTransitions:
|
|
295
|
+
render: ({ layer: t, coordSystem: e, styleReaders: r, shouldAnimateTransitions: o, intro: i }) => /* @__PURE__ */ c(vt, {
|
|
292
296
|
layer: t,
|
|
293
|
-
mainAxis:
|
|
297
|
+
mainAxis: g(e),
|
|
294
298
|
styleReaders: r,
|
|
295
|
-
shouldAnimateTransitions:
|
|
296
|
-
intro:
|
|
299
|
+
shouldAnimateTransitions: o,
|
|
300
|
+
intro: i
|
|
297
301
|
}),
|
|
298
|
-
renderHighlight: ({ layer: t, sourceLayer: e, coordSystem: r, styleReaders:
|
|
302
|
+
renderHighlight: ({ layer: t, sourceLayer: e, coordSystem: r, styleReaders: o }) => /* @__PURE__ */ c(ht, {
|
|
299
303
|
layer: t,
|
|
300
304
|
sourceLayer: e,
|
|
301
|
-
mainAxis:
|
|
302
|
-
styleReaders:
|
|
305
|
+
mainAxis: g(r),
|
|
306
|
+
styleReaders: o
|
|
303
307
|
}),
|
|
304
|
-
renderHover: ({ layer: t, primary: e, group: r, related:
|
|
308
|
+
renderHover: ({ layer: t, primary: e, group: r, related: o, coordSystem: i, styleReaders: a }) => /* @__PURE__ */ c(ut, {
|
|
305
309
|
layer: t,
|
|
306
310
|
primary: e,
|
|
307
|
-
siblings: [...r, ...
|
|
308
|
-
mainAxis:
|
|
311
|
+
siblings: [...r, ...o],
|
|
312
|
+
mainAxis: g(i),
|
|
309
313
|
styleReaders: a
|
|
310
314
|
}),
|
|
311
315
|
renderHoverCompanions: () => null,
|
|
@@ -313,5 +317,5 @@ var w = { direction: "candlestickDirection" }, K = (t, e) => {
|
|
|
313
317
|
});
|
|
314
318
|
export {
|
|
315
319
|
at as CandlestickGeom,
|
|
316
|
-
|
|
320
|
+
yt as candlestick
|
|
317
321
|
};
|
|
@@ -7,9 +7,10 @@ interface CandlestickLayerProps {
|
|
|
7
7
|
intro: LayerIntroPlan | null | undefined;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
-
* The layer's own paint. The
|
|
11
|
-
*
|
|
12
|
-
* candles, so it plays even when data
|
|
10
|
+
* The layer's own paint. The whole layer fades up on one clock, whatever entrance the engine plans: a candle is a
|
|
11
|
+
* rect to the engine, which plans a bar's grow, but a price has no baseline to grow from. The fade is independent
|
|
12
|
+
* of `shouldAnimateTransitions`: it rides the group rather than moving the candles, so it plays even when data
|
|
13
|
+
* changes snap.
|
|
13
14
|
*/
|
|
14
15
|
export declare const CandlestickLayer: ({ layer, mainAxis, styleReaders, shouldAnimateTransitions, intro, }: CandlestickLayerProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
16
|
export {};
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"grammar-of-graphics",
|
|
13
13
|
"candlestick"
|
|
14
14
|
],
|
|
15
|
-
"version": "0.1.
|
|
15
|
+
"version": "0.1.1-beta.1790850980247",
|
|
16
16
|
"type": "module",
|
|
17
17
|
"sideEffects": false,
|
|
18
18
|
"types": "./dist/index.d.ts",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"react": "^19.0.0",
|
|
34
|
-
"@graphysdk/react": "^1.9.0-beta.
|
|
34
|
+
"@graphysdk/react": "^1.9.0-beta.1790850980247"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@testing-library/react": "^16.3.1",
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"vite": "^8.1.5",
|
|
44
44
|
"vite-plugin-dts": "^4.5.4",
|
|
45
45
|
"vitest": "^4.1.11",
|
|
46
|
-
"@graphysdk/react": "1.9.0-beta.
|
|
46
|
+
"@graphysdk/react": "1.9.0-beta.1790850980247",
|
|
47
|
+
"@graphysdk/viz-engine": "1.9.0-beta.1790850980247",
|
|
48
|
+
"@graphytools/eslint-config": "0.0.1",
|
|
47
49
|
"@graphytools/typescript-config": "0.0.1",
|
|
48
|
-
"@
|
|
49
|
-
"@graphytools/vitest-config": "1.0.0",
|
|
50
|
-
"@graphytools/eslint-config": "0.0.1"
|
|
50
|
+
"@graphytools/vitest-config": "1.0.0"
|
|
51
51
|
},
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public"
|