@graphysdk/geom-lollipop 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.md +17 -0
- package/README.md +57 -0
- package/dist/engine/lollipop-data-labels.d.ts +7 -0
- package/dist/engine/lollipop.geom.d.ts +78 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +302 -0
- package/dist/renderer/lollipop-edit-outline.d.ts +3 -0
- package/dist/renderer/lollipop-highlight.d.ts +11 -0
- package/dist/renderer/lollipop-hover.d.ts +12 -0
- package/dist/renderer/lollipop-layer.d.ts +15 -0
- package/dist/renderer/lollipop-paint.d.ts +20 -0
- package/dist/renderer/lollipop.d.ts +15 -0
- package/dist/renderer/utils/lollipop-keys.d.ts +7 -0
- package/dist/utils/read-lollipop.d.ts +20 -0
- package/licenses/PolyForm-Free-Trial-1.0.0.md +93 -0
- package/licenses/PolyForm-NonCommercial-1.0.0.md +131 -0
- package/licenses/PolyForm-Small-Business-1.0.0.md +121 -0
- package/package.json +73 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# License
|
|
2
|
+
|
|
3
|
+
This software is available under any of the following licenses, at your option,
|
|
4
|
+
depending on which one's conditions you meet:
|
|
5
|
+
|
|
6
|
+
- **PolyForm Noncommercial 1.0.0** — for noncommercial use (personal,
|
|
7
|
+
charitable, educational, research, government).
|
|
8
|
+
See [licenses/PolyForm-NonCommercial-1.0.0.md](licenses/PolyForm-NonCommercial-1.0.0.md)
|
|
9
|
+
|
|
10
|
+
- **PolyForm Small Business 1.0.0** — free commercial use for organizations
|
|
11
|
+
under the size thresholds defined in the license.
|
|
12
|
+
See [licenses/PolyForm-Small-Business-1.0.0.md](licenses/PolyForm-Small-Business-1.0.0.md)
|
|
13
|
+
|
|
14
|
+
- **PolyForm Free Trial 1.0.0** — a 32-day evaluation for anyone else.
|
|
15
|
+
See [licenses/PolyForm-Free-Trial-1.0.0.md](licenses/PolyForm-Free-Trial-1.0.0.md)
|
|
16
|
+
|
|
17
|
+
For commercial use beyond these terms, contact [hello@graphy.dev](mailto:hello@graphy.dev) or visit [https://graphy.dev](https://graphy.dev).
|
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# @graphysdk/geom-lollipop
|
|
2
|
+
|
|
3
|
+
> **Beta.** This geom is on a `0.x` version line: a minor release may change its aesthetics, style parts or look. Use a caret range (`^0.1.0`) to take only patches.
|
|
4
|
+
|
|
5
|
+
A lollipop geom for the Graphy charting SDK. It compares one value per category, like a bar, as a head at the value and a stem dropped from it to zero.
|
|
6
|
+
|
|
7
|
+
Learn more at [graphy.dev](https://graphy.dev).
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @graphysdk/geom-lollipop @graphysdk/react
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Requires React 19. Its only peer is `@graphysdk/react`.
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
Data is long, one row per lollipop. Map the category to `x` and the value to `y`, and a group to `color` for grouped lollipops:
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import { createGraphyKit, GraphRenderer } from '@graphysdk/react';
|
|
23
|
+
import { lollipop } from '@graphysdk/geom-lollipop';
|
|
24
|
+
|
|
25
|
+
const kit = createGraphyKit({ plugins: [lollipop] });
|
|
26
|
+
|
|
27
|
+
const spec = kit.pipe(
|
|
28
|
+
kit.createSpec({ x: 'product', y: 'revenue' }),
|
|
29
|
+
kit.geom.lollipop(),
|
|
30
|
+
kit.scale.x.discrete(),
|
|
31
|
+
kit.scale.y.continuous()
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
export function Revenue({ data }) {
|
|
35
|
+
return (
|
|
36
|
+
<kit.GraphProvider spec={spec} data={data}>
|
|
37
|
+
<GraphRenderer />
|
|
38
|
+
</kit.GraphProvider>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Add `kit.coord.flip()` for a horizontal lollipop. Style the heads with `kit.style.geom.lollipop()` and the stems with `kit.style.geom.lollipop.stem()`.
|
|
44
|
+
|
|
45
|
+
## Docs
|
|
46
|
+
|
|
47
|
+
- [Lollipop](https://docs.graphy.dev/sdk-next/graph-types/lollipop)
|
|
48
|
+
|
|
49
|
+
## Feedback
|
|
50
|
+
|
|
51
|
+
This geom is released early to hear what works. Tell us on [Discord](https://discord.gg/yGmYCjkSr).
|
|
52
|
+
|
|
53
|
+
## Licence
|
|
54
|
+
|
|
55
|
+
This package is available under PolyForm Noncommercial, Small Business, or a 32-day Free Trial. Free Trial is local or internal evaluation only — it does not cover a public page. See [what you can do under the trial](https://docs.graphy.dev/licence/evaluation).
|
|
56
|
+
|
|
57
|
+
For a commercial licence, [talk to us](https://graphy.dev/license).
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PlacementResult, PluginPlacementContext } from '@graphysdk/react';
|
|
2
|
+
/**
|
|
3
|
+
* A label per head, printing its value. Under `'auto'` each label sits beyond the head, away from the stem, so a
|
|
4
|
+
* hanging lollipop labels below and a rising one above; an explicit `position` is honoured as written. Stack
|
|
5
|
+
* totals and category labels are bar vocabulary; a lollipop places neither.
|
|
6
|
+
*/
|
|
7
|
+
export declare const placeLollipopDataLabels: (context: PluginPlacementContext) => PlacementResult;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { AnchorContext, AnchorPosition, GeomCompileResult, GeomCompilerInput, GeomObservationPart, GeomStylePart, GeomStyleTarget, Observation, PlacementResult, PluginPlacementContext, Geom } from '@graphysdk/react';
|
|
2
|
+
/** The observations paint the shared geom vocabulary on top of these. */
|
|
3
|
+
declare const HEAD_VOCABULARY: {
|
|
4
|
+
readonly size: "pixels";
|
|
5
|
+
readonly strokeWidth: "pixels";
|
|
6
|
+
};
|
|
7
|
+
declare const STEM_VOCABULARY: {
|
|
8
|
+
readonly stroke: "color";
|
|
9
|
+
readonly alpha: "unitInterval";
|
|
10
|
+
readonly strokeWidth: "pixels";
|
|
11
|
+
readonly dashArray: "dashArray";
|
|
12
|
+
};
|
|
13
|
+
/** Named so the published types reach the observations and every part through `@graphysdk/react`, the package's one peer. */
|
|
14
|
+
interface LollipopStyleTarget extends GeomStyleTarget {
|
|
15
|
+
observation: GeomObservationPart<typeof HEAD_VOCABULARY>;
|
|
16
|
+
parts: {
|
|
17
|
+
stem: GeomStylePart<typeof STEM_VOCABULARY>;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A lollipop: a head at each observation's value and a stem dropped from it to the zero baseline.
|
|
22
|
+
*
|
|
23
|
+
* Data is long, one row per lollipop: `x` is the category, `y` the value and `color` the group. A category
|
|
24
|
+
* holding several groups dodges them across its band, as a grouped bar does. The stem encodes length, so the
|
|
25
|
+
* value axis always holds zero. A horizontal lollipop is `coord.flip()`.
|
|
26
|
+
*/
|
|
27
|
+
export declare class LollipopGeom extends Geom {
|
|
28
|
+
readonly type: "lollipop";
|
|
29
|
+
readonly defaultParams: {};
|
|
30
|
+
readonly positionRoles: readonly [{
|
|
31
|
+
readonly axis: "x";
|
|
32
|
+
readonly role: "point";
|
|
33
|
+
readonly valueKind: "value";
|
|
34
|
+
}, {
|
|
35
|
+
readonly axis: "y";
|
|
36
|
+
readonly role: "min";
|
|
37
|
+
readonly valueKind: "value";
|
|
38
|
+
}, {
|
|
39
|
+
readonly axis: "y";
|
|
40
|
+
readonly role: "max";
|
|
41
|
+
readonly valueKind: "value";
|
|
42
|
+
readonly aes: "y";
|
|
43
|
+
}];
|
|
44
|
+
readonly aesthetics: readonly [{
|
|
45
|
+
readonly kind: "visual";
|
|
46
|
+
readonly name: "color";
|
|
47
|
+
}];
|
|
48
|
+
readonly defaultPosition = "dodge";
|
|
49
|
+
/** A stacked lollipop's stem would start on the head below it, and read as a length it does not encode. */
|
|
50
|
+
readonly supportedPositions: readonly ["identity", "dodge"];
|
|
51
|
+
readonly supportedCoordTypes: readonly ["cartesian", "flip"];
|
|
52
|
+
readonly scaleConstraints: {
|
|
53
|
+
discreteMainAxis: boolean;
|
|
54
|
+
zeroBaseline: boolean;
|
|
55
|
+
};
|
|
56
|
+
readonly legend: {
|
|
57
|
+
suppressWhenSingleItem: boolean;
|
|
58
|
+
};
|
|
59
|
+
readonly dataLabelCoordTypes: readonly ["cartesian", "flip"];
|
|
60
|
+
readonly getDataLabelPlacements: (context: PluginPlacementContext) => PlacementResult;
|
|
61
|
+
/**
|
|
62
|
+
* A hovered category is one unit: its lollipops repaint together. Each stem runs from the baseline to its
|
|
63
|
+
* head inside the category, so the whole of it takes a press for the category, and no stroke runs on to
|
|
64
|
+
* the next one.
|
|
65
|
+
*/
|
|
66
|
+
readonly spatialKind = "spanned-buckets";
|
|
67
|
+
readonly highlightStrategy: "observation-rerender";
|
|
68
|
+
readonly styleTarget: LollipopStyleTarget;
|
|
69
|
+
/**
|
|
70
|
+
* Where the editor raises its annotation trigger and where an annotation on a lollipop lands.
|
|
71
|
+
*
|
|
72
|
+
* An annotation on a lollipop sits on its head, which is where the value reads off the axis. A head has no
|
|
73
|
+
* extent, so every purpose resolves to its centre.
|
|
74
|
+
*/
|
|
75
|
+
readonly resolveAnchorPosition: (observation: Observation, { coordSystem }: AnchorContext) => AnchorPosition | null;
|
|
76
|
+
compile({ data }: GeomCompilerInput): GeomCompileResult;
|
|
77
|
+
}
|
|
78
|
+
export {};
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +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;
|
package/dist/index.d.ts
ADDED
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
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 : {
|
|
7
|
+
observation: t,
|
|
8
|
+
band: e,
|
|
9
|
+
base: r,
|
|
10
|
+
tip: o
|
|
11
|
+
};
|
|
12
|
+
}, g = (t, a) => {
|
|
13
|
+
const e = [];
|
|
14
|
+
for (const r of t) {
|
|
15
|
+
const o = L(r, a);
|
|
16
|
+
o !== null && e.push(o);
|
|
17
|
+
}
|
|
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 = [];
|
|
21
|
+
if (!t.layer.dataLabels.showDataLabels) return {
|
|
22
|
+
labels: a,
|
|
23
|
+
droppedCount: 0
|
|
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);
|
|
26
|
+
for (const p of g(t.layer.data, d)) {
|
|
27
|
+
const y = t.formatLabel(p.observation);
|
|
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, {
|
|
30
|
+
main: p.band,
|
|
31
|
+
cross: p.tip
|
|
32
|
+
}), k = J({
|
|
33
|
+
box: {
|
|
34
|
+
x: H.x * t.panelRect.width,
|
|
35
|
+
y: (1 - H.y) * t.panelRect.height,
|
|
36
|
+
width: 0,
|
|
37
|
+
height: 0
|
|
38
|
+
},
|
|
39
|
+
panel: n,
|
|
40
|
+
orientation: at(d),
|
|
41
|
+
placement: e === "auto" ? "outside" : e,
|
|
42
|
+
justify: e === "auto" ? rt(p) : r,
|
|
43
|
+
align: o,
|
|
44
|
+
offset: s ? i : i + O,
|
|
45
|
+
alignOffset: i + O,
|
|
46
|
+
labelWidth: W,
|
|
47
|
+
labelHeight: I
|
|
48
|
+
});
|
|
49
|
+
a.push({
|
|
50
|
+
layerId: t.layer.id,
|
|
51
|
+
x: k.x,
|
|
52
|
+
y: k.y,
|
|
53
|
+
text: y,
|
|
54
|
+
width: W,
|
|
55
|
+
height: I,
|
|
56
|
+
isRotated: !1,
|
|
57
|
+
role: "observation",
|
|
58
|
+
position: k.position
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
labels: a,
|
|
63
|
+
droppedCount: 0
|
|
64
|
+
};
|
|
65
|
+
}, at = (t) => t === "x" ? {
|
|
66
|
+
valueAxis: "y",
|
|
67
|
+
valueDirectionSign: -1
|
|
68
|
+
} : {
|
|
69
|
+
valueAxis: "x",
|
|
70
|
+
valueDirectionSign: 1
|
|
71
|
+
}, rt = (t) => tt(t) ? "start" : "end", ot = 10, it = 1, st = 2, nt = 0.7, dt = {
|
|
72
|
+
size: "pixels",
|
|
73
|
+
strokeWidth: "pixels"
|
|
74
|
+
}, lt = {
|
|
75
|
+
stroke: "color",
|
|
76
|
+
alpha: "unitInterval",
|
|
77
|
+
strokeWidth: "pixels",
|
|
78
|
+
dashArray: "dashArray"
|
|
79
|
+
}, ht = class extends w {
|
|
80
|
+
constructor(...t) {
|
|
81
|
+
super(...t), this.type = "lollipop", this.defaultParams = {}, this.positionRoles = [
|
|
82
|
+
{
|
|
83
|
+
axis: "x",
|
|
84
|
+
role: "point",
|
|
85
|
+
valueKind: "value"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
axis: "y",
|
|
89
|
+
role: "min",
|
|
90
|
+
valueKind: "value"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
axis: "y",
|
|
94
|
+
role: "max",
|
|
95
|
+
valueKind: "value",
|
|
96
|
+
aes: "y"
|
|
97
|
+
}
|
|
98
|
+
], this.aesthetics = [{
|
|
99
|
+
kind: "visual",
|
|
100
|
+
name: "color"
|
|
101
|
+
}], this.defaultPosition = "dodge", this.supportedPositions = ["identity", "dodge"], this.supportedCoordTypes = ["cartesian", "flip"], this.scaleConstraints = {
|
|
102
|
+
discreteMainAxis: !0,
|
|
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 = $({
|
|
105
|
+
observation: {
|
|
106
|
+
vocabulary: dt,
|
|
107
|
+
aesthetics: {
|
|
108
|
+
fill: "color",
|
|
109
|
+
alpha: "alpha",
|
|
110
|
+
size: "size",
|
|
111
|
+
strokeWidth: "strokeWidth"
|
|
112
|
+
},
|
|
113
|
+
rest: {
|
|
114
|
+
fill: x("geom"),
|
|
115
|
+
fillAlpha: 1,
|
|
116
|
+
size: ot,
|
|
117
|
+
stroke: x("hoverAffordance"),
|
|
118
|
+
strokeWidth: it
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
parts: { stem: {
|
|
122
|
+
vocabulary: lt,
|
|
123
|
+
aesthetics: { stroke: "color" },
|
|
124
|
+
rest: {
|
|
125
|
+
stroke: x("geom"),
|
|
126
|
+
alpha: 1,
|
|
127
|
+
strokeWidth: st,
|
|
128
|
+
dashArray: []
|
|
129
|
+
}
|
|
130
|
+
} }
|
|
131
|
+
}), this.resolveAnchorPosition = (a, { coordSystem: e }) => {
|
|
132
|
+
const r = c(e), o = L(a, r);
|
|
133
|
+
return o === null ? null : r === "x" ? {
|
|
134
|
+
x: o.band,
|
|
135
|
+
y: o.tip
|
|
136
|
+
} : {
|
|
137
|
+
x: o.tip,
|
|
138
|
+
y: o.band
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
compile({ data: t }) {
|
|
143
|
+
const a = t.hasVariable(b.yMin) ? t : t.addConstantVariable(b.yMin, "numeric", 0), e = nt / 2;
|
|
144
|
+
return {
|
|
145
|
+
data: a.addConstantVariable(b.xMin, "numeric", -0.35).addConstantVariable(b.xMax, "numeric", e),
|
|
146
|
+
mapping: {}
|
|
147
|
+
};
|
|
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) => ({
|
|
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;
|
|
157
|
+
return {
|
|
158
|
+
kind: "stroke",
|
|
159
|
+
pathData: `M${o.x},${o.y}L${i.x},${i.y}`,
|
|
160
|
+
width: s
|
|
161
|
+
};
|
|
162
|
+
}, _ = (t, a, e, r) => {
|
|
163
|
+
const o = u(e, {
|
|
164
|
+
main: t,
|
|
165
|
+
cross: a
|
|
166
|
+
});
|
|
167
|
+
return U(F(o.x, o.y), r);
|
|
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 }) => {
|
|
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, {
|
|
175
|
+
lollipop: n,
|
|
176
|
+
mainAxis: a,
|
|
177
|
+
readers: s,
|
|
178
|
+
state: d,
|
|
179
|
+
shouldAnimateTransitions: i
|
|
180
|
+
}, r(n))),
|
|
181
|
+
t.map((n) => /* @__PURE__ */ l(ft, {
|
|
182
|
+
lollipop: n,
|
|
183
|
+
mainAxis: a,
|
|
184
|
+
styleReaders: e,
|
|
185
|
+
state: d,
|
|
186
|
+
shouldAnimateTransitions: i
|
|
187
|
+
}, r(n))),
|
|
188
|
+
o?.primary && /* @__PURE__ */ l(yt, {
|
|
189
|
+
lollipop: o.primary,
|
|
190
|
+
mainAxis: a,
|
|
191
|
+
styleReaders: e
|
|
192
|
+
})
|
|
193
|
+
] });
|
|
194
|
+
}, mt = ({ lollipop: t, mainAxis: a, readers: e, state: r, shouldAnimateTransitions: o }) => {
|
|
195
|
+
const i = u(a, {
|
|
196
|
+
main: t.band,
|
|
197
|
+
cross: t.base
|
|
198
|
+
}), s = u(a, {
|
|
199
|
+
main: t.band,
|
|
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, {
|
|
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),
|
|
210
|
+
strokeWidth: d,
|
|
211
|
+
strokeDasharray: Z(e.get("dashArray", t.observation, r), d),
|
|
212
|
+
shouldAnimateTransitions: o
|
|
213
|
+
});
|
|
214
|
+
}, ft = ({ lollipop: t, mainAxis: a, styleReaders: e, state: r, shouldAnimateTransitions: o }) => {
|
|
215
|
+
const i = u(a, {
|
|
216
|
+
main: t.band,
|
|
217
|
+
cross: t.tip
|
|
218
|
+
}), s = e.get("fill", t.observation, r);
|
|
219
|
+
return /* @__PURE__ */ l(B, {
|
|
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),
|
|
230
|
+
shouldAnimateTransitions: o
|
|
231
|
+
});
|
|
232
|
+
}, yt = ({ lollipop: t, mainAxis: a, styleReaders: e }) => {
|
|
233
|
+
const r = u(a, {
|
|
234
|
+
main: t.band,
|
|
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", {
|
|
238
|
+
"data-testid": "lollipop-hover-ring",
|
|
239
|
+
cx: h(m(r.x)),
|
|
240
|
+
cy: h(f(r.y)),
|
|
241
|
+
r: o + i / 2 + d + s / 2,
|
|
242
|
+
fill: "none",
|
|
243
|
+
stroke: e.get("stroke", t.observation, "hovered"),
|
|
244
|
+
strokeWidth: s
|
|
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]),
|
|
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", {
|
|
252
|
+
"data-testid": "hovered-lollipops",
|
|
253
|
+
children: /* @__PURE__ */ l(P, {
|
|
254
|
+
lollipops: g([a, ...e].map((i) => i.observation), r),
|
|
255
|
+
mainAxis: r,
|
|
256
|
+
styleReaders: o,
|
|
257
|
+
getKey: v(() => A(t), [t]),
|
|
258
|
+
hovered: { primary: L(a.observation, r) }
|
|
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,
|
|
264
|
+
styleReaders: e,
|
|
265
|
+
getKey: v(() => A(t), [t]),
|
|
266
|
+
shouldAnimateTransitions: r
|
|
267
|
+
});
|
|
268
|
+
return o?.type === "fade" ? /* @__PURE__ */ l(K, {
|
|
269
|
+
intro: o,
|
|
270
|
+
children: i
|
|
271
|
+
}) : i;
|
|
272
|
+
}, Wt = j(new ht(), {
|
|
273
|
+
coord: "cartesian",
|
|
274
|
+
swatchShape: "circle",
|
|
275
|
+
guideMode: "band",
|
|
276
|
+
render: ({ layer: t, coordSystem: a, styleReaders: e, shouldAnimateTransitions: r, intro: o }) => /* @__PURE__ */ l(_t, {
|
|
277
|
+
layer: t,
|
|
278
|
+
mainAxis: c(a),
|
|
279
|
+
styleReaders: e,
|
|
280
|
+
shouldAnimateTransitions: r,
|
|
281
|
+
intro: o
|
|
282
|
+
}),
|
|
283
|
+
renderHighlight: ({ layer: t, sourceLayer: a, coordSystem: e, styleReaders: r }) => /* @__PURE__ */ l(kt, {
|
|
284
|
+
layer: t,
|
|
285
|
+
sourceLayer: a,
|
|
286
|
+
mainAxis: c(e),
|
|
287
|
+
styleReaders: r
|
|
288
|
+
}),
|
|
289
|
+
renderHover: ({ layer: t, primary: a, group: e, related: r, coordSystem: o, styleReaders: i }) => /* @__PURE__ */ l(xt, {
|
|
290
|
+
layer: t,
|
|
291
|
+
primary: a,
|
|
292
|
+
siblings: [...e, ...r],
|
|
293
|
+
mainAxis: c(o),
|
|
294
|
+
styleReaders: i
|
|
295
|
+
}),
|
|
296
|
+
renderHoverCompanions: () => null,
|
|
297
|
+
getEditOutlineShapes: ct
|
|
298
|
+
});
|
|
299
|
+
export {
|
|
300
|
+
ht as LollipopGeom,
|
|
301
|
+
Wt as lollipop
|
|
302
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { EditOutlineShape, GeomEditOutlineShapesRendererInput } from '@graphysdk/react';
|
|
2
|
+
/** What point and edit outlines round the lollipops they take: each stem as the stroke it is painted, and each head at its painted size. */
|
|
3
|
+
export declare const getLollipopEditOutlineShapes: ({ layer, coordSystem, panelRect, styleReaders, }: GeomEditOutlineShapesRendererInput) => EditOutlineShape[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { GeomStyleReaders, MainAxis, SceneLayer } from '@graphysdk/react';
|
|
2
|
+
interface HighlightedLollipopsProps {
|
|
3
|
+
layer: SceneLayer;
|
|
4
|
+
/** The whole layer the matched observations were taken from. */
|
|
5
|
+
sourceLayer: SceneLayer;
|
|
6
|
+
mainAxis: MainAxis;
|
|
7
|
+
styleReaders: GeomStyleReaders;
|
|
8
|
+
}
|
|
9
|
+
/** Repaints the matched lollipops above the dimmed layer. A stem belongs to its head alone, so each rises whole. */
|
|
10
|
+
export declare const HighlightedLollipops: ({ layer, sourceLayer, mainAxis, styleReaders }: HighlightedLollipopsProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { GeomStyleReaders, HoverHit, MainAxis, SceneLayer } from '@graphysdk/react';
|
|
2
|
+
interface HoveredLollipopsProps {
|
|
3
|
+
layer: SceneLayer;
|
|
4
|
+
primary: HoverHit;
|
|
5
|
+
/** The other lollipops of the hovered category. */
|
|
6
|
+
siblings: readonly HoverHit[];
|
|
7
|
+
mainAxis: MainAxis;
|
|
8
|
+
styleReaders: GeomStyleReaders;
|
|
9
|
+
}
|
|
10
|
+
/** The hovered category's lollipops, repainted above the dimmed layer. */
|
|
11
|
+
export declare const HoveredLollipops: ({ layer, primary, siblings, mainAxis, styleReaders }: HoveredLollipopsProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { GeomStyleReaders, LayerIntroPlan, MainAxis, SceneLayer } from '@graphysdk/react';
|
|
2
|
+
interface LollipopLayerProps {
|
|
3
|
+
layer: SceneLayer;
|
|
4
|
+
mainAxis: MainAxis;
|
|
5
|
+
styleReaders: GeomStyleReaders;
|
|
6
|
+
shouldAnimateTransitions: boolean;
|
|
7
|
+
intro: LayerIntroPlan | null | undefined;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The layer's own paint. The engine plans a plugin geom's entrance as a fade, so the whole layer comes up on
|
|
11
|
+
* one clock. The fade is independent of `shouldAnimateTransitions`: it rides the group rather than moving the
|
|
12
|
+
* marks, so it plays even when data changes snap.
|
|
13
|
+
*/
|
|
14
|
+
export declare const LollipopLayer: ({ layer, mainAxis, styleReaders, shouldAnimateTransitions, intro, }: LollipopLayerProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { GeomStyleReaders, MainAxis } from '@graphysdk/react';
|
|
2
|
+
import { Lollipop } from '../utils/read-lollipop';
|
|
3
|
+
/** What one pass paints: every stem below, every head above them. */
|
|
4
|
+
export interface LollipopPaintProps {
|
|
5
|
+
lollipops: readonly Lollipop[];
|
|
6
|
+
mainAxis: MainAxis;
|
|
7
|
+
styleReaders: GeomStyleReaders;
|
|
8
|
+
/** What identifies each lollipop across a data change, so a spring moves a mark rather than swapping it. */
|
|
9
|
+
getKey: (lollipop: Lollipop) => string;
|
|
10
|
+
/** Paints in the `hovered` state, ringing this head as the one the tooltip marks primary. */
|
|
11
|
+
hovered?: {
|
|
12
|
+
primary: Lollipop | null;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Whether stems and heads spring to their new positions when the data changes. The hover and highlight
|
|
16
|
+
* repaints mount and unmount with the interaction, so only the layer's own paint animates.
|
|
17
|
+
*/
|
|
18
|
+
shouldAnimateTransitions?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare const LollipopPaint: ({ lollipops, mainAxis, styleReaders, getKey, hovered, shouldAnimateTransitions, }: LollipopPaintProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BoundGeomRendererDefinition } from '@graphysdk/react';
|
|
2
|
+
import { LollipopGeom } from '../engine/lollipop.geom';
|
|
3
|
+
/**
|
|
4
|
+
* The lollipop plugin: pass it to `createGraphyKit({ plugins: [lollipop] })` for `kit.geom.lollipop()`.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* const kit = createGraphyKit({ plugins: [lollipop] });
|
|
8
|
+
* const spec = kit.pipe(
|
|
9
|
+
* kit.createSpec({ x: 'product', y: 'revenue' }),
|
|
10
|
+
* kit.geom.lollipop(),
|
|
11
|
+
* kit.scale.x.discrete(),
|
|
12
|
+
* kit.scale.y.continuous()
|
|
13
|
+
* );
|
|
14
|
+
*/
|
|
15
|
+
export declare const lollipop: BoundGeomRendererDefinition<LollipopGeom>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SceneLayer } from '@graphysdk/react';
|
|
2
|
+
import { Lollipop } from '../../utils/read-lollipop';
|
|
3
|
+
/**
|
|
4
|
+
* A lollipop keys on its `(group, category)`, read from raw values rather than the band: the band moves with the
|
|
5
|
+
* domain, the very change a mark should spring through, not remount on.
|
|
6
|
+
*/
|
|
7
|
+
export declare const createLollipopKeys: (layer: SceneLayer) => ((lollipop: Lollipop) => string);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { MainAxis, Observation } from '@graphysdk/react';
|
|
2
|
+
/** A lollipop placed by where its stem stands on the main axis and the two ends it runs between on the other. */
|
|
3
|
+
export interface Lollipop {
|
|
4
|
+
observation: Observation;
|
|
5
|
+
/** Where the stem stands on the main axis, as a `[0, 1]` fraction: its sub-band's centre under dodge. */
|
|
6
|
+
band: number;
|
|
7
|
+
/** The stem's foot on the value axis, as a `[0, 1]` fraction: the zero baseline. */
|
|
8
|
+
base: number;
|
|
9
|
+
/** The head's position on the value axis, as a `[0, 1]` fraction. */
|
|
10
|
+
tip: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
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.
|
|
15
|
+
*/
|
|
16
|
+
export declare const readLollipop: (observation: Observation, mainAxis: MainAxis) => Lollipop | null;
|
|
17
|
+
/** Reads every lollipop of a layer, skipping an observation with no value to stand on. */
|
|
18
|
+
export declare const readLollipops: (observations: Iterable<Observation>, mainAxis: MainAxis) => Lollipop[];
|
|
19
|
+
/** Whether the head sits below its baseline on the value axis, so the stem hangs rather than rises. */
|
|
20
|
+
export declare const isHanging: (lollipop: Lollipop) => boolean;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# PolyForm Free Trial License 1.0.0
|
|
2
|
+
|
|
3
|
+
<https://polyformproject.org/licenses/free-trial/1.0.0>
|
|
4
|
+
|
|
5
|
+
## Acceptance
|
|
6
|
+
|
|
7
|
+
In order to get any license under these terms, you must agree
|
|
8
|
+
to them as both strict obligations and conditions to all
|
|
9
|
+
your licenses.
|
|
10
|
+
|
|
11
|
+
## Copyright License
|
|
12
|
+
|
|
13
|
+
The licensor grants you a copyright license for the software
|
|
14
|
+
to do everything you might do with the software that would
|
|
15
|
+
otherwise infringe the licensor's copyright in it for any
|
|
16
|
+
permitted purpose. However, you may only make changes or
|
|
17
|
+
new works based on the software according to [Changes and New
|
|
18
|
+
Works License](#changes-and-new-works-license), and you may
|
|
19
|
+
not distribute copies of the software.
|
|
20
|
+
|
|
21
|
+
## Changes and New Works License
|
|
22
|
+
|
|
23
|
+
The licensor grants you an additional copyright license to
|
|
24
|
+
make changes and new works based on the software for any
|
|
25
|
+
permitted purpose.
|
|
26
|
+
|
|
27
|
+
## Patent License
|
|
28
|
+
|
|
29
|
+
The licensor grants you a patent license for the software that
|
|
30
|
+
covers patent claims the licensor can license, or becomes able
|
|
31
|
+
to license, that you would infringe by using the software.
|
|
32
|
+
|
|
33
|
+
## Fair Use
|
|
34
|
+
|
|
35
|
+
You may have "fair use" rights for the software under the
|
|
36
|
+
law. These terms do not limit them.
|
|
37
|
+
|
|
38
|
+
## Free Trial
|
|
39
|
+
|
|
40
|
+
Use to evaluate whether the software suits a particular
|
|
41
|
+
application for less than 32 consecutive calendar days, on
|
|
42
|
+
behalf of you or your company, is use for a permitted purpose.
|
|
43
|
+
|
|
44
|
+
## No Other Rights
|
|
45
|
+
|
|
46
|
+
These terms do not allow you to sublicense or transfer any of
|
|
47
|
+
your licenses to anyone else, or prevent the licensor from
|
|
48
|
+
granting licenses to anyone else. These terms do not imply
|
|
49
|
+
any other licenses.
|
|
50
|
+
|
|
51
|
+
## Patent Defense
|
|
52
|
+
|
|
53
|
+
If you make any written claim that the software infringes or
|
|
54
|
+
contributes to infringement of any patent, your patent license
|
|
55
|
+
for the software granted under these terms ends immediately. If
|
|
56
|
+
your company makes such a claim, your patent license ends
|
|
57
|
+
immediately for work on behalf of your company.
|
|
58
|
+
|
|
59
|
+
## Violations
|
|
60
|
+
|
|
61
|
+
If you violate any of these terms, or do anything with the
|
|
62
|
+
software not covered by your licenses, all your licenses
|
|
63
|
+
end immediately.
|
|
64
|
+
|
|
65
|
+
## No Liability
|
|
66
|
+
|
|
67
|
+
_**As far as the law allows, the software comes as is, without
|
|
68
|
+
any warranty or condition, and the licensor will not be liable
|
|
69
|
+
to you for any damages arising out of these terms or the use
|
|
70
|
+
or nature of the software, under any kind of legal claim.**_
|
|
71
|
+
|
|
72
|
+
## Definitions
|
|
73
|
+
|
|
74
|
+
The **licensor** is the individual or entity offering these
|
|
75
|
+
terms, and the **software** is the software the licensor makes
|
|
76
|
+
available under these terms.
|
|
77
|
+
|
|
78
|
+
**You** refers to the individual or entity agreeing to these
|
|
79
|
+
terms.
|
|
80
|
+
|
|
81
|
+
**Your company** is any legal entity, sole proprietorship,
|
|
82
|
+
or other kind of organization that you work for, plus all
|
|
83
|
+
organizations that have control over, are under the control of,
|
|
84
|
+
or are under common control with that organization. **Control**
|
|
85
|
+
means ownership of substantially all the assets of an entity,
|
|
86
|
+
or the power to direct its management and policies by vote,
|
|
87
|
+
contract, or otherwise. Control can be direct or indirect.
|
|
88
|
+
|
|
89
|
+
**Your licenses** are all the licenses granted to you for the
|
|
90
|
+
software under these terms.
|
|
91
|
+
|
|
92
|
+
**Use** means anything you do with the software requiring one
|
|
93
|
+
of your licenses.
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# PolyForm Noncommercial License 1.0.0
|
|
2
|
+
|
|
3
|
+
<https://polyformproject.org/licenses/noncommercial/1.0.0>
|
|
4
|
+
|
|
5
|
+
## Acceptance
|
|
6
|
+
|
|
7
|
+
In order to get any license under these terms, you must agree
|
|
8
|
+
to them as both strict obligations and conditions to all
|
|
9
|
+
your licenses.
|
|
10
|
+
|
|
11
|
+
## Copyright License
|
|
12
|
+
|
|
13
|
+
The licensor grants you a copyright license for the
|
|
14
|
+
software to do everything you might do with the software
|
|
15
|
+
that would otherwise infringe the licensor's copyright
|
|
16
|
+
in it for any permitted purpose. However, you may
|
|
17
|
+
only distribute the software according to [Distribution
|
|
18
|
+
License](#distribution-license) and make changes or new works
|
|
19
|
+
based on the software according to [Changes and New Works
|
|
20
|
+
License](#changes-and-new-works-license).
|
|
21
|
+
|
|
22
|
+
## Distribution License
|
|
23
|
+
|
|
24
|
+
The licensor grants you an additional copyright license
|
|
25
|
+
to distribute copies of the software. Your license
|
|
26
|
+
to distribute covers distributing the software with
|
|
27
|
+
changes and new works permitted by [Changes and New Works
|
|
28
|
+
License](#changes-and-new-works-license).
|
|
29
|
+
|
|
30
|
+
## Notices
|
|
31
|
+
|
|
32
|
+
You must ensure that anyone who gets a copy of any part of
|
|
33
|
+
the software from you also gets a copy of these terms or the
|
|
34
|
+
URL for them above, as well as copies of any plain-text lines
|
|
35
|
+
beginning with `Required Notice:` that the licensor provided
|
|
36
|
+
with the software. For example:
|
|
37
|
+
|
|
38
|
+
> Required Notice: Copyright Graphy Technologies Ltd. (https://graphy.dev)
|
|
39
|
+
|
|
40
|
+
## Changes and New Works License
|
|
41
|
+
|
|
42
|
+
The licensor grants you an additional copyright license to
|
|
43
|
+
make changes and new works based on the software for any
|
|
44
|
+
permitted purpose.
|
|
45
|
+
|
|
46
|
+
## Patent License
|
|
47
|
+
|
|
48
|
+
The licensor grants you a patent license for the software that
|
|
49
|
+
covers patent claims the licensor can license, or becomes able
|
|
50
|
+
to license, that you would infringe by using the software.
|
|
51
|
+
|
|
52
|
+
## Noncommercial Purposes
|
|
53
|
+
|
|
54
|
+
Any noncommercial purpose is a permitted purpose.
|
|
55
|
+
|
|
56
|
+
## Personal Uses
|
|
57
|
+
|
|
58
|
+
Personal use for research, experiment, and testing for
|
|
59
|
+
the benefit of public knowledge, personal study, private
|
|
60
|
+
entertainment, hobby projects, amateur pursuits, or religious
|
|
61
|
+
observance, without any anticipated commercial application,
|
|
62
|
+
is use for a permitted purpose.
|
|
63
|
+
|
|
64
|
+
## Noncommercial Organizations
|
|
65
|
+
|
|
66
|
+
Use by any charitable organization, educational institution,
|
|
67
|
+
public research organization, public safety or health
|
|
68
|
+
organization, environmental protection organization,
|
|
69
|
+
or government institution is use for a permitted purpose
|
|
70
|
+
regardless of the source of funding or obligations resulting
|
|
71
|
+
from the funding.
|
|
72
|
+
|
|
73
|
+
## Fair Use
|
|
74
|
+
|
|
75
|
+
You may have "fair use" rights for the software under the
|
|
76
|
+
law. These terms do not limit them.
|
|
77
|
+
|
|
78
|
+
## No Other Rights
|
|
79
|
+
|
|
80
|
+
These terms do not allow you to sublicense or transfer any of
|
|
81
|
+
your licenses to anyone else, or prevent the licensor from
|
|
82
|
+
granting licenses to anyone else. These terms do not imply
|
|
83
|
+
any other licenses.
|
|
84
|
+
|
|
85
|
+
## Patent Defense
|
|
86
|
+
|
|
87
|
+
If you make any written claim that the software infringes or
|
|
88
|
+
contributes to infringement of any patent, your patent license
|
|
89
|
+
for the software granted under these terms ends immediately. If
|
|
90
|
+
your company makes such a claim, your patent license ends
|
|
91
|
+
immediately for work on behalf of your company.
|
|
92
|
+
|
|
93
|
+
## Violations
|
|
94
|
+
|
|
95
|
+
The first time you are notified in writing that you have
|
|
96
|
+
violated any of these terms, or done anything with the software
|
|
97
|
+
not covered by your licenses, your licenses can nonetheless
|
|
98
|
+
continue if you come into full compliance with these terms,
|
|
99
|
+
and take practical steps to correct past violations, within
|
|
100
|
+
32 days of receiving notice. Otherwise, all your licenses
|
|
101
|
+
end immediately.
|
|
102
|
+
|
|
103
|
+
## No Liability
|
|
104
|
+
|
|
105
|
+
_**As far as the law allows, the software comes as is, without
|
|
106
|
+
any warranty or condition, and the licensor will not be liable
|
|
107
|
+
to you for any damages arising out of these terms or the use
|
|
108
|
+
or nature of the software, under any kind of legal claim.**_
|
|
109
|
+
|
|
110
|
+
## Definitions
|
|
111
|
+
|
|
112
|
+
The **licensor** is the individual or entity offering these
|
|
113
|
+
terms, and the **software** is the software the licensor makes
|
|
114
|
+
available under these terms.
|
|
115
|
+
|
|
116
|
+
**You** refers to the individual or entity agreeing to these
|
|
117
|
+
terms.
|
|
118
|
+
|
|
119
|
+
**Your company** is any legal entity, sole proprietorship,
|
|
120
|
+
or other kind of organization that you work for, plus all
|
|
121
|
+
organizations that have control over, are under the control of,
|
|
122
|
+
or are under common control with that organization. **Control**
|
|
123
|
+
means ownership of substantially all the assets of an entity,
|
|
124
|
+
or the power to direct its management and policies by vote,
|
|
125
|
+
contract, or otherwise. Control can be direct or indirect.
|
|
126
|
+
|
|
127
|
+
**Your licenses** are all the licenses granted to you for the
|
|
128
|
+
software under these terms.
|
|
129
|
+
|
|
130
|
+
**Use** means anything you do with the software requiring one
|
|
131
|
+
of your licenses.
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# PolyForm Small Business License 1.0.0
|
|
2
|
+
|
|
3
|
+
<https://polyformproject.org/licenses/small-business/1.0.0>
|
|
4
|
+
|
|
5
|
+
## Acceptance
|
|
6
|
+
|
|
7
|
+
In order to get any license under these terms, you must agree
|
|
8
|
+
to them as both strict obligations and conditions to all
|
|
9
|
+
your licenses.
|
|
10
|
+
|
|
11
|
+
## Copyright License
|
|
12
|
+
|
|
13
|
+
The licensor grants you a copyright license for the
|
|
14
|
+
software to do everything you might do with the software
|
|
15
|
+
that would otherwise infringe the licensor's copyright
|
|
16
|
+
in it for any permitted purpose. However, you may
|
|
17
|
+
only distribute the software according to [Distribution
|
|
18
|
+
License](#distribution-license) and make changes or new works
|
|
19
|
+
based on the software according to [Changes and New Works
|
|
20
|
+
License](#changes-and-new-works-license).
|
|
21
|
+
|
|
22
|
+
## Distribution License
|
|
23
|
+
|
|
24
|
+
The licensor grants you an additional copyright license
|
|
25
|
+
to distribute copies of the software. Your license
|
|
26
|
+
to distribute covers distributing the software with
|
|
27
|
+
changes and new works permitted by [Changes and New Works
|
|
28
|
+
License](#changes-and-new-works-license).
|
|
29
|
+
|
|
30
|
+
## Notices
|
|
31
|
+
|
|
32
|
+
You must ensure that anyone who gets a copy of any part of
|
|
33
|
+
the software from you also gets a copy of these terms or the
|
|
34
|
+
URL for them above, as well as copies of any plain-text lines
|
|
35
|
+
beginning with `Required Notice:` that the licensor provided
|
|
36
|
+
with the software. For example:
|
|
37
|
+
|
|
38
|
+
> Required Notice: Copyright Graphy Technologies Ltd. (https://graphy.dev)
|
|
39
|
+
|
|
40
|
+
## Changes and New Works License
|
|
41
|
+
|
|
42
|
+
The licensor grants you an additional copyright license to
|
|
43
|
+
make changes and new works based on the software for any
|
|
44
|
+
permitted purpose.
|
|
45
|
+
|
|
46
|
+
## Patent License
|
|
47
|
+
|
|
48
|
+
The licensor grants you a patent license for the software that
|
|
49
|
+
covers patent claims the licensor can license, or becomes able
|
|
50
|
+
to license, that you would infringe by using the software.
|
|
51
|
+
|
|
52
|
+
## Fair Use
|
|
53
|
+
|
|
54
|
+
You may have "fair use" rights for the software under the
|
|
55
|
+
law. These terms do not limit them.
|
|
56
|
+
|
|
57
|
+
## Small Business
|
|
58
|
+
|
|
59
|
+
Use of the software for the benefit of your company is use for
|
|
60
|
+
a permitted purpose if your company has fewer than 100 total
|
|
61
|
+
individuals working as employees and independent contractors,
|
|
62
|
+
and less than 1,000,000 USD (2019) total revenue in the prior
|
|
63
|
+
tax year. Adjust this revenue threshold for inflation according
|
|
64
|
+
to the United States Bureau of Labor Statistics' consumer price
|
|
65
|
+
index for all urban consumers, U.S. city average, for all items,
|
|
66
|
+
not seasonally adjusted, with 1982–1984=100 reference base.
|
|
67
|
+
|
|
68
|
+
## No Other Rights
|
|
69
|
+
|
|
70
|
+
These terms do not allow you to sublicense or transfer any of
|
|
71
|
+
your licenses to anyone else, or prevent the licensor from
|
|
72
|
+
granting licenses to anyone else. These terms do not imply
|
|
73
|
+
any other licenses.
|
|
74
|
+
|
|
75
|
+
## Patent Defense
|
|
76
|
+
|
|
77
|
+
If you make any written claim that the software infringes or
|
|
78
|
+
contributes to infringement of any patent, your patent license
|
|
79
|
+
for the software granted under these terms ends immediately. If
|
|
80
|
+
your company makes such a claim, your patent license ends
|
|
81
|
+
immediately for work on behalf of your company.
|
|
82
|
+
|
|
83
|
+
## Violations
|
|
84
|
+
|
|
85
|
+
The first time you are notified in writing that you have
|
|
86
|
+
violated any of these terms, or done anything with the software
|
|
87
|
+
not covered by your licenses, your licenses can nonetheless
|
|
88
|
+
continue if you come into full compliance with these terms,
|
|
89
|
+
and take practical steps to correct past violations, within
|
|
90
|
+
32 days of receiving notice. Otherwise, all your licenses
|
|
91
|
+
end immediately.
|
|
92
|
+
|
|
93
|
+
## No Liability
|
|
94
|
+
|
|
95
|
+
_**As far as the law allows, the software comes as is, without
|
|
96
|
+
any warranty or condition, and the licensor will not be liable
|
|
97
|
+
to you for any damages arising out of these terms or the use
|
|
98
|
+
or nature of the software, under any kind of legal claim.**_
|
|
99
|
+
|
|
100
|
+
## Definitions
|
|
101
|
+
|
|
102
|
+
The **licensor** is the individual or entity offering these
|
|
103
|
+
terms, and the **software** is the software the licensor makes
|
|
104
|
+
available under these terms.
|
|
105
|
+
|
|
106
|
+
**You** refers to the individual or entity agreeing to these
|
|
107
|
+
terms.
|
|
108
|
+
|
|
109
|
+
**Your company** is any legal entity, sole proprietorship,
|
|
110
|
+
or other kind of organization that you work for, plus all
|
|
111
|
+
organizations that have control over, are under the control of,
|
|
112
|
+
or are under common control with that organization. **Control**
|
|
113
|
+
means ownership of substantially all the assets of an entity,
|
|
114
|
+
or the power to direct its management and policies by vote,
|
|
115
|
+
contract, or otherwise. Control can be direct or indirect.
|
|
116
|
+
|
|
117
|
+
**Your licenses** are all the licenses granted to you for the
|
|
118
|
+
software under these terms.
|
|
119
|
+
|
|
120
|
+
**Use** means anything you do with the software requiring one
|
|
121
|
+
of your licenses.
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@graphysdk/geom-lollipop",
|
|
3
|
+
"author": "Graphy",
|
|
4
|
+
"description": "Lollipop geom for the Graphy charting SDK (beta)",
|
|
5
|
+
"homepage": "https://docs.graphy.dev/sdk-next/graph-types/lollipop",
|
|
6
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"graphy",
|
|
9
|
+
"chart",
|
|
10
|
+
"react",
|
|
11
|
+
"visualization",
|
|
12
|
+
"grammar-of-graphics",
|
|
13
|
+
"lollipop"
|
|
14
|
+
],
|
|
15
|
+
"version": "0.1.0",
|
|
16
|
+
"type": "module",
|
|
17
|
+
"sideEffects": false,
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"LICENSE.md",
|
|
22
|
+
"licenses",
|
|
23
|
+
"README.md"
|
|
24
|
+
],
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"import": "./dist/index.mjs",
|
|
29
|
+
"require": "./dist/index.cjs"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"react": "^19.0.0",
|
|
34
|
+
"@graphysdk/react": "^1.9.0-beta.1790720825915"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@testing-library/react": "^16.3.1",
|
|
38
|
+
"@types/react": "^19.2.14",
|
|
39
|
+
"@types/react-dom": "^19.2.3",
|
|
40
|
+
"react": "^19.2.4",
|
|
41
|
+
"react-dom": "^19.2.4",
|
|
42
|
+
"rollup-plugin-node-externals": "^8.1.1",
|
|
43
|
+
"vite": "^8.1.5",
|
|
44
|
+
"vite-plugin-dts": "^4.5.4",
|
|
45
|
+
"vitest": "^4.1.11",
|
|
46
|
+
"@graphysdk/react": "1.9.0-beta.1790720825915",
|
|
47
|
+
"@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"
|
|
51
|
+
},
|
|
52
|
+
"publishConfig": {
|
|
53
|
+
"access": "public"
|
|
54
|
+
},
|
|
55
|
+
"lint-staged": {
|
|
56
|
+
"*.{ts,tsx,js,jsx,json,css,md}": [
|
|
57
|
+
"prettier --write"
|
|
58
|
+
],
|
|
59
|
+
"*.{ts,tsx}": [
|
|
60
|
+
"eslint --max-warnings=0 --fix"
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
"scripts": {
|
|
64
|
+
"build": "vite build",
|
|
65
|
+
"test": "vitest run",
|
|
66
|
+
"test:watch": "TZ=utc vitest",
|
|
67
|
+
"lint": "eslint . --max-warnings 0",
|
|
68
|
+
"lint:fix": "eslint . --fix",
|
|
69
|
+
"format": "prettier --write .",
|
|
70
|
+
"format:check": "prettier --check .",
|
|
71
|
+
"typecheck": "tsc --noEmit"
|
|
72
|
+
}
|
|
73
|
+
}
|