@graphysdk/geom-lollipop 0.1.0 → 0.1.1-beta.1790864848006

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/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let t=require("@graphysdk/react"),u=require("react"),l=require("react/jsx-runtime");var b=(e,o)=>{const a=o==="x"?M((0,t.getXMin)(e),(0,t.getXMax)(e))??(0,t.getX)(e):M((0,t.getYMin)(e),(0,t.getYMax)(e))??(0,t.getY)(e),r=o==="x"?(0,t.getYMin)(e):(0,t.getXMin)(e),i=o==="x"?(0,t.getYMax)(e)??(0,t.getY)(e):(0,t.getXMax)(e)??(0,t.getX)(e);return a===null||r===null||i===null?null:{observation:e,band:a,base:r,tip:i}},p=(e,o)=>{const a=[];for(const r of e){const i=b(r,o);i!==null&&a.push(i)}return a},L=e=>e.tip<e.base,M=(e,o)=>e===null||o===null?null:(e+o)/2,O=e=>{const o=[];if(!e.layer.dataLabels.showDataLabels)return{labels:o,droppedCount:0};const{position:a,justify:r,align:i,offset:s}=e.layer.dataLabels,n=r==="panel-start"||r==="panel-end",c=(0,t.readMainAxis)(e.coordSystem),d=(0,t.buildPanelAnchorBox)(e.panelRect);for(const h of p(e.layer.data,c)){const v=e.formatLabel(h.observation);if(v==="")continue;const{width:f,height:P}=e.measureDataLabel("observation","outside",v),k=(e.styleReaders.get("size",h.observation)??0)/2,A=(0,t.composePoint)(c,{main:h.band,cross:h.tip}),g=(0,t.resolveAnchoredLabelCenter)({box:{x:A.x*e.panelRect.width,y:(1-A.y)*e.panelRect.height,width:0,height:0},panel:d,orientation:S(c),placement:a==="auto"?"outside":a,justify:a==="auto"?V(h):r,align:i,offset:n?s:s+k,alignOffset:s+k,labelWidth:f,labelHeight:P});o.push({layerId:e.layer.id,x:g.x,y:g.y,text:v,width:f,height:P,isRotated:!1,role:"observation",position:g.position})}return{labels:o,droppedCount:0}},S=e=>e==="x"?{valueAxis:"y",valueDirectionSign:-1}:{valueAxis:"x",valueDirectionSign:1},V=e=>L(e)?"start":"end",W=10,j=1,B=2,H=.7,D={size:"pixels",strokeWidth:"pixels"},T={stroke:"color",alpha:"unitInterval",strokeWidth:"pixels",dashArray:"dashArray"},_=class extends t.Geom{constructor(...e){super(...e),this.type="lollipop",this.defaultParams={},this.positionRoles=[{axis:"x",role:"point",valueKind:"value"},{axis:"y",role:"min",valueKind:"value"},{axis:"y",role:"max",valueKind:"value",aes:"y"}],this.aesthetics=[{kind:"visual",name:"color"}],this.defaultPosition="dodge",this.supportedPositions=["identity","dodge"],this.supportedCoordTypes=["cartesian","flip"],this.scaleConstraints={discreteMainAxis:!0,zeroBaseline:!0},this.legend={suppressWhenSingleItem:!0},this.dataLabelCoordTypes=["cartesian","flip"],this.getDataLabelPlacements=O,this.spatialKind="spanned-buckets",this.highlightStrategy="observation-rerender",this.styleTarget=(0,t.defineGeomStyleTarget)({observation:{vocabulary:D,aesthetics:{fill:"color",alpha:"alpha",size:"size",strokeWidth:"strokeWidth"},rest:{fill:(0,t.token)("geom"),fillAlpha:1,size:W,stroke:(0,t.token)("hoverAffordance"),strokeWidth:j}},parts:{stem:{vocabulary:T,aesthetics:{stroke:"color"},rest:{stroke:(0,t.token)("geom"),alpha:1,strokeWidth:B,dashArray:[]}}}}),this.resolveAnchorPosition=(o,{coordSystem:a})=>{const r=(0,t.readMainAxis)(a),i=b(o,r);return i===null?null:r==="x"?{x:i.band,y:i.tip}:{x:i.tip,y:i.band}}}compile({data:e}){const o=e.hasVariable(t.POSITION_VARIABLES.yMin)?e:e.addConstantVariable(t.POSITION_VARIABLES.yMin,"numeric",0),a=H/2;return{data:o.addConstantVariable(t.POSITION_VARIABLES.xMin,"numeric",-.35).addConstantVariable(t.POSITION_VARIABLES.xMax,"numeric",a),mapping:{}}}},w=({layer:e,coordSystem:o,panelRect:a,styleReaders:r})=>{const i=(0,t.readMainAxis)(o),s=p(e.data,i),n=(0,t.buildDotsEditOutlineShapes)(s.map(d=>({center:x(d.band,d.tip,i,a),size:(r.get("size",d.observation)??0)+(r.get("strokeWidth",d.observation)??0)}))),c=r.part("stem");return[...c===void 0?[]:s.map(d=>C(d,i,a,c)),...n]},C=(e,o,a,r)=>{const i=x(e.band,e.base,o,a),s=x(e.band,e.tip,o,a),n=r.get("strokeWidth",e.observation)??0;return{kind:"stroke",pathData:`M${i.x},${i.y}L${s.x},${s.y}`,width:n}},x=(e,o,a,r)=>{const i=(0,t.composePoint)(a,{main:e,cross:o});return(0,t.scalePointToPanel)((0,t.projectPointCartesian)(i.x,i.y),r)},m=e=>{const o=(0,t.createStableKeyGenerator)(e.data,e.mapping,e.id);return a=>o(a.observation)},E=.4,R=.2,G=1,X=.5,y=({lollipops:e,mainAxis:o,styleReaders:a,getKey:r,hovered:i,shouldAnimateTransitions:s=!1})=>{const n=a.part("stem"),c=i===void 0?void 0:"hovered";return(0,l.jsxs)(l.Fragment,{children:[n&&e.map(d=>(0,l.jsx)(N,{lollipop:d,mainAxis:o,readers:n,state:c,shouldAnimateTransitions:s},r(d))),e.map(d=>(0,l.jsx)(Y,{lollipop:d,mainAxis:o,styleReaders:a,state:c,shouldAnimateTransitions:s},r(d))),i?.primary&&(0,l.jsx)(z,{lollipop:i.primary,mainAxis:o,styleReaders:a})]})},N=({lollipop:e,mainAxis:o,readers:a,state:r,shouldAnimateTransitions:i})=>{const s=(0,t.composePoint)(o,{main:e.band,cross:e.base}),n=(0,t.composePoint)(o,{main:e.band,cross:e.tip}),c=a.get("strokeWidth",e.observation,r)??0,d=a.get("stroke",e.observation,r);return(0,l.jsx)(t.GeomLine,{"data-testid":"lollipop-stem",x1:(0,t.toPercent)((0,t.toViewBoxX)(s.x)),y1:(0,t.toPercent)((0,t.toViewBoxY)(s.y)),x2:(0,t.toPercent)((0,t.toViewBoxX)(n.x)),y2:(0,t.toPercent)((0,t.toViewBoxY)(n.y)),stroke:d===void 0?void 0:(0,t.toPaintColor)(d),strokeOpacity:a.get("alpha",e.observation,r),strokeWidth:c,strokeDasharray:(0,t.toStrokeDasharray)(a.get("dashArray",e.observation,r),c),shouldAnimateTransitions:i})},Y=({lollipop:e,mainAxis:o,styleReaders:a,state:r,shouldAnimateTransitions:i})=>{const s=(0,t.composePoint)(o,{main:e.band,cross:e.tip}),n=a.get("fill",e.observation,r);return(0,l.jsx)(t.GeomCircle,{"data-testid":"lollipop-head",cx:(0,t.toPercent)((0,t.toViewBoxX)(s.x)),cy:(0,t.toPercent)((0,t.toViewBoxY)(s.y)),r:I(e,a,r),fill:n===void 0?void 0:(0,t.toPaintColor)(n),opacity:a.get("alpha",e.observation,r),fillOpacity:a.get("fillAlpha",e.observation,r),stroke:a.get("stroke",e.observation,r),strokeOpacity:a.get("strokeAlpha",e.observation,r),strokeWidth:a.get("strokeWidth",e.observation,r),shouldAnimateTransitions:i})},z=({lollipop:e,mainAxis:o,styleReaders:a})=>{const r=(0,t.composePoint)(o,{main:e.band,cross:e.tip}),i=I(e,a,"hovered"),s=a.get("strokeWidth",e.observation,"hovered")??0,n=Math.max(G,i*E),c=Math.max(X,i*R);return(0,l.jsx)("circle",{"data-testid":"lollipop-hover-ring",cx:(0,t.toPercent)((0,t.toViewBoxX)(r.x)),cy:(0,t.toPercent)((0,t.toViewBoxY)(r.y)),r:i+s/2+c+n/2,fill:"none",stroke:a.get("stroke",e.observation,"hovered"),strokeWidth:n})},I=(e,o,a)=>(o.get("size",e.observation,a)??0)/2,K=({layer:e,sourceLayer:o,mainAxis:a,styleReaders:r})=>(0,l.jsx)(y,{lollipops:(0,u.useMemo)(()=>p(e.data,a),[e.data,a]),mainAxis:a,styleReaders:r,getKey:(0,u.useMemo)(()=>m(o),[o])}),$=({layer:e,primary:o,siblings:a,mainAxis:r,styleReaders:i})=>(0,l.jsx)("g",{"data-testid":"hovered-lollipops",children:(0,l.jsx)(y,{lollipops:p([o,...a].map(s=>s.observation),r),mainAxis:r,styleReaders:i,getKey:(0,u.useMemo)(()=>m(e),[e]),hovered:{primary:b(o.observation,r)}})}),q=({layer:e,mainAxis:o,styleReaders:a,shouldAnimateTransitions:r,intro:i})=>{const s=(0,l.jsx)(y,{lollipops:(0,u.useMemo)(()=>p(e.data,o),[e.data,o]),mainAxis:o,styleReaders:a,getKey:(0,u.useMemo)(()=>m(e),[e]),shouldAnimateTransitions:r});return i?.type==="fade"?(0,l.jsx)(t.IntroFade,{intro:i,children:s}):s},F=(0,t.defineGeomRenderer)(new _,{coord:"cartesian",swatchShape:"circle",guideMode:"band",render:({layer:e,coordSystem:o,styleReaders:a,shouldAnimateTransitions:r,intro:i})=>(0,l.jsx)(q,{layer:e,mainAxis:(0,t.readMainAxis)(o),styleReaders:a,shouldAnimateTransitions:r,intro:i}),renderHighlight:({layer:e,sourceLayer:o,coordSystem:a,styleReaders:r})=>(0,l.jsx)(K,{layer:e,sourceLayer:o,mainAxis:(0,t.readMainAxis)(a),styleReaders:r}),renderHover:({layer:e,primary:o,group:a,related:r,coordSystem:i,styleReaders:s})=>(0,l.jsx)($,{layer:e,primary:o,siblings:[...a,...r],mainAxis:(0,t.readMainAxis)(i),styleReaders:s}),renderHoverCompanions:()=>null,getEditOutlineShapes:w});exports.LollipopGeom=_;exports.lollipop=F;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let a=require("@graphysdk/react"),u=require("react"),c=require("react/jsx-runtime");var x=(e,r)=>{const t=r==="x"?(0,a.getX)(e):(0,a.getY)(e),o=r==="x"?(0,a.getYMin)(e):(0,a.getXMin)(e),i=r==="x"?(0,a.getYMax)(e)??(0,a.getY)(e):(0,a.getXMax)(e)??(0,a.getX)(e);return t===null||o===null||i===null?null:{observation:e,band:t,base:o,tip:i}},p=(e,r)=>{const t=[];for(const o of e){const i=x(o,r);i!==null&&t.push(i)}return t},M=e=>e.tip<e.base,L=e=>{const r=[];if(!e.layer.dataLabels.showDataLabels)return{labels:r,droppedCount:0};const{position:t,justify:o,align:i,offset:s}=e.layer.dataLabels,n=o==="panel-start"||o==="panel-end",l=(0,a.readMainAxis)(e.coordSystem),d=(0,a.buildPanelAnchorBox)(e.panelRect);for(const h of p(e.layer.data,l)){const v=e.formatLabel(h.observation);if(v==="")continue;const{width:f,height:P}=e.measureDataLabel("observation","outside",v),k=(e.styleReaders.get("size",h.observation)??0)/2,A=(0,a.composePoint)(l,{main:h.band,cross:h.tip}),g=(0,a.resolveAnchoredLabelCenter)({box:{x:A.x*e.panelRect.width,y:(1-A.y)*e.panelRect.height,width:0,height:0},panel:d,orientation:O(l),placement:t==="auto"?"outside":t,justify:t==="auto"?S(h):o,align:i,offset:n?s:s+k,alignOffset:s+k,labelWidth:f,labelHeight:P});r.push({layerId:e.layer.id,x:g.x,y:g.y,text:v,width:f,height:P,isRotated:!1,role:"observation",position:g.position})}return{labels:r,droppedCount:0}},O=e=>e==="x"?{valueAxis:"y",valueDirectionSign:-1}:{valueAxis:"x",valueDirectionSign:1},S=e=>M(e)?"start":"end",V=10,W=1,j=2,B=.7,H={size:"pixels",strokeWidth:"pixels"},D={stroke:"color",alpha:"unitInterval",strokeWidth:"pixels",dashArray:"dashArray"},_=class extends a.Geom{constructor(...e){super(...e),this.type="lollipop",this.defaultParams={},this.positionRoles=[{axis:"x",role:"point",valueKind:"value"},{axis:"y",role:"min",valueKind:"value"},{axis:"y",role:"max",valueKind:"value",aes:"y"}],this.aesthetics=[{kind:"visual",name:"color"}],this.defaultPosition="dodge",this.supportedPositions=["identity","dodge"],this.supportedCoordTypes=["cartesian","flip"],this.scaleConstraints={discreteMainAxis:!0,zeroBaseline:!0},this.legend={suppressWhenSingleItem:!0},this.dataLabelCoordTypes=["cartesian","flip"],this.getDataLabelPlacements=L,this.spatialKind="spanned-buckets",this.highlightStrategy="observation-rerender",this.styleTarget=(0,a.defineGeomStyleTarget)({observation:{vocabulary:H,aesthetics:{fill:"color",alpha:"alpha",size:"size",strokeWidth:"strokeWidth"},rest:{fill:(0,a.token)("geom"),fillAlpha:1,size:V,stroke:(0,a.token)("hoverAffordance"),strokeWidth:W}},parts:{stem:{vocabulary:D,aesthetics:{stroke:"color"},rest:{stroke:(0,a.token)("geom"),alpha:1,strokeWidth:j,dashArray:[]}}}}),this.resolveAnchorPosition=(r,{coordSystem:t})=>{const o=(0,a.readMainAxis)(t),i=x(r,o);return i===null?null:o==="x"?{x:i.band,y:i.tip}:{x:i.tip,y:i.band}}}compile({data:e}){const r=e.hasVariable(a.POSITION_VARIABLES.yMin)?e:e.addConstantVariable(a.POSITION_VARIABLES.yMin,"numeric",0),t=B/2;return{data:r.addConstantVariable(a.POSITION_VARIABLES.xMin,"numeric",-.35).addConstantVariable(a.POSITION_VARIABLES.xMax,"numeric",t),mapping:{}}}},T=({layer:e,coordSystem:r,panelRect:t,styleReaders:o})=>{const i=(0,a.readMainAxis)(r),s=p(e.data,i),n=(0,a.buildDotsEditOutlineShapes)(s.map(d=>({center:b(d.band,d.tip,i,t),size:(o.get("size",d.observation)??0)+(o.get("strokeWidth",d.observation)??0)}))),l=o.part("stem");return[...l===void 0?[]:s.map(d=>w(d,i,t,l)),...n]},w=(e,r,t,o)=>{const i=b(e.band,e.base,r,t),s=b(e.band,e.tip,r,t),n=o.get("strokeWidth",e.observation)??0;return{kind:"stroke",pathData:`M${i.x},${i.y}L${s.x},${s.y}`,width:n}},b=(e,r,t,o)=>{const i=(0,a.composePoint)(t,{main:e,cross:r});return(0,a.scalePointToPanel)((0,a.projectPointCartesian)(i.x,i.y),o)},m=e=>{const r=(0,a.createStableKeyGenerator)(e.data,e.mapping,e.id);return t=>r(t.observation)},E=.4,C=.2,R=1,G=.5,y=({lollipops:e,mainAxis:r,styleReaders:t,getKey:o,hovered:i,shouldAnimateTransitions:s=!1})=>{const n=t.part("stem"),l=i===void 0?void 0:"hovered";return(0,c.jsxs)(c.Fragment,{children:[n&&e.map(d=>(0,c.jsx)(X,{lollipop:d,mainAxis:r,readers:n,state:l,shouldAnimateTransitions:s},o(d))),e.map(d=>(0,c.jsx)(N,{lollipop:d,mainAxis:r,styleReaders:t,state:l,shouldAnimateTransitions:s},o(d))),i?.primary&&(0,c.jsx)(Y,{lollipop:i.primary,mainAxis:r,styleReaders:t})]})},X=({lollipop:e,mainAxis:r,readers:t,state:o,shouldAnimateTransitions:i})=>{const s=(0,a.composePoint)(r,{main:e.band,cross:e.base}),n=(0,a.composePoint)(r,{main:e.band,cross:e.tip}),l=t.get("strokeWidth",e.observation,o)??0,d=t.get("stroke",e.observation,o);return(0,c.jsx)(a.GeomLine,{"data-testid":"lollipop-stem",x1:(0,a.toPercent)((0,a.toViewBoxX)(s.x)),y1:(0,a.toPercent)((0,a.toViewBoxY)(s.y)),x2:(0,a.toPercent)((0,a.toViewBoxX)(n.x)),y2:(0,a.toPercent)((0,a.toViewBoxY)(n.y)),stroke:d===void 0?void 0:(0,a.toPaintColor)(d),strokeOpacity:t.get("alpha",e.observation,o),strokeWidth:l,strokeDasharray:(0,a.toStrokeDasharray)(t.get("dashArray",e.observation,o),l),shouldAnimateTransitions:i})},N=({lollipop:e,mainAxis:r,styleReaders:t,state:o,shouldAnimateTransitions:i})=>{const s=(0,a.composePoint)(r,{main:e.band,cross:e.tip}),n=t.get("fill",e.observation,o);return(0,c.jsx)(a.GeomCircle,{"data-testid":"lollipop-head",cx:(0,a.toPercent)((0,a.toViewBoxX)(s.x)),cy:(0,a.toPercent)((0,a.toViewBoxY)(s.y)),r:I(e,t,o),fill:n===void 0?void 0:(0,a.toPaintColor)(n),opacity:t.get("alpha",e.observation,o),fillOpacity:t.get("fillAlpha",e.observation,o),stroke:t.get("stroke",e.observation,o),strokeOpacity:t.get("strokeAlpha",e.observation,o),strokeWidth:t.get("strokeWidth",e.observation,o),shouldAnimateTransitions:i})},Y=({lollipop:e,mainAxis:r,styleReaders:t})=>{const o=(0,a.composePoint)(r,{main:e.band,cross:e.tip}),i=I(e,t,"hovered"),s=t.get("strokeWidth",e.observation,"hovered")??0,n=Math.max(R,i*E),l=Math.max(G,i*C);return(0,c.jsx)("circle",{"data-testid":"lollipop-hover-ring",cx:(0,a.toPercent)((0,a.toViewBoxX)(o.x)),cy:(0,a.toPercent)((0,a.toViewBoxY)(o.y)),r:i+s/2+l+n/2,fill:"none",stroke:t.get("stroke",e.observation,"hovered"),strokeWidth:n})},I=(e,r,t)=>(r.get("size",e.observation,t)??0)/2,z=({layer:e,sourceLayer:r,mainAxis:t,styleReaders:o})=>(0,c.jsx)(y,{lollipops:(0,u.useMemo)(()=>p(e.data,t),[e.data,t]),mainAxis:t,styleReaders:o,getKey:(0,u.useMemo)(()=>m(r),[r])}),K=({layer:e,primary:r,siblings:t,mainAxis:o,styleReaders:i})=>(0,c.jsx)("g",{"data-testid":"hovered-lollipops",children:(0,c.jsx)(y,{lollipops:p([r,...t].map(s=>s.observation),o),mainAxis:o,styleReaders:i,getKey:(0,u.useMemo)(()=>m(e),[e]),hovered:{primary:x(r.observation,o)}})}),$=({layer:e,mainAxis:r,styleReaders:t,shouldAnimateTransitions:o,intro:i})=>{const s=(0,c.jsx)(y,{lollipops:(0,u.useMemo)(()=>p(e.data,r),[e.data,r]),mainAxis:r,styleReaders:t,getKey:(0,u.useMemo)(()=>m(e),[e]),shouldAnimateTransitions:o});return i?.type==="fade"?(0,c.jsx)(a.IntroFade,{intro:i,children:s}):s},q=(0,a.defineGeomRenderer)(new _,{coord:"cartesian",swatchShape:"circle",guideMode:"band",render:({layer:e,coordSystem:r,styleReaders:t,shouldAnimateTransitions:o,intro:i})=>(0,c.jsx)($,{layer:e,mainAxis:(0,a.readMainAxis)(r),styleReaders:t,shouldAnimateTransitions:o,intro:i}),renderHighlight:({layer:e,sourceLayer:r,coordSystem:t,styleReaders:o})=>(0,c.jsx)(z,{layer:e,sourceLayer:r,mainAxis:(0,a.readMainAxis)(t),styleReaders:o}),renderHover:({layer:e,primary:r,group:t,related:o,coordSystem:i,styleReaders:s})=>(0,c.jsx)(K,{layer:e,primary:r,siblings:[...t,...o],mainAxis:(0,a.readMainAxis)(i),styleReaders:s}),renderHoverCompanions:()=>null,getEditOutlineShapes:T});exports.LollipopGeom=_;exports.lollipop=q;
package/dist/index.mjs CHANGED
@@ -1,35 +1,35 @@
1
- import { Geom as w, GeomCircle as B, GeomLine as z, IntroFade as K, POSITION_VARIABLES as b, buildDotsEditOutlineShapes as N, buildPanelAnchorBox as X, composePoint as u, createStableKeyGenerator as Y, defineGeomRenderer as j, defineGeomStyleTarget as $, getX as S, getXMax as D, getXMin as M, getY as C, getYMax as E, getYMin as T, projectPointCartesian as F, readMainAxis as c, resolveAnchoredLabelCenter as J, scalePointToPanel as U, toPaintColor as R, toPercent as h, toStrokeDasharray as Z, toViewBoxX as m, toViewBoxY as f, token as x } from "@graphysdk/react";
2
- import { useMemo as v } from "react";
3
- import { Fragment as q, jsx as l, jsxs as Q } from "react/jsx-runtime";
4
- var L = (t, a) => {
5
- const e = a === "x" ? G(M(t), D(t)) ?? S(t) : G(T(t), E(t)) ?? C(t), r = a === "x" ? T(t) : M(t), o = a === "x" ? E(t) ?? C(t) : D(t) ?? S(t);
6
- return e === null || r === null || o === null ? null : {
1
+ import { Geom as E, GeomCircle as T, GeomLine as G, IntroFade as R, POSITION_VARIABLES as b, buildDotsEditOutlineShapes as V, buildPanelAnchorBox as w, composePoint as v, createStableKeyGenerator as B, defineGeomRenderer as z, defineGeomStyleTarget as K, getX as S, getXMax as N, getXMin as X, getY as D, getYMax as Y, getYMin as j, projectPointCartesian as $, readMainAxis as c, resolveAnchoredLabelCenter as F, scalePointToPanel as J, toPaintColor as M, toPercent as l, toStrokeDasharray as U, toViewBoxX as m, toViewBoxY as f, token as x } from "@graphysdk/react";
2
+ import { useMemo as u } from "react";
3
+ import { Fragment as Z, jsx as h, jsxs as q } from "react/jsx-runtime";
4
+ var L = (t, r) => {
5
+ const e = r === "x" ? S(t) : D(t), a = r === "x" ? j(t) : X(t), o = r === "x" ? Y(t) ?? D(t) : N(t) ?? S(t);
6
+ return e === null || a === null || o === null ? null : {
7
7
  observation: t,
8
8
  band: e,
9
- base: r,
9
+ base: a,
10
10
  tip: o
11
11
  };
12
- }, g = (t, a) => {
12
+ }, g = (t, r) => {
13
13
  const e = [];
14
- for (const r of t) {
15
- const o = L(r, a);
14
+ for (const a of t) {
15
+ const o = L(a, r);
16
16
  o !== null && e.push(o);
17
17
  }
18
18
  return e;
19
- }, tt = (t) => t.tip < t.base, G = (t, a) => t === null || a === null ? null : (t + a) / 2, et = (t) => {
20
- const a = [];
19
+ }, Q = (t) => t.tip < t.base, tt = (t) => {
20
+ const r = [];
21
21
  if (!t.layer.dataLabels.showDataLabels) return {
22
- labels: a,
22
+ labels: r,
23
23
  droppedCount: 0
24
24
  };
25
- const { position: e, justify: r, align: o, offset: i } = t.layer.dataLabels, s = r === "panel-start" || r === "panel-end", d = c(t.coordSystem), n = X(t.panelRect);
25
+ const { position: e, justify: a, align: o, offset: i } = t.layer.dataLabels, s = a === "panel-start" || a === "panel-end", d = c(t.coordSystem), n = w(t.panelRect);
26
26
  for (const p of g(t.layer.data, d)) {
27
27
  const y = t.formatLabel(p.observation);
28
28
  if (y === "") continue;
29
- const { width: W, height: I } = t.measureDataLabel("observation", "outside", y), O = (t.styleReaders.get("size", p.observation) ?? 0) / 2, H = u(d, {
29
+ const { width: W, height: I } = t.measureDataLabel("observation", "outside", y), O = (t.styleReaders.get("size", p.observation) ?? 0) / 2, H = v(d, {
30
30
  main: p.band,
31
31
  cross: p.tip
32
- }), k = J({
32
+ }), k = F({
33
33
  box: {
34
34
  x: H.x * t.panelRect.width,
35
35
  y: (1 - H.y) * t.panelRect.height,
@@ -37,16 +37,16 @@ var L = (t, a) => {
37
37
  height: 0
38
38
  },
39
39
  panel: n,
40
- orientation: at(d),
40
+ orientation: et(d),
41
41
  placement: e === "auto" ? "outside" : e,
42
- justify: e === "auto" ? rt(p) : r,
42
+ justify: e === "auto" ? at(p) : a,
43
43
  align: o,
44
44
  offset: s ? i : i + O,
45
45
  alignOffset: i + O,
46
46
  labelWidth: W,
47
47
  labelHeight: I
48
48
  });
49
- a.push({
49
+ r.push({
50
50
  layerId: t.layer.id,
51
51
  x: k.x,
52
52
  y: k.y,
@@ -59,24 +59,24 @@ var L = (t, a) => {
59
59
  });
60
60
  }
61
61
  return {
62
- labels: a,
62
+ labels: r,
63
63
  droppedCount: 0
64
64
  };
65
- }, at = (t) => t === "x" ? {
65
+ }, et = (t) => t === "x" ? {
66
66
  valueAxis: "y",
67
67
  valueDirectionSign: -1
68
68
  } : {
69
69
  valueAxis: "x",
70
70
  valueDirectionSign: 1
71
- }, rt = (t) => tt(t) ? "start" : "end", ot = 10, it = 1, st = 2, nt = 0.7, dt = {
71
+ }, at = (t) => Q(t) ? "start" : "end", rt = 10, ot = 1, it = 2, st = 0.7, nt = {
72
72
  size: "pixels",
73
73
  strokeWidth: "pixels"
74
- }, lt = {
74
+ }, dt = {
75
75
  stroke: "color",
76
76
  alpha: "unitInterval",
77
77
  strokeWidth: "pixels",
78
78
  dashArray: "dashArray"
79
- }, ht = class extends w {
79
+ }, ht = class extends E {
80
80
  constructor(...t) {
81
81
  super(...t), this.type = "lollipop", this.defaultParams = {}, this.positionRoles = [
82
82
  {
@@ -101,9 +101,9 @@ var L = (t, a) => {
101
101
  }], this.defaultPosition = "dodge", this.supportedPositions = ["identity", "dodge"], this.supportedCoordTypes = ["cartesian", "flip"], this.scaleConstraints = {
102
102
  discreteMainAxis: !0,
103
103
  zeroBaseline: !0
104
- }, this.legend = { suppressWhenSingleItem: !0 }, this.dataLabelCoordTypes = ["cartesian", "flip"], this.getDataLabelPlacements = et, this.spatialKind = "spanned-buckets", this.highlightStrategy = "observation-rerender", this.styleTarget = $({
104
+ }, this.legend = { suppressWhenSingleItem: !0 }, this.dataLabelCoordTypes = ["cartesian", "flip"], this.getDataLabelPlacements = tt, this.spatialKind = "spanned-buckets", this.highlightStrategy = "observation-rerender", this.styleTarget = K({
105
105
  observation: {
106
- vocabulary: dt,
106
+ vocabulary: nt,
107
107
  aesthetics: {
108
108
  fill: "color",
109
109
  alpha: "alpha",
@@ -113,24 +113,24 @@ var L = (t, a) => {
113
113
  rest: {
114
114
  fill: x("geom"),
115
115
  fillAlpha: 1,
116
- size: ot,
116
+ size: rt,
117
117
  stroke: x("hoverAffordance"),
118
- strokeWidth: it
118
+ strokeWidth: ot
119
119
  }
120
120
  },
121
121
  parts: { stem: {
122
- vocabulary: lt,
122
+ vocabulary: dt,
123
123
  aesthetics: { stroke: "color" },
124
124
  rest: {
125
125
  stroke: x("geom"),
126
126
  alpha: 1,
127
- strokeWidth: st,
127
+ strokeWidth: it,
128
128
  dashArray: []
129
129
  }
130
130
  } }
131
- }), this.resolveAnchorPosition = (a, { coordSystem: e }) => {
132
- const r = c(e), o = L(a, r);
133
- return o === null ? null : r === "x" ? {
131
+ }), this.resolveAnchorPosition = (r, { coordSystem: e }) => {
132
+ const a = c(e), o = L(r, a);
133
+ return o === null ? null : a === "x" ? {
134
134
  x: o.band,
135
135
  y: o.tip
136
136
  } : {
@@ -140,163 +140,163 @@ var L = (t, a) => {
140
140
  };
141
141
  }
142
142
  compile({ data: t }) {
143
- const a = t.hasVariable(b.yMin) ? t : t.addConstantVariable(b.yMin, "numeric", 0), e = nt / 2;
143
+ const r = t.hasVariable(b.yMin) ? t : t.addConstantVariable(b.yMin, "numeric", 0), e = st / 2;
144
144
  return {
145
- data: a.addConstantVariable(b.xMin, "numeric", -0.35).addConstantVariable(b.xMax, "numeric", e),
145
+ data: r.addConstantVariable(b.xMin, "numeric", -0.35).addConstantVariable(b.xMax, "numeric", e),
146
146
  mapping: {}
147
147
  };
148
148
  }
149
- }, ct = ({ layer: t, coordSystem: a, panelRect: e, styleReaders: r }) => {
150
- const o = c(a), i = g(t.data, o), s = N(i.map((n) => ({
149
+ }, lt = ({ layer: t, coordSystem: r, panelRect: e, styleReaders: a }) => {
150
+ const o = c(r), i = g(t.data, o), s = V(i.map((n) => ({
151
151
  center: _(n.band, n.tip, o, e),
152
- size: (r.get("size", n.observation) ?? 0) + (r.get("strokeWidth", n.observation) ?? 0)
153
- }))), d = r.part("stem");
154
- return [...d === void 0 ? [] : i.map((n) => ut(n, o, e, d)), ...s];
155
- }, ut = (t, a, e, r) => {
156
- const o = _(t.band, t.base, a, e), i = _(t.band, t.tip, a, e), s = r.get("strokeWidth", t.observation) ?? 0;
152
+ size: (a.get("size", n.observation) ?? 0) + (a.get("strokeWidth", n.observation) ?? 0)
153
+ }))), d = a.part("stem");
154
+ return [...d === void 0 ? [] : i.map((n) => ct(n, o, e, d)), ...s];
155
+ }, ct = (t, r, e, a) => {
156
+ const o = _(t.band, t.base, r, e), i = _(t.band, t.tip, r, e), s = a.get("strokeWidth", t.observation) ?? 0;
157
157
  return {
158
158
  kind: "stroke",
159
159
  pathData: `M${o.x},${o.y}L${i.x},${i.y}`,
160
160
  width: s
161
161
  };
162
- }, _ = (t, a, e, r) => {
163
- const o = u(e, {
162
+ }, _ = (t, r, e, a) => {
163
+ const o = v(e, {
164
164
  main: t,
165
- cross: a
165
+ cross: r
166
166
  });
167
- return U(F(o.x, o.y), r);
167
+ return J($(o.x, o.y), a);
168
168
  }, A = (t) => {
169
- const a = Y(t.data, t.mapping, t.id);
170
- return (e) => a(e.observation);
171
- }, pt = 0.4, vt = 0.2, gt = 1, bt = 0.5, P = ({ lollipops: t, mainAxis: a, styleReaders: e, getKey: r, hovered: o, shouldAnimateTransitions: i = !1 }) => {
169
+ const r = B(t.data, t.mapping, t.id);
170
+ return (e) => r(e.observation);
171
+ }, vt = 0.4, pt = 0.2, ut = 1, gt = 0.5, P = ({ lollipops: t, mainAxis: r, styleReaders: e, getKey: a, hovered: o, shouldAnimateTransitions: i = !1 }) => {
172
172
  const s = e.part("stem"), d = o === void 0 ? void 0 : "hovered";
173
- return /* @__PURE__ */ Q(q, { children: [
174
- s && t.map((n) => /* @__PURE__ */ l(mt, {
173
+ return /* @__PURE__ */ q(Z, { children: [
174
+ s && t.map((n) => /* @__PURE__ */ h(bt, {
175
175
  lollipop: n,
176
- mainAxis: a,
176
+ mainAxis: r,
177
177
  readers: s,
178
178
  state: d,
179
179
  shouldAnimateTransitions: i
180
- }, r(n))),
181
- t.map((n) => /* @__PURE__ */ l(ft, {
180
+ }, a(n))),
181
+ t.map((n) => /* @__PURE__ */ h(mt, {
182
182
  lollipop: n,
183
- mainAxis: a,
183
+ mainAxis: r,
184
184
  styleReaders: e,
185
185
  state: d,
186
186
  shouldAnimateTransitions: i
187
- }, r(n))),
188
- o?.primary && /* @__PURE__ */ l(yt, {
187
+ }, a(n))),
188
+ o?.primary && /* @__PURE__ */ h(ft, {
189
189
  lollipop: o.primary,
190
- mainAxis: a,
190
+ mainAxis: r,
191
191
  styleReaders: e
192
192
  })
193
193
  ] });
194
- }, mt = ({ lollipop: t, mainAxis: a, readers: e, state: r, shouldAnimateTransitions: o }) => {
195
- const i = u(a, {
194
+ }, bt = ({ lollipop: t, mainAxis: r, readers: e, state: a, shouldAnimateTransitions: o }) => {
195
+ const i = v(r, {
196
196
  main: t.band,
197
197
  cross: t.base
198
- }), s = u(a, {
198
+ }), s = v(r, {
199
199
  main: t.band,
200
200
  cross: t.tip
201
- }), d = e.get("strokeWidth", t.observation, r) ?? 0, n = e.get("stroke", t.observation, r);
202
- return /* @__PURE__ */ l(z, {
201
+ }), d = e.get("strokeWidth", t.observation, a) ?? 0, n = e.get("stroke", t.observation, a);
202
+ return /* @__PURE__ */ h(G, {
203
203
  "data-testid": "lollipop-stem",
204
- x1: h(m(i.x)),
205
- y1: h(f(i.y)),
206
- x2: h(m(s.x)),
207
- y2: h(f(s.y)),
208
- stroke: n === void 0 ? void 0 : R(n),
209
- strokeOpacity: e.get("alpha", t.observation, r),
204
+ x1: l(m(i.x)),
205
+ y1: l(f(i.y)),
206
+ x2: l(m(s.x)),
207
+ y2: l(f(s.y)),
208
+ stroke: n === void 0 ? void 0 : M(n),
209
+ strokeOpacity: e.get("alpha", t.observation, a),
210
210
  strokeWidth: d,
211
- strokeDasharray: Z(e.get("dashArray", t.observation, r), d),
211
+ strokeDasharray: U(e.get("dashArray", t.observation, a), d),
212
212
  shouldAnimateTransitions: o
213
213
  });
214
- }, ft = ({ lollipop: t, mainAxis: a, styleReaders: e, state: r, shouldAnimateTransitions: o }) => {
215
- const i = u(a, {
214
+ }, mt = ({ lollipop: t, mainAxis: r, styleReaders: e, state: a, shouldAnimateTransitions: o }) => {
215
+ const i = v(r, {
216
216
  main: t.band,
217
217
  cross: t.tip
218
- }), s = e.get("fill", t.observation, r);
219
- return /* @__PURE__ */ l(B, {
218
+ }), s = e.get("fill", t.observation, a);
219
+ return /* @__PURE__ */ h(T, {
220
220
  "data-testid": "lollipop-head",
221
- cx: h(m(i.x)),
222
- cy: h(f(i.y)),
223
- r: V(t, e, r),
224
- fill: s === void 0 ? void 0 : R(s),
225
- opacity: e.get("alpha", t.observation, r),
226
- fillOpacity: e.get("fillAlpha", t.observation, r),
227
- stroke: e.get("stroke", t.observation, r),
228
- strokeOpacity: e.get("strokeAlpha", t.observation, r),
229
- strokeWidth: e.get("strokeWidth", t.observation, r),
221
+ cx: l(m(i.x)),
222
+ cy: l(f(i.y)),
223
+ r: C(t, e, a),
224
+ fill: s === void 0 ? void 0 : M(s),
225
+ opacity: e.get("alpha", t.observation, a),
226
+ fillOpacity: e.get("fillAlpha", t.observation, a),
227
+ stroke: e.get("stroke", t.observation, a),
228
+ strokeOpacity: e.get("strokeAlpha", t.observation, a),
229
+ strokeWidth: e.get("strokeWidth", t.observation, a),
230
230
  shouldAnimateTransitions: o
231
231
  });
232
- }, yt = ({ lollipop: t, mainAxis: a, styleReaders: e }) => {
233
- const r = u(a, {
232
+ }, ft = ({ lollipop: t, mainAxis: r, styleReaders: e }) => {
233
+ const a = v(r, {
234
234
  main: t.band,
235
235
  cross: t.tip
236
- }), o = V(t, e, "hovered"), i = e.get("strokeWidth", t.observation, "hovered") ?? 0, s = Math.max(gt, o * pt), d = Math.max(bt, o * vt);
237
- return /* @__PURE__ */ l("circle", {
236
+ }), o = C(t, e, "hovered"), i = e.get("strokeWidth", t.observation, "hovered") ?? 0, s = Math.max(ut, o * vt), d = Math.max(gt, o * pt);
237
+ return /* @__PURE__ */ h("circle", {
238
238
  "data-testid": "lollipop-hover-ring",
239
- cx: h(m(r.x)),
240
- cy: h(f(r.y)),
239
+ cx: l(m(a.x)),
240
+ cy: l(f(a.y)),
241
241
  r: o + i / 2 + d + s / 2,
242
242
  fill: "none",
243
243
  stroke: e.get("stroke", t.observation, "hovered"),
244
244
  strokeWidth: s
245
245
  });
246
- }, V = (t, a, e) => (a.get("size", t.observation, e) ?? 0) / 2, kt = ({ layer: t, sourceLayer: a, mainAxis: e, styleReaders: r }) => /* @__PURE__ */ l(P, {
247
- lollipops: v(() => g(t.data, e), [t.data, e]),
246
+ }, C = (t, r, e) => (r.get("size", t.observation, e) ?? 0) / 2, yt = ({ layer: t, sourceLayer: r, mainAxis: e, styleReaders: a }) => /* @__PURE__ */ h(P, {
247
+ lollipops: u(() => g(t.data, e), [t.data, e]),
248
248
  mainAxis: e,
249
- styleReaders: r,
250
- getKey: v(() => A(a), [a])
251
- }), xt = ({ layer: t, primary: a, siblings: e, mainAxis: r, styleReaders: o }) => /* @__PURE__ */ l("g", {
249
+ styleReaders: a,
250
+ getKey: u(() => A(r), [r])
251
+ }), kt = ({ layer: t, primary: r, siblings: e, mainAxis: a, styleReaders: o }) => /* @__PURE__ */ h("g", {
252
252
  "data-testid": "hovered-lollipops",
253
- children: /* @__PURE__ */ l(P, {
254
- lollipops: g([a, ...e].map((i) => i.observation), r),
255
- mainAxis: r,
253
+ children: /* @__PURE__ */ h(P, {
254
+ lollipops: g([r, ...e].map((i) => i.observation), a),
255
+ mainAxis: a,
256
256
  styleReaders: o,
257
- getKey: v(() => A(t), [t]),
258
- hovered: { primary: L(a.observation, r) }
257
+ getKey: u(() => A(t), [t]),
258
+ hovered: { primary: L(r.observation, a) }
259
259
  })
260
- }), _t = ({ layer: t, mainAxis: a, styleReaders: e, shouldAnimateTransitions: r, intro: o }) => {
261
- const i = /* @__PURE__ */ l(P, {
262
- lollipops: v(() => g(t.data, a), [t.data, a]),
263
- mainAxis: a,
260
+ }), xt = ({ layer: t, mainAxis: r, styleReaders: e, shouldAnimateTransitions: a, intro: o }) => {
261
+ const i = /* @__PURE__ */ h(P, {
262
+ lollipops: u(() => g(t.data, r), [t.data, r]),
263
+ mainAxis: r,
264
264
  styleReaders: e,
265
- getKey: v(() => A(t), [t]),
266
- shouldAnimateTransitions: r
265
+ getKey: u(() => A(t), [t]),
266
+ shouldAnimateTransitions: a
267
267
  });
268
- return o?.type === "fade" ? /* @__PURE__ */ l(K, {
268
+ return o?.type === "fade" ? /* @__PURE__ */ h(R, {
269
269
  intro: o,
270
270
  children: i
271
271
  }) : i;
272
- }, Wt = j(new ht(), {
272
+ }, Pt = z(new ht(), {
273
273
  coord: "cartesian",
274
274
  swatchShape: "circle",
275
275
  guideMode: "band",
276
- render: ({ layer: t, coordSystem: a, styleReaders: e, shouldAnimateTransitions: r, intro: o }) => /* @__PURE__ */ l(_t, {
276
+ render: ({ layer: t, coordSystem: r, styleReaders: e, shouldAnimateTransitions: a, intro: o }) => /* @__PURE__ */ h(xt, {
277
277
  layer: t,
278
- mainAxis: c(a),
278
+ mainAxis: c(r),
279
279
  styleReaders: e,
280
- shouldAnimateTransitions: r,
280
+ shouldAnimateTransitions: a,
281
281
  intro: o
282
282
  }),
283
- renderHighlight: ({ layer: t, sourceLayer: a, coordSystem: e, styleReaders: r }) => /* @__PURE__ */ l(kt, {
283
+ renderHighlight: ({ layer: t, sourceLayer: r, coordSystem: e, styleReaders: a }) => /* @__PURE__ */ h(yt, {
284
284
  layer: t,
285
- sourceLayer: a,
285
+ sourceLayer: r,
286
286
  mainAxis: c(e),
287
- styleReaders: r
287
+ styleReaders: a
288
288
  }),
289
- renderHover: ({ layer: t, primary: a, group: e, related: r, coordSystem: o, styleReaders: i }) => /* @__PURE__ */ l(xt, {
289
+ renderHover: ({ layer: t, primary: r, group: e, related: a, coordSystem: o, styleReaders: i }) => /* @__PURE__ */ h(kt, {
290
290
  layer: t,
291
- primary: a,
292
- siblings: [...e, ...r],
291
+ primary: r,
292
+ siblings: [...e, ...a],
293
293
  mainAxis: c(o),
294
294
  styleReaders: i
295
295
  }),
296
296
  renderHoverCompanions: () => null,
297
- getEditOutlineShapes: ct
297
+ getEditOutlineShapes: lt
298
298
  });
299
299
  export {
300
300
  ht as LollipopGeom,
301
- Wt as lollipop
301
+ Pt as lollipop
302
302
  };
@@ -11,7 +11,7 @@ export interface Lollipop {
11
11
  }
12
12
  /**
13
13
  * Reads where a lollipop sits. The flip is already baked into the position columns, so under `coord.flip()`
14
- * the band interval is `yMin`/`yMax` and the stem runs `xMin` to `xMax`; the main axis says which is which.
14
+ * the stem stands at `y` and runs `xMin` to `xMax`; the main axis says which is which.
15
15
  */
16
16
  export declare const readLollipop: (observation: Observation, mainAxis: MainAxis) => Lollipop | null;
17
17
  /** Reads every lollipop of a layer, skipping an observation with no value to stand on. */
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "grammar-of-graphics",
13
13
  "lollipop"
14
14
  ],
15
- "version": "0.1.0",
15
+ "version": "0.1.1-beta.1790864848006",
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.1790720825915"
34
+ "@graphysdk/react": "^1.9.0-beta.1790864848006"
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.1790720825915",
46
+ "@graphysdk/react": "1.9.0-beta.1790864848006",
47
+ "@graphysdk/viz-engine": "1.9.0-beta.1790864848006",
48
+ "@graphytools/eslint-config": "0.0.1",
47
49
  "@graphytools/typescript-config": "0.0.1",
48
- "@graphytools/vitest-config": "1.0.0",
49
- "@graphysdk/viz-engine": "1.8.0",
50
- "@graphytools/eslint-config": "0.0.1"
50
+ "@graphytools/vitest-config": "1.0.0"
51
51
  },
52
52
  "publishConfig": {
53
53
  "access": "public"