@d3plus/core 4.2.0 → 4.3.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/README.md +374 -296
- package/es/src/charts/Geomap/emit.js +44 -4
- package/es/src/charts/Geomap/emit.js.map +1 -1
- package/es/src/charts/Geomap/index.js +30 -1
- package/es/src/charts/Geomap/index.js.map +1 -1
- package/es/src/charts/Plot/index.js +77 -2
- package/es/src/charts/Plot/index.js.map +1 -1
- package/es/src/charts/Plot/pipeline.js +24 -3
- package/es/src/charts/Plot/pipeline.js.map +1 -1
- package/es/src/charts/features/shapeEmit.js +3 -1
- package/es/src/charts/features/shapeEmit.js.map +1 -1
- package/es/src/charts/viz/Viz.js +63 -10
- package/es/src/charts/viz/Viz.js.map +1 -1
- package/es/src/charts/viz/interactionOpacity.js +4 -1
- package/es/src/charts/viz/interactionOpacity.js.map +1 -1
- package/es/src/charts/viz/vizDefaults.js +4 -1
- package/es/src/charts/viz/vizDefaults.js.map +1 -1
- package/es/src/charts/viz/vizRender.js +7 -3
- package/es/src/charts/viz/vizRender.js.map +1 -1
- package/es/src/charts/viz/vizTypes.js.map +1 -1
- package/es/src/shapes/Shape.js +12 -10
- package/es/src/shapes/Shape.js.map +1 -1
- package/es/src/shapes/hitAreaNode.js +31 -5
- package/es/src/shapes/hitAreaNode.js.map +1 -1
- package/es/src/shapes/interactionPoints.js +30 -0
- package/es/src/shapes/interactionPoints.js.map +1 -0
- package/package.json +9 -9
- package/types/src/charts/Plot/index.d.ts +22 -1
- package/types/src/charts/Plot/pipeline.d.ts +2 -1
- package/types/src/charts/viz/Viz.d.ts +31 -1
- package/types/src/charts/viz/vizTypes.d.ts +18 -0
- package/types/src/shapes/Shape.d.ts +2 -2
- package/types/src/shapes/hitAreaNode.d.ts +5 -4
- package/types/src/shapes/interactionPoints.d.ts +15 -0
- package/umd/d3plus-core.full.js +954 -275
- package/umd/d3plus-core.full.js.map +1 -1
- package/umd/d3plus-core.full.min.js +1285 -1099
- package/umd/d3plus-core.js +267 -39
- package/umd/d3plus-core.js.map +1 -1
- package/umd/d3plus-core.min.js +266 -170
package/umd/d3plus-core.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
@d3plus/core v4.
|
|
2
|
+
@d3plus/core v4.3.0
|
|
3
3
|
Data visualization made easy. A javascript library that extends the popular D3.js to enable fast and beautiful visualizations.
|
|
4
4
|
Copyright (c) 2026 D3plus - https://d3plus.org
|
|
5
5
|
@license MIT
|
|
@@ -147,12 +147,12 @@ e._legendDepth=0;for(let t=0;t<=e._drawDepth;t++){const i=c.map(e=>e[t]);if(!i.s
|
|
|
147
147
|
instance (compute mode — Legend contributes to the scene via its
|
|
148
148
|
`toScene()` collected on Viz.toScene), then returns the margin claim
|
|
149
149
|
derived from the previous render's outerBounds.
|
|
150
|
-
*/(e);return function(e,t,i){const{legendData:s,fill:a,getAttr:o}=t,r=(t,i)=>{let s=e._id(t,i);return Array.isArray(s)&&(s=s[0]),e._hidden.includes(s)||e._solo.length>0&&!e._solo.includes(s)},c=e._legendClass.outerBounds(),h=E(e),l=
|
|
150
|
+
*/(e);return function(e,t,i){const{legendData:s,fill:a,getAttr:o}=t,r=(t,i)=>{let s=e._id(t,i);return Array.isArray(s)&&(s=s[0]),e._hidden.includes(s)||e._solo.length>0&&!e._solo.includes(s)},c=e._legendClass.outerBounds(),h=E(e),l=X(e.schema.legendPosition.bind(e)(h)),d=["top","bottom"].includes(l),u=e.schema.legendPadding(e)?e._padding:{top:0,right:0,bottom:0,left:0},m={transform:`translate(${d?i.left+u.left:i.left}, ${d?i.top:i.top+u.top})`},f=!1!==l&&e.schema.legend.bind(e)(h,s),g=n.elem("g.d3plus-viz-legend",{condition:f&&!e.schema.legendConfig.select,enter:m,parent:e._select,duration:e.schema.duration,update:m}).node();e._legendClass.renderMode("compute").id(a).align(d?"center":l).direction(d?"row":"column").duration(e.schema.duration).data(f?s:[]).height(d?e.schema.height-(i.bottom+i.top):e.schema.height-(i.bottom+i.top+u.bottom+u.top)).locale(e.schema.locale).parent(e).select(g).shape((t,i)=>"Circle"===e.schema.shape(t,i)?"Circle":"Rect").verticalAlign(d?l:"middle").width(d?e.schema.width-(i.left+i.right+u.left+u.right):e.schema.width-(i.left+i.right)).shapeConfig(G.bind(e)(e.schema.shapeConfig,"legend")).shapeConfig({fill:(t,i)=>r(t,i)?e.schema.hiddenColor(t,i):o(t,i,"fill"),labelConfig:{fontOpacity:(t,i)=>r(t,i)?e.schema.hiddenOpacity(t,i):1}}).config(e.schema.legendConfig).render();
|
|
151
151
|
// Margin claim from the *previous* render's outerBounds:
|
|
152
152
|
// `outerBounds()` reads stored state, so on the first render the claim
|
|
153
153
|
// is zero and Legend overlaps the chart for one frame; the next render
|
|
154
154
|
// flows with full margin.
|
|
155
|
-
const p={};return!e.schema.legendConfig.select&&c.height&&(p[l]=d?c.height+2*e._legendClass.padding():c.width+2*e._legendClass.padding()),{panel:null,margin:p}}(e,a,i)}},
|
|
155
|
+
const p={};return!e.schema.legendConfig.select&&c.height&&(p[l]=d?c.height+2*e._legendClass.padding():c.width+2*e._legendClass.padding()),{panel:null,margin:p}}(e,a,i)}},V=new Set([!1,"top","right","bottom","left"]);
|
|
156
156
|
/**
|
|
157
157
|
Canonical sanitizer for `legendPosition` / `colorScalePosition`.
|
|
158
158
|
Falls back to `"bottom"` when the user-supplied accessor returns
|
|
@@ -160,7 +160,7 @@ const p={};return!e.schema.legendConfig.select&&c.height&&(p[l]=d?c.height+2*e._
|
|
|
160
160
|
`vizDrawPure` (for sanitized ctx publication) and by `legendFeature`
|
|
161
161
|
+ `colorScaleFeature` (for their internal positioning math).
|
|
162
162
|
*/
|
|
163
|
-
function
|
|
163
|
+
function X(e){return V.has(e)?e:"bottom"}
|
|
164
164
|
/**
|
|
165
165
|
Runs each feature's `layout` in order, accumulating margin claims so that
|
|
166
166
|
later features see the space already taken by earlier ones. The order of
|
|
@@ -242,7 +242,7 @@ u.on&&u.on.brush&&u.on.brush(e)}).on("end",t=>{!
|
|
|
242
242
|
Helper mirroring drawTimeline's `setTimeFilter`. Triggers a re-render when
|
|
243
243
|
the brush selection changes — kept here so the feature owns its event flow.
|
|
244
244
|
*/
|
|
245
|
-
function(e,t){if(Array.isArray(t)||(t=[t,t]),JSON.stringify(t)!==JSON.stringify(e._timelineSelection)){e._timelineSelection=t;const i=t.map(Number);e.timeFilter(t=>{const s=n.date(e.schema.time(t)).getTime();return s>=i[0]&&s<=i[1]}).render()}}(e,t),u.on&&u.on.end&&u.on.end(t)}).render(),{panel:null,margin:{bottom:l.outerBounds().height+2*l.padding()}}}},ie={name:"colorScale",configFields:["colorScale","colorScaleConfig","colorScaleMaxSize","colorScalePadding","colorScalePosition"],layout:({viz:e,layoutMargin:i})=>{const a=Array.from(t.rollup(e._data,t=>s.merge(t,e.schema.aggs),(t,i)=>`${e.schema.time?e.schema.time(t,i):"all"}-${e._ids(t,i).join("_")}`).values()),o=
|
|
245
|
+
function(e,t){if(Array.isArray(t)||(t=[t,t]),JSON.stringify(t)!==JSON.stringify(e._timelineSelection)){e._timelineSelection=t;const i=t.map(Number);e.timeFilter(t=>{const s=n.date(e.schema.time(t)).getTime();return s>=i[0]&&s<=i[1]}).render()}}(e,t),u.on&&u.on.end&&u.on.end(t)}).render(),{panel:null,margin:{bottom:l.outerBounds().height+2*l.padding()}}}},ie={name:"colorScale",configFields:["colorScale","colorScaleConfig","colorScaleMaxSize","colorScalePadding","colorScalePosition"],layout:({viz:e,layoutMargin:i})=>{const a=Array.from(t.rollup(e._data,t=>s.merge(t,e.schema.aggs),(t,i)=>`${e.schema.time?e.schema.time(t,i):"all"}-${e._ids(t,i).join("_")}`).values()),o=X(e.schema.colorScalePosition.bind(e)(E(e))),r=["top","bottom"].includes(o),c=e.schema.colorScale&&o,h=e.schema.colorScalePadding(e)?e._padding:{top:0,right:0,bottom:0,left:0},l=e.schema.width-(i.left+i.right+h.left+h.right),d=r?t.min([e.schema.colorScaleMaxSize,l]):e.schema.width-(i.left+i.right),u=e.schema.height-(i.bottom+i.top+h.bottom+h.top),m=r?e.schema.height-(i.bottom+i.top):t.min([e.schema.colorScaleMaxSize,u]),f={opacity:o?1:0,transform:`translate(${r?i.left+h.left+(l-d)/2:i.left}, ${r?i.top:i.top+h.top+(u-m)/2})`},g=n.elem("g.d3plus-viz-colorScale",{condition:c&&!e.schema.colorScaleConfig.select,enter:f,parent:e._select,duration:e.schema.duration,update:f}).node();if(!e.schema.colorScale)return{panel:null,margin:{}};const p=a.filter((t,i)=>{const s=e.schema.colorScale(t,i);return null!=s}),y=e.schema.colorScaleConfig||{},_=!y.bucketAxis&&["buckets","jenks","quantile"].includes("string"==typeof y.scale?y.scale:"");
|
|
246
246
|
// Discrete (bucket/jenks/quantile) colorScales render their swatches via an
|
|
247
247
|
// internal Legend, which composes cleanly through the Viz scene — so run
|
|
248
248
|
// them in compute mode (like the legend) so the Viz's toScene owns them and
|
|
@@ -707,7 +707,10 @@ function xe(e){const t=c.hsl(e);return Number.isNaN(t.l)?e:(t.s=0,`${t}`)}
|
|
|
707
707
|
graph, so this reapplies it here: darken the fill by `darken` for the stroke
|
|
708
708
|
and multiply the stroke width by `widthMult` (treating a 0/absent width as 1,
|
|
709
709
|
matching the shape defaults). Non-mark nodes (labels, groups) are untouched.
|
|
710
|
-
*/function ke(e,t,i){const s={...e.paint??{}};let n="string"==typeof s.fill?s.fill:void 0;
|
|
710
|
+
*/function ke(e,t,i){const s={...e.paint??{}};let n="string"==typeof s.fill?s.fill:void 0;
|
|
711
|
+
// No visible paint to emphasize (e.g. an invisible hit-area node): leave it
|
|
712
|
+
// untouched — darkening `transparent`/`none` would format to opaque black.
|
|
713
|
+
if(n&&"transparent"!==n&&"none"!==n||(n="string"==typeof s.stroke?s.stroke:void 0),!n||"transparent"===n||"none"===n)return e;const a=c.color(n);a&&(s.stroke=a.darker(t).formatHex());const o="number"==typeof s.strokeWidth&&s.strokeWidth?s.strokeWidth:1;return s.strokeWidth=o*i,{...e,paint:s}}
|
|
711
714
|
/**
|
|
712
715
|
Reads the interaction predicate + treatment off a viz, or null when nothing
|
|
713
716
|
is set. Precedence: transient `hover`, then `active`, then the standing
|
|
@@ -840,9 +843,10 @@ let n="Circle"===e.schema.shape?"function"==typeof e.schema.shapeConfig.r?e.sche
|
|
|
840
843
|
the swatch↔hit-area crossing) but a DISTINCT `key`: the hit-area and the
|
|
841
844
|
visible geometry are siblings, and the SVG keyed join can't hold two nodes
|
|
842
845
|
under one key — sharing it made the geometry re-enter (collapse→grow) on every
|
|
843
|
-
redraw (a "pulse" on e.g. every timeline step). Returns null when no
|
|
844
|
-
|
|
845
|
-
|
|
846
|
+
redraw (a "pulse" on e.g. every timeline step). Returns null when no hitArea
|
|
847
|
+
is configured. A path-style hitArea (Line: a fat, transparent stroke) reuses
|
|
848
|
+
the resolved geometry `d`/`transform` so the hover target overlaps the
|
|
849
|
+
visible line exactly while extending past its ~1px stroke.
|
|
846
850
|
*/
|
|
847
851
|
/** Follows the chart (`__d3plus__`) and shape (`__d3plusShape__`) wrappers back
|
|
848
852
|
to the source datum, so a `sort` comparator sees the same object the other
|
|
@@ -949,10 +953,10 @@ return Te({data:this._data,dataFilter:this._dataFilter?this._dataFilter.bind(thi
|
|
|
949
953
|
@param callback Optional callback invoked after rendering completes.
|
|
950
954
|
*/
|
|
951
955
|
/**
|
|
952
|
-
Resolves a style accessor
|
|
953
|
-
|
|
956
|
+
Resolves a style accessor. For a nested shape (Line/Area) the accessor gets
|
|
957
|
+
the merged aggregate `d.data`/`d.i` — matching `_nestWrapper` + scene datum.
|
|
954
958
|
@private
|
|
955
|
-
*/_styleVal(e,t,i){
|
|
959
|
+
*/_styleVal(e,t,i){return"function"!=typeof e?e:t.nested&&t.key&&t.values?e(t.data,t.i):e(t,i)}
|
|
956
960
|
/**
|
|
957
961
|
Builds the resolved Transform for a data point, mirroring _applyTransform.
|
|
958
962
|
@private
|
|
@@ -990,19 +994,34 @@ const i=this._getTextureKey(e,t);return{fill:i?`pattern:${i}`:Ne(this._styleVal(
|
|
|
990
994
|
// (Pie/Donut/Pack/Treemap/Network/Priestley/Radar/RadialMatrix/Geomap…).
|
|
991
995
|
// Standalone shape.render() consumers (no collectComputed wrapper) get
|
|
992
996
|
// labels through Shape.render's own SvgRenderer path below.
|
|
993
|
-
return e.forEach((e,n)=>{const a=this._sceneGeometry(e,n);if(!a)return;const o=this._nestWrapper(this.schema.id)(e,n),r=e.__d3plusShape__?e.data:e,c=this._sceneTransform(e,n)
|
|
997
|
+
return e.forEach((e,n)=>{const a=this._sceneGeometry(e,n);if(!a)return;const o=this._nestWrapper(this.schema.id)(e,n),r=e.__d3plusShape__?e.data:e,c=this._sceneTransform(e,n),h=
|
|
998
|
+
/**
|
|
999
|
+
For a nested shape datum (Line/Area, whose datum wraps many points) returns a
|
|
1000
|
+
spreadable scene-node fragment carrying each point's content-space position
|
|
1001
|
+
paired with its source datum, so the pointer bridge can report the point
|
|
1002
|
+
nearest the cursor rather than the whole-series aggregate. Points the
|
|
1003
|
+
`defined` accessor rejects, or whose position isn't finite (a missing value),
|
|
1004
|
+
are skipped — so the nearest match is always a real, defined point. Returns
|
|
1005
|
+
an empty object for non-nested data (spreads to nothing).
|
|
1006
|
+
*/
|
|
1007
|
+
function(e,t,i,s){if(!e.__d3plusShape__||!Array.isArray(e.values))return{};const n=e.values,a=[];return n.forEach((e,n)=>{if("function"==typeof s&&!1===s(e,n))return;const o=Number(t(e,n)),r=Number(i(e,n));Number.isFinite(o)&&Number.isFinite(r)&&a.push({x:o,y:r,datum:e,index:"number"==typeof e.i?e.i:n})}),a.length?{interactionPoints:a}:{}}(e,this.schema.x,this.schema.y,this.schema.defined);
|
|
994
1008
|
// Push the hit area (if any) before the geometry so it sits behind it.
|
|
995
|
-
|
|
1009
|
+
// Line's is a fat path built from the geometry `d`; Bar/legend etc. a rect.
|
|
1010
|
+
if(this.schema.hitArea){const i=function(e,t,i,s,n,a,o,r,c){const h="function"==typeof e?e(t,i,s):e;if(!h)return null;
|
|
1011
|
+
// Path-style hitArea (Line): widen the hover target to a fat transparent
|
|
1012
|
+
// stroke over the line's own geometry. `stroke: transparent` (not "none") is
|
|
1013
|
+
// painted, so it hit-tests across the full width on both backends.
|
|
1014
|
+
if("number"!=typeof h.width&&"string"==typeof c)return{type:"path",d:c,key:`${n}::hit`,datum:a,index:i,shapeType:o,paint:{fill:"none",stroke:"transparent",strokeWidth:"number"==typeof h["stroke-width"]?h["stroke-width"]:10,vectorEffect:"non-scaling-stroke"},transform:r,aria:{hidden:!0}};return"number"!=typeof h.width||"number"!=typeof h.height?null:{type:"rect",x:"number"==typeof h.x?h.x:-h.width/2,y:"number"==typeof h.y?h.y:-h.height/2,width:h.width,height:h.height,key:`${n}::hit`,datum:a,index:i,shapeType:o,paint:{fill:"transparent"},transform:r,aria:{hidden:!0}}}(this.schema.hitArea,e,n,this._aes(e,n),o,r,this._name,c,a.d);
|
|
996
1015
|
// Share the datum's rank so the hit area stays paired just behind its
|
|
997
1016
|
// own geometry (equal `z`, kept in push order by the stable sort).
|
|
998
|
-
i&&t.push(s?{...i,z:s[n]}:i)}t.push({...a,key:o,datum:r,index:n,shapeType:this._name,paint:this._scenePaint(e,n),transform:c,aria:{role:Ne(this._nestWrapper(this.schema.role)(e,n)),label:Ne(this._nestWrapper(this.schema.ariaLabel)(e,n))},...s?{z:s[n]}:{}});
|
|
1017
|
+
i&&t.push(s?{...i,...h,z:s[n]}:{...i,...h})}t.push({...a,key:o,datum:r,index:n,shapeType:this._name,paint:this._scenePaint(e,n),transform:c,aria:{role:Ne(this._nestWrapper(this.schema.role)(e,n)),label:Ne(this._nestWrapper(this.schema.ariaLabel)(e,n))},...h,...s?{z:s[n]}:{}});
|
|
999
1018
|
// backgroundImage: collect a per-datum image (see backgroundImageLayout for
|
|
1000
1019
|
// the cover/contain fit). The wrapping group carries the shape transform,
|
|
1001
1020
|
// so the image box + clip stay in local space.
|
|
1002
|
-
const
|
|
1021
|
+
const l=this._nestWrapper(this.schema.backgroundImage)(e,n);if(l){const t=a,s=Fe(t,"string"!=typeof t.d&&"number"!=typeof t.width&&"number"!=typeof t.r?this._aes(e,n).points??[]:[],"contain"===this._nestWrapper(this.schema.backgroundImageFit)(e,n)?"contain":"cover");
|
|
1003
1022
|
// Only Area/Line lack a `d`/box and need polygon points; Path/Rect/Circle
|
|
1004
1023
|
// derive their layout from `d`/width/r directly.
|
|
1005
|
-
s&&i.push({key:o,index:n,datum:r,url:
|
|
1024
|
+
s&&i.push({key:o,index:n,datum:r,url:l,box:s.box,clip:s.clip,preserveAspectRatio:s.preserveAspectRatio,opacity:We(this._nestWrapper(this.schema.opacity)(e,n)),transform:c})}}),
|
|
1006
1025
|
// Emit background images AFTER shape children so they paint above the
|
|
1007
1026
|
// shape's fill — matches the DOM order where the <image> was
|
|
1008
1027
|
// appended as a sibling of the shape.
|
|
@@ -1145,7 +1164,7 @@ _sceneGeometry(e,t){const i=this._getWidth(e,t),s=this._getHeight(e,t);return{ty
|
|
|
1145
1164
|
// Shape.labelConfig defaults so plotPaint's userConfig override
|
|
1146
1165
|
// path doesn't have to know about it.
|
|
1147
1166
|
Object.assign(this.schema.labelConfig,{textAnchor:"middle"}),this.schema.x=F("x"),this.schema.x0=F("x"),this.schema.x1=null,this.schema.y=L(0),this.schema.y0=L(0),this.schema.y1=F("y")}}
|
|
1148
|
-
/** Circle's own fluent accessor schema, layered on top of Shape's. */const
|
|
1167
|
+
/** Circle's own fluent accessor schema, layered on top of Shape's. */const Ve=[{key:"r",coerce:"accessor",default:F("r")},
|
|
1149
1168
|
// Motion-trail toggle: when true, the animate layer sweeps a tapering cone
|
|
1150
1169
|
// behind each point as it moves between frames (Timeline play), on both the
|
|
1151
1170
|
// SVG and Canvas backends.
|
|
@@ -1155,7 +1174,7 @@ Object.assign(this.schema.labelConfig,{textAnchor:"middle"}),this.schema.x=F("x"
|
|
|
1155
1174
|
// keeps a long slowly-fading tail. Requires `trail: true`. Setting it also
|
|
1156
1175
|
// makes the chart use a single-period timeline + fixed axes automatically
|
|
1157
1176
|
// (see vizPreDraw) — the conditions a persistent trail needs to stay coherent.
|
|
1158
|
-
{key:"trailPersist",coerce:"identity",default:0}];class
|
|
1177
|
+
{key:"trailPersist",coerce:"identity",default:0}];class Xe extends Ge{
|
|
1159
1178
|
/**
|
|
1160
1179
|
Provides the default positioning to the <rect> elements.
|
|
1161
1180
|
@private
|
|
@@ -1176,7 +1195,7 @@ _sceneGeometry(e,t){return{type:"circle",cx:0,cy:0,r:Number(this.schema.r(e,t)),
|
|
|
1176
1195
|
/**
|
|
1177
1196
|
Invoked when creating a new class instance, and overrides any default parameters inherited from Shape.
|
|
1178
1197
|
@private
|
|
1179
|
-
*/constructor(){super("circle"),re(this,
|
|
1198
|
+
*/constructor(){super("circle"),re(this,Ve),this._name="Circle",
|
|
1180
1199
|
// Bound the label to the full circle (diameter box) and tag it
|
|
1181
1200
|
// `shape: "circle"`, so the label TextBox flows text as circle chords —
|
|
1182
1201
|
// lines fill the interior, shorter near the top and bottom and full width
|
|
@@ -1237,7 +1256,7 @@ _dataFilter(e){const i=t.groups(e,this.schema.id).map(([i,n])=>{const a={key:i,v
|
|
|
1237
1256
|
@private
|
|
1238
1257
|
*/constructor(){super(),re(this,Qe),this._name="Line",this._path=P.line(),
|
|
1239
1258
|
// Line-specific overrides of inherited Shape defaults.
|
|
1240
|
-
this.schema.fill=L("none"),this.schema.stroke=L("black"),this.schema.strokeWidth=L(1),this.schema.hitArea=L({d:e=>this._path(e.values),fill:"none","stroke-width":10,transform:null})}}const et={Circle:
|
|
1259
|
+
this.schema.fill=L("none"),this.schema.stroke=L("black"),this.schema.strokeWidth=L(1),this.schema.hitArea=L({d:e=>this._path(e.values),fill:"none","stroke-width":10,transform:null})}}const et={Circle:Xe,Rect:Je},tt=[{key:"duration",coerce:"identity",default:600},{key:"endpoint",coerce:"const",default:F("endpoint","Rect")},{key:"length",coerce:"const",default:F("length",25)},{key:"orient",coerce:"const",default:F("orient","top")},{key:"renderMode",coerce:"identity",default:"full"},{key:"x",coerce:"const",default:F("x",0)},{key:"y",coerce:"const",default:F("y",0)}];
|
|
1241
1260
|
/** Whisker's fluent accessor schema. Config storage lives on `this.schema.<key>`. */class it extends j{
|
|
1242
1261
|
/**
|
|
1243
1262
|
Draws the whisker.
|
|
@@ -1268,7 +1287,7 @@ e&&setTimeout(e,this.schema.duration+100),this}
|
|
|
1268
1287
|
/**
|
|
1269
1288
|
Invoked when creating a new class instance, and overrides any default parameters inherited from BaseClass.
|
|
1270
1289
|
@private
|
|
1271
|
-
*/constructor(){super(),re(this,tt),this.schema.endpointConfig={Circle:{r:F("r",5)}},this.schema.lineConfig={},this._whiskerEndpoint=[]}}const st={Circle:
|
|
1290
|
+
*/constructor(){super(),re(this,tt),this.schema.endpointConfig={Circle:{r:F("r",5)}},this.schema.lineConfig={},this._whiskerEndpoint=[]}}const st={Circle:Xe,Rect:Je},nt=e=>"function"==typeof e?e:F(e),at=[{key:"orient",coerce:"const",default:F("orient","vertical")},{key:"outlier",coerce:"const",default:F("outlier","Circle")},{key:"rectWidth",coerce:"const",default:L(50)},{key:"renderMode",coerce:"identity",default:"full"},{key:"whiskerMode",coerce:e=>Array.isArray(e)?e:[e,e],default:["tukey","tukey"]},{key:"x",coerce:nt,default:F("x",250)},{key:"y",coerce:nt,default:F("y",250)}];
|
|
1272
1291
|
// Box's x/y setters wrap every non-function (including numbers) in
|
|
1273
1292
|
// `accessor(...)`, unlike the "accessor" coerce which would `constant(...)`
|
|
1274
1293
|
// a non-string — so a custom coerce preserves the exact behavior.
|
|
@@ -1363,7 +1382,7 @@ _sceneGeometry(e,t){return{type:"path",d:String(this.schema.d(e,t))}}
|
|
|
1363
1382
|
/**
|
|
1364
1383
|
Invoked when creating a new class instance, and overrides any default parameters inherited from Shape.
|
|
1365
1384
|
@private
|
|
1366
|
-
*/constructor(){super("path"),re(this,lt),this._name="Path",this.schema.labelBounds=(e,t,i)=>{const s=this.schema.labelConfig.rotate,n=p.largestRect(i.points,{angle:s?s(e,t):0});return!!n&&{angle:n.angle,width:n.width,height:n.height,x:n.cx-n.width/2,y:n.cy-n.height/2}},this.schema.labelConfig=Object.assign(this.schema.labelConfig,{textAnchor:"middle",verticalAlign:"middle"})}}var ut=Object.freeze({__proto__:null,Area:qe,Bar:Ke,Box:rt,Circle:
|
|
1385
|
+
*/constructor(){super("path"),re(this,lt),this._name="Path",this.schema.labelBounds=(e,t,i)=>{const s=this.schema.labelConfig.rotate,n=p.largestRect(i.points,{angle:s?s(e,t):0});return!!n&&{angle:n.angle,width:n.width,height:n.height,x:n.cx-n.width/2,y:n.cy-n.height/2}},this.schema.labelConfig=Object.assign(this.schema.labelConfig,{textAnchor:"middle",verticalAlign:"middle"})}}var ut=Object.freeze({__proto__:null,Area:qe,Bar:Ke,Box:rt,Circle:Xe,Image:ht,Line:Ze,Path:dt,Rect:Je,Shape:Ge,Whisker:it});
|
|
1367
1386
|
/* catches for -0 and less*/const mt=e=>e<0||Object.is(e,-0),ft=e=>Math.pow(10,Math.floor(Math.log10(Math.abs(e))))*Math.pow(-1,mt(e)?1:0),gt=e=>Math.pow(10,Math.ceil(Math.log10(Math.abs(e))))*Math.pow(-1,mt(e)?1:0),pt=e=>{const t=`${e}`;if(t.includes("e-")||"0"===t)return 0;const i=t.match(/(-*[0-9]+\.[0]*)([0-8]+)9{3,}[0-9]+$/);if(i)return+`${i[1]}${+i[2]+1}`;const s=t.match(/(-*[0-9]+\.[0]*)([1-9]+)0*[0-9]*0{3,}[0-9]+$/);return s?+`${s[1]}${+s[2]}`:e},yt=936e5;
|
|
1368
1387
|
/**
|
|
1369
1388
|
* Calculates ticks from a given scale (negative and/or positive)
|
|
@@ -2010,12 +2029,12 @@ const o=n.elem("rect.d3plus-Timeline-play-hit",{parent:i,condition:s.length>0});
|
|
|
2010
2029
|
// the scene itself at the end of render() so Axis.render() must not paint
|
|
2011
2030
|
// a half-built scene mid-way through.
|
|
2012
2031
|
this._managesOwnScenePaint=!0}}
|
|
2013
|
-
/** Tooltip's fluent accessor schema. Config storage lives on `this.schema.<key>`. */const
|
|
2032
|
+
/** Tooltip's fluent accessor schema. Config storage lives on `this.schema.<key>`. */const Vt=[{key:"arrow",coerce:"const",default:F("arrow","")},{key:"background",coerce:"const",default:L(u.colorDefaults.light)},{key:"body",coerce:"const",default:F("body","")},{key:"border",coerce:"const",default:L("1px solid rgba(0, 0, 0, 0.25)")},{key:"borderRadius",coerce:"const",default:L("4px")},{key:"className",coerce:"identity",default:"d3plus-tooltip"},{key:"footer",coerce:"const",default:F("footer","")},{key:"height",coerce:"const",default:L("auto")},{key:"id",coerce:"const",default:(e,t)=>`${t}`},{key:"offset",coerce:"const",default:L(5)},{key:"padding",coerce:"const",default:L("10px")},{key:"pointerEvents",coerce:"const",default:L("auto")},{key:"tbody",coerce:"identity",default:[]},{key:"thead",coerce:"identity",default:[]},{key:"title",coerce:"const",default:F("title","")},{key:"maxWidth",coerce:"const",default:L("300px")},{key:"minWidth",coerce:"const",default:L("200px")},{key:"width",coerce:"const",default:L("auto")}];
|
|
2014
2033
|
/**
|
|
2015
2034
|
* Creates a virtual reference element for Floating UI.
|
|
2016
2035
|
* @param {Number[]} position
|
|
2017
2036
|
* @private
|
|
2018
|
-
*/function
|
|
2037
|
+
*/function Xt(e=[0,0]){return{getBoundingClientRect:()=>({width:0,height:0,x:e[0],y:e[1],top:e[1],right:e[0],bottom:e[1],left:e[0]})}}
|
|
2019
2038
|
/**
|
|
2020
2039
|
* Positions a tooltip using Floating UI.
|
|
2021
2040
|
* @private
|
|
@@ -2066,7 +2085,7 @@ let t=e._portalEl??null;return t&&t.isConnected||(t=document.createElement("div"
|
|
|
2066
2085
|
Fetches table contents given functions or values.
|
|
2067
2086
|
@private
|
|
2068
2087
|
*/
|
|
2069
|
-
function(e){if("function"==typeof e){const s=i.select(this.parentNode.parentNode).datum();return e(s,t._data.indexOf(s),s)}return e}),Jt(this,o,r,"footer"),Jt(this,o,r,"arrow"),function(e,t,i,s){t.attr("id",(t,i)=>`d3plus-tooltip-${t?e.schema.id(t,i):""}`).style("visibility","hidden").call(t=>Qt(e,t)).each(function(t,i){const s=e.schema.id(t,i),n=document.getElementById(`d3plus-tooltip-${s}`),a=document.getElementById(`d3plus-tooltip-arrow-${s}`),o=a.offsetHeight,r=a.getBoundingClientRect().height/2;a.style.bottom=`-${o/2}px`;const c=e.schema.position(t,i),h=Array.isArray(c)?
|
|
2088
|
+
function(e){if("function"==typeof e){const s=i.select(this.parentNode.parentNode).datum();return e(s,t._data.indexOf(s),s)}return e}),Jt(this,o,r,"footer"),Jt(this,o,r,"arrow"),function(e,t,i,s){t.attr("id",(t,i)=>`d3plus-tooltip-${t?e.schema.id(t,i):""}`).style("visibility","hidden").call(t=>Qt(e,t)).each(function(t,i){const s=e.schema.id(t,i),n=document.getElementById(`d3plus-tooltip-${s}`),a=document.getElementById(`d3plus-tooltip-arrow-${s}`),o=a.offsetHeight,r=a.getBoundingClientRect().height/2;a.style.bottom=`-${o/2}px`;const c=e.schema.position(t,i),h=Array.isArray(c)?Xt(c):c;e._tooltipRefs[s]={reference:h,arrowEl:a,tooltip:n,arrowHeight:o,arrowDistance:r},Ut(h,n,a,e.schema.offset(t,i),r,o)}),i.each(function(t,i){const s=e.schema.id(t,i),n=e.schema.position(t,i),a=e._tooltipRefs[s];a&&(a.reference=Array.isArray(n)?Xt(n):n,Ut(a.reference,a.tooltip,a.arrowEl,e.schema.offset(t,i),a.arrowDistance,a.arrowHeight))}).call(t=>Qt(e,t)),s.exit().each(function(t,i){const s=e.schema.id(t,i);delete e._tooltipRefs[s]}).remove()}(this,o,r,a),e&&setTimeout(e,100),this}arrowStyle(e){return arguments.length?(this.schema.arrowStyle=n.assign(this.schema.arrowStyle,e),this):this.schema.arrowStyle}bodyStyle(e){return arguments.length?(this.schema.bodyStyle=n.assign(this.schema.bodyStyle,e),this):this.schema.bodyStyle}parent(e){if(!arguments.length)return this._parentEl;const t=this._parentEl,i=e||void 0;return t&&t!==i&&this._portalEl&&(
|
|
2070
2089
|
// Switching parents: tear down this Tooltip's own (body-level) portal
|
|
2071
2090
|
// so it doesn't sit orphaned. A re-render against the new parent
|
|
2072
2091
|
// creates a fresh one. Other Tooltip instances own their own portals.
|
|
@@ -2074,7 +2093,7 @@ this._portalEl.remove(),this._portalEl=void 0),this._parentEl=i,this}data(e){ret
|
|
|
2074
2093
|
/**
|
|
2075
2094
|
Invoked when creating a new class instance, and sets any default parameters.
|
|
2076
2095
|
@private
|
|
2077
|
-
*/constructor(){super(),re(this,
|
|
2096
|
+
*/constructor(){super(),re(this,Vt),this._data=[],this._tooltipRefs={},this.schema.arrowStyle={content:"",background:"inherit",border:"inherit","border-width":"0 1px 1px 0",height:"10px",position:"absolute",transform:"rotate(45deg)",width:"10px"},this.schema.bodyStyle={"font-size":"12px","font-weight":"400","z-index":"1"},this.schema.footerStyle={"font-size":"9px","font-weight":"400","margin-top":"5px","z-index":"1"},this.schema.position=e=>[e.x,e.y],this.schema.tableStyle={"border-collapse":"collapse","border-spacing":"0",width:"100%"},this.schema.tbodyStyle={"font-size":"12px","text-align":"center"},this.schema.theadStyle={"font-size":"12px","font-weight":"600","text-align":"center"},this.schema.titleStyle={"font-size":"14px","font-weight":"600","margin-bottom":"5px","text-align":"center"},this.schema.tooltipStyle={"box-shadow":"0 1px 5px rgba(0, 0, 0, 0.25)",color:(e,t)=>u.colorContrast(this.schema.background(e,t)),"font-family":r.fontFamilyStringify(r.fontFamily)},this.schema.trStyle={"border-top":(e,t)=>t?"1px solid rgba(0, 0, 0, 0.1)":"none"},this.schema.tdStyle={}}}
|
|
2078
2097
|
/**
|
|
2079
2098
|
Default label function for the legend. Bound to a Viz instance; forwards
|
|
2080
2099
|
to `viz._drawLabel` at the legend's group-depth.
|
|
@@ -2178,7 +2197,11 @@ const hi=[{key:"ariaHidden",coerce:"identity"},{key:"cache",coerce:"identity"},{
|
|
|
2178
2197
|
function li(e){e.schema.on={"click.shape":ti.bind(e),"click.legend":ii.bind(e),mouseenter:si.bind(e),mouseleave:ni.bind(e),"mousemove.shape":oi.bind(e),"mousemove.legend":ai.bind(e)},e._queue=[];
|
|
2179
2198
|
// Applies a detected container resize: re-sizes the SVG and re-renders when
|
|
2180
2199
|
// the observed size actually differs from what the chart last drew at.
|
|
2181
|
-
const t=t=>{const{width:i,height:s}=t[0].contentRect;(i!==e.schema.width&&e._autoWidth||s!==e.schema.height&&e._autoHeight)&&i&&s&&(e._setSVGSize(i,s),e._callback||e.render())},i=function(e,t){let i;return function(...s){const n=this;clearTimeout(i),i=setTimeout(()=>e.apply(n,s),t)}}(t,e.schema.detectResizeDelay);
|
|
2200
|
+
const t=t=>{const{width:i,height:s}=t[0].contentRect;(i!==e.schema.width&&e._autoWidth||s!==e.schema.height&&e._autoHeight)&&i&&s&&(e._setSVGSize(i,s),e._callback||e.render())},i=function(e,t){let i;return function(...s){const n=this;clearTimeout(i),i=setTimeout(()=>e.apply(n,s),t)}}(t,e.schema.detectResizeDelay);
|
|
2201
|
+
// Guarded so a chart can be constructed in an environment without a DOM (e.g.
|
|
2202
|
+
// before `@d3plus/ssr` installs one). Auto-resize is a browser-only feature;
|
|
2203
|
+
// when absent, `_resizeObserver` stays undefined and its call sites skip it.
|
|
2204
|
+
e._resizeObserver="undefined"==typeof ResizeObserver?void 0:new ResizeObserver(s=>{
|
|
2182
2205
|
// The first real-size notification after `observe()` reports the
|
|
2183
2206
|
// container's settled layout size, which on an auto-sized chart often
|
|
2184
2207
|
// differs from the size the chart just measured pre-layout (the
|
|
@@ -2404,7 +2427,7 @@ function(e){const i=e._data instanceof Array&&e._data.length>0?Object.keys(e._da
|
|
|
2404
2427
|
// Viz instance. Lifecycle (DOM setup, viewport detection, data
|
|
2405
2428
|
// loading, callback timing) stays on the class because it's
|
|
2406
2429
|
// inherently instance-bound.
|
|
2407
|
-
vi(e),!e._messageClass._isVisible||e.schema.noDataMessage&&!e._filteredData.length||(e._messageClass.hide(),"0"===e._select.attr("opacity")&&e._select.transition().duration(e.schema.duration).attr("opacity",1)),e.schema.detectResize&&(e._autoWidth||e._autoHeight)?e._resizeObserver
|
|
2430
|
+
vi(e),!e._messageClass._isVisible||e.schema.noDataMessage&&!e._filteredData.length||(e._messageClass.hide(),"0"===e._select.attr("opacity")&&e._select.transition().duration(e.schema.duration).attr("opacity",1)),e.schema.detectResize&&(e._autoWidth||e._autoHeight)?e._resizeObserver?.observe(e._select.node().parentNode):e._resizeObserver?.unobserve(e._select.node().parentNode),i&&setTimeout(()=>{i(),e._callback=void 0},e.schema.duration+100)}
|
|
2408
2431
|
/**
|
|
2409
2432
|
Loads any queued data (showing the loading message while in flight) then
|
|
2410
2433
|
draws the chart.
|
|
@@ -2450,7 +2473,10 @@ const n=e._select.selectAll("desc").data([0]),a=n.enter().append("desc").attr("i
|
|
|
2450
2473
|
Clears the visibility/resize/scroll poll timers and scroll listener so a
|
|
2451
2474
|
re-render doesn't stack duplicate timers.
|
|
2452
2475
|
@private
|
|
2453
|
-
*/(e,s),function(e){e._visiblePoll=clearInterval(e._visiblePoll),e._resizePoll=clearTimeout(e._resizePoll),e._scrollPoll=clearTimeout(e._scrollPoll),
|
|
2476
|
+
*/(e,s),function(e){e._visiblePoll=clearInterval(e._visiblePoll),e._resizePoll=clearTimeout(e._resizePoll),e._scrollPoll=clearTimeout(e._scrollPoll),
|
|
2477
|
+
// scrollContainer is "" when constructed without a window (headless/SSR);
|
|
2478
|
+
// there is nothing to unbind and select("") throws on an invalid selector.
|
|
2479
|
+
e.schema.scrollContainer&&i.select(e.schema.scrollContainer).on(`scroll.${e._uuid}`,null)}
|
|
2454
2480
|
/**
|
|
2455
2481
|
Installs the visibility/scroll detection that defers rendering until the
|
|
2456
2482
|
chart is on-screen. Returns true when a detection branch took ownership of
|
|
@@ -2470,7 +2496,7 @@ e._featurePanels=[],e._chartScene=[],e._chartTransform=void 0,e._shapes=[];
|
|
|
2470
2496
|
// can't drift. One frozen `resolveSpec` snapshot feeds both accessors:
|
|
2471
2497
|
// the position accessors take the resolved config as their argument, so
|
|
2472
2498
|
// a single snapshot reflects config once instead of twice.
|
|
2473
|
-
const s=E(e),n=
|
|
2499
|
+
const s=E(e),n=X(e.schema.legendPosition.bind(e)(s)),a=X(e.schema.colorScalePosition.bind(e)(s));i.legendPosition=n,i.colorScalePosition=a;
|
|
2474
2500
|
// `running` is the cross-call margin accumulator, threaded into each
|
|
2475
2501
|
// runLayout as its baseMargin so features read the live running total via
|
|
2476
2502
|
// ctx.layoutMargin (not viz._margin). Seeded from viz._margin so the math
|
|
@@ -2708,7 +2734,20 @@ for(const e of t)e&&"string"==typeof e.key&&e.key.toLowerCase().includes("back")
|
|
|
2708
2734
|
/**
|
|
2709
2735
|
Draws the visualization given the specified configuration.
|
|
2710
2736
|
@param callback Optional callback invoked after rendering completes.
|
|
2711
|
-
*/render(e){return zi(this,e)}
|
|
2737
|
+
*/render(e){return zi(this,e)}
|
|
2738
|
+
/**
|
|
2739
|
+
Serializes the most recently rendered output to an SVG string. Returns
|
|
2740
|
+
`""` if the chart has not been rendered yet. Both backends support this:
|
|
2741
|
+
the SVG backend returns its live `<svg>`, the canvas backend re-renders the
|
|
2742
|
+
retained scene through a throwaway SVG backend. Primarily used for
|
|
2743
|
+
server-side rendering (see `@d3plus/ssr`).
|
|
2744
|
+
*/toSVGString(){return this._sceneRenderer?.toSVGString?.()??""}
|
|
2745
|
+
/**
|
|
2746
|
+
Returns the underlying canvas element of the most recent render when the
|
|
2747
|
+
canvas backend is active (`renderer("canvas")`), or `undefined` otherwise.
|
|
2748
|
+
Server-side callers cast this to their native canvas to encode a raster
|
|
2749
|
+
(see `@d3plus/ssr`).
|
|
2750
|
+
*/toCanvas(){return"canvas"===this._renderer?this._sceneRenderer?.toCanvas?.():void 0}renderer(e){return arguments.length?(this._renderer="canvas"===e?"canvas":"svg",this):this._renderer}renderMode(e){return arguments.length?(this._renderMode=e,this):this._renderMode||"full"}
|
|
2712
2751
|
/**
|
|
2713
2752
|
Public entry point that renders this chart through the @d3plus/render
|
|
2714
2753
|
pluggable backends. The compute pass happens via render() (in an svg
|
|
@@ -2733,7 +2772,11 @@ const s=this._sceneTarget||i;if(!s)return;const a=function(e,t){return"canvas"==
|
|
|
2733
2772
|
// transition timers; without this, switching kind (svg<->canvas) or
|
|
2734
2773
|
// container orphans that DOM in the user's element, stacking the old
|
|
2735
2774
|
// mode's output behind the new one and accumulating on every switch.
|
|
2736
|
-
this._sceneRenderer&&"function"==typeof this._sceneRenderer.destroy&&this._sceneRenderer.destroy();const e="canvas"===t?o.CanvasRenderer:o.SvgRenderer;this._sceneRenderer=new e,
|
|
2775
|
+
this._sceneRenderer&&"function"==typeof this._sceneRenderer.destroy&&this._sceneRenderer.destroy();const e="canvas"===t?o.CanvasRenderer:o.SvgRenderer;this._sceneRenderer=new e,
|
|
2776
|
+
// `_scenePixelRatio`, when set (e.g. by @d3plus/ssr for hi-res PNG output),
|
|
2777
|
+
// fixes the canvas backing-store scale; otherwise the renderer falls back
|
|
2778
|
+
// to `devicePixelRatio`.
|
|
2779
|
+
this._sceneRenderer.mount({container:a,width:c,height:h,pixelRatio:this._scenePixelRatio}),
|
|
2737
2780
|
// Bridge renderer pointer events → viz.schema.on handlers. Without this,
|
|
2738
2781
|
// tooltips never fire on the v4 scene-rendered path because
|
|
2739
2782
|
// `shape.on(evt, fn)` in plotPaint only wires d3-selection
|
|
@@ -2787,6 +2830,16 @@ if(void 0!==f&&(this._trailSeq=f),this._sceneRenderer.drawScene(r,{duration:u,se
|
|
|
2787
2830
|
// native brush handles), so re-enable events on just that group. On the
|
|
2788
2831
|
// SVG backend `_select` IS the scene host, so events must stay enabled.
|
|
2789
2832
|
this._select&&(this._select.style("pointer-events","canvas"===t?"none":null),this._container&&this._container.style("pointer-events","canvas"===t?"none":null),"canvas"===t&&this._select.select("g.d3plus-viz-timeline").style("pointer-events","auto")),"svg"===t){const e=s&&"function"==typeof s.querySelector?s:null,t=e?e.querySelector(":scope > g.d3plus-viz-timeline"):null;t&&e.appendChild(t)}}
|
|
2833
|
+
/**
|
|
2834
|
+
Resolves the `(d, i, x)` a picked scene node reports to interaction
|
|
2835
|
+
handlers (tooltip, click, user `on` handlers). `pick.datum` is the raw
|
|
2836
|
+
scene datum; for a Plot shape that's the wrapped record `{data, i}`, which
|
|
2837
|
+
handlers expect unwrapped to `(d.data, d.i, wrapped)`. The base does that
|
|
2838
|
+
unwrap; Plot overrides this to report the point nearest the cursor for
|
|
2839
|
+
multi-point shapes (Line/Area) so a series tooltip reflects the hovered
|
|
2840
|
+
x rather than the whole-series aggregate.
|
|
2841
|
+
@private
|
|
2842
|
+
*/_interactionDatum(e,t){const i=e.datum;return{d:i&&i.data?i.data:i,i:i&&"number"==typeof i.i?i.i:e.index??0,x:i}}
|
|
2790
2843
|
/**
|
|
2791
2844
|
Routes a renderer pointer event to the matching `viz.schema.on` handlers.
|
|
2792
2845
|
Bridges the v4 scene-rendered path (SvgRenderer/CanvasRenderer), where
|
|
@@ -2828,16 +2881,16 @@ if("axis"===s.interactionGroup||"timeline"===s.interactionGroup)return;
|
|
|
2828
2881
|
// legend swatches route to legend handlers on Canvas too — where the
|
|
2829
2882
|
// single canvas element has no per-shape DOM to walk. Fall back to SVG
|
|
2830
2883
|
// DOM ancestry for nodes the stamp didn't reach.
|
|
2831
|
-
const n=e.nativeEvent&&e.nativeEvent.target,a="legend"===s.interactionGroup||!(!n||"function"!=typeof n.closest)&&!!n.closest('[data-key="viz-legend"]'),o=a?"legend":"shape",r=`${e.type}.${o}`,c
|
|
2884
|
+
const n=e.nativeEvent&&e.nativeEvent.target,a="legend"===s.interactionGroup||!(!n||"function"!=typeof n.closest)&&!!n.closest('[data-key="viz-legend"]'),o=a?"legend":"shape",r=`${e.type}.${o}`,{d:c,i:h,x:l}=this._interactionDatum(t,e),d="string"==typeof s.shapeType?s.shapeType:null;this._lastScenePick={d:c,i:h,x:l,isLegend:a,shapeType:d},this._hoverDatum=l,i(r,c,h,l),
|
|
2832
2885
|
// Shape-class-scoped handlers (`"click.Bar"`, `"mousemove.Circle"`). The
|
|
2833
2886
|
// emitting shape stamps its type onto the node; on the scene path this is
|
|
2834
2887
|
// the only place these fire (compute-mode shapes wire no DOM listeners).
|
|
2835
2888
|
// Legend nodes are excluded so a legend swatch's shape type can't
|
|
2836
2889
|
// masquerade as a chart-shape handler.
|
|
2837
|
-
!a&&d&&i(`${e.type}.${d}`,h,l
|
|
2890
|
+
!a&&d&&i(`${e.type}.${d}`,c,h,l),
|
|
2838
2891
|
// Also fire the un-suffixed handler (e.g. "mousemove") so user-registered
|
|
2839
2892
|
// global handlers see the event too.
|
|
2840
|
-
i(e.type,h,l
|
|
2893
|
+
i(e.type,c,h,l)}
|
|
2841
2894
|
/**
|
|
2842
2895
|
Coalesces interaction-driven scene repaints (hover/active dimming) into a
|
|
2843
2896
|
single paint per animation frame. A fast pointer sweep across a dense
|
|
@@ -2849,13 +2902,13 @@ i(e.type,h,l,c)}
|
|
|
2849
2902
|
*/_scheduleSceneRepaint(){this._sceneRenderer&&("function"==typeof requestAnimationFrame?null==this._sceneRepaintRAF&&(this._sceneRepaintRAF=requestAnimationFrame(()=>{this._sceneRepaintRAF=void 0,this._drawSceneToTarget(0)})):this._drawSceneToTarget(0))}
|
|
2850
2903
|
/**
|
|
2851
2904
|
Tears down the visualization: disconnects the ResizeObserver and removes DOM event listeners. Call this when unmounting to avoid memory leaks.
|
|
2852
|
-
*/destroy(){return this._resizeObserver
|
|
2905
|
+
*/destroy(){return this._resizeObserver?.disconnect(),this._tooltipClass.data([]).render(),i.select("body").on(`touchstart.${this._uuid}`,null),
|
|
2853
2906
|
// Clear the visibility/resize/scroll poll timers + scroll listener
|
|
2854
2907
|
// so a destroyed chart doesn't keep firing intervals/timeouts that
|
|
2855
2908
|
// hold the entire viz instance alive. Without this, an SPA that
|
|
2856
2909
|
// mounts/unmounts charts on tab switches leaks the scene tree +
|
|
2857
2910
|
// a 200ms-interval timer per leaked chart.
|
|
2858
|
-
this._visiblePoll&&(this._visiblePoll=clearInterval(this._visiblePoll)),this._resizePoll&&(this._resizePoll=clearTimeout(this._resizePoll)),this._scrollPoll&&(this._scrollPoll=clearTimeout(this._scrollPoll)),null!=this._sceneRepaintRAF&&("function"==typeof cancelAnimationFrame&&cancelAnimationFrame(this._sceneRepaintRAF),this._sceneRepaintRAF=void 0),i.select(this.schema.scrollContainer).on(`scroll.${this._uuid}`,null),
|
|
2911
|
+
this._visiblePoll&&(this._visiblePoll=clearInterval(this._visiblePoll)),this._resizePoll&&(this._resizePoll=clearTimeout(this._resizePoll)),this._scrollPoll&&(this._scrollPoll=clearTimeout(this._scrollPoll)),null!=this._sceneRepaintRAF&&("function"==typeof cancelAnimationFrame&&cancelAnimationFrame(this._sceneRepaintRAF),this._sceneRepaintRAF=void 0),this.schema.scrollContainer&&i.select(this.schema.scrollContainer).on(`scroll.${this._uuid}`,null),
|
|
2859
2912
|
// Destroy the active scene renderer (clears its own pointer-rect
|
|
2860
2913
|
// listeners, overlay host, canvas/svg DOM, timers).
|
|
2861
2914
|
this._sceneRenderer&&"function"==typeof this._sceneRenderer.destroy&&(this._sceneRenderer.destroy(),this._sceneRenderer=void 0),this}
|
|
@@ -2961,9 +3014,9 @@ const g=P.stack().keys(u).offset(e._stackOffset).order(Array.isArray(f)?P.stackO
|
|
|
2961
3014
|
/** Measures one line's label (width, position, overlap coords). */const qi=({viz:e,plotFormattedData:i,plotScales:s,plotConfigScales:a,plotTestAxes:o,plotLineLabelTest:r,y2Exists:c})=>{const h=i||[];if(!e.schema.lineLabels||c)return{plotLabelWidths:[],plotLargestLabel:void 0,plotXRangeMax:void 0};const l=h.filter(t=>"Line"===t.shape&&("function"!=typeof e.schema.lineLabels||e.schema.lineLabels(t.data,t.i))),d=t.groups(l,e=>e.id);if(!d.length)return{plotLabelWidths:[],plotLargestLabel:void 0,plotXRangeMax:void 0};const{testLineShape:u,testTextBox:m}=r,{xTest:f,yTest:g}=o,p=s.x.domain(),y=s.y.domain(),_=a.xConfigScale,x=a.yConfigScale,b=e.schema.width-e._margin.left-e._margin.right,k=Hi(e,"Line");u.config(k);const v=u.labelConfig(),C=void 0!==v.fontColor?v.fontColor:m.fontColor(),S=void 0!==v.fontSize?v.fontSize:m.fontSize(),w=void 0!==v.fontWeight?v.fontWeight:m.fontWeight(),z=void 0!==v.fontFamily?v.fontFamily:m.fontFamily(),D=void 0!==v.padding?v.padding:m.padding(),M={labelFunction:k.label||e._drawLabel,fontColorAccessor:C,fontSizeAccessor:S,fontWeightAccessor:w,fontFamilyAccessor:z,paddingAccessor:D,xEstimate:e=>("log"===_&&0===e&&(e=p[0]<0?f._d3Scale.domain()[1]:f._d3Scale.domain()[0]),f._getPosition.bind(f)(e)),yEstimate:e=>("log"===x&&0===e&&(e=y[0]<0?g._d3Scale.domain()[1]:g._d3Scale.domain()[0]),g._getPosition.bind(g)(e))},A=d.map(e=>function([e,i],s){const{labelFunction:a,fontColorAccessor:o,fontSizeAccessor:r,fontWeightAccessor:c,fontFamilyAccessor:h,paddingAccessor:l,xEstimate:d,yEstimate:u}=s;let m,f=i[i.length-1];for(;f.__d3plus__&&f.data;)f=f.data,m=f.i;const g="function"==typeof a?a(f,m):a,p="function"==typeof o?o(f,m):o,y="function"==typeof r?r(f,m):r,_="function"==typeof c?c(f,m):c;let x="function"==typeof h?h(f,m):h;Array.isArray(x)&&(x=x.map(e=>`'${e}'`).join(", "));const b="function"==typeof l?l(f,m):l,k=n.textWidth(g,{"font-size":y,"font-family":x,"font-weight":_}),v=i.map(e=>[d(e.x),u(e.y)]),C=t.max(i.map(e=>d(e.x))),S=i.find(e=>d(e.x)===C).y;return{id:e,labelWidth:k+2*b,spaceNeeded:k+4*b,value:S,yEstimate:u(S),padding:b,fontSize:y,fontColor:p,maxX:C,xValue:t.max(i,e=>e.x),coords:v}}(e,M)).sort((e,t)=>y[1]>y[0]?e.value-t.value:t.value-e.value).filter((e,t,i)=>{const{fontSize:s,id:n,labelWidth:a,maxX:o,yEstimate:r}=e;return 0===i.filter(e=>e.id!==n&&e.coords.some(t=>(t[0]>o||t[0]===o&&e.maxX!==o)&&t[0]<=o+a&&t[1]<=r+.75*s&&t[1]>=r-.75*s)).length}),$=t.max(A,e=>e.maxX),B=t.max(A.map(e=>e.labelWidth));
|
|
2962
3015
|
// Each accessor falls back from the Line shape's labelConfig to the test
|
|
2963
3016
|
// TextBox's getter; both yield a d3plus config value (constant or accessor).
|
|
2964
|
-
let P;const T=$===f._getRange.bind(f)()[1]?t.max(A.filter(e=>e.maxX===$),e=>e.spaceNeeded):0;if(T){P=b-t.min([T,b/4])-e._margin.right}return{plotLabelWidths:A,plotLargestLabel:B,plotXRangeMax:P}},Yi=B,Ki=({viz:e})=>{if(!e._filteredData||!e._filteredData.length)return{plotFormattedData:[],plotAxisData:[],x2Exists:!1,y2Exists:!1};const i=!!e.schema.time&&e.schema.time(e._filteredData[0],0),s=e._x2Time=i&&e._x2(e._filteredData[0],0)===i,a=e._xTime=i&&e._x(e._filteredData[0],0)===i,o=e._y2Time=i&&e._y2(e._filteredData[0],0)===i,r=e._yTime=i&&e._y(e._filteredData[0],0)===i,c=a||s||r||o,h=(t,i)=>`${!c&&e.schema.time?e.schema.time(t,i):"time"}_${e.schema.stacked?`${e.schema.groupBy.length>1?e._ids(t,i).slice(0,-1).join("_"):"group"}`:`${e._ids(t,i).join("_")}`}`,l=(t,i)=>{const c={__d3plus__:!0,data:t,group:h(t,i),i:i,hci:e._confidence&&e._confidence[1]&&e._confidence[1](t,i),id:e._ids(t,i).slice(0,e._drawDepth+1).join("_"),lci:e._confidence&&e._confidence[0]&&e._confidence[0](t,i),shape:e.schema.shape(t,i),x:a?n.date(e._x(t,i)):e._x(t,i),x2:s?n.date(e._x2(t,i)):e._x2(t,i),y:r?n.date(e._y(t,i)):e._y(t,i),y2:o?n.date(e._y2(t,i)):e._y2(t,i)};return c.discrete="Bar"===c.shape?`${c[e.schema.discrete]}_${c.group}`:`${c[e.schema.discrete]}`,c.id="Bar"===c.shape?`${c.id}_${c[e.schema.discrete]}`:c.id,c},d=e._formattedData=e._filteredData.map(l),u=e._axisPersist?e._data.map(l):d;if(e._size){const i=t.extent(u,t=>e._size(t.data));e._sizeScaleD3=Yi[`scale${e.schema.sizeScale.charAt(0).toUpperCase()}${e.schema.sizeScale.slice(1)}`]().domain(i).range([i[0]===i[1]?e.schema.sizeMax:t.min([e.schema.sizeMax/2,e.schema.sizeMin]),e.schema.sizeMax])}else e._sizeScaleD3=()=>e.schema.sizeMin;const m=u.some(e=>void 0!==e.x2),f=u.some(e=>void 0!==e.y2);return{plotFormattedData:d,plotAxisData:u,x2Exists:m,y2Exists:f,plotStackGroup:h}},
|
|
3017
|
+
let P;const T=$===f._getRange.bind(f)()[1]?t.max(A.filter(e=>e.maxX===$),e=>e.spaceNeeded):0;if(T){P=b-t.min([T,b/4])-e._margin.right}return{plotLabelWidths:A,plotLargestLabel:B,plotXRangeMax:P}},Yi=B,Ki=e=>null===e||"number"==typeof e&&!Number.isFinite(e)||Array.isArray(e)&&0===e.length,Vi=e=>!(Ki(e.x)||Ki(e.y)||void 0!==e.x2&&Ki(e.x2)||void 0!==e.y2&&Ki(e.y2)),Xi=({viz:e})=>{if(!e._filteredData||!e._filteredData.length)return{plotFormattedData:[],plotAxisData:[],x2Exists:!1,y2Exists:!1};const i=!!e.schema.time&&e.schema.time(e._filteredData[0],0),s=e._x2Time=i&&e._x2(e._filteredData[0],0)===i,a=e._xTime=i&&e._x(e._filteredData[0],0)===i,o=e._y2Time=i&&e._y2(e._filteredData[0],0)===i,r=e._yTime=i&&e._y(e._filteredData[0],0)===i,c=a||s||r||o,h=(t,i)=>`${!c&&e.schema.time?e.schema.time(t,i):"time"}_${e.schema.stacked?`${e.schema.groupBy.length>1?e._ids(t,i).slice(0,-1).join("_"):"group"}`:`${e._ids(t,i).join("_")}`}`,l=(t,i)=>{const c={__d3plus__:!0,data:t,group:h(t,i),i:i,hci:e._confidence&&e._confidence[1]&&e._confidence[1](t,i),id:e._ids(t,i).slice(0,e._drawDepth+1).join("_"),lci:e._confidence&&e._confidence[0]&&e._confidence[0](t,i),shape:e.schema.shape(t,i),x:a?n.date(e._x(t,i)):e._x(t,i),x2:s?n.date(e._x2(t,i)):e._x2(t,i),y:r?n.date(e._y(t,i)):e._y(t,i),y2:o?n.date(e._y2(t,i)):e._y2(t,i)};return c.discrete="Bar"===c.shape?`${c[e.schema.discrete]}_${c.group}`:`${c[e.schema.discrete]}`,c.id="Bar"===c.shape?`${c.id}_${c[e.schema.discrete]}`:c.id,c},d=e._formattedData=e._filteredData.map(l).filter(Vi),u=e._axisPersist?e._data.map(l).filter(Vi):d;if(e._size){const i=t.extent(u,t=>e._size(t.data));e._sizeScaleD3=Yi[`scale${e.schema.sizeScale.charAt(0).toUpperCase()}${e.schema.sizeScale.slice(1)}`]().domain(i).range([i[0]===i[1]?e.schema.sizeMax:t.min([e.schema.sizeMax/2,e.schema.sizeMin]),e.schema.sizeMax])}else e._sizeScaleD3=()=>e.schema.sizeMin;const m=u.some(e=>void 0!==e.x2),f=u.some(e=>void 0!==e.y2);return{plotFormattedData:d,plotAxisData:u,x2Exists:m,y2Exists:f,plotStackGroup:h}},Ui=({viz:e,plotFormattedData:i,plotAxisData:a})=>{const o=i||[],r=a||[];function c(i){const a=e[`_${i}Time`],c=a?o:r,h=c.filter(e=>![NaN,void 0,!1].includes(e[i]));if(!h.length)return[];const l="number"==typeof h[0][i];let d=e.schema.discrete===i?t.rollups(h,t=>1===t.length?t[0].data:s.merge(t.map(e=>e.data),e.schema.aggs),e=>e[i]).sort((t,s)=>{if(e.schema[`${i}Sort`])return e.schema[`${i}Sort`](t[1],s[1]);return(a||l?parseFloat(t[0]):t[0])-(a||l?parseFloat(s[0]):s[0])}).map(([e])=>a?n.date(e):l?parseFloat(e):e):s.unique(h.sort((t,s)=>e.schema[`${i}Sort`]?e.schema[`${i}Sort`](t.data,s.data):t[i]-s[i]).map(e=>e[i]),e=>`${e}`);return e.schema.discrete!==i.charAt(0)&&e._confidence&&(e._confidence[0]&&(d=d.concat(c.map(e=>e.lci))),e._confidence[1]&&(d=d.concat(c.map(e=>e.hci)))),d}return{xData:c("x"),x2Data:c("x2"),yData:c("y"),y2Data:c("y2")}},Ji=({viz:e,plotFormattedData:i,plotAxisData:s,plotScales:n,plotConfigScales:a})=>{const o=i||[],r=s||[];let{x:c,y:h,x2:l,y2:d}=n;const{xConfigScale:u,yConfigScale:m,x2ConfigScale:f,y2ConfigScale:g}=a,p=n.xScale,y=n.yScale;if("Point"!==("x"===e.schema.discrete?y:p)){t.groups(r,e=>e.shape).forEach(([t,i])=>{if(["Bar","Box"].includes(t)&&Li("x"===e.schema.discrete?c:h,o,e.schema.discrete),e._buffer[t]){const s=e._buffer[t].bind(e)({data:i,x:c,y:h,yScale:m,xScale:u,config:e.schema.shapeConfig[t]});c=s[0],h=s[1];const n=e._buffer[t].bind(e)({data:i,x:l,y:d,yScale:g,xScale:f,x2:!0,y2:!0,config:e.schema.shapeConfig[t]});l=n[0],d=n[1]}})}return{plotScales:{...n,x:c,y:h,x2:l,y2:d}}},Qi=({viz:e,plotAxisData:t,plotScales:i,x2Exists:n,y2Exists:a,x2Data:o,y2Data:r,yData:c})=>{const h=t||[],{x:l,y:d,x2:u,y2:m,xScale:f,yScale:g,x2Scale:p,y2Scale:y}=i,_=l.domain(),x=u.domain(),b=d.domain(),k=m.domain(),v={barConfig:{"stroke-width":0},gridSize:0,labels:[],title:!1,tickSize:0},C=n?{data:o}:v,S=a?{data:r}:v,w="x"===e.schema.discrete?e.schema.width>e._discreteCutoff&&e.schema.width>e.schema.xCutoff:e.schema.width>e.schema.xCutoff,z="y"===e.schema.discrete?e.schema.height>e._discreteCutoff&&e.schema.height>e.schema.yCutoff:e.schema.height>e.schema.yCutoff,D={data:c,locale:e.schema.locale,rounding:e.schema.yDomain?"none":"outside",scalePadding:d.padding?d.padding():0};!w&&z&&(D.barConfig={stroke:"transparent"},D.tickSize=0,D.shapeConfig={labelBounds:(t,i)=>{const{width:s,y:n}=t.labelBounds,a=e.schema.height/2;return{x:i?-a:0,y:n,width:s,height:a}},labelConfig:{padding:0,rotate:0},labelRotation:!1});
|
|
2965
3018
|
// Bar labels — used to suppress redundant axis ticks.
|
|
2966
|
-
const M=Hi(e,"Bar"),A=void 0!==M.label?"function"==typeof M.label?M.label:()=>M.label:e._drawLabel,$=h.map(e=>A(e.data,e.i)).filter(e=>"number"==typeof e||e).map(String),B=(e,t)=>{const i=s.unique(h.map(t=>t[e]));return"Point"===t&&i.every(e=>$.includes(`${e}`))?[]:null};return{plotDefaultConfig:v,plotDefaultX2Config:C,plotDefaultY2Config:S,plotShowX:w,plotShowY:z,plotYC:D,plotBarLabels:$,plotXTicks:B("x",f),plotX2Ticks:B("x2",p),plotYTicks:B("y",g),plotY2Ticks:B("y2",y),plotXDomain:_,plotX2Domain:x,plotYDomain:b,plotY2Domain:k}},
|
|
3019
|
+
const M=Hi(e,"Bar"),A=void 0!==M.label?"function"==typeof M.label?M.label:()=>M.label:e._drawLabel,$=h.map(e=>A(e.data,e.i)).filter(e=>"number"==typeof e||e).map(String),B=(e,t)=>{const i=s.unique(h.map(t=>t[e]));return"Point"===t&&i.every(e=>$.includes(`${e}`))?[]:null};return{plotDefaultConfig:v,plotDefaultX2Config:C,plotDefaultY2Config:S,plotShowX:w,plotShowY:z,plotYC:D,plotBarLabels:$,plotXTicks:B("x",f),plotX2Ticks:B("x2",p),plotYTicks:B("y",g),plotY2Ticks:B("y2",y),plotXDomain:_,plotX2Domain:x,plotYDomain:b,plotY2Domain:k}},Zi=({viz:e,plotFormattedData:i,plotAxisData:s,plotInitialDomains:n})=>{const a=i||[],o=s||[];let r=n;const c=e.schema.width-e._margin.left-e._margin.right,h=e.schema.height-e._margin.top-e._margin.bottom,l=e.schema.discrete?"x"===e.schema.discrete?"y":"x":void 0,d=e.schema.discrete?"x"===e.schema.discrete?"y2":"x2":void 0,u=[l,d].filter(e=>e);function m(t){const i=e[`_${t}Time`]?"Time":e.schema.discrete===t||e.schema[`${t}Sort`]?"Point":"Linear",s=e.schema[`${t}Domain`]?e.schema[`${t}Domain`].slice():r[t],n=e.schema[`${t}2Domain`]?e.schema[`${t}2Domain`].slice():r[`${t}2`];return"Point"!==i&&(s&&void 0===s[0]&&(s[0]=r[t][0]),s&&void 0===s[1]&&(s[1]=r[t][1]),n&&void 0===n[0]&&(n[0]=r[`${t}2`][0]),n&&void 0===n[1]&&(n[1]=r[`${t}2`][1])),[s,i,n,i]}const[f,g,p,y]=m("x"),[_,x,b,k]=m("y"),v=(i,s)=>{const n=e[`_${i}Config`].scale;if("auto"===n){if(e.schema.discrete===i)return s;const n=o.map(e=>e[i]);return t.deviation(n)/t.mean(n)>3?"log":"linear"}return n||s},C=v("y",x).toLowerCase(),S=v("y2",k).toLowerCase(),w=v("x",g).toLowerCase(),z=v("x2",y).toLowerCase();
|
|
2967
3020
|
// `.slice()` the fallback so domains.x2 isn't ALIASED to domains.x
|
|
2968
3021
|
// (and same for y2 ↔ y). Without the slice, later in this function
|
|
2969
3022
|
// the baseline-extension loop does `domains[o][0] = b` — when `o`
|
|
@@ -2973,7 +3026,7 @@ r={x:f,x2:p||f.slice(),y:_,y2:b||_.slice()},Object.keys(r).forEach(i=>{"log"===e
|
|
|
2973
3026
|
// `.slice()` first so we never mutate the user's config array in
|
|
2974
3027
|
// place — on the next render the (already-reversed) array would
|
|
2975
3028
|
// reverse back, alternating chart correctness across renders.
|
|
2976
|
-
const i=e[`_${t}Config`].domain.slice();"x"===e.schema.discrete&&i.reverse(),r[t]=i}else if(t&&void 0!==e.schema.baseline){const i=e.schema.baseline;r[t]&&r[t][0]>i?r[t][0]=i:r[t]&&r[t][1]<i&&(r[t][1]=i)}});const D=Yi[`scale${g}`]().domain(r.x).range(t.range(0,c+1,c/(r.x.length-1))),M=Yi[`scale${y}`]().domain(r.x2).range(t.range(0,c+1,c/(r.x2.length-1))),A=Yi[`scale${x}`]().domain(r.y.slice().reverse()).range(t.range(0,h+1,h/(r.y.length-1))),$=Yi[`scale${k}`]().domain(r.y2.slice().reverse()).range(t.range(0,h+1,h/(r.y2.length-1)));return{plotDomains:r,plotScales:{x:D,y:A,x2:M,y2:$,xScale:g,yScale:x,x2Scale:y,y2Scale:k},plotConfigScales:{xConfigScale:w,yConfigScale:C,x2ConfigScale:z,y2ConfigScale:S},plotOpps:{opp:l,opp2:d,opps:u}}},
|
|
3029
|
+
const i=e[`_${t}Config`].domain.slice();"x"===e.schema.discrete&&i.reverse(),r[t]=i}else if(t&&void 0!==e.schema.baseline){const i=e.schema.baseline;r[t]&&r[t][0]>i?r[t][0]=i:r[t]&&r[t][1]<i&&(r[t][1]=i)}});const D=Yi[`scale${g}`]().domain(r.x).range(t.range(0,c+1,c/(r.x.length-1))),M=Yi[`scale${y}`]().domain(r.x2).range(t.range(0,c+1,c/(r.x2.length-1))),A=Yi[`scale${x}`]().domain(r.y.slice().reverse()).range(t.range(0,h+1,h/(r.y.length-1))),$=Yi[`scale${k}`]().domain(r.y2.slice().reverse()).range(t.range(0,h+1,h/(r.y2.length-1)));return{plotDomains:r,plotScales:{x:D,y:A,x2:M,y2:$,xScale:g,yScale:x,x2Scale:y,y2Scale:k},plotConfigScales:{xConfigScale:w,yConfigScale:C,x2ConfigScale:z,y2ConfigScale:S},plotOpps:{opp:l,opp2:d,opps:u}}},es={defaults:{annotations:[],axisPersist:!1,barPadding:0,discreteCutoff:100,groupPadding:5,lineMarkers:!1,shape:L("Circle")}};
|
|
2977
3030
|
/** d3-scale's scale constructors, indexed by the dynamic `scale<Type>` name. */
|
|
2978
3031
|
/**
|
|
2979
3032
|
MEASURE half of the joint axis solve. Configures + measures the four
|
|
@@ -2984,7 +3037,7 @@ const i=e[`_${t}Config`].domain.slice();"x"===e.schema.discrete&&i.reverse(),r[t
|
|
|
2984
3037
|
`measureLineLabels` is invoked once, after the first x-axis measure and
|
|
2985
3038
|
before the re-measure, so its `xRangeMax` can re-bound the x range.
|
|
2986
3039
|
*/
|
|
2987
|
-
function
|
|
3040
|
+
function ts(e,i,s){const{yBounds:n,yWidth:a,y2Bounds:o,y2Width:r}=
|
|
2988
3041
|
/** Measure the y/y2 test axes and report their bounds + claimed widths. */function(e,t){const{yTest:i,y2Test:s,yDomain:n,y2Domain:a,yTicks:o,y2Ticks:r,yConfigScale:c,y2ConfigScale:h,defaultY2Config:l,yC:d,showY:u,y2Exists:m,height:f,width:g}=t;u&&i.domain(n).height(f).maxSize(g/2).range([void 0,void 0]).ticks(o).width(g).config(d).config(e._yConfig).scale(c).measure();const p=i.outerBounds(),y=p.width?p.width+i.padding():void 0;m&&s.domain(a).height(f).range([void 0,void 0]).ticks(r).width(g).config(d).config(l).config(e._y2Config).scale(h).measure();const _=s.outerBounds();return{yBounds:p,yWidth:y,y2Bounds:_,y2Width:_.width?_.width+s.padding():void 0}}
|
|
2989
3042
|
/** Build the shared x-axis config object, including the no-y-axis variant. */(e,i),c=function(e,t){const{xTicks:i,showX:s,showY:n,xData:a,xScalePadding:o}=t,r={data:a,locale:e.schema.locale,rounding:e.schema.xDomain?"none":"outside",scalePadding:o};return!n&&s&&(r.barConfig={stroke:"transparent"},r.tickSize=0,r.shapeConfig={labelBounds:(t,i)=>{const{height:s,y:n}=t.labelBounds,a=e.schema.width/2;return{x:i?-a:0,y:n,width:a,height:s}},labelConfig:{padding:0,rotate:0,textAnchor:e=>i&&e.id===i[0]?"start":"end"},labelRotation:!1}),r}
|
|
2990
3043
|
/**
|
|
@@ -3004,7 +3057,7 @@ function Zi(e,i,s){const{yBounds:n,yWidth:a,y2Bounds:o,y2Width:r}=
|
|
|
3004
3057
|
bumps the line labels, and queues axis scenes for the emit phase.
|
|
3005
3058
|
Returns everything `plotEmit` needs to consume.
|
|
3006
3059
|
*/
|
|
3007
|
-
function
|
|
3060
|
+
function is(e,i){let{x:s,y:n}=i;const{labelWidths:a}=i,{xHeight:o,x2Height:r,topOffset:c,height:h,horizontalMargin:l,verticalMargin:d}=i;let u=[r,h-(o+c+d)];const{yBounds:m,yWidth:f,y2Bounds:g,y2Width:p,xOffsetLeft:y,xOffsetRight:_}=function(e,i,s){const{yDomain:n,y2Domain:a,yConfigScale:o,y2ConfigScale:r}=i,{defaultY2Config:c,showY:h,y2Exists:l,yC:d}=i,{yTicks:u,x2TestRange:m,xTestRange:f,height:g,width:p}=i,{yTest:y,y2Test:_}=i;let{xOffsetRight:x}=i;h&&y.domain(n).height(g).maxSize(p/2).range(s).ticks(u).width(p).config(d).config(e._yConfig).scale(o).measure();const b=y.outerBounds(),k=b.width?b.width+y.padding():void 0,v=t.max([k,f[0],m[0]]);l&&_.config(d).domain(a).gridSize(0).height(g).range(s).width(p-t.max([0,x-i.y2Width])).title(!1).config(e._y2Config).config(c).scale(r).measure();const C=_.outerBounds(),S=C.width?C.width+_.padding():void 0;return x=t.max([0,S,p-f[1],p-m[1]]),{yBounds:b,yWidth:k,y2Bounds:C,y2Width:S,xOffsetLeft:v,xOffsetRight:x}}
|
|
3008
3061
|
/**
|
|
3009
3062
|
Set `viz._chartTransform` and derive the per-axis relative transform
|
|
3010
3063
|
helper used when absorbing axis scenes into `_chartScene`.
|
|
@@ -3043,25 +3096,25 @@ function(e,i,s){let n={};return i&&(t.groups(i,e=>e.xValue).forEach(([,i])=>{con
|
|
|
3043
3096
|
position. Returns the compute-mode scene nodes (empty when nothing was
|
|
3044
3097
|
bumped). Coords are relative to `_chartTransform`, which the chart-cells
|
|
3045
3098
|
group applies.
|
|
3046
|
-
*/(e,a,u);let C=e._xAxis.barConfig()["stroke-width"];return C&&(C/=2),{x:s,y:n,xRange:x,yRange:u,xOffsetLeft:y,xOffsetRight:_,yWidth:f,y2Width:p,yBounds:m,y2Bounds:g,axisSceneQueue:k,yOffset:C||0,labelPositions:v}}const
|
|
3099
|
+
*/(e,a,u);let C=e._xAxis.barConfig()["stroke-width"];return C&&(C/=2),{x:s,y:n,xRange:x,yRange:u,xOffsetLeft:y,xOffsetRight:_,yWidth:f,y2Width:p,yBounds:m,y2Bounds:g,axisSceneQueue:k,yOffset:C||0,labelPositions:v}}const ss=new Ze,ns=new Gt,as=(e,t)=>Oi.prototype._draw.call(e,t);function os(e,i){if(!e._filteredData.length&&!e._annotations?.length)
|
|
3047
3100
|
// Empty data: still run super._draw so the chart shell (title /
|
|
3048
3101
|
// legend / total / timeline / colorScale) refreshes — features
|
|
3049
3102
|
// tear down their DOM via .data([]) in their layout body, and
|
|
3050
3103
|
// vizDrawPure resets _chartScene/_featurePanels/_shapes. Without
|
|
3051
3104
|
// this, the previous render's chart shell (incl. aria-labels)
|
|
3052
3105
|
// lingers in the DOM and toScene() emits stale nodes.
|
|
3053
|
-
return
|
|
3106
|
+
return as(e,i),e;
|
|
3054
3107
|
// Throwaway measure-only axes. Allocated per draw, configured + measured
|
|
3055
3108
|
// below, then garbage-collected when the function returns. Plot no longer
|
|
3056
3109
|
// owns long-lived Axis instances just to compute layout. gridSize(0)
|
|
3057
3110
|
// signals "labels-only" measure: the production axes (`_xAxis`,
|
|
3058
3111
|
// `_yAxis`, …) handle grid rendering with their default gridSize.
|
|
3059
3112
|
const s=(new St).align("end").gridSize(0),n=(new Dt).align("start").gridSize(0),a=(new wt).align("start").gridSize(0),o=(new wt).align("end").gridSize(0),{data:r,axisData:c,x2Exists:h,y2Exists:l,xData:d,x2Data:u,yData:m,y2Data:f,stackGroup:g}=
|
|
3060
|
-
/** Runs format + per-axis-value stages; returns formatted data and axis-value bundles. */function(e){const t=he({viz:e},[
|
|
3113
|
+
/** Runs format + per-axis-value stages; returns formatted data and axis-value bundles. */function(e){const t=he({viz:e},[Xi,Ui]);
|
|
3061
3114
|
// Time flags (xTime/x2Time/yTime/y2Time) are written onto `viz` by
|
|
3062
3115
|
// `formatPlotData` and read directly via `viz._xTime` etc. downstream.
|
|
3063
3116
|
return{data:t.plotFormattedData,axisData:t.plotAxisData,x2Exists:t.x2Exists,y2Exists:t.y2Exists,xData:t.xData,x2Data:t.x2Data,yData:t.yData,y2Data:t.y2Data,stackGroup:t.plotStackGroup}}
|
|
3064
|
-
/** Runs domain + scale stages; returns domains, stack data, and scale bundles. */(e),p=e.schema.height-e._margin.top-e._margin.bottom,y=e.schema.discrete?"x"===e.schema.discrete?"y":"x":void 0,_=e.schema.width-e._margin.left-e._margin.right,x=function(e,t,i,s,n){const{xData:a,x2Data:o,yData:r,y2Data:c}=n,h=he({viz:e,plotFormattedData:t,plotAxisData:i,xData:a,x2Data:o,yData:r,y2Data:c,plotStackGroup:s},[Ii,
|
|
3117
|
+
/** Runs domain + scale stages; returns domains, stack data, and scale bundles. */(e),p=e.schema.height-e._margin.top-e._margin.bottom,y=e.schema.discrete?"x"===e.schema.discrete?"y":"x":void 0,_=e.schema.width-e._margin.left-e._margin.right,x=function(e,t,i,s,n){const{xData:a,x2Data:o,yData:r,y2Data:c}=n,h=he({viz:e,plotFormattedData:t,plotAxisData:i,xData:a,x2Data:o,yData:r,y2Data:c,plotStackGroup:s},[Ii,Zi]);
|
|
3065
3118
|
// Stacked/non-stacked domain construction + domain/scale setup are stages
|
|
3066
3119
|
// on `plotDef`. Run them together and read all the outputs the paint phase
|
|
3067
3120
|
// below needs.
|
|
@@ -3070,9 +3123,9 @@ return{plotInitialDomains:h.plotInitialDomains,plotDiscreteKeys:h.plotDiscreteKe
|
|
|
3070
3123
|
// Opposite-axis scale extension via buffers lives in the
|
|
3071
3124
|
// `extendPlotOppScales` stage. Reassigns x/y/x2/y2 from the stage's
|
|
3072
3125
|
// returned scales bundle.
|
|
3073
|
-
const a=he({viz:e,plotFormattedData:t,plotAxisData:i,plotScales:{...s.plotScales,...n},plotConfigScales:s.plotConfigScales},[
|
|
3074
|
-
/** Runs axis-layout prep; returns domains, default configs, show flags, ticks, and bar labels. */(e,r,c,x,{x:S,y:w,x2:z,y2:D}));const R=function(e,t,i,s,n,a){const{x2Exists:o,y2Exists:r}=n,{x2Data:c,y2Data:h,yData:l}=a,d=he({viz:e,plotAxisData:t,plotScales:{...i.plotScales,...s},x2Exists:o,y2Exists:r,x2Data:c,y2Data:h,yData:l},[
|
|
3075
|
-
/** Builds the line-label width measure callback for the four-axis margin solve. */(e,c,x,{x:S,y:w,x2:z,y2:D},{x2Exists:h,y2Exists:l},{x2Data:u,y2Data:f,yData:m}),L=R.plotXDomain,E=R.plotX2Domain,F=R.plotYDomain,W=R.plotY2Domain,N=R.plotDefaultConfig,H=R.plotDefaultX2Config,j=R.plotDefaultY2Config,G=R.plotShowX,I=R.plotShowY,q=R.plotYC,Y=R.plotXTicks,K=R.plotX2Ticks,
|
|
3126
|
+
const a=he({viz:e,plotFormattedData:t,plotAxisData:i,plotScales:{...s.plotScales,...n},plotConfigScales:s.plotConfigScales},[Ji]).plotScales;return{x:a.x,y:a.y,x2:a.x2,y2:a.y2}}
|
|
3127
|
+
/** Runs axis-layout prep; returns domains, default configs, show flags, ticks, and bar labels. */(e,r,c,x,{x:S,y:w,x2:z,y2:D}));const R=function(e,t,i,s,n,a){const{x2Exists:o,y2Exists:r}=n,{x2Data:c,y2Data:h,yData:l}=a,d=he({viz:e,plotAxisData:t,plotScales:{...i.plotScales,...s},x2Exists:o,y2Exists:r,x2Data:c,y2Data:h,yData:l},[Qi]);return{plotDefaultConfig:d.plotDefaultConfig,plotDefaultX2Config:d.plotDefaultX2Config,plotDefaultY2Config:d.plotDefaultY2Config,plotShowX:d.plotShowX,plotShowY:d.plotShowY,plotYC:d.plotYC,plotBarLabels:d.plotBarLabels,plotXTicks:d.plotXTicks,plotX2Ticks:d.plotX2Ticks,plotYTicks:d.plotYTicks,plotY2Ticks:d.plotY2Ticks,plotXDomain:d.plotXDomain,plotX2Domain:d.plotX2Domain,plotYDomain:d.plotYDomain,plotY2Domain:d.plotY2Domain}}
|
|
3128
|
+
/** Builds the line-label width measure callback for the four-axis margin solve. */(e,c,x,{x:S,y:w,x2:z,y2:D},{x2Exists:h,y2Exists:l},{x2Data:u,y2Data:f,yData:m}),L=R.plotXDomain,E=R.plotX2Domain,F=R.plotYDomain,W=R.plotY2Domain,N=R.plotDefaultConfig,H=R.plotDefaultX2Config,j=R.plotDefaultY2Config,G=R.plotShowX,I=R.plotShowY,q=R.plotYC,Y=R.plotXTicks,K=R.plotX2Ticks,V=R.plotYTicks,X=R.plotY2Ticks,U=R.plotBarLabels,J=e.schema.lineLabels&&!l,Q=function(e,t,i,s,n){const{xTest:a,yTest:o}=n;return()=>{const n=he({viz:e,plotFormattedData:t,plotScales:i.plotScales,plotConfigScales:i.plotConfigScales,plotTestAxes:{xTest:a,yTest:o},plotLineLabelTest:{testLineShape:ss,testTextBox:ns},y2Exists:s},[qi]);return{labelWidths:n.plotLabelWidths,largestLabel:n.plotLargestLabel,xRangeMax:n.plotXRangeMax}}}(e,r,x,l,{xTest:s,yTest:a}),{yBounds:Z,y2Bounds:ee,yWidth:te,y2Width:ie,xC:se,xRangeMax:ne,labelWidths:ae,largestLabel:oe,xTestRange:re,x2TestRange:ce,x2Height:le,xOffsetLeft:de,xOffsetRight:ue,topOffset:me,xHeight:fe}=ts(e,{xTest:s,yTest:a,x2Test:n,y2Test:o,xDomain:L,x2Domain:E,yDomain:F,y2Domain:W,xTicks:Y,x2Ticks:K,yTicks:V,y2Ticks:X,xConfigScale:$,x2ConfigScale:P,yConfigScale:B,y2ConfigScale:T,defaultX2Config:H,defaultY2Config:j,yC:q,showX:G,showY:I,x2Exists:h,y2Exists:l,height:p,width:_,xData:d,xScalePadding:S.padding?S.padding():0},Q);as(e,i);const ge={domains:b,shapeData:O,axisData:c,data:r,discreteKeys:k,stackData:v,stackKeys:C,x:S,y:w,x2:z,y2:D,xScale:M,yScale:A,xConfigScale:$,yConfigScale:B,x2ConfigScale:P,y2ConfigScale:T,xDomain:L,yDomain:F,x2Domain:E,y2Domain:W,xData:d,yData:m,x2Data:u,y2Data:f,x2Exists:h,y2Exists:l,showX:G,showY:I,defaultConfig:N,defaultX2Config:H,defaultY2Config:j,yC:q,xC:se,xTicks:Y,yTicks:V,x2Ticks:K,y2Ticks:X,labelWidths:ae,largestLabel:oe,xRangeMax:ne,xTest:s,yTest:a,x2Test:n,y2Test:o,yBounds:Z,y2Bounds:ee,yWidth:te,y2Width:ie,xHeight:fe,x2Height:le,xOffsetLeft:de,xOffsetRight:ue,topOffset:me,xTestRange:re,x2TestRange:ce,height:p,width:_,opp:y,barLabels:U,showLineLabels:J,stackGroup:g,horizontalMargin:e._margin.left+e._margin.right,verticalMargin:e._margin.top+e._margin.bottom};return e._paint(ge)}
|
|
3076
3129
|
/**
|
|
3077
3130
|
Plot label/size placement helpers. Both are invoked bound to a Plot
|
|
3078
3131
|
instance (`fn.bind(this)`), so they read the live axis scales +
|
|
@@ -3080,42 +3133,42 @@ const a=he({viz:e,plotFormattedData:t,plotAxisData:i,plotScales:{...s.plotScales
|
|
|
3080
3133
|
*/
|
|
3081
3134
|
/**
|
|
3082
3135
|
Default shape size, routed through the chart's internal sizeScale.
|
|
3083
|
-
*/function
|
|
3136
|
+
*/function rs(e){
|
|
3084
3137
|
// When `_size` is unset, `_sizeScaleD3` is the constant `() => sizeMin`,
|
|
3085
3138
|
// so the `null` argument is ignored (cast to satisfy the scale signature).
|
|
3086
3139
|
return this._sizeScaleD3(this._size?this._size(e):null)}
|
|
3087
3140
|
/**
|
|
3088
3141
|
Determines if a Bar label should be placed outside of the Bar.
|
|
3089
|
-
*/function
|
|
3142
|
+
*/function cs(e,t){
|
|
3090
3143
|
// Force all Stacked Bars to use "inside" labels.
|
|
3091
3144
|
if(this.schema.stacked)return!1;
|
|
3092
3145
|
// Detect user "outside" or "inside" override.
|
|
3093
3146
|
const i=this._labelPosition(e,t);if("outside"===i)return!0;
|
|
3094
3147
|
// Run "auto" logic based on available space, against the non-discrete axis.
|
|
3095
3148
|
if("inside"===i)return!1;const s="x"===this.schema.discrete.charAt(0)?"y":"x",n=this.schema.discrete.replace(this.schema.discrete.charAt(0),s),a="y"===n?this._yAxis:this._xAxis,o="y"===n?this._y:this._x,r=a._d3Scale.range(),c=o(e,t),h=c<0,l=a._getPosition(0),d="y"===n?h?r[1]-l:l-r[0]:h?l-r[0]:r[1]-l,u=a._getPosition(c);return Math.abs(h?l-u:u-l)<d/2}
|
|
3096
|
-
/** Builds the `Area` shape config; `self` is the Plot instance. */function
|
|
3097
|
-
/** Builds the top-level `ariaLabel` accessor; `self` is the Plot instance. */function
|
|
3149
|
+
/** Builds the `Area` shape config; `self` is the Plot instance. */function hs(e){return{label:(t,i)=>!!e.schema.stacked&&e._drawLabel(t,i),labelBounds:(e,i,s)=>{let n=p.largestRect(s.points,{angle:t.range(-20,20,5)});if((!n||n.height<20||n.width<50)&&(n=p.largestRect(s.points,{angle:t.range(-80,80,5)})),!n)return null;const a=t.min(s.points,e=>e[0]),o=t.max(s.points.filter(e=>e[0]===a),e=>e[1]);return{angle:n.angle,width:n.width,height:n.height,x:n.cx-n.width/2-a,y:n.cy-n.height/2-o}},labelConfig:{fontMin:6,fontResize:!0,padding:10}}}
|
|
3150
|
+
/** Builds the top-level `ariaLabel` accessor; `self` is the Plot instance. */function ls(e){return(t,i)=>{let s="";return t.nested?s=`${e._drawLabel(t.data,t.i)}`:(s=`${e._drawLabel(t,i)}`,void 0!==e._x(t,i)&&(s+=`, x: ${e._x(t,i)}`),void 0!==e._y(t,i)&&(s+=`, y: ${e._y(t,i)}`),void 0!==e._x2(t,i)&&(s+=`, x2: ${e._x2(t,i)}`),void 0!==e._y2(t,i)&&(s+=`, y2: ${e._y2(t,i)}`)),`${s}.`}}
|
|
3098
3151
|
/** Builds the `Bar.labelConfig` block (dynamic-`this` accessors preserved). */
|
|
3099
|
-
/** Builds the `Line` shape config; `self` is the Plot instance. */function
|
|
3152
|
+
/** Builds the `Line` shape config; `self` is the Plot instance. */function ds(e){return{curve:()=>e.schema.discrete?`monotone${e.schema.discrete.charAt(0).toUpperCase()}`:"linear",fill:L("none"),labelConfig:{fontColor:(t,i)=>{const s="function"==typeof e.schema.shapeConfig.Line.stroke?e.schema.shapeConfig.Line.stroke(t,i):e.schema.shapeConfig.Line.stroke;return u.colorLegible(s)},fontResize:!1,padding:5,textAnchor:"start",verticalAlign:"middle"},strokeWidth:L(2)}}function us(){return{Area:hs(this),ariaLabel:ls(this),Bar:{labelBounds(e,t,i){const s="y"===this.schema.discrete?"width":"height",n="y"===this.schema.discrete?"height":"width",a="x"===this.schema.discrete.charAt(0)?"y":"x",o="y"===a,r=this.schema.discrete.replace(this.schema.discrete.charAt(0),a),c=("y"===r?this._yAxis:this._xAxis)._d3Scale.range(),h=Math.abs(c[1]-c[0]),l=("y"===r?this._y:this._x)(e,t)<0;return cs.bind(this)(e,t)?{[s]:h-i[s],[n]:i[n],x:o?-i.width/2:l?-h:i.width+1,y:o?l?i.height+1:-h:-i.height/2+1}:{[s]:i[s],[n]:i[n],x:o?-i.width/2:l?(this.schema.stacked,1-i.width):-1,y:o?l?(this.schema.stacked,1):1-i.height:-i.height/2+1}},labelConfig:{fontMax:16,fontMin:6,fontResize:!0,fontColor(e,t){if(cs.bind(this)(e,t)){const e="transparent"===this._backgroundConfig.fill?n.backgroundColor(this._select.node()):this._backgroundConfig.fill;return u.colorContrast(e)}return u.colorContrast("function"==typeof this.schema.shapeConfig.fill?this.schema.shapeConfig.fill(e,t):this.schema.shapeConfig.fill)},fontStroke(e,t){if(cs.bind(this)(e,t)){const e="transparent"===this._backgroundConfig.fill?n.backgroundColor(this._select.node()):this._backgroundConfig.fill;return u.colorContrast(e)}return"transparent"},fontStrokeWidth(e,t){return cs.bind(this)(e,t)?.1:0},padding:3,textAnchor(e,t){const i="x"===this.schema.discrete.charAt(0)?"y":"x",s="y"===i,a=("y"===this.schema.discrete.replace(this.schema.discrete.charAt(0),i)?this._y:this._x)(e,t)<0,o=s?"middle":cs.bind(this)(e,t)?a?"end":"start":a?"start":"end";return n.rtl()?"start"===o?"end":"end"===o?"start":o:o},verticalAlign(e,t){const i="x"===this.schema.discrete.charAt(0)?"y":"x",s="y"===i,n=("y"===this.schema.discrete.replace(this.schema.discrete.charAt(0),i)?this._y:this._x)(e,t)<0;return s?cs.bind(this)(e,t)?n?"top":"bottom":n?"bottom":"top":"middle"}}},Circle:{r:rs.bind(this),
|
|
3100
3153
|
// Scatter/bubble points leave a motion trail when they move between
|
|
3101
3154
|
// frames (Timeline play). Only affects Circle/Rect marks, so Bar/Line/Area
|
|
3102
3155
|
// plots are unaffected; opt out per chart with shapeConfig.Circle.trail.
|
|
3103
|
-
trail:!0},Line:
|
|
3156
|
+
trail:!0},Line:ds(this),Rect:{height:e=>2*rs.bind(this)(e),width:e=>2*rs.bind(this)(e),
|
|
3104
3157
|
// Square scatter marks trail like Circle points do; the cone is sized to
|
|
3105
3158
|
// the square's silhouette perpendicular to travel (corner-to-corner at
|
|
3106
3159
|
// 45°). Opt out per chart with shapeConfig.Rect.trail: false.
|
|
3107
3160
|
trail:!0}}}
|
|
3108
|
-
/** Marks a comparator as an already-resolved d3plus stack order. */function
|
|
3161
|
+
/** Marks a comparator as an already-resolved d3plus stack order. */function ms(e){return e.__d3plusStackOrder=!0,e}
|
|
3109
3162
|
// @types/d3-shape types the order accessors' param as a single `Series`,
|
|
3110
3163
|
// though d3 passes the full stack array; this cast satisfies the signature.
|
|
3111
3164
|
/**
|
|
3112
3165
|
Sums a single stack series, ignoring non-numeric segments.
|
|
3113
3166
|
*/
|
|
3114
|
-
function
|
|
3167
|
+
function fs(e){let t,i=-1,s=0;const n=e.length;for(;++i<n;)(t=+e[i][1])&&(s+=t);return s}
|
|
3115
3168
|
/**
|
|
3116
3169
|
Stack order: series with the smallest summed value on the bottom of the
|
|
3117
3170
|
stack (matches d3's `stackOrderAscending`).
|
|
3118
|
-
*/const ms
|
|
3171
|
+
*/const gs=ms(e=>P.stackOrderAscending(e)),ps=ms(e=>P.stackOrderDescending(e)),ys=ms(e=>{const t=e.map(fs),i=e.map(e=>e.key.split("_")[0]);return P.stackOrderNone(e).sort((e,s)=>i[e].localeCompare(i[s])||t[e]-t[s])}),_s=ms(e=>ys(e).reverse());
|
|
3119
3172
|
/**
|
|
3120
3173
|
Stack order: series with the largest summed value on the bottom of the
|
|
3121
3174
|
stack (matches d3's `stackOrderDescending`). Plot's default.
|
|
@@ -3125,25 +3178,25 @@ function us(e){let t,i=-1,s=0;const n=e.length;for(;++i<n;)(t=+e[i][1])&&(s+=t);
|
|
|
3125
3178
|
data field, letting users order stacks by any value in their data rather
|
|
3126
3179
|
than only the plotted one. `value` receives each series' original datum.
|
|
3127
3180
|
*/
|
|
3128
|
-
function
|
|
3181
|
+
function xs(e,t="descending"){return ms(i=>{const s=i.map(t=>{let i=0;for(let s=0;s<t.length;s++){
|
|
3129
3182
|
// Each stacked point carries `.data` = the discrete group's rows;
|
|
3130
3183
|
// pick the row for this series and read the field off its datum.
|
|
3131
3184
|
const n=(t[s].data||[]).find(e=>e.id===t.key);if(n&&n.data){const t=+e(n.data);isNaN(t)||(i+=t)}}return i});return P.stackOrderNone(i).sort((e,i)=>"ascending"===t?s[e]-s[i]:s[i]-s[e])})}
|
|
3132
|
-
/** Named stack orders accepted by `Plot.stackOrder`. */const
|
|
3185
|
+
/** Named stack orders accepted by `Plot.stackOrder`. */const bs={ascending:gs,descending:ps,key:ys,keyReverse:_s,none:ms(e=>P.stackOrderNone(e)),data:ms(e=>P.stackOrderNone(e)),insideOut:ms(e=>P.stackOrderInsideOut(e)),appearance:ms(e=>P.stackOrderAppearance(e)),reverse:ms(e=>P.stackOrderReverse(e))},ks=Object.keys(bs);
|
|
3133
3186
|
/** The named orders accepted by `Plot.stackOrder`, for docs/validation. */
|
|
3134
3187
|
/**
|
|
3135
3188
|
Diverging stack offset: positive segments stack upward from zero,
|
|
3136
3189
|
negative segments stack downward.
|
|
3137
3190
|
*/
|
|
3138
|
-
function
|
|
3139
|
-
/** Named stack offsets accepted by `Plot.stackOffset`. */const
|
|
3191
|
+
function vs(e,t){let i,s,n,a,o,r;if(!((i=e.length)>0))return;const c=e[t[0]].length;for(let h=0;h<c;++h)for(r=o=0,a=0;a<i;++a)(n=(s=e[t[a]][h])[1]-s[0])>=0?(s[0]=r,s[1]=r+=n):n<0?(s[1]=o,s[0]=o+=n):s[0]=r}
|
|
3192
|
+
/** Named stack offsets accepted by `Plot.stackOffset`. */const Cs={diverging:vs,none:P.stackOffsetNone,expand:P.stackOffsetExpand,silhouette:P.stackOffsetSilhouette,wiggle:P.stackOffsetWiggle},Ss=Object.keys(Cs);
|
|
3140
3193
|
/** The named offsets accepted by `Plot.stackOffset`, for docs/validation. */
|
|
3141
3194
|
/**
|
|
3142
3195
|
Clone the base shape config and, for stacked Area/Bar, inject the
|
|
3143
3196
|
stacking-aware opp/opp0/opp1 accessors that read the precomputed
|
|
3144
3197
|
`stackData` cube.
|
|
3145
3198
|
*/
|
|
3146
|
-
function
|
|
3199
|
+
function ws(e,t){const{viz:i,opp:s,x:n,y:a,stackData:o,domains:r,stackKeyIndex:c,discreteKeyIndex:h}=e,l=Object.assign({},e.shapeConfig);
|
|
3147
3200
|
// Bubble plots: when a `size` accessor is set, default to layering circles
|
|
3148
3201
|
// largest-behind so smaller marks stay visible under bigger ones. This is a
|
|
3149
3202
|
// default — `finishShape` applies the user's `shapeConfig` afterwards, so an
|
|
@@ -3152,10 +3205,13 @@ if("Circle"===t&&i._size){const e=i._size;l.sort=(t,i)=>(Number(e(i))||0)-(Numbe
|
|
|
3152
3205
|
/**
|
|
3153
3206
|
Shared tail: wire shape events, apply the user's shapeConfig, render in
|
|
3154
3207
|
compute mode, and collect the resulting scene nodes.
|
|
3155
|
-
*/function
|
|
3156
|
-
/** Generic path — every shape key without a dedicated emitter (incl. stacked Area). */const
|
|
3208
|
+
*/function zs(e,t,i){const{viz:s,events:n}=e;s._wirePlotShapeEvents(i,t,n);const a=Hi(s,t);return void 0===s.schema.shapeConfig.duration&&delete a.duration,i.config(a).render(),ji(i)}
|
|
3209
|
+
/** Generic path — every shape key without a dedicated emitter (incl. stacked Area). */const Ds=(e,t)=>zs(e,t,Fi(t).renderMode("compute").config(ws(e,t)).data(e.values)),Ms={Bar:e=>{const{viz:i,x:s,y:n,xScale:a,yScale:o,xDomain:r,yDomain:c,xRange:h,yRange:l,values:d}=e,u=Fi("Bar").renderMode("compute").config(ws(e,"Bar")).data(d);let m;const f="x"===i.schema.discrete?s:n,g="x"===i.schema.discrete?a:o,p="x"===i.schema.discrete?r:c,y="x"===i.schema.discrete?h:l;if("Point"!==g&&2===p.length){const e=Array.from(new Set(d.map(e=>f(e[i.schema.discrete]))));e.unshift(y[0]-e[0]-y[0]),e.push(y[1]+y[1]-e[e.length-1]),m=e.reduce((e,t,i,s)=>{if(i){const n=Math.abs(t-s[i-1]);n<e&&(e=n)}return e},1/0)}else m=p.length>1?f(p[1])-f(p[0]):y[y.length-1]-y[0];i._groupPadding<m&&(m-=i._groupPadding);let _=m||1;const x=t.groups(d,e=>e[i.schema.discrete],e=>e.group),b=t.merge(x.map(([,e])=>e.map(([e])=>e))),k=Array.from(new Set(b)),v=i.schema.discrete,C=e.shapeConfig[v];if(1===t.max(x.map(([,e])=>e.length)))u[v]((e,t)=>C(e,t));else{_=(_-i.schema.barPadding*k.length-1)/k.length;const e=m/2-_/2,t=B.scaleLinear().domain([0,k.length-1]).range([-e,e]);u[v]((e,i)=>C(e,i)+t(k.indexOf(e.group)))}return u.width(_),u.height(_),zs(e,"Bar",u)},Line:e=>{const{viz:t,x:i,y:s,values:a,width:o,showLineLabels:r,labelWidths:c,largestLabel:h,labelPositions:l}=e,d=[],u=Fi("Line").renderMode("compute").config(ws(e,"Line")).data(a);if(u.duration(1.5*o),t._confidence){const o=t._confidence,r=Object.assign({},e.shapeConfig),c=t.schema.discrete||"x",h="x"===c?"y":"x",l="x"===c?s:i;r[`${h}0`]=e=>l(o[0]?e.lci:e[h]),r[`${h}1`]=e=>l(o[1]?e.hci:e[h]);const u=Fi("Area").renderMode("compute").config(r).data(a),m=Object.assign({},t.schema.shapeConfig,t._confidenceConfig);
|
|
3210
|
+
// Fresh object — must NOT mutate the shared `shapeConfig`, or the confidence
|
|
3211
|
+
// fill/fillOpacity leak onto every other shape and every later render.
|
|
3212
|
+
u.config(n.assign(Hi(t,"Line",m),Hi(t,"Area",m))).render(),d.push(...ji(u))}u.config({discrete:e.shapeConfig.discrete||"x",label:!!r&&((e,i)=>{if(!("function"!=typeof t.schema.lineLabels||t.schema.lineLabels(e.data,e.i)))return!1;const s=c.find(t=>t.id===e.id);if(s){const n=s.newY||s.defaultY,a=c.filter(e=>e.newY===n);return a.length>1?a[0].id===e.id&&`+${m.formatAbbreviate(a.length,t.schema.locale)} ${t.schema.translate("more")}`:t._drawLabel(e,i)}return!1}),labelBounds:!!r&&((e,i,s)=>{const[n,a]=s.points[0],[o,r]=s.points[s.points.length-1],c=t.schema.height/4;return{x:o-n,y:r-a-c/2-(l[e.id]?r-l[e.id]:0),width:h,height:c}})}),d.push(...zs(e,"Line",u));const f=Fi("Circle").renderMode("compute").data(t._lineMarkers?a:[]).config(e.shapeConfig).config(t._lineMarkerConfig).id(e=>`${e.id}_${e.discrete}`);return t._wirePlotShapeEvents(f,"Circle",e.events),f.render(),d.push(...ji(f)),d}};
|
|
3157
3213
|
/** Bar — discrete-axis spacing + multi-series grouping offsets. */
|
|
3158
|
-
/** Dispatch a shape group to its emitter (falling back to the generic path). */function
|
|
3214
|
+
/** Dispatch a shape group to its emitter (falling back to the generic path). */function As(e,t){return(Ms[t]??Ds)(e,t)}
|
|
3159
3215
|
/**
|
|
3160
3216
|
Emits the background Rect into `out` (prepended) when a non-transparent
|
|
3161
3217
|
`backgroundConfig.fill` is set; no-op otherwise.
|
|
@@ -3171,7 +3227,7 @@ if("Circle"===t&&i._size){const e=i._size;l.sort=(t,i)=>(Number(e(i))||0)-(Numbe
|
|
|
3171
3227
|
match old→new by id frame-to-frame and TWEEN instead of exit/entering. The
|
|
3172
3228
|
subtree is marked inert (annotations never show tooltips).
|
|
3173
3229
|
*/
|
|
3174
|
-
function
|
|
3230
|
+
function $s(e,t){const i=[];try{const t=e.toScene();t&&Array.isArray(t.children)&&t.children.length&&i.push(t);const s=e._labelClass;if(s&&"function"==typeof s.toScene){const e=s.toScene();e&&Array.isArray(e.children)&&e.children.length&&i.push(e)}}catch{return null}if(!i.length)return null;const s={type:"group",key:t,children:i};
|
|
3175
3231
|
/**
|
|
3176
3232
|
Annotations are decorative chrome, not data marks. Stamp their scene nodes
|
|
3177
3233
|
`interactive: false` so the renderer's hit-test skips them: they fire no
|
|
@@ -3182,13 +3238,13 @@ return function(e){const t=e=>{e.interactive=!1;const i=e.children;if(i)for(cons
|
|
|
3182
3238
|
/**
|
|
3183
3239
|
Renders back/front annotations, pushing back-layer scenes onto `out` and
|
|
3184
3240
|
returning the front-layer shape instances for later absorption.
|
|
3185
|
-
*/function
|
|
3241
|
+
*/function Bs(e,t,i,s,n,a){
|
|
3186
3242
|
// Annotations run in `renderMode("compute")` and their scenes are
|
|
3187
3243
|
// absorbed into `_chartScene`. Layering: "back" annotations absorb here
|
|
3188
3244
|
// (before the main shape loop below); "front" annotations queue and
|
|
3189
3245
|
// absorb AFTER the shape loop, giving back → shapes → front.
|
|
3190
|
-
const o=[];return Object.keys(e._previousAnnotations).forEach(r=>{const c=e._annotations.filter(e=>"back"===r&&!e.layer||e.layer===r),h=c.map(e=>e.shape);c.forEach((c,h)=>{const l=(t=>{const o=Fi(t.shape).renderMode("compute").duration(e.schema.duration).config(t).config({x:e=>e.x2?i(e.x2,"x2"):i(e.x),x0:"x"===e.schema.discrete?e=>e.x2?i(e.x2,"x2"):i(e.x):i(n.x[0]),x1:"x"===e.schema.discrete?null:e=>e.x2?i(e.x2,"x2"):i(e.x),y:e=>e.y2?s(e.y2,"y2"):s(e.y),y0:"y"===e.schema.discrete?e=>e.y2?s(e.y2,"y2"):s(e.y):s(n.y[1])-a,y1:"y"===e.schema.discrete?null:e=>e.y2?s(e.y2,"y2"):s(e.y)-a});return o.render(),o})(c);if("front"===r)o.push(l);else{const e
|
|
3191
|
-
/** Builds the per-shape `shapeConfig` object shared across the shape loop. */const
|
|
3246
|
+
const o=[];return Object.keys(e._previousAnnotations).forEach(r=>{const c=e._annotations.filter(e=>"back"===r&&!e.layer||e.layer===r),h=c.map(e=>e.shape);c.forEach((c,h)=>{const l=(t=>{const o=Fi(t.shape).renderMode("compute").duration(e.schema.duration).config(t).config({x:e=>e.x2?i(e.x2,"x2"):i(e.x),x0:"x"===e.schema.discrete?e=>e.x2?i(e.x2,"x2"):i(e.x):i(n.x[0]),x1:"x"===e.schema.discrete?null:e=>e.x2?i(e.x2,"x2"):i(e.x),y:e=>e.y2?s(e.y2,"y2"):s(e.y),y0:"y"===e.schema.discrete?e=>e.y2?s(e.y2,"y2"):s(e.y):s(n.y[1])-a,y1:"y"===e.schema.discrete?null:e=>e.y2?s(e.y2,"y2"):s(e.y)-a});return o.render(),o})(c);if("front"===r)o.push(l);else{const e=$s(l,`annotation-${r}-${h}`);e&&t.push(e)}});e._previousAnnotations[r].filter(e=>!h.includes(e)).forEach(e=>{Fi(e).renderMode("compute").data([]).render()}),e._previousAnnotations[r]=h}),o}
|
|
3247
|
+
/** Builds the per-shape `shapeConfig` object shared across the shape loop. */const Ps=e=>"string"==typeof e.key&&e.key.startsWith("grid-"),Ts=e=>{e.interactionGroup="axis";const t=e.children;if(t)for(const e of t)Ts(e)};
|
|
3192
3248
|
/**
|
|
3193
3249
|
Stamps `interactionGroup: "axis"` onto an axis scene subtree so the pointer
|
|
3194
3250
|
bridge can skip shape tooltips on axis ticks, and so the hover/active
|
|
@@ -3202,7 +3258,7 @@ const o=[];return Object.keys(e._previousAnnotations).forEach(r=>{const c=e._ann
|
|
|
3202
3258
|
Returns the flat `SceneNode[]` array that the caller (`Plot._paint`)
|
|
3203
3259
|
merges into `_chartScene`.
|
|
3204
3260
|
*/
|
|
3205
|
-
function
|
|
3261
|
+
function Os(e,t,i){const s=[],{shapeData:a,domains:o}=t,{labelWidths:r}=t,{x:c,y:h,xRange:l,yRange:d,yOffset:u,axisSceneQueue:m}=i,f=
|
|
3206
3262
|
/**
|
|
3207
3263
|
Drains the deferred axis-scene queue, splitting each axis into its
|
|
3208
3264
|
gridline children (rendered behind the data shapes) and everything else
|
|
@@ -3211,7 +3267,7 @@ function Ps(e,t,i){const s=[],{shapeData:a,domains:o}=t,{labelWidths:r}=t,{x:c,y
|
|
|
3211
3267
|
group's `_chartTransform` composes with this to land at the right
|
|
3212
3268
|
absolute position.
|
|
3213
3269
|
*/
|
|
3214
|
-
function(e){const t=[],i=[];return e.forEach(({key:e,transform:s,axis:n})=>{if(!n||"function"!=typeof n.toScene)return;const a=n.toScene();if(!a)return;const o=a.children||[],r=o.filter(
|
|
3270
|
+
function(e){const t=[],i=[];return e.forEach(({key:e,transform:s,axis:n})=>{if(!n||"function"!=typeof n.toScene)return;const a=n.toScene();if(!a)return;const o=a.children||[],r=o.filter(Ps),c=o.filter(e=>!Ps(e));if(r.length){const i={type:"group",key:`${e}-grid`,transform:s,children:r};Ts(i),t.push(i)}if(c.length){const t={type:"group",key:e,transform:s,children:c};Ts(t),i.push(t)}}),{grid:t,rest:i}}(m);!function(e,t,i,s){
|
|
3215
3271
|
// Background Rect: skip rendering when transparent (the default) — under
|
|
3216
3272
|
// the scene path it would emit a 5th `rect.d3plus-render-rect` that
|
|
3217
3273
|
// confuses bar-counting tests. When a user customizes
|
|
@@ -3231,8 +3287,8 @@ const a=Fi("Rect").renderMode("compute").data([{}]).x(i[0]-e._margin.left+(i[1]-
|
|
|
3231
3287
|
// shape scene, so the prepend is a few entries at most.
|
|
3232
3288
|
const o=ji(a);t.unshift(...o)}}(e,s,l,d),
|
|
3233
3289
|
// Gridlines sit just above the background, behind the data shapes.
|
|
3234
|
-
s.push(...f.grid),s.push(...function(e,t){const i=t.filter(e=>void 0!==e.newY);if(!i.length)return[];const s=i.map(t=>n.assign({x:e._xAxis._getPosition.bind(e._xAxis)(t.xValue),y:t.defaultY},t)).concat(i.map(t=>n.assign({x:e._xAxis._getPosition.bind(e._xAxis)(t.xValue)+t.padding-1,y:t.newY||t.defaultY},t))),a=Fi("Line").config({data:s,stroke:e=>e.fontColor,x:e=>e.x,y:e=>e.y}).config(e._labelConnectorConfig).renderMode("compute");return a.render(),ji(a)}(e,r));const g=
|
|
3235
|
-
/** Runs the main shape loop, pushing each shape's scene nodes onto `out`. */(e,c,h,o,u);return function(e,t,i,s,n){const{shapeData:a,domains:o,discreteKeys:r,stackData:c,stackKeys:h,xDomain:l,yDomain:d}=i,{xScale:u,yScale:m}=i,{labelWidths:f,largestLabel:g}=i,{width:p}=i,{opp:y,showLineLabels:_}=i,{x:x,y:b,xRange:k,yRange:v,labelPositions:C}=s,S=Object.keys(e.schema.on),w=new Map;for(let e=0;e<h.length;e++)w.set(h[e],e);const z=new Map;for(let e=0;e<r.length;e++)z.set(r[e],e);const D={viz:e,shapeConfig:n,events:S,x:x,y:b,xScale:u,yScale:m,xDomain:l,yDomain:d,xRange:k,yRange:v,opp:y,domains:o,stackData:c,stackKeyIndex:w,discreteKeyIndex:z,showLineLabels:_,labelWidths:f,largestLabel:g,labelPositions:C,width:p,values:[]};a.forEach(([e,i])=>{t.push(...
|
|
3290
|
+
s.push(...f.grid),s.push(...function(e,t){const i=t.filter(e=>void 0!==e.newY);if(!i.length)return[];const s=i.map(t=>n.assign({x:e._xAxis._getPosition.bind(e._xAxis)(t.xValue),y:t.defaultY},t)).concat(i.map(t=>n.assign({x:e._xAxis._getPosition.bind(e._xAxis)(t.xValue)+t.padding-1,y:t.newY||t.defaultY},t))),a=Fi("Line").config({data:s,stroke:e=>e.fontColor,x:e=>e.x,y:e=>e.y}).config(e._labelConnectorConfig).renderMode("compute");return a.render(),ji(a)}(e,r));const g=Bs(e,s,c,h,o,u),p=function(e,t,i,s,n){const a=e.schema.discrete||"x";return{discrete:e.schema.discrete,duration:e.schema.duration,label:t=>e._drawLabel(t.data,t.i),x:e=>void 0!==e.x2?t(e.x2,"x2"):t(e.x),x0:"x"===a?e=>e.x2?t(e.x2,"x2"):t(e.x):t("number"==typeof e.schema.baseline?e.schema.baseline:s.x[0]),x1:"x"===a?null:e=>e.x2?t(e.x2,"x2"):t(e.x),y:e=>void 0!==e.y2?i(e.y2,"y2"):i(e.y),y0:"y"===a?e=>e.y2?i(e.y2,"y2"):i(e.y):i("number"==typeof e.schema.baseline?e.schema.baseline:s.y[1])-n,y1:"y"===a?null:e=>e.y2?i(e.y2,"y2"):i(e.y)-n}}
|
|
3291
|
+
/** Runs the main shape loop, pushing each shape's scene nodes onto `out`. */(e,c,h,o,u);return function(e,t,i,s,n){const{shapeData:a,domains:o,discreteKeys:r,stackData:c,stackKeys:h,xDomain:l,yDomain:d}=i,{xScale:u,yScale:m}=i,{labelWidths:f,largestLabel:g}=i,{width:p}=i,{opp:y,showLineLabels:_}=i,{x:x,y:b,xRange:k,yRange:v,labelPositions:C}=s,S=Object.keys(e.schema.on),w=new Map;for(let e=0;e<h.length;e++)w.set(h[e],e);const z=new Map;for(let e=0;e<r.length;e++)z.set(r[e],e);const D={viz:e,shapeConfig:n,events:S,x:x,y:b,xScale:u,yScale:m,xDomain:l,yDomain:d,xRange:k,yRange:v,opp:y,domains:o,stackData:c,stackKeyIndex:w,discreteKeyIndex:z,showLineLabels:_,labelWidths:f,largestLabel:g,labelPositions:C,width:p,values:[]};a.forEach(([e,i])=>{t.push(...As({...D,values:i},e))})}
|
|
3236
3292
|
/** Runs shape exits in compute mode and updates `viz._previousShapes`. */(e,s,t,i,p),function(e,t,i){const s=t.map(([e])=>e);s.includes("Line")&&(e._confidence&&s.push("Area"),e._lineMarkers&&s.push("Circle")),
|
|
3237
3293
|
// Run exits in compute mode so Box/Whisker/Shape don't fall through
|
|
3238
3294
|
// to their body-svg / body-div fallback when `_select` is unset.
|
|
@@ -3241,7 +3297,7 @@ s.push(...f.grid),s.push(...function(e,t){const i=t.filter(e=>void 0!==e.newY);i
|
|
|
3241
3297
|
e._previousShapes.filter(e=>!s.includes(e)).forEach(e=>{const t=Fi(e);"function"==typeof t.renderMode&&t.renderMode("compute"),"function"==typeof t.select&&t.select(null),t.config(i).data([]).render()}),e._previousShapes=s}(e,a,p),
|
|
3242
3298
|
// Absorb queued front annotations AFTER the shape loop so they render
|
|
3243
3299
|
// above shapes.
|
|
3244
|
-
g.forEach((e,t)=>{const i
|
|
3300
|
+
g.forEach((e,t)=>{const i=$s(e,`annotation-front-${t}`);i&&s.push(i)}),
|
|
3245
3301
|
// Ticks, tick labels, domain bar, and title render on top of the shapes.
|
|
3246
3302
|
s.push(...f.rest),s}
|
|
3247
3303
|
/**
|
|
@@ -3257,19 +3313,19 @@ s.push(...f.rest),s}
|
|
|
3257
3313
|
|
|
3258
3314
|
@param viz The Plot instance (or any subclass: BarChart, LinePlot, …).
|
|
3259
3315
|
@param pCtx Cross-phase locals produced by `Plot._draw`.
|
|
3260
|
-
*/function
|
|
3316
|
+
*/function Rs(e,t){return Os(e,t,is(e,t))}
|
|
3261
3317
|
/**
|
|
3262
3318
|
@module barBuffer
|
|
3263
3319
|
Adds a buffer to either side of the non-discrete axis.
|
|
3264
3320
|
|
|
3265
3321
|
|
|
3266
3322
|
@param buffer @private
|
|
3267
|
-
*/const
|
|
3323
|
+
*/const Ls=e=>Math.pow(10,Math.ceil(Math.log10(Math.abs(e))))*Math.pow(-1,e<0?1:0);
|
|
3268
3324
|
/**
|
|
3269
3325
|
@module numericBuffer
|
|
3270
3326
|
@private
|
|
3271
3327
|
*/
|
|
3272
|
-
function
|
|
3328
|
+
function Es(e,t,i,s,n,a,o,r){if(void 0===i||isNaN(a[0])||isNaN(a[1]))return a;if(r&&(a=a.slice().reverse(),n=n.slice().reverse()),a[0]===a[1]){if(a=a.slice(),"log"===t)(a=[(c=a[0],Math.pow(10,Math.floor(Math.log10(Math.abs(c))))*Math.pow(-1,c<0?1:0)),Ls(a[0])])[1]<a[0]&&a.reverse();else{const e=Math.abs(parseFloat(a[0].toPrecision(1).replace(/[0-9]{1}$/,"1")));a[0]-=e,a[1]+=e}return e.domain(r?a.slice().reverse():a),r?a.reverse():a}var c;const h=a[0]===a[1]?10:Math.abs(Math.log(a[1]-a[0])/100),d=()=>{let n=e.copy(),a=!1;if("log"===t){let t=e.domain().slice(),i=e.range().slice();if(r&&(t=t.reverse(),i=i.reverse()),a=t[0]*t[1]<0,a){const e=l.scaleLog().domain([1e-6,Math.abs(t[o])]).range([0,1])(Math.abs(t[o?0:1])),s=e/(e+1)*(i[1]-i[0]);t=(0===o?[t[0],1e-6]:[1e-6,t[1]]).map(Math.abs),i=0===o?[i[0],i[0]+s]:[i[0]+s,i[1]]}n=l.scaleLog().domain(t).range(i)}let c=!1;const h=n.range();let d;return d=n("log"===t&&a?Math.abs(i):i),r?0===o?c=d+s>h[o]:1===o&&(c=d-s<h[o]):0===o?c=d-s<h[o]:1===o&&(c=d+s>h[o]),c};if(e.invert&&d()){const n=10;if("log"===t){let t=0;for(;t<10&&d();){const i=(0===o?-1:1)*(a[o]<0?-1:1);a[o]+=a[o]*h*i,e.domain(r?a.slice().reverse():a),t++}}else if(0===o){const t=e.invert(e(i)+(s+n)*(r?1:-1));t<a[o]&&(a[o]=t,e.domain(r?a.slice().reverse():a))}else if(1===o){const t=e.invert(e(i)+(s+n)*(r?-1:1));t>a[o]&&(a[o]=t,e.domain(r?a.slice().reverse():a))}}return r?a.reverse():a}
|
|
3273
3329
|
/**
|
|
3274
3330
|
@module circleBuffer
|
|
3275
3331
|
Adds a buffer to either side of the non-discrete axis.
|
|
@@ -3279,14 +3335,14 @@ function Rs(e,t,i,s,n,a,o,r){if(void 0===i||isNaN(a[0])||isNaN(a[1]))return a;if
|
|
|
3279
3335
|
@private
|
|
3280
3336
|
*/
|
|
3281
3337
|
/* eslint no-cond-assign: 0*/ // @ts-ignore
|
|
3282
|
-
const{theme:
|
|
3338
|
+
const{theme:Fs}=f,Ws=[{key:"barPadding",coerce:"identity"},{key:"baseline",coerce:"identity"},{key:"lineLabels",coerce:"identity"},{key:"shapeSort",coerce:"identity"},{key:"sizeMax",coerce:"identity"},{key:"sizeMin",coerce:"identity"},{key:"sizeScale",coerce:"identity"},{key:"stacked",coerce:"identity"},{key:"xCutoff",coerce:"identity"},{key:"xDomain",coerce:"identity"},{key:"x2Domain",coerce:"identity"},{key:"xSort",coerce:"identity"},{key:"x2Sort",coerce:"identity"},{key:"yCutoff",coerce:"identity"},{key:"yDomain",coerce:"identity"},{key:"y2Domain",coerce:"identity"},{key:"ySort",coerce:"identity"},{key:"y2Sort",coerce:"identity"}],Ns={Bar:function({data:e,x:i,y:s,x2:n,y2:a,buffer:o=10}){const r=n?"x2":"x",c=a?"y2":"y",h="x"===this.schema.discrete?s:i,l=h.domain().slice(),d="x"===this.schema.discrete;let u,m;if(d&&l.reverse(),this.schema.stacked){const i=t.groups(e,e=>`${e[this.schema.discrete]}_${e.group}`).map(([,e])=>e.map(e=>e[d?c:r]));m=i.map(e=>t.sum(e.filter(e=>e>0))),u=i.map(e=>t.sum(e.filter(e=>e<0)))}else{const t=e.map(e=>e[d?c:r]);m=t.filter(e=>e>0),u=t.filter(e=>e<0)}let f=h(t.max(m));(d?f<h(0):f>h(0))&&(f+=d?-o:o),f=h.invert(f);let g=h(t.min(u));return(d?g>h(0):g<h(0))&&(g+=d?o:-o),g=h.invert(g),f>l[1]&&(l[1]=f),g<l[0]&&(l[0]=g),d&&l.reverse(),h.domain(l),[i,s]}
|
|
3283
3339
|
/**
|
|
3284
3340
|
@module boxBuffer
|
|
3285
3341
|
Adds a buffer to either side of the non-discrete axis.
|
|
3286
3342
|
|
|
3287
3343
|
|
|
3288
3344
|
@param buffer @private
|
|
3289
|
-
*/,Box:function({data:e,x:i,y:s,x2:n,y2:a,buffer:o=10}){const r=n?"x2":"x",c=a?"y2":"y",h="x"===this.schema.discrete?s:i,l=h.domain().slice(),d="x"===this.schema.discrete;let u,m;if(d&&l.reverse(),this.schema.stacked){const i=t.groups(e,e=>e[this.schema.discrete]).map(([,e])=>e.map(e=>e[d?c:r]));m=i.map(e=>t.sum(e.filter(e=>e>0))),u=i.map(e=>t.sum(e.filter(e=>e<0)))}else m=e.map(e=>e[d?c:r]),u=m;let f=h(t.max(m));f+=d?-o:o,f=h.invert(f);let g=h(t.min(u));return g+=d?o:-o,g=h.invert(g),f>l[1]&&(l[1]=f),g<l[0]&&(l[0]=g),d&&l.reverse(),h.domain(l),[i,s]},Circle:function({data:e,x:t,y:i,x2:s,y2:n,yScale:a,xScale:o,config:r,buffer:c}){t=t.copy(),i=i.copy();const h=s?"x2":"x",l=n?"y2":"y";let d=t.domain().slice(),u=i.domain().slice();const m=t.range(),f=i.range();return!t.invert&&t.padding&&Li(t,e,this.schema.discrete),!i.invert&&i.padding&&Li(i,e,this.schema.discrete),(t.invert||i.invert)&&e.forEach(e=>{const s=c||2*(r?.r)(e.data,e.i);t.invert&&(d=
|
|
3345
|
+
*/,Box:function({data:e,x:i,y:s,x2:n,y2:a,buffer:o=10}){const r=n?"x2":"x",c=a?"y2":"y",h="x"===this.schema.discrete?s:i,l=h.domain().slice(),d="x"===this.schema.discrete;let u,m;if(d&&l.reverse(),this.schema.stacked){const i=t.groups(e,e=>e[this.schema.discrete]).map(([,e])=>e.map(e=>e[d?c:r]));m=i.map(e=>t.sum(e.filter(e=>e>0))),u=i.map(e=>t.sum(e.filter(e=>e<0)))}else m=e.map(e=>e[d?c:r]),u=m;let f=h(t.max(m));f+=d?-o:o,f=h.invert(f);let g=h(t.min(u));return g+=d?o:-o,g=h.invert(g),f>l[1]&&(l[1]=f),g<l[0]&&(l[0]=g),d&&l.reverse(),h.domain(l),[i,s]},Circle:function({data:e,x:t,y:i,x2:s,y2:n,yScale:a,xScale:o,config:r,buffer:c}){t=t.copy(),i=i.copy();const h=s?"x2":"x",l=n?"y2":"y";let d=t.domain().slice(),u=i.domain().slice();const m=t.range(),f=i.range();return!t.invert&&t.padding&&Li(t,e,this.schema.discrete),!i.invert&&i.padding&&Li(i,e,this.schema.discrete),(t.invert||i.invert)&&e.forEach(e=>{const s=c||2*(r?.r)(e.data,e.i);t.invert&&(d=Es(t,o??"linear",e[h],s,m,d,0,!1),d=Es(t,o??"linear",e[h],s,m,d,1,!1)),i.invert&&(u=Es(i,a??"linear",e[l],s,f,u,0,!0),u=Es(i,a??"linear",e[l],s,f,u,1,!0))}),[t,i]}
|
|
3290
3346
|
/**
|
|
3291
3347
|
@module lineBuffer
|
|
3292
3348
|
Adds a buffer to either side of the non-discrete axis.
|
|
@@ -3302,12 +3358,12 @@ const{theme:Ls}=f,Es=[{key:"barPadding",coerce:"identity"},{key:"baseline",coerc
|
|
|
3302
3358
|
|
|
3303
3359
|
@param buffer Defaults to the width/height of the largest Rect.
|
|
3304
3360
|
@private
|
|
3305
|
-
*/,Rect:function({data:e,x:t,y:i,x2:s,y2:n,yScale:a,xScale:o,config:r}){t=t.copy(),i=i.copy();const c=s?"x2":"x",h=n?"y2":"y";let l=t.domain().slice(),d=i.domain().slice();const u=t.range(),m=i.range();return!t.invert&&t.padding&&Li(t,e,this.schema.discrete),!i.invert&&i.padding&&Li(i,e,this.schema.discrete),(t.invert||i.invert)&&e.forEach(e=>{if(t.invert){const i=(r?.width)(e.data,e.i);l=
|
|
3361
|
+
*/,Rect:function({data:e,x:t,y:i,x2:s,y2:n,yScale:a,xScale:o,config:r}){t=t.copy(),i=i.copy();const c=s?"x2":"x",h=n?"y2":"y";let l=t.domain().slice(),d=i.domain().slice();const u=t.range(),m=i.range();return!t.invert&&t.padding&&Li(t,e,this.schema.discrete),!i.invert&&i.padding&&Li(i,e,this.schema.discrete),(t.invert||i.invert)&&e.forEach(e=>{if(t.invert){const i=(r?.width)(e.data,e.i);l=Es(t,o??"linear",e[c],i,u,l,0,!1),l=Es(t,o??"linear",e[c],i,u,l,1,!1)}if(i.invert){const t=(r?.height)(e.data,e.i);d=Es(i,a??"linear",e[h],t,m,d,0,!0),d=Es(i,a??"linear",e[h],t,m,d,1,!0)}}),[t,i]}};
|
|
3306
3362
|
// E4: Plot's identity-coerce accessor schema (18 keys). installFluent's
|
|
3307
3363
|
// per-key idempotence lets this co-exist with vizSchema on the parent
|
|
3308
3364
|
// Viz.prototype — installFluent walks the actual prototype (Plot.prototype
|
|
3309
3365
|
// here) and skips keys already present.
|
|
3310
|
-
class
|
|
3366
|
+
class Hs extends Oi{
|
|
3311
3367
|
/**
|
|
3312
3368
|
Extends the preDraw behavior of the abstract Viz class.
|
|
3313
3369
|
@private
|
|
@@ -3356,10 +3412,25 @@ return e.root.children.unshift(...t),e}
|
|
|
3356
3412
|
`.shape`, and shape-class-scoped (`.Bar`) handlers — the same three
|
|
3357
3413
|
buckets this method wires, so SVG and Canvas behave identically.
|
|
3358
3414
|
*/_wirePlotShapeEvents(e,t,i){const s=i.filter(e=>e.includes(`.${t}`)),n=i.filter(e=>!e.includes(".")),a=i.filter(e=>e.includes(".shape")),o=e=>(t,i,s,n)=>this.schema.on[e](t.data,t.i,s,n);for(const t of n)e.on(t,o(t));for(const t of a)e.on(t,o(t));for(const t of s)e.on(t,o(t))}
|
|
3415
|
+
/**
|
|
3416
|
+
For a multi-point shape (Line/Area) reports the point nearest the cursor
|
|
3417
|
+
along the discrete axis, so every mouse event (tooltip, click, user
|
|
3418
|
+
handlers) reflects the hovered x rather than the whole-series aggregate.
|
|
3419
|
+
Non-nested shapes and legend swatches fall through to the base (aggregate)
|
|
3420
|
+
behavior.
|
|
3421
|
+
@private
|
|
3422
|
+
*/_interactionDatum(e,t){const i=e.node,s=i&&i.interactionPoints;if(i&&"legend"!==i.interactionGroup&&Array.isArray(s)&&s.length&&t&&Array.isArray(t.point)){const e=this._nearestInteractionPoint(s,t.point);if(e){const t=e.datum;return{d:t&&t.data?t.data:t,i:"number"==typeof t.i?t.i:e.index,x:t}}}return super._interactionDatum(e,t)}
|
|
3423
|
+
/**
|
|
3424
|
+
Picks the interaction point closest to a surface-local cursor position
|
|
3425
|
+
along the discrete axis. `event.point` is post-zoom surface space while the
|
|
3426
|
+
points are in pre-zoom content space (they live under the `viz-zoom`
|
|
3427
|
+
group), so the cursor is un-zoomed by `_zoomTransform` before comparing.
|
|
3428
|
+
@private
|
|
3429
|
+
*/_nearestInteractionPoint(e,t){const i=this._zoomTransform,s=i&&i.scale?i.scale:1,n=(t[0]-(i?i.x:0))/s,a=(t[1]-(i?i.y:0))/s,o="y"===this.schema.discrete?"y":"x",r="y"===o?a:n;let c=null,h=1/0;for(const t of e){const e=Math.abs(t[o]-r);e<h&&(h=e,c=t)}return c}
|
|
3359
3430
|
/**
|
|
3360
3431
|
Extends the draw behavior of the abstract Viz class.
|
|
3361
3432
|
@private
|
|
3362
|
-
*/_draw(e){return
|
|
3433
|
+
*/_draw(e){return os(this,e)}
|
|
3363
3434
|
/**
|
|
3364
3435
|
Paint phase: production axis rendering, shape buffer setup, and shape
|
|
3365
3436
|
emission with event handlers. Receives all cross-phase locals from
|
|
@@ -3371,7 +3442,7 @@ return e.root.children.unshift(...t),e}
|
|
|
3371
3442
|
// function of its inputs. `super._draw` resets `_chartScene` to []
|
|
3372
3443
|
// before the paint phase, so the emit output IS the scene. Viz.toScene
|
|
3373
3444
|
// wraps the collection in viz-chart-cells + zoom transform.
|
|
3374
|
-
return this._chartScene=
|
|
3445
|
+
return this._chartScene=Rs(this,e),this}
|
|
3375
3446
|
/**
|
|
3376
3447
|
Allows drawing custom shapes to be used as annotations in the provided x/y plot. This method accepts custom config objects for the [Shape](http://d3plus.org/docs/#Shape) class, either a single config object or an array of config objects. Each config object requires an additional parameter, the "shape", which denotes which [Shape](http://d3plus.org/docs/#Shape) sub-class to use ([Rect](http://d3plus.org/docs/#Rect), [Line](http://d3plus.org/docs/#Line), etc).
|
|
3377
3448
|
|
|
@@ -3385,7 +3456,7 @@ return this._chartScene=Ts(this,e),this}
|
|
|
3385
3456
|
*/backgroundConfig(e){return arguments.length?(this._backgroundConfig=n.assign(this._backgroundConfig,e),this):this._backgroundConfig}
|
|
3386
3457
|
/**
|
|
3387
3458
|
Determines whether or not to add additional padding at the ends of x or y scales. The most commone use for this is in Scatter Plots, so that the shapes do not appear directly on the axis itself. The value provided can either be `true` or `false` to toggle the behavior for all shape types, or a keyed Object for each shape type (ie. `{Bar: false, Circle: true, Line: false}`).
|
|
3388
|
-
*/buffer(e){if(arguments.length){if(e)if(!0===e)this._buffer=
|
|
3459
|
+
*/buffer(e){if(arguments.length){if(e)if(!0===e)this._buffer=Ns;else{this._buffer=n.assign({},this._buffer,e);for(const e in this._buffer){const t=this._buffer;!0===t[e]&&(t[e]=Ns[e])}}else this._buffer={};return this}return this._buffer}
|
|
3389
3460
|
/**
|
|
3390
3461
|
The confidence interval as an array of [lower, upper] bounds.
|
|
3391
3462
|
|
|
@@ -3428,7 +3499,7 @@ return this._chartScene=Ts(this,e),this}
|
|
|
3428
3499
|
or `"wiggle"` — or a custom offset function. Unknown names warn and fall
|
|
3429
3500
|
back to `"diverging"`. If *value* is not specified, returns the current
|
|
3430
3501
|
stack offset function.
|
|
3431
|
-
*/stackOffset(e){return arguments.length?(this._stackOffset="function"==typeof(t=e)?t:"string"==typeof t&&t in
|
|
3502
|
+
*/stackOffset(e){return arguments.length?(this._stackOffset="function"==typeof(t=e)?t:"string"==typeof t&&t in Cs?Cs[t]:(console.warn(`[d3plus] Unknown stackOffset "${t}". Expected one of: ${Ss.join(", ")}; or an offset function. Falling back to "diverging".`),vs),this):this._stackOffset;
|
|
3432
3503
|
/**
|
|
3433
3504
|
Normalizes a `stackOffset` input into an offset function. Warns and falls
|
|
3434
3505
|
back to the diverging default on an unrecognized name.
|
|
@@ -3456,7 +3527,7 @@ var t}
|
|
|
3456
3527
|
function(e){if("function"==typeof e)
|
|
3457
3528
|
// Already-resolved order (constructor default / config() reset) passes
|
|
3458
3529
|
// through; a bare user function is treated as a value accessor.
|
|
3459
|
-
return e.__d3plusStackOrder?e:
|
|
3530
|
+
return e.__d3plusStackOrder?e:xs(e);if(Array.isArray(e))return e;if(e&&"object"==typeof e){const{value:t,order:i}=e;return xs("function"==typeof t?t:F(t),i)}return"string"==typeof e?e in bs?bs[e]:(console.warn(`[d3plus] Unknown stackOrder "${e}". Expected one of: ${ks.join(", ")}; an array of series keys; a value accessor; or a {value, order} config. Falling back to "descending".`),ps):ps}(e),this):this._stackOrder}
|
|
3460
3531
|
/**
|
|
3461
3532
|
Accessor function or string key for the x-axis value of each data point.
|
|
3462
3533
|
*/x(e){return arguments.length?("function"==typeof e?this._x=e:(this._x=F(e),this._xKey=e),this):this._x}
|
|
@@ -3490,43 +3561,48 @@ return e.__d3plusStackOrder?e:ys(e);if(Array.isArray(e))return e;if(e&&"object"=
|
|
|
3490
3561
|
// E4: install identity-coerce accessors on Plot.prototype. Defaults
|
|
3491
3562
|
// are still applied below imperatively from plotDef; installFluent
|
|
3492
3563
|
// skips slots that are already set, so the constructor wins.
|
|
3493
|
-
re(this,
|
|
3564
|
+
re(this,Ws);
|
|
3494
3565
|
// E3: scalar defaults sourced from plotDef.
|
|
3495
|
-
const e=
|
|
3566
|
+
const e=es.defaults;this._axisPersist=e.axisPersist,this._annotations=e.annotations,this._backgroundConfig={duration:0,fill:"transparent"},this.schema.barPadding=e.barPadding,this._buffer=n.assign({},Ns,{Bar:!1,Line:!1}),this._confidenceConfig={
|
|
3567
|
+
// A line's colour is its stroke, so the confidence band fills with that
|
|
3568
|
+
// same colour (at the reduced opacity below). Prefer a per-Line stroke
|
|
3569
|
+
// override, else the shared stroke accessor (the Line config itself sets
|
|
3570
|
+
// no `stroke` — the colour comes from the top-level `shapeConfig.stroke`).
|
|
3571
|
+
fill:(e,t)=>{const{Line:i,stroke:s}=this.schema.shapeConfig,n=i&&void 0!==i.stroke?i.stroke:s;return"function"==typeof n?n(e,t):n},fillOpacity:L(.5)},this._discreteCutoff=e.discreteCutoff,this._groupPadding=e.groupPadding,this._labelConnectorConfig={strokeDasharray:"1 1"},this._labelPosition=L("auto"),this._lineMarkerConfig={fill:(e,t)=>u.colorAssign(this._id(e,t)),r:L(3)},this._lineMarkers=e.lineMarkers,this._previousAnnotations={back:[],front:[]},this._previousShapes=[],this.schema.shape=e.shape,this.schema.shapeConfig=n.assign(this.schema.shapeConfig,us.call(this)),this._shapeOrder=["Area","Path","Bar","Box","Line","Rect","Circle"],this.schema.shapeSort=(e,t)=>this._shapeOrder.indexOf(e)-this._shapeOrder.indexOf(t),this.schema.sizeMax=20,this.schema.sizeMin=5,this.schema.sizeScale="sqrt",this._stackOffset=vs,this._stackOrder=ps,this.schema.timelineConfig=n.assign(this.schema.timelineConfig,{brushMin:()=>this._xTime||this._yTime||this._x2Time||this._y2Time?2:1}),this._x=F("x"),this._xKey="x",this._xAxis=(new St).align("end"),
|
|
3496
3572
|
// _xTest/_yTest/_x2Test/_y2Test are NOT persistent fields anymore. The
|
|
3497
3573
|
// measure-only test axes are allocated as locals inside `_draw` and
|
|
3498
3574
|
// garbage-collected after each draw — proving Plot doesn't need to
|
|
3499
3575
|
// own a long-lived Axis instance just for layout. See measureAxis()
|
|
3500
3576
|
// in axisLayout.ts for the standalone shape.
|
|
3501
|
-
this._xConfig={gridConfig:{stroke:e=>{if(this.schema.discrete&&"x"===this.schema.discrete.charAt(0))return"transparent";const t=this._xAxis.range(),i=this._xAxis._getPosition.bind(this._xAxis)(e.id);if(t[0]===i)return"transparent";const s=this._select?n.backgroundColor(this._select.node()):"rgb(255, 255, 255)";return u.colorContrast(s)===u.colorDefaults.dark?
|
|
3577
|
+
this._xConfig={gridConfig:{stroke:e=>{if(this.schema.discrete&&"x"===this.schema.discrete.charAt(0))return"transparent";const t=this._xAxis.range(),i=this._xAxis._getPosition.bind(this._xAxis)(e.id);if(t[0]===i)return"transparent";const s=this._select?n.backgroundColor(this._select.node()):"rgb(255, 255, 255)";return u.colorContrast(s)===u.colorDefaults.dark?Fs.colors.gray[200]:Fs.colors.gray[600]}}},this.schema.xCutoff=150,this._x2=F("x2"),this._x2Key="x2",this._x2Axis=(new Dt).align("start"),this._x2Config={},this._y=F("y"),this._yKey="y",this._yAxis=(new wt).align("start"),this._yKey="y",this._yConfig={gridConfig:{stroke:e=>{if(this.schema.discrete&&"y"===this.schema.discrete.charAt(0))return"transparent";const t=this._yAxis.range(),i=this._yAxis._getPosition.bind(this._yAxis)(e.id);if(t[t.length-1]===i)return"transparent";const s=this._select?n.backgroundColor(this._select.node()):"rgb(255, 255, 255)";return u.colorContrast(s)===u.colorDefaults.dark?Fs.colors.gray[200]:Fs.colors.gray[600]}}},this.schema.yCutoff=150,this._y2=F("y2"),this._y2Key="y2",this._y2Axis=(new zt).align("end"),this._y2Config={}}}
|
|
3502
3578
|
/**
|
|
3503
3579
|
Creates an area plot based on an array of data.
|
|
3504
3580
|
*/
|
|
3505
|
-
var
|
|
3581
|
+
var js=Ri({name:"AreaPlot",paintDriven:!0,features:[ee,Q,Z,ne],ctx:{},fields:[{key:"baseline",default:0},{key:"discrete",default:"x"},{key:"shape",default:L("Area"),coerce:"const"}]},Hs);
|
|
3506
3582
|
/**
|
|
3507
3583
|
Creates a bar chart based on an array of data.
|
|
3508
3584
|
*/
|
|
3509
|
-
var
|
|
3585
|
+
var Gs=Ri({name:"BarChart",paintDriven:!0,features:[ee,Q,Z,ne],ctx:{},fields:[{key:"baseline",default:0},{key:"discrete",default:"x"},{key:"shape",default:L("Bar"),coerce:"const"},{key:"legend",coerce:"const",factory:e=>{const t=e.schema.legend;return(i,s)=>s.map(e.schema.groupBy[e._legendDepth].bind(e)).sort().join()!==e._filteredData.map(e.schema.groupBy[e._legendDepth].bind(e)).sort().join()&&t.call(e,i,s)}}]},Hs);
|
|
3510
3586
|
/**
|
|
3511
3587
|
Creates a simple box and whisker based on an array of data.
|
|
3512
3588
|
*/
|
|
3513
|
-
var
|
|
3589
|
+
var Is=Ri({name:"BoxWhisker",paintDriven:!0,features:[ee,Q,Z,ne],ctx:{},fields:[{key:"discrete",default:"x"},{key:"shape",default:L("Box"),coerce:"const"},{key:"tooltipConfig",merge:!0,factory:e=>({title:(t,i)=>{if(!t)return"";for(;t.__d3plus__&&t.data;)i=(t=t.data).i;const s=e.schema.label;if(s)return s(t,i);const n=e._ids(t,i).slice(0,e._drawDepth);return n[n.length-1]}})}]},Hs);const qs={name:"BumpChart",paintDriven:!0,features:[ee,Q,Z,ne],setup:e=>{const t=e;t.y2((t,i)=>e._y(t,i)),t.yConfig({tickFormat:t=>{const i=e._formattedData??[],s=i[0].x instanceof Date?i[0].x.getTime():i[0].x,n=i.filter(e=>(e.x instanceof Date?e.x.getTime():e.x)===s),a=n.find(e=>e.y===t);return a?e._drawLabel(a,a.i):""}}),t.y2Config({tickFormat:t=>{const i=e._formattedData??[],s=i[i.length-1].x instanceof Date?i[i.length-1].x.getTime():i[i.length-1].x,n=i.filter(e=>(e.x instanceof Date?e.x.getTime():e.x)===s),a=n.find(e=>e.y===t);return a?e._drawLabel(a,a.i):""}}),t.ySort((t,i)=>e._y(i)-e._y(t)),t.y2Sort((t,i)=>e._y(i)-e._y(t))},ctx:{},fields:[{key:"discrete",default:"x"},{key:"shape",default:L("Line"),coerce:"const"}]};
|
|
3514
3590
|
/**
|
|
3515
3591
|
Creates a bump chart based on an array of data.
|
|
3516
|
-
*/var
|
|
3592
|
+
*/var Ys=Ri(qs,Hs);const Ks=({viz:e})=>{const{width:t,height:i}=le(e),s=Math.min(t,i)/2,n=e.ctx.pie,a=e.schema.padAngle??0,o=e.schema.padPixel??0,r=e.schema.sort,c=e.schema.value,h=n.padAngle(a||o/s).sort(r).value(c)(e._filteredData),l=h.reduce((e,t)=>e+t.value,0);h.forEach((e,t)=>{e.__d3plus__=!0,e.i=t;
|
|
3517
3593
|
// The tooltip binds the unwrapped row, so the slice's share of the total
|
|
3518
3594
|
// must live on the row for the tooltip accessor to read it. Mirrors
|
|
3519
3595
|
// Treemap stamping `share` onto `d.data`.
|
|
3520
|
-
const i=l?e.value/l:0;e.share=i,e.data.share=i});const d=e.schema.innerRadius;return e.ctx.arcData=P.arc().innerRadius("function"==typeof d?d:()=>d).outerRadius(s),e.ctx.pieData=h,e.ctx.pieWidth=t,e.ctx.pieHeight=i,{shapeData:h}},
|
|
3596
|
+
const i=l?e.value/l:0;e.share=i,e.data.share=i});const d=e.schema.innerRadius;return e.ctx.arcData=P.arc().innerRadius("function"==typeof d?d:()=>d).outerRadius(s),e.ctx.pieData=h,e.ctx.pieWidth=t,e.ctx.pieHeight=i,{shapeData:h}},Vs={fontMin:8,fontMax:50,fontResize:!0,padding:5,textAnchor:"start",verticalAlign:"top",
|
|
3521
3597
|
// Honor the rotation/anchor `buildLabelData` precomputes onto each record
|
|
3522
3598
|
// (`.r` / `.rotateAnchor`). TextBox's `rotate` accessor receives the raw
|
|
3523
3599
|
// label record; `rotateAnchor` receives the laid-out datum whose `.data`
|
|
3524
3600
|
// is that record — so both shapes are checked.
|
|
3525
3601
|
rotate(e){const t=e.r??e.data?.r;return"number"==typeof t?t:0},rotateAnchor(e){const t=e.rotateAnchor??e.data?.rotateAnchor;return Array.isArray(t)?t:[(e.w??0)/2,(e.h??0)/2]},fontColor(e,t){const i="function"==typeof this._fill?this._fill(e,t):this._fill;return"string"==typeof i?u.colorContrast(i):"black"}};
|
|
3526
|
-
/** Defaults that match Shape's `_labelConfig` so chart emits look like Shape labels. */function
|
|
3602
|
+
/** Defaults that match Shape's `_labelConfig` so chart emits look like Shape labels. */function Xs(e){const t=Te(e);if(!t.length)return[];const i=(new Gt).config({...Vs,...e.labelConfig??{}}).data(t).renderMode("compute");try{const e=i.toScene();return Array.isArray(e?.children)?e.children:[]}catch{return[]}}function Us(e,t,i){return"function"==typeof e?e(t,i):e}const Js={name:"Pie",features:[ee,Q,Z,ne],layoutStage:Ks,emit:({viz:e,shapeData:t})=>{const i=t??[];if(!i.length)return[];const s=e.ctx.arcData,n=e.schema.shapeConfig??{};return[...i.map(t=>{const i=Us(n.fill,t.data,t.i??0),a=Us(n.stroke,t.data,t.i??0),o=Us(n.strokeWidth,t.data,t.i??0);return{type:"path",key:`pie-${e._ids(t.data,t.i??0).join("-")}`,d:s(t),datum:t.data,paint:{fill:"string"==typeof i?i:void 0,stroke:a,strokeWidth:o}}}),...Xs({data:i,label:(t,s)=>e._drawLabel(i[s].data,i[s].i??s),
|
|
3527
3603
|
// The largest inscribed rectangle is in chart-centered path coordinates,
|
|
3528
3604
|
// so the anchor is the origin and labelBounds carries the absolute box.
|
|
3529
|
-
x:()=>0,y:()=>0,aes:()=>({}),rotate:L(0),id:(e,t)=>`pie-label-${t}`,labelBounds:(e,t)=>{const n=p.largestRect(p.path2polygon(s(i[t])),{angle:0});return!!n&&{angle:n.angle,width:n.width,height:n.height,x:n.cx-n.width/2,y:n.cy-n.height/2}},labelConfig:{fontColor:e=>{const t=e.data??e,i=
|
|
3605
|
+
x:()=>0,y:()=>0,aes:()=>({}),rotate:L(0),id:(e,t)=>`pie-label-${t}`,labelBounds:(e,t)=>{const n=p.largestRect(p.path2polygon(s(i[t])),{angle:0});return!!n&&{angle:n.angle,width:n.width,height:n.height,x:n.cx-n.width/2,y:n.cy-n.height/2}},labelConfig:{fontColor:e=>{const t=e.data??e,i=Us(n.fill,t.data,t.i??0);return u.colorContrast("string"==typeof i?i:"rgb(255, 255, 255)")},fontResize:!0,textAnchor:"middle",verticalAlign:"middle"}})]},chartTransform:e=>de(e,e.ctx.pieWidth,e.ctx.pieHeight),ctx:{pie:y.pie()},fields:[{key:"innerRadius",default:0},{key:"padAngle"},{key:"padPixel",default:0},{key:"value",default:F("value"),coerce:e=>"function"==typeof e?e:F(e)},{key:"sort",factory:e=>{const t=e.schema.value;return(e,i)=>t(i)-t(e)}},{key:"legendSort",factory:e=>{const t=e.schema.value;return(e,i)=>t(i)-t(e)}},{key:"shapeConfig",merge:!0,factory:e=>({ariaLabel:(t,i)=>{const s=e.ctx.pieData;return s?`${++s[i].index}. ${e._drawLabel(t,i)}, ${e.schema.value(t,i)}.`:""},Path:{labelConfig:{fontResize:!0}}})},{key:"tooltipConfig",merge:!0,factory:e=>({tbody:[[()=>e.schema.translate("Share"),(t,i,s)=>{
|
|
3530
3606
|
// A ColorScale range swatch carries no per-row share, so sum the
|
|
3531
3607
|
// share of every datum that falls in its color range.
|
|
3532
3608
|
if(s._isColorScaleBucket){const t=ye(e,s.color,e.schema.value);return null==t?"":`${m.formatAbbreviate(100*t,e.schema.locale)}%`}
|
|
@@ -3537,15 +3613,15 @@ const n=Array.isArray(s.share)?s.share.reduce((e,t)=>e+t,0):s.share;return Numbe
|
|
|
3537
3613
|
/**
|
|
3538
3614
|
Uses the d3 pie layout to create SVG arcs based on an array of data.
|
|
3539
3615
|
*/
|
|
3540
|
-
var
|
|
3616
|
+
var Qs=Ri(Js);
|
|
3541
3617
|
/**
|
|
3542
3618
|
Extends the Pie visualization to create a donut chart.
|
|
3543
3619
|
*/
|
|
3544
|
-
var
|
|
3620
|
+
var Zs=Ri({name:"Donut",
|
|
3545
3621
|
// Inherits Pie's full pipeline (features + emit). Donut adds no
|
|
3546
3622
|
// chart-specific layout stage of its own — `super._draw` (Pie's)
|
|
3547
3623
|
// handles the layout.
|
|
3548
|
-
features:
|
|
3624
|
+
features:Js.features,emit:Js.emit,ctx:{},fields:[{key:"padPixel",default:2},{key:"innerRadius",factory:e=>()=>{const{width:i,height:s}=le(e);return(t.min([i,s])??0)/4}}]},Qs);const en=[{matches:["cartodb","cartocdn"],text:"© <a href='http://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors, © <a href='https://carto.com/attribution' target='_blank'>CARTO</a>"},{matches:["opentopomap.org"],text:"© <a href='http://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors"},{matches:["arcgisonline.com"],text:"Powered by <a href='https://developers.arcgis.com/terms/attribution/' target='_blank'>Esri</a>"},{matches:["/watercolor/"],text:"Map tiles by <a href='http://stamen.com' target='_blank'>Stamen Design</a>, under <a href='http://creativecommons.org/licenses/by/3.0' target='_blank'>CC BY 3.0</a>. Data by <a href='http://openstreetmap.org' target='_blank'>OpenStreetMap</a>, under <a href='http://www.openstreetmap.org/copyright' target='_blank'>ODbL</a>."},{matches:["stamen-tiles","stamen.com"],text:"Map tiles by <a href='http://stamen.com' target='_blank'>Stamen Design</a>, under <a href='http://creativecommons.org/licenses/by/3.0' target='_blank'>CC BY 3.0</a>. Data by <a href='http://openstreetmap.org' target='_blank'>OpenStreetMap</a>, under <a href='http://creativecommons.org/licenses/by-sa/3.0' target='_blank'>CC BY SA</a>."}];
|
|
3549
3625
|
/**
|
|
3550
3626
|
`ensureZoomDom(viz, kind)` — sets up the inner `<svg>` + zoom group +
|
|
3551
3627
|
hitArea that d3-zoom and tile-loading need.
|
|
@@ -3568,28 +3644,34 @@ features:Vs.features,emit:Vs.emit,ctx:{},fields:[{key:"padPixel",default:2},{key
|
|
|
3568
3644
|
scene-graph-native interaction path (renderer.on(...) dispatch +
|
|
3569
3645
|
tile-data → image scene nodes) would let this go away; until then,
|
|
3570
3646
|
it's the documented home for the imperative half of v4 zoom.
|
|
3571
|
-
*/function
|
|
3647
|
+
*/function tn(e,t){const{kind:i,width:s,height:n,duration:a,ocean:o}=t,r="network"===i?"d3plus-network":"d3plus-geomap",c="geomap"===i&&o||"transparent";let h=e._select.selectAll(`svg.${r}`).data([0]);if(h=h.enter().append("svg").attr("class",r).attr("opacity",0).attr("width",s).attr("height",n).attr("x",e._margin.left).attr("y",e._margin.top).style("background-color",c).merge(h),e._container=h,h.transition().duration(a).attr("opacity",1).attr("width",s).attr("height",n).attr("x",e._margin.left).attr("y",e._margin.top),"network"===i){
|
|
3572
3648
|
// Hit-area for "click outside any node" → reset focus + zoom.
|
|
3573
3649
|
const t=h.selectAll(`rect.${r}-hitArea`).data([0]);t.enter().append("rect").attr("class",`${r}-hitArea`).merge(t).attr("width",s).attr("height",n).attr("fill","transparent").on("click",()=>{e._focus&&(e.active(!1),e._focus=void 0,e._zoomToBounds(null))});let i=h.selectAll(`g.${r}-zoomGroup`).data([0]);i=i.enter().append("g").attr("class",`${r}-zoomGroup`).merge(i),e._zoomGroup=i}else{
|
|
3574
3650
|
// Geomap also needs an ocean rect (under tiles + paths) and the tile
|
|
3575
3651
|
// group that `_renderTiles` mutates with map imagery.
|
|
3576
|
-
const t=h.selectAll(`rect.${r}-ocean`).data([0]);t.enter().append("rect").attr("class",`${r}-ocean`).merge(t).attr("width",s).attr("height",n).attr("fill",o||"transparent");let i=h.selectAll(`g.${r}-tileGroup`).data([0]);i=i.enter().append("g").attr("class",`${r}-tileGroup`).merge(i),e._tileGroup=i;let a=h.selectAll(`g.${r}-zoomGroup`).data([0]);a=a.enter().append("g").attr("class",`${r}-zoomGroup`).merge(a),e._zoomGroup=a}}function
|
|
3577
|
-
/** Reduces fit features, trimming far-flung MultiPolygon parts via path geometry. */const
|
|
3578
|
-
/** Builds projected-point extent bounds + padding when no fit features exist. */(s.extentBounds.features,r),!s.extentBounds.features.length&&c.length&&function(e,i,s,n){const a=[[void 0,void 0],[void 0,void 0]];s.forEach((t,i)=>{const s=e.schema.projection(e.schema.point(t,i));(void 0===a[0][0]||s[0]<a[0][0])&&(a[0][0]=s[0]),(void 0===a[1][0]||s[0]>a[1][0])&&(a[1][0]=s[0]),(void 0===a[0][1]||s[1]<a[0][1])&&(a[0][1]=s[1]),(void 0===a[1][1]||s[1]>a[1][1])&&(a[1][1]=s[1])}),i.extentBounds={type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"MultiPoint",coordinates:a.map(t=>e.schema.projection.invert(t))}}]};const o=t.max(s,(t,i)=>n(e.schema.pointSize(t,i)));i.effectivePadding={top:e.schema.projectionPadding.top+o,right:e.schema.projectionPadding.right+o,bottom:e.schema.projectionPadding.bottom+o,left:e.schema.projectionPadding.left+o}}(i,s,c,u)}const m=s.effectivePadding||i.schema.projectionPadding;return s.effectivePadding=void 0,i.schema.projection=i.schema.projection.fitExtent(s.extentBounds.features.length?[[m.left,m.top],[n-m.right,a-m.bottom]]:[[0,0],[n,a]],s.extentBounds.features.length?s.extentBounds:{type:"Sphere"}),s.geomapWidth=n,s.geomapHeight=a,s.geomapCtx={topoData:l,pathFn:e=>r(e.feature),pointData:c,pointR:(e,t)=>u(i.schema.pointSize(e,t)),pointSort:(e,t)=>i.schema.pointSize(t)-i.schema.pointSize(e),pointX:(e,t)=>i.schema.projection(i.schema.point(e,t))[0],pointY:(e,t)=>i.schema.projection(i.schema.point(e,t))[1]},{shapeData:l}},
|
|
3652
|
+
const t=h.selectAll(`rect.${r}-ocean`).data([0]);t.enter().append("rect").attr("class",`${r}-ocean`).merge(t).attr("width",s).attr("height",n).attr("fill",o||"transparent");let i=h.selectAll(`g.${r}-tileGroup`).data([0]);i=i.enter().append("g").attr("class",`${r}-tileGroup`).merge(i),e._tileGroup=i;let a=h.selectAll(`g.${r}-zoomGroup`).data([0]);a=a.enter().append("g").attr("class",`${r}-zoomGroup`).merge(a),e._zoomGroup=a}}function sn(e,t){const i=t&&e.objects[t]?t:Object.keys(e.objects)[0];return w.feature(e,i)}
|
|
3653
|
+
/** Reduces fit features, trimming far-flung MultiPolygon parts via path geometry. */const nn=({viz:e})=>{const i=e,s=e.ctx,{width:n,height:a}=le(i),o=i.schema.topojson?sn(i.schema.topojson,i.schema.topojsonKey):{type:"FeatureCollection",features:[]};s.coordData=o,i.schema.topojsonFilter&&(o.features=o.features.filter(i.schema.topojsonFilter));const r=T.geoPath().projection(i.schema.projection);s.path=r;const c=i._filteredData.filter((e,t)=>i.schema.point(e,t)instanceof Array),h=i._filteredData.filter((e,t)=>!(i.schema.point(e,t)instanceof Array)).reduce((e,t,s)=>(e[i._id(t,s)]=t,e),{}),l=o.features.reduce((e,t)=>{const s=i.schema.topojsonId(t);return e.push({__d3plus__:!0,data:h[s],feature:t,id:s}),e},[]),d=`scale${i.schema.pointSizeScale.charAt(0).toUpperCase()}${i.schema.pointSizeScale.slice(1)}`,u=B[d]().domain(t.extent(c,(e,t)=>i.schema.pointSize(e,t))).range([i.schema.pointSizeMin,i.schema.pointSizeMax]);if(!i._zoomSet||!s.extentBounds){const e=i.schema.fitObject?sn(i.schema.fitObject,i.schema.fitKey):o;s.extentBounds={type:"FeatureCollection",features:i.schema.fitFilter?e.features.filter(i.schema.fitFilter):e.features.slice()},s.extentBounds.features=function(e,i){return e.reduce((e,s)=>{const n=s;if(!n.geometry)return e;const a={type:n.type,id:n.id,geometry:{coordinates:n.geometry.coordinates,type:n.geometry.type}};if("MultiPolygon"===n.geometry.type&&n.geometry.coordinates.length>1){const e=[],s=[];n.geometry.coordinates.forEach(t=>{a.geometry.coordinates=[t],e.push(i.area(a))}),a.geometry.coordinates=[n.geometry.coordinates[e.indexOf(t.max(e))]];const o=i.centroid(a);n.geometry.coordinates.forEach(e=>{a.geometry.coordinates=[e],s.push(p.pointDistance(i.centroid(a),o))});const r=t.quantile(e.reduce((t,i,n)=>(s[n]&&t.push(e[n]/s[n]),t),[]),.9);a.geometry.coordinates=n.geometry.coordinates.filter((t,i)=>{const n=s[i];return 0===n||e[i]/n>=r})}return e.push(a),e},[])}
|
|
3654
|
+
/** Builds projected-point extent bounds + padding when no fit features exist. */(s.extentBounds.features,r),!s.extentBounds.features.length&&c.length&&function(e,i,s,n){const a=[[void 0,void 0],[void 0,void 0]];s.forEach((t,i)=>{const s=e.schema.projection(e.schema.point(t,i));(void 0===a[0][0]||s[0]<a[0][0])&&(a[0][0]=s[0]),(void 0===a[1][0]||s[0]>a[1][0])&&(a[1][0]=s[0]),(void 0===a[0][1]||s[1]<a[0][1])&&(a[0][1]=s[1]),(void 0===a[1][1]||s[1]>a[1][1])&&(a[1][1]=s[1])}),i.extentBounds={type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"MultiPoint",coordinates:a.map(t=>e.schema.projection.invert(t))}}]};const o=t.max(s,(t,i)=>n(e.schema.pointSize(t,i)));i.effectivePadding={top:e.schema.projectionPadding.top+o,right:e.schema.projectionPadding.right+o,bottom:e.schema.projectionPadding.bottom+o,left:e.schema.projectionPadding.left+o}}(i,s,c,u)}const m=s.effectivePadding||i.schema.projectionPadding;return s.effectivePadding=void 0,i.schema.projection=i.schema.projection.fitExtent(s.extentBounds.features.length?[[m.left,m.top],[n-m.right,a-m.bottom]]:[[0,0],[n,a]],s.extentBounds.features.length?s.extentBounds:{type:"Sphere"}),s.geomapWidth=n,s.geomapHeight=a,s.geomapCtx={topoData:l,pathFn:e=>r(e.feature),pointData:c,pointR:(e,t)=>u(i.schema.pointSize(e,t)),pointSort:(e,t)=>i.schema.pointSize(t)-i.schema.pointSize(e),pointX:(e,t)=>i.schema.projection(i.schema.point(e,t))[0],pointY:(e,t)=>i.schema.projection(i.schema.point(e,t))[1]},{shapeData:l}},an=Object.assign({},T,O,R);function on(e){const t=en.find(t=>t.matches.some(t=>e.includes(t)));return!!t&&t.text}
|
|
3579
3655
|
/** Installs `_renderTiles`, the per-instance method that mutates the tile group. */
|
|
3580
|
-
/** Installs the imperative fluent accessors on the Geomap instance. */function
|
|
3656
|
+
/** Installs the imperative fluent accessors on the Geomap instance. */function rn(e){
|
|
3581
3657
|
// Imperative fluent accessors. Parameter type is `unknown` since each
|
|
3582
3658
|
// method accepts a function or a value (or for fitFilter/topojsonFilter,
|
|
3583
3659
|
// also an array of ids). Each branch narrows with typeof / instanceof.
|
|
3584
3660
|
!
|
|
3585
3661
|
/** Installs the fit/point fluent accessors. */function(e){const t=e;t.fitFilter=function(e){if(arguments.length){if(this._zoomSet=!1,"function"==typeof e)return this.schema.fitFilter=e,this;const t=e instanceof Array?e:[e];return this.schema.fitFilter=e=>t.includes(e.id),this}return this.schema.fitFilter},t.fitKey=function(e){return arguments.length?(this.schema.fitKey=e,this._zoomSet=!1,this):this.schema.fitKey},t.fitObject=function(e,t){return arguments.length?(s.addToQueue.bind(this)(e,t,"fitObject"),this._zoomSet=!1,this):this.schema.fitObject},t.point=function(e){return arguments.length?(this.schema.point="function"==typeof e?e:L(e),this):this.schema.point},t.pointSize=function(e){return arguments.length?(this.schema.pointSize="function"==typeof e?e:L(e),this):this.schema.pointSize}}
|
|
3586
|
-
/** Installs the projection fluent accessors. */(e),function(e){const t=e;t.projection=function(e){return arguments.length&&"geoMercator"!==e&&t.tiles(!1),arguments.length?(this.schema.projection="string"==typeof e?
|
|
3587
|
-
/** Installs the tile fluent accessors. */(e),function(e){const t=e;t.tiles=function(e){if(arguments.length){this.schema.tiles=e;const t=
|
|
3588
|
-
/** Installs the topojson fluent accessors. */(e),function(e){const t=e;t.topojson=function(e,t){return arguments.length?(s.addToQueue.bind(this)(e,t,"topojson"),this._zoomSet=!1,this):this.schema.topojson},t.topojsonFill=function(e){return arguments.length?(this.schema.topojsonFill="function"==typeof e?e:L(e),this):this.schema.topojsonFill},t.topojsonFilter=function(e){if(arguments.length){if(this._zoomSet=!1,"function"==typeof e)return this.schema.topojsonFilter=e,this;const t=e instanceof Array?e:[e];return this.schema.topojsonFilter=e=>t.includes(e.id),this}return this.schema.topojsonFilter},t.topojsonKey=function(e){return arguments.length?(this.schema.topojsonKey=e,this._zoomSet=!1,this):this.schema.topojsonKey},t.topojsonId=function(e){return arguments.length?(this.schema.topojsonId="function"==typeof e?e:F(e),this):this.schema.topojsonId}}(e)}const
|
|
3589
|
-
//
|
|
3590
|
-
// (
|
|
3591
|
-
//
|
|
3592
|
-
|
|
3662
|
+
/** Installs the projection fluent accessors. */(e),function(e){const t=e;t.projection=function(e){return arguments.length&&"geoMercator"!==e&&t.tiles(!1),arguments.length?(this.schema.projection="string"==typeof e?an[e]?an[e]():an.geoMercator():e,this):this.schema.projection},t.projectionPadding=function(e){return arguments.length?(this.schema.projectionPadding=n.parseSides(e),this):this.schema.projectionPadding},t.projectionRotate=function(e){return arguments.length?(this.schema.projection.rotate(e),t.tiles(!1),this._zoomSet=!1,this):this.schema.projectionRotate}}
|
|
3663
|
+
/** Installs the tile fluent accessors. */(e),function(e){const t=e;t.tiles=function(e){if(arguments.length){this.schema.tiles=e;const t=on(this.schema.tileUrl);return e&&""===this.schema.attribution?this.schema.attribution=t:e||this.schema.attribution!==t||(this.schema.attribution=""),this}return this.schema.tiles},t.tileUrl=function(e){return arguments.length?(this.schema.tileUrl=e,this.schema.tiles&&(this.schema.attribution=on(e)),this._tileGroup&&this._renderTiles.bind(this)(),this):this.schema.tileUrl}}
|
|
3664
|
+
/** Installs the topojson fluent accessors. */(e),function(e){const t=e;t.topojson=function(e,t){return arguments.length?(s.addToQueue.bind(this)(e,t,"topojson"),this._zoomSet=!1,this):this.schema.topojson},t.topojsonFill=function(e){return arguments.length?(this.schema.topojsonFill="function"==typeof e?e:L(e),this):this.schema.topojsonFill},t.topojsonFilter=function(e){if(arguments.length){if(this._zoomSet=!1,"function"==typeof e)return this.schema.topojsonFilter=e,this;const t=e instanceof Array?e:[e];return this.schema.topojsonFilter=e=>t.includes(e.id),this}return this.schema.topojsonFilter},t.topojsonKey=function(e){return arguments.length?(this.schema.topojsonKey=e,this._zoomSet=!1,this):this.schema.topojsonKey},t.topojsonId=function(e){return arguments.length?(this.schema.topojsonId="function"==typeof e?e:F(e),this):this.schema.topojsonId}}(e)}const cn={name:"Geomap",features:[ee,Q,Z,ne],layoutStage:nn,emit:({viz:e})=>{const t=e.ctx.geomapCtx;if(!t)return[];const i=[];
|
|
3665
|
+
// The ocean rect and basemap tiles normally live in the imperative geomap
|
|
3666
|
+
// <svg> (`_container`), outside the scene graph. That's fine on-screen, but a
|
|
3667
|
+
// server render serializes only the scene, so under SSR (`viz._ssr`) — and on
|
|
3668
|
+
// the canvas backend, whose compute <svg> keeps its ocean transparent — paint
|
|
3669
|
+
// them into the scene here, beneath the geography, so the output is complete.
|
|
3670
|
+
if("canvas"===e._renderer||e._ssr){const t=e.schema.ocean;if(t&&"transparent"!==t){const{width:s,height:n}=le(e);i.push({type:"rect",key:"geomap-ocean",x:e._margin.left,y:e._margin.top,width:s,height:n,paint:{fill:t}})}}
|
|
3671
|
+
// Basemap tiles, pre-fetched + inlined as data URIs by @d3plus/ssr. Placed
|
|
3672
|
+
// above the ocean and below the geography, at the positions `_computeTileList`
|
|
3673
|
+
// derives from the fitted projection (same math as the live `_renderTiles`).
|
|
3674
|
+
const s=e._ssrTiles;if(s&&s.size&&"function"==typeof e._computeTileList)for(const t of e._computeTileList()){const e=s.get(t.key);e&&i.push({type:"image",key:`geomap-tile-${t.key}`,x:t.x,y:t.y,width:t.size,height:t.size,href:e,preserveAspectRatio:"none",interactive:!1})}if(t.topoData&&t.topoData.length){const s=Hi(e,"Path");for(let e=0;e<t.topoData.length;e++){const n=t.topoData[e],a=n.data??n,o=Ni(s,a,e);i.push({type:"path",key:`geomap-path-${n.id}`,d:t.pathFn(n),datum:a,
|
|
3593
3675
|
// Topojson geography is a data shape: keep its border stroke a constant
|
|
3594
3676
|
// screen width as the map zooms (v3 parity), rather than scaling with
|
|
3595
3677
|
// the zoom transform. Honors an explicit shapeConfig.vectorEffect.
|
|
@@ -3613,7 +3695,18 @@ chartTransform:()=>{},
|
|
|
3613
3695
|
// chart-cells group, so it stays fixed while pan/zoom moves the map beneath it.
|
|
3614
3696
|
chartClip:e=>{const{width:t,height:i}=le(e);return{type:"rect",x:e._margin.left,y:e._margin.top,width:t,height:i}},setup:e=>{const t=e;e.schema.zoom=!0,e._zoomSet=!1,e.schema.tiles=!0,e._tileGen=k.tile(),function(e){
|
|
3615
3697
|
// `_renderTiles` is a per-instance method that mutates the tile group.
|
|
3616
|
-
e._renderTiles=function(e=d.zoomTransform((this._zoomEventTarget||this._container).node()),t=0){
|
|
3698
|
+
e._renderTiles=function(e=d.zoomTransform((this._zoomEventTarget||this._container).node()),t=0){
|
|
3699
|
+
// Under SSR the basemap is composited into the scene graph (see geomapEmit +
|
|
3700
|
+
// `_computeTileList`), so skip the imperative <image> tile layer entirely.
|
|
3701
|
+
// It wouldn't be serialized anyway, and its transform transition relies on
|
|
3702
|
+
// SVGGElement.transform.baseVal, which headless DOMs don't implement.
|
|
3703
|
+
if(this._ssr)return;let i=[];this.schema.tiles&&(i=this._tileGen.extent(this._zoomBehavior.translateExtent()).scale(this.schema.projection.scale()*(2*Math.PI)*e.k).translate(e.apply(this.schema.projection.translate()))(),this._tileGroup.transition().duration(t).attr("transform",e));const s=this._tileGroup.selectAll("image.d3plus-geomap-tile").data(i,([e,t,i])=>`${e}-${t}-${i}`);s.exit().transition().duration(t).attr("opacity",0).remove();const n=i.scale/e.k,a=s.enter().append("image").attr("class","d3plus-geomap-tile");a.attr("opacity",0).transition().duration(t).attr("opacity",1),s.merge(a).attr("width",n).attr("height",n).attr("xlink:href",([e,t,i])=>this.schema.tileUrl.replace("{s}",["a","b","c"][3*Math.random()|0]).replace("{z}",`${i}`).replace("{x}",`${e}`).replace("{y}",`${t}`)).attr("x",([t])=>t*n+i.translate[0]*n-e.x/e.k).attr("y",([,t])=>t*n+i.translate[1]*n-e.y/e.k)},
|
|
3704
|
+
// Static (identity-transform) tile list for server-side rendering: the tile
|
|
3705
|
+
// URLs + their positions in projection pixel space, so @d3plus/ssr can fetch
|
|
3706
|
+
// them and geomapEmit can place them as scene image nodes (both SVG string and
|
|
3707
|
+
// canvas output then include the basemap, with no network at view time).
|
|
3708
|
+
// Deterministic `{s}` = "a" so tiles are cacheable across renders.
|
|
3709
|
+
e._computeTileList=function(){if(!this.schema.tiles)return[];const e=this._tileGen.extent(this._zoomBehavior.translateExtent()).scale(this.schema.projection.scale()*(2*Math.PI)).translate(this.schema.projection.translate())(),t=e.scale;return e.map(([i,s,n])=>({key:`${i}-${s}-${n}`,url:this.schema.tileUrl.replace("{s}","a").replace("{z}",`${n}`).replace("{x}",`${i}`).replace("{y}",`${s}`),x:i*t+e.translate[0]*t,y:s*t+e.translate[1]*t,size:t}))}}
|
|
3617
3710
|
/** Wraps `_draw` to ensure the DOM zoom group + zoom wiring exist before drawing. */(e),function(e){
|
|
3618
3711
|
// Wrap _draw to ensure DOM zoom group + zoom wiring.
|
|
3619
3712
|
const t=e._draw.bind(e);e._draw=function(i){
|
|
@@ -3627,7 +3720,7 @@ const t=e._draw.bind(e);e._draw=function(i){
|
|
|
3627
3720
|
// its zoomScroll/zoomPan disabling); clear any stale handler on the geomap
|
|
3628
3721
|
// svg so an ocean event isn't zoomed twice. (Canvas keeps its own target —
|
|
3629
3722
|
// the <canvas>, set in `_drawSceneToTarget`.)
|
|
3630
|
-
"canvas"!==e._renderer&&e._select&&(e._zoomEventTarget=e._select,e._container&&e._container.on(".zoom",null));const s=t(i),{width:n,height:a}=le(e);return
|
|
3723
|
+
"canvas"!==e._renderer&&e._select&&(e._zoomEventTarget=e._select,e._container&&e._container.on(".zoom",null));const s=t(i),{width:n,height:a}=le(e);return tn(e,{kind:"geomap",width:n,height:a,duration:e.schema.duration,
|
|
3631
3724
|
// On the canvas backend this imperative ocean rect lives in the compute
|
|
3632
3725
|
// <svg>, which overlays the <canvas> and would hide the geography. Keep
|
|
3633
3726
|
// it transparent there; geomapEmit paints the ocean into the scene (and
|
|
@@ -3642,29 +3735,32 @@ ocean:"canvas"===e._renderer?"transparent":e.schema.ocean}),e._zoomSet||(e._zoom
|
|
|
3642
3735
|
// interaction surface: CanvasRenderer's pick drives tooltips and d3-zoom
|
|
3643
3736
|
// drives pan/zoom on the same element. (On SVG this is a no-op — the scene
|
|
3644
3737
|
// svg already sits on top and handles both.)
|
|
3645
|
-
const s=e._drawSceneToTarget.bind(e);e._drawSceneToTarget=function(t){if(s(t),"canvas"===e._renderer
|
|
3738
|
+
const s=e._drawSceneToTarget.bind(e);e._drawSceneToTarget=function(t){if(s(t),"canvas"===e._renderer&&// Under SSR the canvas is a headless native surface with no
|
|
3739
|
+
// addEventListener; there is no interaction to wire, so skip the
|
|
3740
|
+
// pointer/zoom rebind entirely.
|
|
3741
|
+
!e._ssr&&e._sceneRenderer&&"function"==typeof e._sceneRenderer.toCanvas){const t=e._sceneRenderer.toCanvas();t&&(
|
|
3646
3742
|
// The compute svg is absolutely positioned over the canvas; an svg root
|
|
3647
3743
|
// hit-tests its whole box, so even an empty one swallows the canvas's
|
|
3648
3744
|
// pointer events. The canvas is the sole render + interaction surface in
|
|
3649
3745
|
// canvas mode, so make the entire compute svg transparent to events.
|
|
3650
|
-
e._select&&e._select.style("pointer-events","none"),e._container&&e._container.style("pointer-events","none"),e._zoomEventTarget=i.select(t),e.schema.zoom&&!e._brushing&&e._zoomEventTarget.call(e._zoomBehavior))}}}(e),
|
|
3746
|
+
e._select&&e._select.style("pointer-events","none"),e._container&&e._container.style("pointer-events","none"),e._zoomEventTarget=i.select(t),e.schema.zoom&&!e._brushing&&e._zoomEventTarget.call(e._zoomBehavior))}}}(e),rn(e),
|
|
3651
3747
|
// Seed the default tile URL through the wrapped accessor so attribution is set.
|
|
3652
|
-
t.tileUrl("https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}@2x.png")},ctx:{},fields:[{key:"fitObject",default:!1},{key:"noDataMessage",default:!1},{key:"ocean",default:"#d4dadc"},{key:"point",default:F("point")},{key:"pointSize",default:L(1)},{key:"pointSizeMax",default:10},{key:"pointSizeMin",default:5},{key:"pointSizeScale",default:"linear"},{key:"projection",default:
|
|
3748
|
+
t.tileUrl("https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}@2x.png")},ctx:{},fields:[{key:"fitObject",default:!1},{key:"noDataMessage",default:!1},{key:"ocean",default:"#d4dadc"},{key:"point",default:F("point")},{key:"pointSize",default:L(1)},{key:"pointSizeMax",default:10},{key:"pointSizeMin",default:5},{key:"pointSizeScale",default:"linear"},{key:"projection",default:an.geoMercator()},{key:"projectionPadding",default:n.parseSides(20)},{key:"shape",default:L("Circle"),coerce:"const"},{key:"topojson",default:!1},{key:"topojsonFill",default:L("#f5f5f3")},{key:"topojsonFilter",default:e=>!["010"].includes(e.id)},{key:"topojsonId",default:F("id")},{key:"shapeConfig",merge:!0,factory:e=>({ariaLabel:(t,i)=>`${e._drawLabel(t,i)}, ${e.schema.pointSize(t,i)}`,hoverOpacity:1,Path:{ariaLabel:(t,i)=>{const s=e.schema.colorScale,n=s?`, ${s(t,i)}`:"";return`${e._drawLabel(t,i)}${n}.`},fill:(t,i)=>{const s=e.ctx.coordData?.features??[],n=e.schema.colorScale;if(n&&!s.includes(t)){const i=n(t);if(null!=i){if(e._colorScaleClass._colorScale)return e._colorScaleClass._colorScale(i);let t=e._colorScaleClass.color();return t instanceof Array&&(t=t[t.length-1]),t}}return e.schema.topojsonFill(t,i)},on:{mouseenter:(t,i,s,n)=>(e.ctx.coordData?.features??[]).includes(t)?null:e.schema.on.mouseenter.bind(e)(t,i,s,n),"mousemove.shape":(t,i,s,n)=>(e.ctx.coordData?.features??[]).includes(t)?null:e.schema.on["mousemove.shape"].bind(e)(t,i,s,n),mouseleave:(t,i,s,n)=>(e.ctx.coordData?.features??[]).includes(t)?null:e.schema.on.mouseleave.bind(e)(t,i,s,n)},stroke:(t,i)=>{const s=e.schema.shapeConfig.Path,n="function"==typeof s.fill?s.fill(t,i):s.fill,a=c.color(n);return a?a.darker():n},strokeWidth:1},
|
|
3653
3749
|
// Coordinate points (Circles) leave a motion trail when they move
|
|
3654
3750
|
// between frames (e.g. Timeline play); opt out with Circle.trail: false.
|
|
3655
3751
|
Circle:{trail:!0}})}]};
|
|
3656
3752
|
/**
|
|
3657
3753
|
Creates a geographical map with zooming, panning, image tiles, and the ability to layer choropleth paths and coordinate points.
|
|
3658
|
-
*/var
|
|
3754
|
+
*/var hn=Ri(cn);
|
|
3659
3755
|
/**
|
|
3660
3756
|
Creates a line plot based on an array of data.
|
|
3661
3757
|
*/
|
|
3662
|
-
var
|
|
3758
|
+
var ln=Ri({name:"LinePlot",paintDriven:!0,features:[ee,Q,Z,ne],ctx:{},fields:[{key:"discrete",default:"x"},{key:"shape",default:L("Line"),coerce:"const"}]},Hs);
|
|
3663
3759
|
/**
|
|
3664
3760
|
@module matrixData
|
|
3665
3761
|
@private
|
|
3666
3762
|
*/
|
|
3667
|
-
function
|
|
3763
|
+
function dn(e){const t=this._filteredData,i=(this.schema.rowList||s.unique(t.map(this.schema.row))).sort(this.schema.rowSort),n=(this.schema.columnList||s.unique(t.map(this.schema.column))).sort(this.schema.columnSort);if(!i.length||!n.length)return{rowValues:[],columnValues:[],shapeData:[]};var a,o;return{rowValues:i,columnValues:n,shapeData:(a=i,o=n,[].concat(...a.map(e=>o.map(t=>[e,t])))).map(([e,i])=>{const s={__d3plusTooltip__:!0,__d3plus__:!0,column:i,row:e},n=t.findIndex((t,s)=>this.schema.row(t,s)===e&&this.schema.column(t,s)===i);return n>=0?(s.i=n,s.data=t[n]):s.data={row:e,column:i},s})}}const un=({viz:e})=>{const t=dn.bind(e)(e._filteredData),{rowValues:i,columnValues:s,shapeData:n}=t;if(!i.length||!s.length)return{shapeData:[]};const{width:a,height:o}=le(e),r=a/s.length<120||void 0;
|
|
3668
3764
|
// Force rotation when columns are too narrow for horizontal labels; otherwise
|
|
3669
3765
|
// pass `undefined` so the axis auto-rotates whenever its labels would overlap
|
|
3670
3766
|
// or truncate (forcing `false` here suppressed that and dropped long labels).
|
|
@@ -3679,27 +3775,27 @@ c.renderMode("compute").select(void 0).height(o-e._padding.bottom).maxSize(u).ra
|
|
|
3679
3775
|
/**
|
|
3680
3776
|
`matrixEmit` — Rect cells positioned by the row/column scales stashed
|
|
3681
3777
|
on `viz.ctx`.
|
|
3682
|
-
*/function
|
|
3778
|
+
*/function mn(e,t,i){return"function"==typeof e?e(t,i):e}const fn={align:"start",barConfig:{stroke:0},gridSize:0,padding:5,paddingInner:0,paddingOuter:0,scale:"band",tickSize:0},gn=(e,t)=>`${e}`.localeCompare(`${t}`),pn={name:"Matrix",features:[ee,Q,Z,ne],layoutStage:un,emit:({viz:e,shapeData:t})=>{const i=t??[];if(!i.length)return[];const s=e.ctx.columnScale,n=e.ctx.rowScale,a=e.ctx.cellWidth,o=e.ctx.cellHeight,r=e.schema.cellPadding??0,c=e.schema.shapeConfig??{};return i.map((e,t)=>{const i=mn(c.fill,e,t),h=mn(c.stroke,e,t),l=mn(c.strokeWidth,e,t),d=a-r,u=o-r;return{type:"rect",key:`matrix-${t}`,x:s(e.column)+a/2-d/2,y:n(e.row)+o/2-u/2,width:d,height:u,datum:e,paint:{fill:"string"==typeof i?i:void 0,stroke:h,strokeWidth:l}}})},chartTransform:e=>({x:0,y:e._margin.top}),setup:e=>{const t=e.schema.on["mousemove.shape"];e.schema.on["mousemove.shape"]=(i,s,n,a)=>{
|
|
3683
3779
|
// A colorScale swatch routes through the shape path but has no row/column,
|
|
3684
3780
|
// so its row/column hover would match nothing and wipe out the bucket
|
|
3685
3781
|
// highlight `mouseenter` already set. Leave that highlight in place.
|
|
3686
|
-
if(t(i,s,n,a),_e(n)||_e(i))return;const o=I.bind(e)("row",i,s),r=I.bind(e)("column",i,s);e.hover((t,i)=>(I.bind(e)("row",t,i)===o||I.bind(e)("column",t,i)===r)&&"number"==typeof e.schema.colorScale(t,i))}},ctx:{rowAxis:new Ct,columnAxis:new Ct},fields:[{key:"cellPadding",default:2},{key:"column",default:F("column"),coerce:e=>"function"==typeof e?e:F(e)},{key:"row",default:F("row"),coerce:e=>"function"==typeof e?e:F(e)},{key:"columnList"},{key:"rowList"},{key:"columnSort",default:
|
|
3782
|
+
if(t(i,s,n,a),_e(n)||_e(i))return;const o=I.bind(e)("row",i,s),r=I.bind(e)("column",i,s);e.hover((t,i)=>(I.bind(e)("row",t,i)===o||I.bind(e)("column",t,i)===r)&&"number"==typeof e.schema.colorScale(t,i))}},ctx:{rowAxis:new Ct,columnAxis:new Ct},fields:[{key:"cellPadding",default:2},{key:"column",default:F("column"),coerce:e=>"function"==typeof e?e:F(e)},{key:"row",default:F("row"),coerce:e=>"function"==typeof e?e:F(e)},{key:"columnList"},{key:"rowList"},{key:"columnSort",default:gn},{key:"rowSort",default:gn},{key:"rowConfig",merge:!0,default:{orient:"left",...fn}},{key:"columnConfig",merge:!0,default:{orient:"top",...fn}},{key:"label",coerce:"const",factory:e=>(t,i)=>`${I.bind(e)("row",t,i)} / ${I.bind(e)("column",t,i)}`}]};
|
|
3687
3783
|
/**
|
|
3688
3784
|
Creates a simple rows/columns Matrix view of any dataset.
|
|
3689
3785
|
*/
|
|
3690
|
-
var
|
|
3691
|
-
/** Resolves filtered data + schema nodes into laid-out node records (pre-layout). */function
|
|
3786
|
+
var yn=Ri(pn);
|
|
3787
|
+
/** Resolves filtered data + schema nodes into laid-out node records (pre-layout). */function _n(e){const i=e._filteredData.reduce((t,i,s)=>(t[e._id(i,s)]=i,t),{});let s=e.schema.nodes.reduce((i,s,n)=>(i[((i,s)=>`${e._id(i,s)||e.schema.nodeGroupBy[t.min([e._drawDepth,e.schema.nodeGroupBy.length-1])](i,s)}`)(s,n)]=s,i),{});const n=Array.from(new Set(Object.keys(i).concat(Object.keys(s)))).map((t,n)=>{const a=i[t],o=s[t];if(void 0===o)return!1;const r=(e,t=e=>void 0!==e)=>void 0!==a&&t(e(a))?e(a):e(o);return{__d3plus__:!0,data:a||o,i:n,id:t,fx:r(e._x,e=>!isNaN(e)),fy:r(e._y,e=>!isNaN(e)),node:o,r:e._size?r(e._size):e.schema.sizeMin,shape:r(e.schema.shape)}}).filter(e=>!!e);
|
|
3692
3788
|
// rawNodes was used above; drop to avoid retention.
|
|
3693
3789
|
return s={},n}
|
|
3694
|
-
/** Resolves schema links against nodes, stashing nodeLookup + linkLookup on ctx. */const
|
|
3790
|
+
/** Resolves schema links against nodes, stashing nodeLookup + linkLookup on ctx. */const xn=({viz:e})=>{const i=e,{width:s,height:n}=le(i);Array.isArray(i._filteredData)||(i._filteredData=[]),Array.isArray(i.schema.nodes)||(i.schema.nodes=[]),Array.isArray(i.schema.links)||(i.schema.links=[]);const a=_n(i),o=function(e,t){const i=t.reduce((e,t)=>(e[t.id]=t,e),{});e.ctx.nodeLookup=i;const s=new Map;for(const e of t)s.set(e.node,e);const n=e.schema.links.map(t=>{const n=typeof t.source;return{size:e.schema.linkSize(t),source:"number"===n?s.get(e.schema.nodes[t.source]):"string"===n?i[t.source]:i[t.source.id],target:"number"===n?s.get(e.schema.nodes[t.target]):"string"===n?i[t.target]:i[t.target.id]}});return e.ctx.linkLookup=n.reduce((e,t)=>(e[t.source.id]||(e[t.source.id]=[]),e[t.source.id].push(t.target),e[t.target.id]||(e[t.target.id]=[]),e[t.target.id].push(t.source),e),{}),n}
|
|
3695
3791
|
/** Runs the d3-force simulation, rotating results to the largest fitting rect. */(i,a);a.some(e=>void 0===e.fx||void 0===e.fy)&&function(e,i){const s=B.scaleLinear().domain(t.extent(i,e=>e.size)).range([.1,.5]),n=z.forceSimulation().force("link",z.forceLink(i).id(e=>e.id).distance(1).strength(e=>s(e.size)).iterations(4)).force("charge",z.forceManyBody().strength(-1)).stop(),a=1-Math.pow(.001,.01);n.velocityDecay(0),n.alphaMin(.001),n.alphaDecay(a),n.alphaDecay(0),n.nodes(e),n.tick(100).stop();const o=e.map(e=>[e.vx??0,e.vy??0]);let r=0,c=0,h=0;if(2===o.length)r=100;else if(o.length>2){const e=D.polygonHull(o)||[],t=p.largestRect(e,{verbose:!0});r=t.angle,c=t.cx,h=t.cy}e.forEach(e=>{const t=p.pointRotate([e.vx??0,e.vy??0],Math.PI/180*r*-1,[c,h]);e.fx=t[0],e.fy=t[1]})}
|
|
3696
3792
|
/** Positions nodes within bounds and assigns final r/width/height via a fitted radius scale. */(a,o);const r=function(e,i,s,n){const a=t.extent(i.map(e=>e.fx)),o=t.extent(i.map(e=>e.fy)),r=B.scaleLinear().domain(a).range([0,s]),c=B.scaleLinear().domain(o).range([0,n]),h=(a[1]-a[0])/(o[1]-o[0])||1,l=s/n;if(h>l){const e=n*l/h;c.range([(n-e)/2,n-(n-e)/2])}else{const e=s*h/l;r.range([(s-e)/2,s-(s-e)/2])}i.forEach(e=>{e.x=r(e.fx),e.y=c(e.fy)});const d=t.extent(i.map(e=>e.r));let u=e.schema.sizeMax||t.max([1,t.min(t.merge(i.map(e=>i.map(t=>e===t?null:p.pointDistance([e.x??0,e.y??0],[t.x??0,t.y??0])))))/2]);const m=B[`scale${e.schema.sizeScale.charAt(0).toUpperCase()}${e.schema.sizeScale.slice(1)}`]().domain(d).range([d[0]===d[1]?u:t.min([u/2,e.schema.sizeMin]),u]),f=r.domain(),g=c.domain(),y=f[1]-f[0],_=g[1]-g[0];i.forEach(e=>{const t=m(e.r)+3,i=e.x??0,s=e.y??0;f[0]>r.invert(i-t)&&(f[0]=r.invert(i-t)),f[1]<r.invert(i+t)&&(f[1]=r.invert(i+t)),g[0]>c.invert(s-t)&&(g[0]=c.invert(s-t)),g[1]<c.invert(s+t)&&(g[1]=c.invert(s+t))});const x=f[1]-f[0],b=g[1]-g[0];u*=t.min([y/x,_/b]),m.range([d[0]===d[1]?u:t.min([u/2,e.schema.sizeMin]),u]),r.domain(f),c.domain(g);const k=(h>l?s:n)/2;return i.forEach(e=>{e.x=r(e.fx),e.fx=e.x,e.y=c(e.fy),e.fy=e.y,e.r=m(e.r)||k,e.width=2*e.r,e.height=2*e.r}),m}
|
|
3697
|
-
/** Normalizes link stroke sizes onto the linkSizeScale, mutating each link's size. */(i,a,s,n);!function(e,i,s){const n=t.extent(i,e=>e.size);if(n[0]!==n[1]){const t=B[`scale${e.schema.linkSizeScale.charAt(0).toUpperCase()}${e.schema.linkSizeScale.slice(1)}`]().domain(n).range([e.schema.linkSizeMin,s.range()[0]]);i.forEach(e=>{e.size=t(e.size)})}}(i,o,r);const c=Hi(i,"Path",i.schema.shapeConfig,"edge");delete c.on;const h={label:e=>!!(a.length<=i.schema.dataCutoff||i._hover&&i._hover(e)||i._active&&i._active(e))&&i._drawLabel(e.data||e.node,e.i)},l=Array.from(t.groups(a,e=>e.shape));return i.ctx.networkCtx={links:o,linkConfig:c,linkD:e=>`M${e.source.x},${e.source.y} ${e.target.x},${e.target.y}`,nodeGroups:l,nodeShapeConfig:h},{shapeData:a}};function
|
|
3793
|
+
/** Normalizes link stroke sizes onto the linkSizeScale, mutating each link's size. */(i,a,s,n);!function(e,i,s){const n=t.extent(i,e=>e.size);if(n[0]!==n[1]){const t=B[`scale${e.schema.linkSizeScale.charAt(0).toUpperCase()}${e.schema.linkSizeScale.slice(1)}`]().domain(n).range([e.schema.linkSizeMin,s.range()[0]]);i.forEach(e=>{e.size=t(e.size)})}}(i,o,r);const c=Hi(i,"Path",i.schema.shapeConfig,"edge");delete c.on;const h={label:e=>!!(a.length<=i.schema.dataCutoff||i._hover&&i._hover(e)||i._active&&i._active(e))&&i._drawLabel(e.data||e.node,e.i)},l=Array.from(t.groups(a,e=>e.shape));return i.ctx.networkCtx={links:o,linkConfig:c,linkD:e=>`M${e.source.x},${e.source.y} ${e.target.x},${e.target.y}`,nodeGroups:l,nodeShapeConfig:h},{shapeData:a}};function bn(e,i,s){return`${e._id(i,s)||e.schema.nodeGroupBy[t.min([e._drawDepth,e.schema.nodeGroupBy.length-1])](i,s)}`}
|
|
3698
3794
|
/** Installs the `click.shape` handler that focuses/zooms a node + its links. */
|
|
3699
|
-
/** Installs the shape/legend/mouse event handlers that drive Network focus + hover. */function
|
|
3795
|
+
/** Installs the shape/legend/mouse event handlers that drive Network focus + hover. */function kn(e,t){!function(e,t){e.schema.on["click.shape"]=(i,s,n,a)=>{if(e._tooltipClass.data([]).render(),e._drawDepth>=e.schema.groupBy.length-1){const o=bn(e,i,s);if(e._focus&&e._focus===o)t.active(!1),e.schema.on.mouseenter.bind(e)(i,s,n,a),e._focus=void 0,e._zoomToBounds(null);else{t.hover(!1);const i=e.ctx.linkLookup[o]??[],s=e.ctx.nodeLookup[o],n=[o];let a=[s.x-s.r,s.x+s.r],r=[s.y-s.r,s.y+s.r];i.forEach(e=>{n.push(e.id),e.x-e.r<a[0]&&(a[0]=e.x-e.r),e.x+e.r>a[1]&&(a[1]=e.x+e.r),e.y-e.r<r[0]&&(r[0]=e.y-e.r),e.y+e.r>r[1]&&(r[1]=e.y+e.r)}),t.active((t,i)=>t.source&&t.target?t.source.id===o||t.target.id===o:n.includes(bn(e,t,i))),e._focus=o;const c=d.zoomTransform((e._zoomEventTarget||e._container).node());a=a.map(e=>e*c.k+c.x),r=r.map(e=>e*c.k+c.y),e._zoomToBounds([[a[0],r[0]],[a[1],r[1]]])}}}}
|
|
3700
3796
|
/** Installs the `click.legend` handler that focuses/zooms a legend group. */(e,t),function(e,t){e.schema.on["click.legend"]=(i,s,n,a)=>{const o=e._ids(i,s),r=o[o.length-1],c=e._id(i,s);if(e._drawDepth>=e.schema.groupBy.length-1){if(e._focus&&e._focus===c)t.active(!1),e._focus=void 0,e._zoomToBounds(null);else{t.hover(!1);const i=(Array.isArray(c)?c:[c]).map(t=>e.ctx.nodeLookup[String(t)]),s=[`${r}`];let n=[i[0].x-i[0].r,i[0].x+i[0].r],a=[i[0].y-i[0].r,i[0].y+i[0].r];i.forEach(e=>{s.push(e.id),e.x-e.r<n[0]&&(n[0]=e.x-e.r),e.x+e.r>n[1]&&(n[1]=e.x+e.r),e.y-e.r<a[0]&&(a[0]=e.y-e.r),e.y+e.r>a[1]&&(a[1]=e.y+e.r)}),t.active((t,i)=>{if(t.source&&t.target)return s.includes(t.source.id)&&s.includes(t.target.id);const n=e._ids(t,i);return s.includes(`${n[n.length-1]}`)}),e._focus=c;const o=d.zoomTransform((e._zoomEventTarget||e._container).node());n=n.map(e=>e*o.k+o.x),a=a.map(e=>e*o.k+o.y),e._zoomToBounds([[n[0],a[0]],[n[1],a[1]]])}e.schema.on.mouseenter.bind(e)(i,s,n,a),e.schema.on["mousemove.legend"].bind(e)(i,s,n,a)}}}
|
|
3701
|
-
/** Installs mouseenter/mouseleave/mousemove handlers that drive hover highlighting. */(e,t),function(e,t){e.schema.on.mouseenter=()=>{},e.schema.on["mouseleave.shape"]=()=>{t.hover(!1)};const i=e.schema.on["mousemove.shape"];e.schema.on["mousemove.shape"]=(s,n,a,o)=>{i(s,n,a,o);const r=
|
|
3702
|
-
/** Installs the per-instance fluent methods (links/nodes/nodeGroupBy/size/x/y/hover). */const
|
|
3797
|
+
/** Installs mouseenter/mouseleave/mousemove handlers that drive hover highlighting. */(e,t),function(e,t){e.schema.on.mouseenter=()=>{},e.schema.on["mouseleave.shape"]=()=>{t.hover(!1)};const i=e.schema.on["mousemove.shape"];e.schema.on["mousemove.shape"]=(s,n,a,o)=>{i(s,n,a,o);const r=bn(e,s,n),c=e.ctx.linkLookup[r]??[],h=e.ctx.nodeLookup[r],l=[r],d=[h.x-h.r,h.x+h.r],u=[h.y-h.r,h.y+h.r];c.forEach(e=>{l.push(e.id),e.x-e.r<d[0]&&(d[0]=e.x-e.r),e.x+e.r>d[1]&&(d[1]=e.x+e.r),e.y-e.r<u[0]&&(u[0]=e.y-e.r),e.y+e.r>u[1]&&(u[1]=e.y+e.r)}),t.hover((t,i)=>t.source&&t.target?t.source.id===r||t.target.id===r:l.includes(`${e._ids(t,i)[e._drawDepth]}`))}}(e,t)}
|
|
3798
|
+
/** Installs the per-instance fluent methods (links/nodes/nodeGroupBy/size/x/y/hover). */const vn={name:"Network",features:[ee,Q,Z,ne],layoutStage:xn,emit:({viz:e})=>{const t=e.ctx.networkCtx;if(!t)return[];const i=[];if(t.links&&t.links.length)for(let e=0;e<t.links.length;e++){const s=t.links[e],n=s,a=Ni(t.linkConfig,n,e);
|
|
3703
3799
|
// Link's strokeWidth comes from the layout-injected `d.size`.
|
|
3704
3800
|
"number"==typeof s.size&&(a.strokeWidth=s.size),i.push({type:"path",key:`network-link-${s.source.id??""}-${s.target.id??""}-${e}`,d:t.linkD(s),datum:n,paint:a})}if(t.nodeGroups&&t.nodeGroups.length)for(const[s,n]of t.nodeGroups){if(!n.length)continue;const a={...Hi(e,s),...t.nodeShapeConfig};for(let e=0;e<n.length;e++){const t=n[e],o=t.data??t,r=Ni(a,o,t.i??e);if(
|
|
3705
3801
|
// Nodes are data shapes: keep their stroke a constant screen width as the
|
|
@@ -3710,11 +3806,11 @@ void 0===r.vectorEffect&&(r.vectorEffect="non-scaling-stroke"),"Circle"===s)i.pu
|
|
|
3710
3806
|
}
|
|
3711
3807
|
// Labels via the chart-specific label fn. labelBounds is the
|
|
3712
3808
|
// shape's aes (r for circles, width/height for rects).
|
|
3713
|
-
const o=t.nodeShapeConfig.label;if(o){const e=
|
|
3809
|
+
const o=t.nodeShapeConfig.label;if(o){const e=Xs({data:n,label:(e,t)=>o(e,t),x:e=>e.x,y:e=>e.y,aes:e=>{const t=e;return"Circle"===s?{r:t.r,width:2*t.r,height:2*t.r}:{width:t.width??0,height:t.height??0}},rotate:L(0),id:e=>`network-label-${e.id}`,labelBounds:(e,t,i)=>{const n=i;if("Circle"===s){const e=n.r??0;return{width:1.5*e,height:1.5*e,x:.75*-e,y:.75*-e}}const a=n.width??0,o=n.height??0;return{width:a,height:o,x:-a/2,y:-o/2}},labelConfig:{...a.labelConfig??{fontResize:!0},fontColor:e=>{const t=e.data??e,i=Wi(a.fill,t.data??t,t.i??0);return u.colorContrast("string"==typeof i?i:"rgb(255, 255, 255)")}}});i.push(...e)}}return i},
|
|
3714
3810
|
// Network needs a real DOM element for d3-zoom binding; the hitArea click
|
|
3715
3811
|
// handler closes over class state. `setup` installs the event surface;
|
|
3716
3812
|
// `chartTransform` (default margin-origin) is fine for the scene.
|
|
3717
|
-
setup:e=>{const i=e;e.schema.zoom=!0,
|
|
3813
|
+
setup:e=>{const i=e;e.schema.zoom=!0,kn(e,i),
|
|
3718
3814
|
// `links()` / `nodes()` / `nodeGroupBy()` / `size()` / `x()` / `y()` /
|
|
3719
3815
|
// `hover()` need imperative method bodies (queue loading, aggs side
|
|
3720
3816
|
// effects). Install them per-instance.
|
|
@@ -3738,18 +3834,18 @@ const n=i._draw.bind(e);i._draw=function(t){
|
|
|
3738
3834
|
// with its zoomScroll/zoomPan disabling; clear the network svg's handlers
|
|
3739
3835
|
// so an event over the background isn't zoomed twice. (Canvas keeps the
|
|
3740
3836
|
// default target.)
|
|
3741
|
-
"canvas"!==e._renderer&&e._select&&(e._zoomEventTarget=e._select,e._container&&e._container.on(".zoom",null));const i=n(t),{width:s,height:a}=le(e);return
|
|
3837
|
+
"canvas"!==e._renderer&&e._select&&(e._zoomEventTarget=e._select,e._container&&e._container.on(".zoom",null));const i=n(t),{width:s,height:a}=le(e);return tn(e,{kind:"network",width:s,height:a,duration:e.schema.duration}),i}},ctx:{},fields:[{key:"links",default:[]},{key:"linkSize",default:L(1),coerce:e=>"function"==typeof e?e:L(e)},{key:"linkSizeMin",default:1},{key:"linkSizeScale",default:"sqrt"},{key:"noDataMessage",default:!1},{key:"nodeGroupBy",default:[F("id")]},{key:"tooltipConfig",merge:!0,factory:e=>({title:t=>t&&t.source&&t.target?`${t.source.id} → ${t.target.id}`:e._drawLabel(t,"number"==typeof t.i?t.i:0)})},{key:"nodes",default:[]},{key:"sizeMax"},{key:"sizeMin",default:5},{key:"sizeScale",default:"sqrt"},{key:"shape",default:L("Circle"),coerce:"const"},{key:"shapeConfig",merge:!0,factory:e=>({ariaLabel:(t,i)=>{const s=e._size,n=s?`, ${s(t,i)}`:"";return`${e._drawLabel(t,i)}${n}.`},labelConfig:{duration:0,fontMin:1,fontResize:!0,labelPadding:0,textAnchor:"middle",verticalAlign:"middle"},Path:{fill:"none",label:!1,stroke:"#eee"}})}]};
|
|
3742
3838
|
/**
|
|
3743
3839
|
Creates a network visualization based on a defined set of nodes and edges.
|
|
3744
|
-
*/var
|
|
3840
|
+
*/var Cn=Ri(vn);const Sn=({viz:e})=>{const t=e._filteredData;if(!t||!t.length)return{shapeData:[]};const i=e.schema.height-e._margin.top-e._margin.bottom,n=e.schema.width-e._margin.left-e._margin.right,a=Math.min(i,n),o=s.nestGroups(t,e.schema.groupBy.slice(0,e._drawDepth+1)),r=e.schema.packOpacity,c=e.ctx.pack.padding(e.schema.layoutPadding).size([a,a])(M.hierarchy({key:o.key,values:o},e=>e.values).sum(e.schema.sum).sort(e.schema.sort)).descendants().filter((e,t)=>{const i=e;i.__d3plus__=!0,i.i=t,i.id=i.parent?i.parent.data.key:"root";const s=i.data;return s.__d3plusOpacity__=i.height?r(s,t):1,s.__d3plusTooltip__=!i.height,!i.children||i.children.length>1});return e.ctx.packDiameter=a,e.ctx.packOffsetX=(n-a)/2,e.ctx.packOffsetY=(i-a)/2,{shapeData:c}};function wn(e,t,i){return"function"==typeof e?e(t,i):e}
|
|
3745
3841
|
/**
|
|
3746
3842
|
Walk a nested hierarchy, collecting every descendant into a flat array.
|
|
3747
3843
|
Used by Pack's hover handlers to highlight the subtree under a hovered
|
|
3748
3844
|
node.
|
|
3749
3845
|
*/
|
|
3750
|
-
function
|
|
3846
|
+
function zn(e,t=[]){return e.values?e.values.forEach(e=>{t.push(e),zn(e,t)}):t.push(e),t}const Dn={name:"Pack",features:[ee,Q,Z,ne],layoutStage:Sn,emit:({viz:e,shapeData:t})=>{const i=t??[];if(!i.length)return[];const s=e.schema.shapeConfig??{},n=(s.Circle??{}).label;
|
|
3751
3847
|
// Pack's per-shape config is nested under `Circle`.
|
|
3752
|
-
return[...i.map((e,t)=>{const i=e.data,n=
|
|
3848
|
+
return[...i.map((e,t)=>{const i=e.data,n=wn(s.fill,i,t),a=wn(s.stroke,i,t),o=wn(s.strokeWidth,i,t);return{type:"circle",key:`pack-${e.id}-${e.i}`,cx:e.x,cy:e.y,r:e.r,datum:i,paint:{fill:"string"==typeof n?n:void 0,stroke:a,opacity:i.__d3plusOpacity__,strokeWidth:o}}}),...Xs({data:i,label:(e,t)=>{const i=e;return!i.children&&(n?n(i.data,t):!!i.parent&&(i.data.id??!1))},x:e=>e.x,y:e=>e.y,
|
|
3753
3849
|
// Store the leaf's source row (not the d3-hierarchy node) as the label's
|
|
3754
3850
|
// `.data`, matching the circle node's datum (`d.data` above). Without this
|
|
3755
3851
|
// the label and its circle unwrap to different objects, so on hover the
|
|
@@ -3764,12 +3860,12 @@ setup:e=>{const t=e.hover.bind(e);e.hover=i=>(t(i),e.schema.legend&&e._legendCla
|
|
|
3764
3860
|
// Pack layers wrap-and-extend versions for the events that need
|
|
3765
3861
|
// pack-specific hover behavior. `merge` keeps Viz's other handlers
|
|
3766
3862
|
// intact.
|
|
3767
|
-
key:"on",merge:!0,factory:e=>{const t=e.schema.on["mousemove.legend"],i=e.schema.on["mousemove.shape"],s=t=>e.hover(t);return{mouseenter:()=>{},"mousemove.legend":(i,n,a,o)=>{t(i,n,a,o);const r=e._ids(i,n),c=
|
|
3863
|
+
key:"on",merge:!0,factory:e=>{const t=e.schema.on["mousemove.legend"],i=e.schema.on["mousemove.shape"],s=t=>e.hover(t);return{mouseenter:()=>{},"mousemove.legend":(i,n,a,o)=>{t(i,n,a,o);const r=e._ids(i,n),c=zn(i);s(e=>(Object.keys(e).filter(e=>"value"!==e).every(t=>{const s=i[t];return null!=s&&s.includes(e[t])})?c.push(e):r.includes(e.key)&&c.push(...zn(e,[e])),c.includes(e)))},"mousemove.shape":(e,t,n,a)=>{e.__d3plusTooltip__&&i(e,t,n,a);const o=zn(e,[e]);s(e=>o.includes(e))}}}}]};
|
|
3768
3864
|
/**
|
|
3769
3865
|
Uses the d3 pack layout to create a Circle Packing chart based on an array of data.
|
|
3770
|
-
*/var
|
|
3771
|
-
/** Greedy first-fit lane packer; mutates `d.lane` and returns total lane count. */const
|
|
3772
|
-
/** Runs both axes, pushes the axis scene, and stashes scales/bandWidth on `viz.ctx`. */function
|
|
3866
|
+
*/var Mn=Ri(Dn);
|
|
3867
|
+
/** Greedy first-fit lane packer; mutates `d.lane` and returns total lane count. */const An=({viz:e})=>{const i=e._filteredData;if(!i)return{shapeData:[]};const a=e.schema.start,o=e.schema.end,r=e._id,c=e.schema.axisConfig,h="time"===c?.scale,l=i.map((e,t)=>({__d3plus__:!0,data:e,end:h?n.date(o(e,t)):o(e,t),i:t,id:r(e,t),start:h?n.date(a(e,t)):a(e,t)})).filter(e=>Number(e.end)-Number(e.start)>0).sort((e,t)=>Number(e.start)-Number(t.start));let d;if(e.schema.groupBy.length>1&&e._drawDepth>0){const t=[];for(let i=0;i<e._drawDepth;i++)t.push(t=>e.schema.groupBy[i](t.data,t.i));d=s.nestGroups(l,t)}else d=[{values:l}];const u=(e=>{let t=0;return e.forEach(e=>{let i=[];e.values.forEach(e=>{i=i.map(t=>!(!1!==t&&t<=e.start)&&t);const s=i.indexOf(!1);s<0?(e.lane=t+i.length,i.push(e.end)):(i[s]=e.end,e.lane=t+s)}),t+=i.length}),t})(d);return((e,i,s)=>{const n={domain:[t.min(i,e=>Number(e.start))??0,t.max(i,e=>Number(e.end))??0],height:e.schema.height-e._margin.top-e._margin.bottom,width:e.schema.width-e._margin.left-e._margin.right},a=e.ctx.axisTest,o=e.ctx.axis;a.config(n).config(e.schema.axisConfig).measure(),o.config(n).config(e.schema.axisConfig).renderMode("compute").select(void 0).render();const r=o.toScene();var c;r&&((c=e)._chartScene||(c._chartScene=[])).push({type:"group",key:"priestley-axis",transform:{x:e._margin.left,y:e._margin.top},children:r.children??[]});const h=B.scaleBand().domain(t.range(0,s,1).map(String)).paddingInner(e.schema.paddingInner).paddingOuter(e.schema.paddingOuter).rangeRound([e.schema.height-e._margin.bottom-a.outerBounds().height-a.schema.padding,e._margin.top+a.schema.padding]);e.ctx.xScale=o._d3Scale,e.ctx.yScale=h,e.ctx.bandWidth=h.bandwidth()})(e,l,u),{shapeData:l}};
|
|
3868
|
+
/** Runs both axes, pushes the axis scene, and stashes scales/bandWidth on `viz.ctx`. */function $n(e,t,i){return"function"==typeof e?e(t,i):e}const Bn={name:"Priestley",features:[ee,Q,Z,ne],layoutStage:An,emit:({viz:e,shapeData:t})=>{const i=t??[];if(!i.length)return[];const s=e.ctx.xScale,n=e.ctx.yScale,a=e.ctx.bandWidth,o=e.schema.shapeConfig??{};return[...i.map((e,t)=>{const i=$n(o.fill,e.data,t),r=$n(o.stroke,e.data,t),c=$n(o.strokeWidth,e.data,t),h=Math.abs(s(e.end)-s(e.start)),l=h>2?h-2:h,d=s(e.start)+(s(e.end)-s(e.start))/2-l/2,u=(n(String(e.lane))??0)+a/2;return{type:"rect",shapeType:"Bar",key:`priestley-${e.id}-${t}`,transform:{x:d,y:u},x:0,y:-a/2,width:l,height:a,datum:e.data,paint:{fill:"string"==typeof i?i:void 0,stroke:r,strokeWidth:c}}}),...Xs({data:i,label:(t,s)=>e._drawLabel(i[s].data,s),x:(e,t)=>{const n=i[t];return s(n.start)+(s(n.end)-s(n.start))/2},y:(e,t)=>(n(String(i[t].lane))??0)+a/2,aes:(e,t)=>{const n=i[t],o=Math.abs(s(n.end)-s(n.start));return{width:o>2?o-2:o,height:a}},rotate:L(0),id:(e,t)=>`priestley-label-${i[t].id}-${t}`,labelBounds:(e,t,i)=>{const{width:s,height:n}=i;return{x:-s/2,y:-n/2,width:s,height:n}},labelConfig:{fontColor:e=>{const t=e.data??e,i=$n(o.fill,t.data,t.i);return u.colorContrast("string"==typeof i?i:"rgb(255, 255, 255)")},fontResize:!1,textAnchor:"start",verticalAlign:"top"}})]},
|
|
3773
3869
|
// Priestley positions in absolute scale coordinates — no chart transform.
|
|
3774
3870
|
chartTransform:()=>{},
|
|
3775
3871
|
// The default start/end accessors are functions, so the fields' `onSet`
|
|
@@ -3781,48 +3877,48 @@ const s="function"==typeof i?null:i;s&&!e.schema.aggs[s]&&(e.schema.aggs[s]=t.ma
|
|
|
3781
3877
|
/**
|
|
3782
3878
|
Creates a Priestley timeline based on an array of data.
|
|
3783
3879
|
*/
|
|
3784
|
-
var
|
|
3880
|
+
var Pn=Ri(Bn);const Tn=2*Math.PI,On=({viz:e})=>{const{width:n,height:a}=le(e),o=e.schema.outerPadding,r=e.schema.levels,c=e.schema.metric,h=e.schema.value,l=e.schema.axisConfig,d=(t.min([a,n])??0)/2-o,u=Math.max(0,d),m=e._filteredData,f=t.groups(m,c),g=t.groups(m,e._id,c),p=t.max(g.map(([,e])=>e.map(([,e])=>t.sum(e,(e,t)=>h(e,t)))).flat());if(!p)return e.ctx.groupData=[],e.ctx.pathConfig={},{shapeData:[]};
|
|
3785
3881
|
// Decorations: emitted as flat SceneNodes onto `_chartScene` (the
|
|
3786
3882
|
// chart-transformed group). Replaces the old `absorbShapeIntoChartScene`
|
|
3787
3883
|
// calls that span up transient `Circle`/`Rect`/`Path` instances in
|
|
3788
3884
|
// compute mode.
|
|
3789
3885
|
const y=Array.isArray(e._chartScene)?e._chartScene:e._chartScene=[],_=l.shapeConfig??{};((e,t,i,s,n)=>{const a=Hi(e,"Circle",i);delete a.label;
|
|
3790
3886
|
// Background concentric circles, one per level.
|
|
3791
|
-
const o=[];for(let e=0;e<s;e++){const t=n*((e+1)/s),i={id:e,r:t},r=Ni(a,i,e);o.push({type:"circle",key:`radar-radial-${e}`,cx:0,cy:0,r:t,datum:i,paint:r})}o.length&&t.push({type:"group",key:"radar-radial-circles",children:o})})(e,y,_,r,u);const x=e.schema.shapeConfig?.labelConfig,b=f.length,k=f.map(([t,i],n)=>{const a=2*(1.4*(x?.fontSize?.(i,n)??11)),r=o,c=parseInt(String(360-360/b*n/90),10)%4+1,h=
|
|
3887
|
+
const o=[];for(let e=0;e<s;e++){const t=n*((e+1)/s),i={id:e,r:t},r=Ni(a,i,e);o.push({type:"circle",key:`radar-radial-${e}`,cx:0,cy:0,r:t,datum:i,paint:r})}o.length&&t.push({type:"group",key:"radar-radial-circles",children:o})})(e,y,_,r,u);const x=e.schema.shapeConfig?.labelConfig,b=f.length,k=f.map(([t,i],n)=>{const a=2*(1.4*(x?.fontSize?.(i,n)??11)),r=o,c=parseInt(String(360-360/b*n/90),10)%4+1,h=Tn/b*n;let l=360/b*n,d="start",m=10;2!==c&&3!==c||(m=-r-10,d="end",l+=180);const f={x:m,y:-a/2,width:r,height:a};return{__d3plus__:!0,data:s.merge(i,e.schema.aggs),i:n,id:t,key:t,angle:l,textAnchor:d,labelBounds:f,rotateAnchor:[-m,a/2],x:u*Math.cos(h),y:u*Math.sin(h)}}).sort((e,t)=>Number(e.key)-Number(t.key));((e,t,i,s,n)=>{
|
|
3792
3888
|
// Axis labels: one TextNode per axis, positioned at the axis vertex,
|
|
3793
3889
|
// rotated to read along the spoke. The original code used a Rect with
|
|
3794
3890
|
// zero width/height + label; here we emit only labels.
|
|
3795
|
-
const a=
|
|
3891
|
+
const a=Xs({data:n,label:e=>e.id,x:e=>e.x,y:e=>e.y,aes:()=>({}),rotate:e=>e.angle||0,id:e=>e.id,labelBounds:e=>e.labelBounds,labelConfig:i.shapeConfig?.labelConfig??{}});a.length&&t.push({type:"group",key:"radar-axis-labels",children:a});
|
|
3796
3892
|
// Radial spokes: one Path from center to each axis vertex.
|
|
3797
|
-
const o=Hi(e,"Path",s),r=n.map((e,t)=>{const i=Ni(o,e,t);return{type:"path",key:`radar-spoke-${e.id}`,d:`M0,0 ${-e.x},${-e.y}`,datum:e,paint:i}});r.length&&t.push({type:"group",key:"radar-axis-spokes",children:r})})(e,y,l,_,k);const v=g.map(([i,n])=>{const a=n.map(([,e],i)=>{const s=t.sum(e,(e,t)=>h(e,t))/p*u,n=
|
|
3893
|
+
const o=Hi(e,"Path",s),r=n.map((e,t)=>{const i=Ni(o,e,t);return{type:"path",key:`radar-spoke-${e.id}`,d:`M0,0 ${-e.x},${-e.y}`,datum:e,paint:i}});r.length&&t.push({type:"group",key:"radar-axis-spokes",children:r})})(e,y,l,_,k);const v=g.map(([i,n])=>{const a=n.map(([,e],i)=>{const s=t.sum(e,(e,t)=>h(e,t))/p*u,n=Tn/b*i;return{x:s*Math.cos(n),y:s*Math.sin(n)}}),o=`M ${a[0].x} ${a[0].y} ${a.map(e=>`L ${e.x} ${e.y}`).join(" ")} L ${a[0].x} ${a[0].y}`,r=e.schema.aggs;return{__d3plus__:!0,arr:n.map(([,e])=>s.merge(e,r)),id:i,points:a,d:o,data:s.merge(n.map(([,e])=>s.merge(e,r)),r)}}),C=((e,s,n)=>{const a=Hi(e,"Path"),o=Object.keys(a.on??{});
|
|
3798
3894
|
// Event-handler wrappers: cursor → nearest polygon vertex resolution.
|
|
3799
|
-
a.on={};for(const r of o)a.on[r]=(a,o,c,h)=>{const l=a.points.map(e=>e.x+s/2),d=a.points.map(e=>e.y+n/2),u=i.pointer(h,e._select.node()),m=l.map(e=>Math.abs(e-u[0])),f=d.map(e=>Math.abs(e-u[1])),g=m.map((e,t)=>e+f[t]);e.schema.on[r].call(e,a.arr[g.indexOf(t.min(g))],o,c,h)};return a})(e,n,a);return e.ctx.groupData=v,e.ctx.pathConfig=C,{shapeData:v}},
|
|
3895
|
+
a.on={};for(const r of o)a.on[r]=(a,o,c,h)=>{const l=a.points.map(e=>e.x+s/2),d=a.points.map(e=>e.y+n/2),u=i.pointer(h,e._select.node()),m=l.map(e=>Math.abs(e-u[0])),f=d.map(e=>Math.abs(e-u[1])),g=m.map((e,t)=>e+f[t]);e.schema.on[r].call(e,a.arr[g.indexOf(t.min(g))],o,c,h)};return a})(e,n,a);return e.ctx.groupData=v,e.ctx.pathConfig=C,{shapeData:v}},Rn={name:"Radar",features:[ee,Q,Z,ne],layoutStage:On,emit:({viz:e})=>{const t=e.ctx.groupData,i=e.ctx.pathConfig;if(!t||!i||!t.length)return[];const s=[];for(let e=0;e<t.length;e++){const n=t[e],a=n.data??n,o=Ni(i,a,e);s.push({type:"path",key:`radar-${n.id}`,d:n.d,datum:a,paint:o})}return s},chartTransform:e=>{const{width:t,height:i}=le(e);return de(e,t,i)},ctx:{},fields:[{key:"discrete",default:"metric"},{key:"levels",default:6},{key:"metric",default:F("metric"),coerce:e=>"function"==typeof e?e:F(e)},{key:"outerPadding",default:100},{key:"shape",default:L("Path"),coerce:"const"},{key:"value",default:F("value"),coerce:e=>"function"==typeof e?e:F(e)},{key:"axisConfig",merge:!0,factory:e=>({shapeConfig:{fill:L("none"),labelConfig:{fontColor:()=>{const t=e._select?n.backgroundColor(e._select.node()):"rgb(255, 255, 255)";return u.colorContrast(t)},fontResize:!1,padding:0,textAnchor:e=>e.data?.textAnchor??"middle",verticalAlign:"middle"},stroke:()=>{const t=e._select?n.backgroundColor(e._select.node()):"rgb(255, 255, 255)";return u.colorContrast(t)},strokeWidth:L(1)}})}]};
|
|
3800
3896
|
/** Emits background concentric circles, one per level, onto `chartScene`. */
|
|
3801
3897
|
/**
|
|
3802
3898
|
Creates a radar visualization based on an array of data.
|
|
3803
3899
|
*/
|
|
3804
|
-
var
|
|
3900
|
+
var Ln=Ri(Rn);const En=2*Math.PI,Fn=({viz:e})=>{const{rowValues:i,columnValues:s,shapeData:n}=dn.bind(e)(e._filteredData),{width:a,height:o}=le(e);if(!i.length||!s.length)return e.ctx.radialMatrixWidth=a,e.ctx.radialMatrixHeight=o,{shapeData:[]};e.ctx.radialMatrixWidth=a,e.ctx.radialMatrixHeight=o;const r=100,c=(t.min([o-100,a-200])??0)/2,h=s.slice().reverse();h.unshift(h.pop());const l=h.length,d=h.map((e,t)=>{const i=t/l*En,s=Math.round(180*i/Math.PI),n=Math.floor((s+90)/90%4+1),a=[0,180].includes(s)?-50:[2,3].includes(n)?-100:0,o=[90,270].includes(s)?-25:[2,1].includes(n)?-50:0;return{key:e,angle:s,quadrant:n,radians:i,x:c*Math.sin(i+Math.PI)+a,y:c*Math.cos(i+Math.PI)+o}}),u=e.schema.columnConfig;((e,t,i,s,n)=>{const a=e.ctx.columnLabels;a.renderMode("compute").select(void 0).data(t).x(e=>e.x).y(e=>e.y).text(e=>e.key).width(i).height(s).config(n).render();const o=a.toScene();var r;o&&((r=e)._chartScene||(r._chartScene=[])).push({type:"group",key:"radialmatrix-columns",children:o.children??[]})})(e,u.labels instanceof Array?d.filter(e=>u.labels.includes(e.key)):d,r,50,u.shapeConfig?.labelConfig);const m=(0,e.schema.innerRadius)(c),f=(c-m)/i.length,g=d.length>1?d[1].radians-d[0].radians:En,p=i.slice().reverse(),y=new Map;p.forEach((e,t)=>y.set(e,t));const _=new Map;s.forEach((e,t)=>_.set(e,t));const x=e.schema.cellPadding,b=P.arc().padAngle(x/c).innerRadius(e=>m+(y.get(e.row)??0)*f+x/2).outerRadius(e=>m+((y.get(e.row)??0)+1)*f-x/2).startAngle(e=>d[_.get(e.column)??0].radians-g/2).endAngle(e=>d[_.get(e.column)??0].radians+g/2);return e.ctx.arcData=b,{shapeData:n}};
|
|
3805
3901
|
/** Renders the column-label TextBox in compute mode and absorbs it into `_chartScene`. */
|
|
3806
3902
|
/**
|
|
3807
3903
|
`radialMatrixEmit` — Path SceneNodes for each arc cell, using the
|
|
3808
3904
|
`arcData` generator stashed on `viz.ctx`.
|
|
3809
3905
|
*/
|
|
3810
|
-
function
|
|
3906
|
+
function Wn(e,t,i){return"function"==typeof e?e(t,i):e}const Nn=(e,t)=>`${e}`.localeCompare(`${t}`),Hn={name:"RadialMatrix",features:[ee,Q,Z,ne],layoutStage:Fn,emit:({viz:e,shapeData:t})=>{const i=t??[];if(!i.length)return[];const s=e.ctx.arcData,n=e.schema.shapeConfig??{};return i.map((t,i)=>{const a=Wn(n.fill,t,i),o=Wn(n.stroke,t,i),r=Wn(n.strokeWidth,t,i);return{type:"path",key:`rm-${e._ids(t,i).join("-")}`,d:s(t),datum:t,paint:{fill:"string"==typeof a?a:void 0,stroke:o,strokeWidth:r}}})},chartTransform:e=>de(e,e.ctx.radialMatrixWidth,e.ctx.radialMatrixHeight),setup:e=>{const t=e.schema.on["mousemove.shape"];e.schema.on["mousemove.shape"]=(i,s,n,a)=>{
|
|
3811
3907
|
// A colorScale swatch routes through the shape path but has no row/column,
|
|
3812
3908
|
// so its row/column hover would match nothing and wipe out the bucket
|
|
3813
3909
|
// highlight `mouseenter` already set. Leave that highlight in place.
|
|
3814
|
-
if(t(i,s,n,a),_e(n)||_e(i))return;const o=I.bind(e)("row",i,s),r=I.bind(e)("column",i,s);e.hover((t,i)=>I.bind(e)("row",t,i)===o||I.bind(e)("column",t,i)===r)}},ctx:{columnLabels:new Gt},fields:[{key:"cellPadding",default:2},{key:"column",default:F("column"),coerce:e=>"function"==typeof e?e:F(e)},{key:"row",default:F("row"),coerce:e=>"function"==typeof e?e:F(e)},{key:"columnList"},{key:"rowList"},{key:"columnSort",default:
|
|
3910
|
+
if(t(i,s,n,a),_e(n)||_e(i))return;const o=I.bind(e)("row",i,s),r=I.bind(e)("column",i,s);e.hover((t,i)=>I.bind(e)("row",t,i)===o||I.bind(e)("column",t,i)===r)}},ctx:{columnLabels:new Gt},fields:[{key:"cellPadding",default:2},{key:"column",default:F("column"),coerce:e=>"function"==typeof e?e:F(e)},{key:"row",default:F("row"),coerce:e=>"function"==typeof e?e:F(e)},{key:"columnList"},{key:"rowList"},{key:"columnSort",default:Nn},{key:"rowSort",default:Nn},{key:"innerRadius",default:e=>e/5,coerce:e=>"function"==typeof e?e:L(e)},{key:"columnConfig",merge:!0,factory:e=>({shapeConfig:{labelConfig:{fontColor:()=>{const t=e._select?n.backgroundColor(e._select.node()):"rgb(255, 255, 255)";return u.colorContrast(t)},padding:5,textAnchor:e=>[0,180].includes(e.angle)?"middle":[2,3].includes(e.quadrant)?"end":"start",verticalAlign:e=>[90,270].includes(e.angle)?"middle":[2,1].includes(e.quadrant)?"bottom":"top"}}})},{key:"label",coerce:"const",factory:e=>(t,i)=>`${I.bind(e)("row",t,i)} / ${I.bind(e)("column",t,i)}`}]};
|
|
3815
3911
|
/**
|
|
3816
3912
|
Creates a radial layout of a rows/columns Matrix of any dataset.
|
|
3817
3913
|
*/
|
|
3818
|
-
var
|
|
3914
|
+
var jn=Ri(Hn);
|
|
3819
3915
|
/** Shared empty `ringsCtx` value for the early-return branches. */
|
|
3820
3916
|
/**
|
|
3821
3917
|
Claim the center node + two rings, compute each node's angle/position, build
|
|
3822
3918
|
the radius scale, and size every node. Returns the rebuilt `nodes` array
|
|
3823
3919
|
plus the `primaries`/`secondaries` rings.
|
|
3824
3920
|
*/
|
|
3825
|
-
function
|
|
3921
|
+
function Gn(e,i,s,n,a,o){const{width:r,height:c,primaryRing:h,secondaryRing:l}=a;n.x=r/2,n.y=c/2,n.r=e.schema.sizeMin?t.max([e.schema.sizeMin,.65*h]):e.schema.sizeMax?t.min([e.schema.sizeMax,.65*h]):.65*h;const d=[n],u=[];(s[e.schema.center]||[]).forEach(t=>{const i=t.source.id===e.schema.center?t.target:t.source;i.edges=s[i.id].filter(t=>t.source.id!==e.schema.center||t.target.id!==e.schema.center),i.edge=t,d.push(i),u.push(i)}),u.sort((e,t)=>e.edges.length-t.edges.length);const m=[];let f=0;u.forEach(e=>{const t=e.id;e.edges=e.edges.filter(e=>!d.includes(e.source)&&e.target.id===t||!d.includes(e.target)&&e.source.id===t),f+=e.edges.length||1,e.edges.forEach(e=>{const{source:i,target:s}=e,n=s.id===t?i:s;d.push(n)})});const g=2*Math.PI;let p=0;u.forEach((e,t)=>{const i=e.edges,s=i.length||1,n=g/f*s;0===t&&(p-=n/2);const a=p+n/2-g/4;e.radians=a,e.x=r/2+h*Math.cos(a),e.y=c/2+h*Math.sin(a),p+=n,i.forEach((t,i)=>{const n=t.source.id===e.id?t.target:t.source,o=g/f,h=a-o*s/2+o/2+o*i;n.radians=h,n.x=r/2+l*Math.cos(h),n.y=c/2+l*Math.sin(h),m.push(n)})}),
|
|
3826
3922
|
/**
|
|
3827
3923
|
Build the radius scale from the size extent (or ring defaults) and assign
|
|
3828
3924
|
each ring node its `ring` + `r`. Mutates `center.r` and every ring node.
|
|
@@ -3831,7 +3927,7 @@ function(e,i,s,n,a,o){const{ringWidth:r}=s,c=r/2,h=r/4;let l=c/2-4;c/2-4<8&&(l=t
|
|
|
3831
3927
|
/**
|
|
3832
3928
|
Resolve link endpoints to placed nodes, compute bezier control points for
|
|
3833
3929
|
spline edges, and push every edge onto `edges` (mutated in place).
|
|
3834
|
-
*/(e,n,a,o,u,m);return{nodes:[n].concat(u).concat(m),primaries:u,secondaries:m}}const
|
|
3930
|
+
*/(e,n,a,o,u,m);return{nodes:[n].concat(u).concat(m),primaries:u,secondaries:m}}const In=({viz:e})=>{const i=e;if(Array.isArray(i._filteredData)||(i._filteredData=[]),Array.isArray(i.schema.nodes)||(i.schema.nodes=[]),Array.isArray(i.schema.links)||(i.schema.links=[]),!i._filteredData.length&&!i.schema.nodes.length&&!i.schema.links.length)return i.ctx.nodeLookup={},i.ctx.linkLookup={},i.ctx.ringsCtx={edges:[],nodeGroups:[],linkConfig:{},linkD:()=>"",nodeShapeConfig:{}},{viz:e};const s=i._filteredData.reduce((e,t,s)=>(e[i._id(t,s)]=t,e),{}),{nodeLookup:a,links:o,linkMap:r}=
|
|
3835
3931
|
/**
|
|
3836
3932
|
Build the Rings node set + link descriptors from filtered data and schema
|
|
3837
3933
|
nodes/links. Stashes `nodeLookup` on `viz.ctx` and returns the working
|
|
@@ -3849,17 +3945,17 @@ const n=a[s];if(n)return n;if(!isNaN(s)){const e=a[parseFloat(s)];if(e)return e}
|
|
|
3849
3945
|
// the raw value, then its coerced form.
|
|
3850
3946
|
let f=a[i.schema.center];if(f||null==i.schema.center||isNaN(i.schema.center)||(f=a[parseFloat(i.schema.center)]),!f)return i.ctx.ringsCtx={edges:[],nodeGroups:[],linkConfig:{},linkD:()=>"",nodeShapeConfig:{}},{viz:e};
|
|
3851
3947
|
// Normalize so downstream comparisons against node ids use the matched id.
|
|
3852
|
-
i.schema.center=f.id;const{nodes:g,primaries:p,secondaries:y}=
|
|
3948
|
+
i.schema.center=f.id;const{nodes:g,primaries:p,secondaries:y}=Gn(i,0,r,f,m,s);return function(e,t,i,s,n,a,o,r){const{width:c,height:h,ringWidth:l,primaryRing:d,secondaryRing:u}=o;i.forEach(e=>{const o=e.edge;["source","target"].forEach(e=>{o[e]=t.find(t=>t.id===o[e].id)}),r.push(o),n[e.id].forEach(n=>{const o=n.source.id===e.id?n.target:n.source;if(o.id===a.id)return;let m=s.find(e=>e.id===o.id);if(m||(m=i.find(e=>e.id===o.id)),!m)return;n.spline=!0;const f=c/2,g=h/2,p=d+.5*(u-d);["source","target"].forEach((i,s)=>{const a=n[i],o=a.radians,r=a.ring,c=a.x,h=a.y,d=a.r,u=2===r?o+Math.PI:o;n[`${i}X`]=c+Math.cos(u)*d,n[`${i}Y`]=h+Math.sin(u)*d,n[`${i}BisectX`]=f+p*Math.cos(o),n[`${i}BisectY`]=g+p*Math.sin(o),n[i]=t.find(e=>e.id===a.id);const y=n[i];void 0===y.edges&&(y.edges={});const _=0===s?n.target.id:n.source.id,x=y.edges;y.id===e.id?x[_]={angle:e.radians+Math.PI,radius:l/2}:x[_]={angle:m.radians,radius:l/2}}),r.push(n)})})}
|
|
3853
3949
|
/** Compute each node's label bounds, rotation, and text anchor (mutated in place). */(0,g,p,y,r,f,m,l),function(e,t,i){const{primaryRing:s,ringWidth:n}=i;t.forEach(t=>{if(t.id===e.schema.center)return void(t.labelBounds={x:-s/2,y:-s/2,width:s,height:s});const i=e.schema.shapeConfig.labelConfig,a=1.4*(i?.fontSize&&i.fontSize(t)||11),o=2*a,r=n-t.r;let c=t.radians*(180/Math.PI),h=t.r+5,l="start";(c<-90||c>90)&&(h=-t.r-r-5,l="end",c+=180),t.labelBounds={x:h,y:-a/2,width:r,height:o},t.rotate=c,t.textAnchor=l})}
|
|
3854
3950
|
/**
|
|
3855
3951
|
Build the link/node shape config + `linkD` accessor, scale link strokes, and
|
|
3856
3952
|
stash `linkLookup` + `ringsCtx` on `viz.ctx`.
|
|
3857
|
-
*/(i,g,m),function(e,i,s,a,o){e.ctx.linkLookup=a.reduce((e,t)=>(e[t.source.id]||(e[t.source.id]=[]),e[t.source.id].push(t.target),e[t.target.id]||(e[t.target.id]=[]),e[t.target.id].push(t.source),e),{});const r=t.extent(a,e=>e.size);if(r[0]!==r[1]){const s=t.min(i,e=>e.r),n=B[`scale${e.schema.linkSizeScale.charAt(0).toUpperCase()}${e.schema.linkSizeScale.slice(1)}`]().domain(r).range([e.schema.linkSizeMin,s]);a.forEach(e=>{e.size=n(e.size)})}const c=Hi(e,"Path",e.schema.shapeConfig,"edge");delete c.on;const h={label:t=>!!(i.length<=e.schema.dataCutoff||e._hover&&e._hover(t)||e._active&&e._active(t))&&e._drawLabel(t.data||t.node,t.i),labelBounds:e=>e.labelBounds,labelConfig:{fontColor:t=>{const i=t.data??t;if(i.id===e.schema.center){const t=Wi(Hi(e,i.key??i.shape).fill,i.data??i,i.i);return u.colorContrast("string"==typeof t?t:"rgb(255, 255, 255)")}return u.colorContrast(e._select?n.backgroundColor(e._select.node()):"rgb(255, 255, 255)")},fontResize:t=>(t.data??t).id===e.schema.center,padding:0,textAnchor:t=>{const i=t.data??t;return s[i.id]?.textAnchor||Hi(e,i.key??i.shape).labelConfig.textAnchor},verticalAlign:t=>(t.data??t).id===e.schema.center?"middle":"top"},rotate:e=>s[e.id].rotate||0},l=Array.from(t.groups(i,e=>e.shape));e.ctx.ringsCtx={edges:o,nodeGroups:l,linkConfig:c,linkD:e=>e.spline?`M${e.sourceX},${e.sourceY}C${e.sourceBisectX},${e.sourceBisectY} ${e.targetBisectX},${e.targetBisectY} ${e.targetX},${e.targetY}`:`M${e.source.x},${e.source.y} ${e.target.x},${e.target.y}`,nodeShapeConfig:h}}(i,g,a,o,l),{shapeData:g}};const
|
|
3953
|
+
*/(i,g,m),function(e,i,s,a,o){e.ctx.linkLookup=a.reduce((e,t)=>(e[t.source.id]||(e[t.source.id]=[]),e[t.source.id].push(t.target),e[t.target.id]||(e[t.target.id]=[]),e[t.target.id].push(t.source),e),{});const r=t.extent(a,e=>e.size);if(r[0]!==r[1]){const s=t.min(i,e=>e.r),n=B[`scale${e.schema.linkSizeScale.charAt(0).toUpperCase()}${e.schema.linkSizeScale.slice(1)}`]().domain(r).range([e.schema.linkSizeMin,s]);a.forEach(e=>{e.size=n(e.size)})}const c=Hi(e,"Path",e.schema.shapeConfig,"edge");delete c.on;const h={label:t=>!!(i.length<=e.schema.dataCutoff||e._hover&&e._hover(t)||e._active&&e._active(t))&&e._drawLabel(t.data||t.node,t.i),labelBounds:e=>e.labelBounds,labelConfig:{fontColor:t=>{const i=t.data??t;if(i.id===e.schema.center){const t=Wi(Hi(e,i.key??i.shape).fill,i.data??i,i.i);return u.colorContrast("string"==typeof t?t:"rgb(255, 255, 255)")}return u.colorContrast(e._select?n.backgroundColor(e._select.node()):"rgb(255, 255, 255)")},fontResize:t=>(t.data??t).id===e.schema.center,padding:0,textAnchor:t=>{const i=t.data??t;return s[i.id]?.textAnchor||Hi(e,i.key??i.shape).labelConfig.textAnchor},verticalAlign:t=>(t.data??t).id===e.schema.center?"middle":"top"},rotate:e=>s[e.id].rotate||0},l=Array.from(t.groups(i,e=>e.shape));e.ctx.ringsCtx={edges:o,nodeGroups:l,linkConfig:c,linkD:e=>e.spline?`M${e.sourceX},${e.sourceY}C${e.sourceBisectX},${e.sourceBisectY} ${e.targetBisectX},${e.targetBisectY} ${e.targetX},${e.targetY}`:`M${e.source.x},${e.source.y} ${e.target.x},${e.target.y}`,nodeShapeConfig:h}}(i,g,a,o,l),{shapeData:g}};const qn={name:"Rings",features:[ee,Q,Z,ne],layoutStage:In,emit:({viz:e})=>{const t=e.ctx.ringsCtx;if(!t)return[];const i=[];if(t.edges&&t.edges.length)for(let e=0;e<t.edges.length;e++){const s=t.edges[e],n=s,a=Ni(t.linkConfig,n,e);"number"==typeof s.size&&(a.strokeWidth=s.size),i.push({type:"path",key:`rings-link-${s.source.id}-${s.target.id}`,d:t.linkD(s),datum:n,paint:a})}if(t.nodeGroups&&t.nodeGroups.length){const s=t.nodeShapeConfig;for(const[n,a]of t.nodeGroups){if(!a.length)continue;const o={...Hi(e,n),...t.nodeShapeConfig};for(let e=0;e<a.length;e++){const t=a[e],r=t.data??t,c=Ni(o,r,t.i??e);
|
|
3858
3954
|
// Nodes are data shapes: keep their stroke a constant screen width as the
|
|
3859
3955
|
// diagram zooms (the edges above deliberately scale with the zoom).
|
|
3860
3956
|
void 0===c.vectorEffect&&(c.vectorEffect="non-scaling-stroke");const h=s.rotate?s.rotate(t):0,l=h?{x:t.x,y:t.y,rotate:h}:{x:t.x,y:t.y};if("Circle"===n)i.push({type:"circle",key:`rings-${n}-${t.id}`,cx:0,cy:0,r:t.r,datum:r,paint:c,transform:l});else if("Rect"===n){const s=Number(Wi(o.width,r,t.i??e)??2*t.r),a=Number(Wi(o.height,r,t.i??e)??2*t.r);i.push({type:"rect",key:`rings-${n}-${t.id}`,x:-s/2,y:-a/2,width:s,height:a,datum:r,paint:c,transform:l})}
|
|
3861
3957
|
// Other shape kinds: skipped (Rings's default is Circle).
|
|
3862
|
-
}if(s.label&&s.labelBounds){const e=s.label,t=s.labelBounds,n=
|
|
3958
|
+
}if(s.label&&s.labelBounds){const e=s.label,t=s.labelBounds,n=Xs({data:a,label:(t,i)=>e(t,i),x:e=>e.x,y:e=>e.y,aes:e=>({r:e.r}),rotate:e=>s.rotate?s.rotate(e):0,id:e=>`rings-label-${e.id}`,labelBounds:(e,i)=>t(e),labelConfig:s.labelConfig??{}});i.push(...n)}}}return i},setup:e=>{!
|
|
3863
3959
|
/** Installs Rings' nodes/links/size/hover fluent accessors onto the instance. */function(e){const t=e,i=(e,t,i,n)=>s.addToQueue.bind(e)(t,i,n);t.links=function(e,t){return arguments.length?(i(this,e,t,"links"),this):this.schema.links},t.nodes=function(e,t){return arguments.length?(i(this,e,t,"nodes"),this):this.schema.nodes},t.linkSize=function(e){return arguments.length?(this.schema.linkSize="function"==typeof e?e:L(e),this):this.schema.linkSize},t.nodeGroupBy=function(e){if(!arguments.length)return this.schema.nodeGroupBy;const t=e instanceof Array?e:[e];return this.schema.nodeGroupBy=t.map(e=>"function"==typeof e?e:(this.schema.aggs[e]||(this.schema.aggs[e]=(e,t)=>{const i=Array.from(new Set(e.map(t)));return 1===i.length?i[0]:i}),F(e))),this},t.size=function(e){return arguments.length?(this._size="function"!=typeof e&&e?F(e):e,this):this._size},t.hover=function(e){const t=e;return this._hover=e,this._shapes.forEach(e=>e.hover(t)),this.schema.legend&&this._legendClass.hover(t),
|
|
3864
3960
|
// Scene-emit charts dim via applyInteractionOpacity during toScene(); a
|
|
3865
3961
|
// hover change only takes effect once a repaint is scheduled.
|
|
@@ -3874,7 +3970,7 @@ e.hover?.(!1),e._tooltipClass?.data([]).render(),e.schema.center=t.id,e._margin=
|
|
|
3874
3970
|
e._sceneRenderer&&e._drawSceneToTarget(e.schema.duration)}},ctx:{},fields:[{key:"center"},{key:"tooltipConfig",merge:!0,factory:e=>({title:t=>{const i=t;return t&&i.source&&i.target?`${i.source.id} → ${i.target.id}`:e._drawLabel(t,"number"==typeof t.i?t.i:0)}})},{key:"links",default:[]},{key:"linkSize",default:L(1)},{key:"linkSizeMin",default:1},{key:"linkSizeScale",default:"sqrt"},{key:"noDataMessage",default:!1},{key:"nodes",default:[]},{key:"sizeMax"},{key:"sizeMin",default:5},{key:"sizeScale",default:"sqrt"},{key:"shape",default:L("Circle"),coerce:"const"},{key:"shapeConfig",merge:!0,factory:e=>({ariaLabel:(t,i)=>{const s=e._size,n=s?`, ${s(t,i)}`:"";return`${e._drawLabel(t,i)}${n}.`},labelConfig:{duration:0,fontMin:1,fontResize:!0,labelPadding:0,textAnchor:"middle",verticalAlign:"middle"},Path:{fill:"none",label:!1,stroke:"#eee",strokeWidth:1}})}]};
|
|
3875
3971
|
/**
|
|
3876
3972
|
Creates a ring visualization based on a defined set of nodes and edges.
|
|
3877
|
-
*/var
|
|
3973
|
+
*/var Yn=Ri(qn);const Kn=({viz:e})=>{const i=e,{width:s,height:n}=le(i),a=Array.isArray(i.schema.nodes)&&i.schema.nodes.length>0,o=Array.isArray(i.schema.links)&&i.schema.links.length>0;if(!a&&!o)return i.ctx.nodeLookup={},i.ctx.linkLookup={},{viz:e};let r;if(a)r=i.schema.nodes;else{const e=new Set,t=[];for(const s of i.schema.links){const n=s[i.schema.linksSource];e.has(n)||(e.add(n),t.push(n));const a=s[i.schema.linksTarget];e.has(a)||(e.add(a),t.push(a))}r=t.map(e=>({id:e}))}const c=r.map((e,t)=>({__d3plus__:!0,data:e,i:t,id:i.schema.nodeId(e,t),node:e,shape:"Rect"})),h=c.reduce((e,t,i)=>(e[String(t.id)]=i,e),{});i.ctx.nodeLookup=h;const l=o?i.schema.links.map((e,t)=>({source:h[String(e[i.schema.linksSource])],target:h[String(e[i.schema.linksTarget])],value:i.schema.value(e,t)})):[];i.ctx.linkLookup=l.reduce((e,t)=>(e[t.source]||(e[t.source]=[]),e[t.source].push(t.target),e[t.target]||(e[t.target]=[]),e[t.target].push(t.source),e),{}),i.ctx.sankey.nodeAlign(i.schema.nodeAlign).nodePadding(i.schema.nodePadding).nodeWidth(i.schema.nodeWidth).nodes(c).nodeSort(i.schema.nodeSort).links(l).linkSort(i.schema.linkSort).iterations(i.schema.iterations).size([s,n])();const d=Array.from(t.groups(c,e=>e.shape));return i.ctx.sankeyCtx={links:l,nodeGroups:d,pathFn:i.ctx.path},{shapeData:c}},Vn={center:A.sankeyCenter,justify:A.sankeyJustify,left:A.sankeyLeft,right:A.sankeyRight},Xn={name:"Sankey",features:[ee,Q,Z,ne],layoutStage:Kn,emit:({viz:e})=>{const t=e.ctx.sankeyCtx;if(!t)return[];const i=[],s=e.schema.shapeConfig?.Path??{};
|
|
3878
3974
|
// Sankey's link config is the raw `viz.schema.shapeConfig.Path` (no
|
|
3879
3975
|
// configPrep wrap) because links are raw `{source, target, value}`
|
|
3880
3976
|
// records — not d3plus-wrapped.
|
|
@@ -3883,7 +3979,7 @@ if(t.links&&t.links.length)for(let e=0;e<t.links.length;e++){const n=t.links[e],
|
|
|
3883
3979
|
}}return i},setup:e=>{const t=e;e.schema.on.mouseenter=()=>{},e.schema.on["mouseleave.shape"]=()=>{t.hover(!1)};const i=e.schema.on["mousemove.shape"];e.schema.on["mousemove.shape"]=(s,n,a,o)=>{if(i(s,n,a,o),e._focus&&e._focus===s.id)return t.hover(!1),e.schema.on.mouseenter.bind(e)(s,n,a,o),void(e._focus=void 0);
|
|
3884
3980
|
// An edge datum is a `{source, target}` link, not a node — highlight the
|
|
3885
3981
|
// hovered link plus its two endpoint nodes.
|
|
3886
|
-
const r=s;if(r.source&&r.target){const i=r.source.id,s=r.target.id;return void t.hover((t,n)=>{if(t.source&&t.target)return t.source.id===i&&t.target.id===s;const a=e.schema.nodeId(t,n);return a===i||a===s})}const c=e.schema.nodeId(s,n),h=e.ctx.nodeLookup[String(c)],l=e.ctx.nodeLookup,d=Object.keys(l).reduce((e,t)=>(e[l[t]]=isNaN(Number(t))?t:parseInt(t,10),e),{}),u=e.ctx.linkLookup[h]??[],m=[c];u.forEach(e=>m.push(d[e])),t.hover((t,i)=>t.source&&t.target?t.source.id===c||t.target.id===c:m.includes(e.schema.nodeId(t,i)))},t.links=function(e,t){return arguments.length?(s.addToQueue.bind(this)(e,t,"links"),this):this.schema.links},t.nodes=function(e,t){return arguments.length?(s.addToQueue.bind(this)(e,t,"nodes"),this):this.schema.nodes},t.nodeAlign=function(e){return arguments.length?(this.schema.nodeAlign="function"==typeof e?e:
|
|
3982
|
+
const r=s;if(r.source&&r.target){const i=r.source.id,s=r.target.id;return void t.hover((t,n)=>{if(t.source&&t.target)return t.source.id===i&&t.target.id===s;const a=e.schema.nodeId(t,n);return a===i||a===s})}const c=e.schema.nodeId(s,n),h=e.ctx.nodeLookup[String(c)],l=e.ctx.nodeLookup,d=Object.keys(l).reduce((e,t)=>(e[l[t]]=isNaN(Number(t))?t:parseInt(t,10),e),{}),u=e.ctx.linkLookup[h]??[],m=[c];u.forEach(e=>m.push(d[e])),t.hover((t,i)=>t.source&&t.target?t.source.id===c||t.target.id===c:m.includes(e.schema.nodeId(t,i)))},t.links=function(e,t){return arguments.length?(s.addToQueue.bind(this)(e,t,"links"),this):this.schema.links},t.nodes=function(e,t){return arguments.length?(s.addToQueue.bind(this)(e,t,"nodes"),this):this.schema.nodes},t.nodeAlign=function(e){return arguments.length?(this.schema.nodeAlign="function"==typeof e?e:Vn[e],this):this.schema.nodeAlign},t.nodeId=function(e){return arguments.length?(this.schema.nodeId="function"==typeof e?e:F(e),this):this.schema.nodeId},t.value=function(e){return arguments.length?(this.schema.value="function"==typeof e?e:F(e),this):this.schema.value},t.hover=function(e){return this._hover=e,(this._shapes??[]).forEach(t=>t.hover(e)),this.schema.legend&&this._legendClass&&this._legendClass.hover(e),
|
|
3887
3983
|
// Scene-rendered Sankey emits into `_chartScene`, not `_shapes`, so the
|
|
3888
3984
|
// forEach above can't dim anything. Repaint so the scene's
|
|
3889
3985
|
// interaction-opacity pass re-reads `_hover` and dims non-matching nodes.
|
|
@@ -3892,13 +3988,13 @@ this._sceneRenderer&&this._scheduleSceneRepaint(),this}},ctx:{sankey:A.sankey(),
|
|
|
3892
3988
|
/**
|
|
3893
3989
|
Creates a Sankey visualization based on a defined set of nodes and links.
|
|
3894
3990
|
*/
|
|
3895
|
-
var
|
|
3991
|
+
var Un=Ri(Xn);
|
|
3896
3992
|
/**
|
|
3897
3993
|
Creates a stacked area plot based on an array of data.
|
|
3898
3994
|
*/
|
|
3899
|
-
var
|
|
3900
|
-
/** Merge a branch's leaf values (recursively) through the schema aggs. */function
|
|
3901
|
-
/** Run the d3-hierarchy tree layout, flatten branch aggregations, and tag nodes. */function
|
|
3995
|
+
var Jn=Ri({name:"StackedArea",paintDriven:!0,features:[ee,Q,Z,ne],ctx:{},fields:[{key:"stacked",default:!0}]},js);
|
|
3996
|
+
/** Merge a branch's leaf values (recursively) through the schema aggs. */function Qn(e,t){return s.merge(t.values.map(t=>t.key&&t.values?Qn(e,t):t),e.schema.aggs)}
|
|
3997
|
+
/** Run the d3-hierarchy tree layout, flatten branch aggregations, and tag nodes. */function Zn(e,t,i){const n=e.ctx.tree.separation(e.schema.separation).size([t,i])(M.hierarchy({key:"root",values:s.nest(e._filteredData,e.schema.groupBy.slice(0,e._drawDepth+1))},e=>e.key&&e.values?e.values:null).sort(e.schema.sort)).descendants().filter(t=>(t.depth??0)<=e.schema.groupBy.length&&!!t.parent);return n.forEach((t,i)=>{const s=t.data;s.key&&s.values&&(t.data=Qn(e,s)),t.__d3plus__=!0,t.i=i,
|
|
3902
3998
|
// The tooltip binds the unwrapped row, so the per-node hierarchy depth
|
|
3903
3999
|
// (needed to label the node at its own level) must live on the row.
|
|
3904
4000
|
// Mirrors Treemap stamping `share`/`rank` onto `d.data`.
|
|
@@ -3906,7 +4002,7 @@ t.data.depth=t.depth}),n}
|
|
|
3906
4002
|
/**
|
|
3907
4003
|
Measure label height + per-depth label widths, then rescale y coordinates.
|
|
3908
4004
|
Stashes `labelHeight`/`labelWidths` on `viz.ctx`.
|
|
3909
|
-
*/const
|
|
4005
|
+
*/const ea=({viz:e})=>{const i=e.schema.orient,a="vertical"===i,o="horizontal"===i,r=a?e.schema.height-e._margin.top-e._margin.bottom:e.schema.width-e._margin.left-e._margin.right,c=o?e.schema.height-e._margin.top-e._margin.bottom:e.schema.width-e._margin.left-e._margin.right,h=a?"left":"top",d=Zn(e,c,r),{labelHeight:u,labelWidths:m}=function(e,i,n,a,o,r,c){let h=e.schema.shapeConfig.r;if("function"!=typeof h){const e=h;h=()=>e}const d=t.max(i,e=>1===e.depth?h(e.data,e.i):0),u=t.max(i,e=>e.children?0:h(e.data,e.i)),m=t.extent(i,e=>e.y),f=t.min([n?50:100,(m[1]-d-u)/(e.schema.groupBy.length+1)]);e.ctx.labelHeight=f;const g=s.nest(i,e=>e.depth).map(i=>{const s=i.values;return s.reduce((i,n,a)=>{const r=a<s.length-1?s[a+1].x:o+e._margin[c],h=a?s[a-1].x:e._margin[c];return t.min([i,r-n.x,n.x-h])},o)});e.ctx.labelWidths=g;const p=l.scaleLinear().domain(m).range([d+f,r-u-f]);return i.forEach(e=>{const t=p(e.y);a?(e.y=e.x,e.x=t):e.y=t}),{labelHeight:f,labelWidths:g}}
|
|
3910
4006
|
/** Build the per-shape config object consumed by the Tree's shape emit. */(e,d,a,o,c,r,h);
|
|
3911
4007
|
/**
|
|
3912
4008
|
Build link descriptors + per-shape groupings and stash
|
|
@@ -3920,15 +4016,15 @@ e.ctx.linksData=h,e.ctx.linkD=e=>{let t=c.r;"function"==typeof t&&(t=t(e.data,e.
|
|
|
3920
4016
|
kind (`type`, geometry coords) plus an `aes` record used by
|
|
3921
4017
|
labelBounds. The position of the shape is taken from the node datum's
|
|
3922
4018
|
`x` and `y` (Tree layout sets these on every TreeNode).
|
|
3923
|
-
*/function
|
|
4019
|
+
*/function ta(e,t,i){const s=t.data??t,n=t.i??0,a=t.x??0,o=t.y??0;switch(e){case"Circle":{const e=Number(Wi(i.r,s,n)??0);return{geom:{type:"circle",cx:a,cy:o,r:e},aes:{r:e}}}case"Rect":{const e=Number(Wi(i.width,s,n)??0),t=Number(Wi(i.height,s,n)??0);return{geom:{type:"rect",x:a-e/2,y:o-t/2,width:e,height:t},aes:{width:e,height:t}}}case"Path":return{geom:{type:"path",d:String(Wi(i.d,s,n)??"")},aes:{}};default:return null}}const ia={name:"Tree",features:[ee,Q,Z,ne],layoutStage:ea,emit:({viz:e})=>{const t=e.ctx.linksData,i=e.ctx.linkD,s=e.ctx.shapeGroups,n=e.ctx.shapeConfig;if(!s||!n)return[];const a=[];
|
|
3924
4020
|
// Links (Path nodes between parent and child).
|
|
3925
4021
|
if(t&&t.length&&i){const s=Hi(e,"Path");for(let n=0;n<t.length;n++){const o=t[n],r=o.data??o,c=Ni(s,r,n),h=e._ids(r,n)[(o.depth??1)-1],l=o.x??0,d=o.y??0;a.push({type:"path",key:`tree-link-${h}`,d:i(o),datum:r,paint:c,transform:{x:l,y:d}})}}
|
|
3926
4022
|
// Per-shape-kind node groups.
|
|
3927
4023
|
for(const{key:t,values:i}of s){if(!i.length)continue;const s={...Hi(e,t),...n},o=i;
|
|
3928
4024
|
// Chart-specific shapeConfig overrides (label, labelBounds, etc.).
|
|
3929
|
-
for(let e=0;e<o.length;e++){const i=o[e],r=i.data??i,c=
|
|
4025
|
+
for(let e=0;e<o.length;e++){const i=o[e],r=i.data??i,c=ta(t,i,s);if(!c)continue;const h=n.id(i,e),l=Ni(s,r,e);a.push({...c.geom,key:`tree-${t}-${h}`,datum:r,paint:l})}
|
|
3930
4026
|
// Labels via the chart-specific labelBounds/label/labelConfig.
|
|
3931
|
-
const r=
|
|
4027
|
+
const r=Xs({data:o,label:(e,t)=>n.label(e,t),x:e=>e.x??0,y:e=>e.y??0,aes:e=>ta(t,e,s)?.aes??{},rotate:L(0),id:(e,t)=>n.id(e,t),labelBounds:(e,t,i)=>n.labelBounds(e,t,i),labelConfig:n.labelConfig});a.push(...r)}return a},ctx:{tree:M.tree(),previousShapes:[]},fields:[{key:"orient",default:"vertical"},{key:"separation",default:(e,t)=>e.parent===t.parent?1:2},{key:"shape",default:L("Circle"),coerce:"const"},{key:"shapeConfig",merge:!0,factory:e=>({ariaLabel:(t,i)=>(e.ctx.linksData&&e._chartScene,e._drawLabel(t,i)),labelConfig:{fontColor:()=>{const t=e._select?n.backgroundColor(e._select.node()):"rgb(255, 255, 255)";return u.colorContrast(t)}},Path:{fill:"none",stroke:u.colorDefaults.missing,strokeWidth:2},r:L(7),width:L(12),height:L(12)})},{key:"tooltipConfig",merge:!0,factory:e=>({
|
|
3932
4028
|
// The Tooltip calls `title(d, i)` with the bound row; the node's
|
|
3933
4029
|
// hierarchy depth is stamped onto that row in applyTreeLayout, so the
|
|
3934
4030
|
// label resolves at the node's own level rather than the leaf level.
|
|
@@ -3936,25 +4032,25 @@ title:(t,i)=>e._drawLabel(t,i,(t.depth??1)-1)})},{key:"legendTooltip",merge:!0,f
|
|
|
3936
4032
|
/**
|
|
3937
4033
|
Uses d3's tree layout to create a tidy tree chart based on an array of data.
|
|
3938
4034
|
*/
|
|
3939
|
-
var
|
|
4035
|
+
var sa=Ri(ia);const na=({viz:e})=>{const t=e._filteredData;if(!t||!t.length)return{shapeData:[]};const{width:i,height:n}=le(e),a=s.nestGroups(t,e.schema.groupBy.slice(0,e._drawDepth+1)),o=M.hierarchy({values:a},e=>e.values).sum(e.schema.sum).sort(e.schema.sort),r=e.ctx.treemap.padding(e.schema.layoutPadding).size([i,n]).tile(e.schema.tile)(o),c=[];r.children&&function i(n){for(const a of n){if(a.depth<=e._drawDepth){i(a.children??[]);continue}const n=a.data,o=n.values??[],r=1===o.length?t.indexOf(o[0]):void 0,h=a;h.__d3plus__=!0,h.id=n.key,h.i=void 0!==r&&r>-1?r:void 0,
|
|
3940
4036
|
// Replace the wrapper branch with the merged source datum.
|
|
3941
4037
|
h.data=s.merge(o,e.schema.aggs),h.x=a.x0+(a.x1-a.x0)/2,h.y=a.y0+(a.y1-a.y0)/2,c.push(h)}}(r.children);
|
|
3942
4038
|
// Per-record rank — attached to the source datum so `ariaLabel` reads
|
|
3943
4039
|
// `d.rank` directly instead of indexOf'ing a viz-level array.
|
|
3944
|
-
const h=e.schema.sort;c.slice().sort(h).forEach((e,t)=>{e.data.rank=t});const l=r.value,d=e.schema.sum;return c.forEach(e=>{const t=d(e.data)/l;e.share=t,e.data.share=t}),{shapeData:c}};function
|
|
4040
|
+
const h=e.schema.sort;c.slice().sort(h).forEach((e,t)=>{e.data.rank=t});const l=r.value,d=e.schema.sum;return c.forEach(e=>{const t=d(e.data)/l;e.share=t,e.data.share=t}),{shapeData:c}};function aa(e,t,i){return"function"==typeof e?e(t,i):e}
|
|
3945
4041
|
/**
|
|
3946
4042
|
Walks `data` to `drawDepth` and merges entries whose `thresholdKey`
|
|
3947
4043
|
value falls below `threshold(branchData) * totalSum` into a single
|
|
3948
4044
|
aggregated row at that depth. Returns the kept set; original `data`
|
|
3949
4045
|
is not mutated.
|
|
3950
4046
|
*/
|
|
3951
|
-
function
|
|
4047
|
+
function oa(e,i){const{aggs:n,drawDepth:a,groupBy:o,threshold:r,thresholdKey:c}=i,h=t.sum(e,c);if(!r||!c)return e;
|
|
3952
4048
|
/**
|
|
3953
4049
|
Explores the data tree recursively and merges elements under
|
|
3954
4050
|
the indicated threshold.
|
|
3955
4051
|
*/return function e(i,l){if(l<a)return[...t.group(i,o[l])].reduce((t,[,i])=>{const s=e(i,l+1)??[];return t.concat(s)},[]);if(l===a){const e=Math.min(1,Math.max(0,r(i)));if(!isFinite(e)||isNaN(e))return null;
|
|
3956
4052
|
// Single-pass O(N) partition into kept + removed bucket.
|
|
3957
|
-
const t=[],a=[],o=e*h;for(let e=0;e<i.length;e++){const s=i[e];c(s)<o?t.push(s):a.push(s)}if(t.length>0){const i=s.merge(t,n);i._isAggregation=!0,i._threshold=e,a.push(i)}return a}throw new Error("Depth is higher than the amount of grouping levels.")}(e,0)??e}const
|
|
4053
|
+
const t=[],a=[],o=e*h;for(let e=0;e<i.length;e++){const s=i[e];c(s)<o?t.push(s):a.push(s)}if(t.length>0){const i=s.merge(t,n);i._isAggregation=!0,i._threshold=e,a.push(i)}return a}throw new Error("Depth is higher than the amount of grouping levels.")}(e,0)??e}const ra={treemapBinary:M.treemapBinary,treemapDice:M.treemapDice,treemapResquarify:M.treemapResquarify,treemapSlice:M.treemapSlice,treemapSliceDice:M.treemapSliceDice,treemapSquarify:M.treemapSquarify},ca=e=>!!e.children&&1===e.children.length&&!0===e.children[0].data._isAggregation,ha={name:"Treemap",features:[ee,Q,Z,ne],layoutStage:na,emit:({viz:e,shapeData:t})=>{const i=t??[];if(!i.length)return[];const s=e.schema.locale,n=e._drawLabel,a=e.schema.shapeConfig??{};return[...i.map(t=>{const i=aa(a.fill,t.data,t.i),o=aa(a.stroke,t.data,t.i),r=aa(a.opacity,t.data,t.i),c=aa(a.strokeWidth,t.data,t.i);return{type:"rect",key:`treemap-${t.id}`,x:t.x0,y:t.y0,width:t.x1-t.x0,height:t.y1-t.y0,datum:t.data,paint:{fill:"string"==typeof i?i:void 0,stroke:"string"==typeof o||null==o?o:String(o),opacity:r,strokeWidth:c},aria:{label:`${n(t.data,t.i??0)}, ${e.schema.sum(t.data)}, ${m.formatAbbreviate(100*t.share,s)}%`}}}),...Xs({data:i,label:e=>{const t=e;return[n(t.data,t.i??0),`${m.formatAbbreviate(100*t.share,s)}%`]},x:e=>{const t=e;return t.x0+(t.x1-t.x0)/2},y:e=>{const t=e;return t.y0+(t.y1-t.y0)/2},aes:e=>{const t=e;return{width:t.x1-t.x0,height:t.y1-t.y0}},rotate:L(0),id:e=>e.id,labelBounds:(e,t,i)=>{const{width:s,height:n}=i;let a=Math.min(32,.5*(n-10));return a<8&&(a=0),[{width:s,height:n-a,x:-s/2,y:-n/2},{width:s,height:a+10,x:-s/2,y:n/2-a-10}]},labelConfig:{fontMax:32,textAnchor:e=>e&&0===e.l?"start":"middle",verticalAlign:e=>e&&0===e.l?"top":"bottom",fontColor:e=>{const t=e&&e.data?e.data:e,i=aa(a.fill,t,t.i);return"string"==typeof i?u.colorContrast(i):void 0}}})]},thresholdFunction:(e,t)=>oa(t,{aggs:e.schema.aggs,drawDepth:e._drawDepth,groupBy:e.schema.groupBy,threshold:e.schema.threshold,thresholdKey:e.schema.thresholdKey}),ctx:{treemap:M.treemap().round(!0)},fields:[{key:"layoutPadding",default:1},{key:"sort",default:(e,t)=>(t.value??0)-(e.value??0),decorate:(e,t)=>{const i=t;return(e,t)=>{const s=ca(e),n=ca(t);return s&&!n?1:!s&&n?-1:i(e,t)}}},{key:"sum",default:F("value"),coerce:e=>"function"==typeof e?e:F(e),onSet:(e,t)=>{e.schema.thresholdKey=t}},{key:"tile",default:M.treemapSquarify,coerce:e=>{if("string"!=typeof e)return e;const t=`treemap${e.charAt(0).toUpperCase()}${e.slice(1)}`;return ra[t]??M.treemapSquarify}},{key:"shapeConfig",merge:!0,factory:e=>({ariaLabel:(t,i)=>{const s="number"==typeof t.rank?`${t.rank+1}. `:"",n=e.schema.sum;return`${s}${e._drawLabel(t,i)}, ${n(t,i)}.`},labelConfig:{fontMax:32,fontMin:8,fontResize:!0,padding:5}})},{key:"tooltipConfig",merge:!0,factory:e=>({tbody:[[()=>e.schema.translate("Share"),(t,i,s)=>{
|
|
3958
4054
|
// A ColorScale range swatch carries no per-row share, so sum the
|
|
3959
4055
|
// share of every datum that falls in its color range.
|
|
3960
4056
|
if(s._isColorScaleBucket){const t=ye(e,s.color,e.schema.sum);return null==t?"":`${m.formatAbbreviate(100*t,e.schema.locale)}%`}
|
|
@@ -3965,9 +4061,9 @@ const n=Array.isArray(s.share)?s.share.reduce((e,t)=>e+t,0):s.share;return Numbe
|
|
|
3965
4061
|
/**
|
|
3966
4062
|
Uses the d3 treemap layout to create SVG rectangles based on an array of data.
|
|
3967
4063
|
*/
|
|
3968
|
-
var
|
|
4064
|
+
var la=Ri(ha);e.Area=qe,e.AreaPlot=js,e.Axis=Ct,e.AxisBottom=St,e.AxisLeft=wt,e.AxisRight=zt,e.AxisTop=Dt,e.Bar=Ke,e.BarChart=Gs,e.BaseClass=j,e.Box=rt,e.BoxWhisker=Is,e.BumpChart=Ys,e.Circle=Xe,e.ColorScale=Rt,e.Donut=Zs,e.Geomap=hn,e.Image=ht,e.Legend=$t,e.Line=Ze,e.LinePlot=ln,e.Matrix=yn,e.Message=Lt,e.Network=Cn,e.Pack=Mn,e.Path=dt,e.Pie=Qs,e.Plot=Hs,e.Priestley=Pn,e.RESET=W,e.Radar=Ln,e.RadialMatrix=jn,e.Rect=Je,e.Rings=Yn,e.Sankey=Un,e.Shape=Ge,e.StackedArea=Jn,e.TextBox=Gt,e.Timeline=Kt,e.Tooltip=Zt,e.Tree=sa,e.Treemap=la,e.Viz=Oi,e.Whisker=it,e.accessor=F,e.applyGeomapLayout=nn,e.applyMatrixLayout=un,e.applyNetworkLayout=xn,e.applyPackLayout=Sn,e.applyPieLayout=Ks,e.applyPriestleyLayout=An,e.applyRadarLayout=On,e.applyRadialMatrixLayout=Fn,e.applyRingsLayout=In,e.applySankeyLayout=Kn,e.applyTreeLayout=ea,e.applyTreemapLayout=na,e.backFeature=ee,e.colorScaleFeature=ie,e.computeAxisLayout=function(e){
|
|
3969
4065
|
// Free function from axisLayout.ts. Mutates `axis` (so instance-slot
|
|
3970
4066
|
// readers stay in sync) and returns the layout artifacts; we re-shape
|
|
3971
4067
|
// its result + the mutated instance fields into the stable `AxisLayout` API.
|
|
3972
|
-
return Pe(e),{bounds:e._outerBounds,d3Scale:e._d3Scale,d3ScaleNegative:e._d3ScaleNegative,getPosition:t=>e._getPosition(t),availableTicks:e._availableTicks,visibleTicks:e._visibleTicks,margin:e._margin}},e.configPrep=G,e.constant=L,e.createFluent=function(e,t={}){const i=new Map(e.map(e=>[e.key,e])),s={};for(const i of e)i.key in t&&(s[i.key]=oe(i,t[i.key]));const n={};for(const t of e)n[t.key]=function(...e){return e.length?(s[t.key]=oe(t,e[0]),n):s[t.key]};return n.config=function(...e){if(!e.length)return{...s};const t=e[0];for(const e in t){if(!Object.prototype.hasOwnProperty.call(t,e))continue;const n=i.get(e);s[e]=n?oe(n,t[e]):t[e]}return n},n},e.geomapDef=
|
|
4068
|
+
return Pe(e),{bounds:e._outerBounds,d3Scale:e._d3Scale,d3ScaleNegative:e._d3ScaleNegative,getPosition:t=>e._getPosition(t),availableTicks:e._availableTicks,visibleTicks:e._visibleTicks,margin:e._margin}},e.configPrep=G,e.constant=L,e.createFluent=function(e,t={}){const i=new Map(e.map(e=>[e.key,e])),s={};for(const i of e)i.key in t&&(s[i.key]=oe(i,t[i.key]));const n={};for(const t of e)n[t.key]=function(...e){return e.length?(s[t.key]=oe(t,e[0]),n):s[t.key]};return n.config=function(...e){if(!e.length)return{...s};const t=e[0];for(const e in t){if(!Object.prototype.hasOwnProperty.call(t,e))continue;const n=i.get(e);s[e]=n?oe(n,t[e]):t[e]}return n},n},e.geomapDef=cn,e.installFluent=re,e.legendFeature=K,e.matrixDef=pn,e.measureAxis=Pe,e.networkDef=vn,e.packDef=Dn,e.pieDef=Js,e.plotEmit=Os,e.plotPaint=Rs,e.priestleyDef=Bn,e.radarDef=Rn,e.radialMatrixDef=Hn,e.renderAxes=is,e.resolveSpec=E,e.ringsDef=qn,e.runLayout=U,e.runStages=he,e.runVizPipeline=vi,e.sankeyDef=Xn,e.subtitleFeature=Z,e.timelineFeature=te,e.titleFeature=Q,e.totalFeature=ne,e.treeDef=ia,e.treemapDef=ha,e.vizDraw=Mi,e.vizDrawPure=Di,e.vizPostThresholdCtx=Bi,e.vizPreDraw=Pi,e.vizPreDrawPure=$i});
|
|
3973
4069
|
//# sourceMappingURL=d3plus-core.js.map
|