@d3plus/core 4.0.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +303 -292
- package/es/src/charts/events/click.legend.js +1 -1
- package/es/src/charts/events/click.legend.js.map +1 -1
- package/es/src/charts/events/mousemove.legend.js +1 -1
- package/es/src/charts/events/mousemove.legend.js.map +1 -1
- package/es/src/charts/features/features.js +3 -3
- package/es/src/charts/features/features.js.map +1 -1
- package/es/src/charts/features/featuresLegend.js +1 -1
- package/es/src/charts/features/featuresLegend.js.map +1 -1
- package/es/src/charts/viz/VizBase.js.map +1 -1
- package/es/src/charts/viz/VizBaseConfig.js.map +1 -1
- package/es/src/components/TextBox.js +21 -5
- package/es/src/components/TextBox.js.map +1 -1
- package/es/src/shapes/Circle.js +12 -4
- package/es/src/shapes/Circle.js.map +1 -1
- package/es/src/shapes/buildLabelData.js +59 -4
- package/es/src/shapes/buildLabelData.js.map +1 -1
- package/es/src/utils/D3plusConfig.js.map +1 -1
- package/package.json +10 -10
- package/types/src/charts/viz/VizBase.d.ts +4 -4
- package/types/src/charts/viz/VizBaseConfig.d.ts +4 -3
- package/types/src/utils/D3plusConfig.d.ts +40 -12
- package/umd/d3plus-core.full.js +515 -264
- package/umd/d3plus-core.full.js.map +1 -1
- package/umd/d3plus-core.full.min.js +785 -699
- package/umd/d3plus-core.js +45 -16
- package/umd/d3plus-core.js.map +1 -1
- package/umd/d3plus-core.min.js +35 -12
package/umd/d3plus-core.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
@d3plus/core v4.
|
|
2
|
+
@d3plus/core v4.1.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,7 +147,7 @@ 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=V(e.schema.legendPosition.bind(e)(h)),d=["top","bottom"].includes(l),u=e.schema.legendPadding()?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();
|
|
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=V(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
|
|
@@ -198,7 +198,7 @@ if(r&&n.push(r),s.top+=c.top??0,s.right+=c.right??0,s.bottom+=c.bottom??0,s.left
|
|
|
198
198
|
(title, subtitle, total). Each feature passes the viz fields that source its
|
|
199
199
|
text + TextBox + config; the helper computes the panel + margin claim using
|
|
200
200
|
the TextBox's pure `_textData()` (no DOM).
|
|
201
|
-
*/function J(e,t){const{viz:i,layoutMargin:s}=e,n=t.getText(i);if(!n)return{panel:null,margin:{}};const a=i.schema[t.paddingMethod]()?i._padding:{right:0,left:0},o=i.schema.width-(s.left+s.right+a.left+a.right),r=i[t.textClassKey];r.data([{text:n}]).locale(i.schema.locale).width(o).config(i.schema[t.configKey]);const c=r._textData();if(!c.length)return{panel:null,margin:{}};const h=c[0],l=s.left+a.left,d=s.top,u=h.lH,m=i.schema[t.configKey]?.padding??0,f=h.lines.length*u+2*m,g=h.lines.map((e,t)=>({text:e,x:"middle"===h.tA?o/2:"end"===h.tA?o:0,y:(t+1)*u-(u-h.fS),width:h.widths?.[t]??0}));return{panel:{type:"text",key:t.panelKey,x:0,y:0,lines:g,font:{family:h.fF,size:h.fS,anchor:"middle"===h.tA||"end"===h.tA||"start"===h.tA?h.tA:"start",baseline:"alphabetic"},paint:{fill:h.fC,opacity:h.fO},transform:{x:l,y:d}},margin:{top:f}}}
|
|
201
|
+
*/function J(e,t){const{viz:i,layoutMargin:s}=e,n=t.getText(i);if(!n)return{panel:null,margin:{}};const a=i.schema[t.paddingMethod](i)?i._padding:{right:0,left:0},o=i.schema.width-(s.left+s.right+a.left+a.right),r=i[t.textClassKey];r.data([{text:n}]).locale(i.schema.locale).width(o).config(i.schema[t.configKey]);const c=r._textData();if(!c.length)return{panel:null,margin:{}};const h=c[0],l=s.left+a.left,d=s.top,u=h.lH,m=i.schema[t.configKey]?.padding??0,f=h.lines.length*u+2*m,g=h.lines.map((e,t)=>({text:e,x:"middle"===h.tA?o/2:"end"===h.tA?o:0,y:(t+1)*u-(u-h.fS),width:h.widths?.[t]??0}));return{panel:{type:"text",key:t.panelKey,x:0,y:0,lines:g,font:{family:h.fF,size:h.fS,anchor:"middle"===h.tA||"end"===h.tA||"start"===h.tA?h.tA:"start",baseline:"alphabetic"},paint:{fill:h.fC,opacity:h.fO},transform:{x:l,y:d}},margin:{top:f}}}
|
|
202
202
|
/**
|
|
203
203
|
Title as a FeatureModule. Uses `_titleClass._textData()` for height
|
|
204
204
|
(pure compute, no DOM) and returns the margin claim explicitly.
|
|
@@ -216,7 +216,7 @@ if(!s.length)return{panel:null,margin:{top:n}};const a=s[0];return{panel:{type:"
|
|
|
216
216
|
instance (compute mode — scene comes from Timeline.toScene via Viz.toScene's
|
|
217
217
|
components collection) and claims `margin.bottom` from its outerBounds.
|
|
218
218
|
*/
|
|
219
|
-
const te={name:"timeline",configFields:["timeline","timelineConfig","timelinePadding"],layout:({viz:e,layoutMargin:i})=>{let a=e.schema.time&&e.schema.timeline;const o=a?s.unique(e._data.map(e.schema.time)).map(e=>n.date(e)):[];a=a&&o.length>1;const r=e.schema.timelinePadding()?e._padding:{right:0,left:0},c={transform:`translate(${i.left+r.left}, 0)`},h=n.elem("g.d3plus-viz-timeline",{condition:a,enter:c,parent:e._select,duration:e.schema.duration,update:c}).node();if(!a)return{panel:null,margin:{}};const l=e._timelineClass.renderMode("compute").domain(t.extent(o)).duration(e.schema.duration).height(e.schema.height-i.bottom).locale(e.schema.locale).select(h).ticks(o.sort((e,t)=>+e-+t)).width(e.schema.width-(i.left+i.right+r.left+r.right)),d=t.extent(o);
|
|
219
|
+
const te={name:"timeline",configFields:["timeline","timelineConfig","timelinePadding"],layout:({viz:e,layoutMargin:i})=>{let a=e.schema.time&&e.schema.timeline;const o=a?s.unique(e._data.map(e.schema.time)).map(e=>n.date(e)):[];a=a&&o.length>1;const r=e.schema.timelinePadding(e)?e._padding:{right:0,left:0},c={transform:`translate(${i.left+r.left}, 0)`},h=n.elem("g.d3plus-viz-timeline",{condition:a,enter:c,parent:e._select,duration:e.schema.duration,update:c}).node();if(!a)return{panel:null,margin:{}};const l=e._timelineClass.renderMode("compute").domain(t.extent(o)).duration(e.schema.duration).height(e.schema.height-i.bottom).locale(e.schema.locale).select(h).ticks(o.sort((e,t)=>+e-+t)).width(e.schema.width-(i.left+i.right+r.left+r.right)),d=t.extent(o);
|
|
220
220
|
// Clamp bound = the full time range (every tick); it never goes stale
|
|
221
221
|
// mid-render. Clamping to `viz._filteredData`'s extent instead collapsed a
|
|
222
222
|
// freshly-committed range down to the previous selection — the release
|
|
@@ -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=V(e.schema.colorScalePosition.bind(e)(E(e))),r=["top","bottom"].includes(o),c=e.schema.colorScale&&o,h=e.schema.colorScalePadding()?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:"");
|
|
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=V(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
|
|
@@ -823,7 +823,13 @@ let n="Circle"===e.schema.shape?"function"==typeof e.schema.shapeConfig.r?e.sche
|
|
|
823
823
|
compute via `_labelClass` can call this directly + emit their own text
|
|
824
824
|
nodes — no Shape class needed for labels-only data flows. The Shape
|
|
825
825
|
classes themselves reach it through `this._buildLabelData()`.
|
|
826
|
-
*/function Te(e){const{data:t,dataFilter:i,label:s,labelBounds:n,x:a,y:o,aes:r,rotate:c,id:h,datum:l}=e,d=[];return(i?i(t):t).forEach((e,i)=>{let u=e;e.nested&&e.key&&e.values&&(u=e.values[0],i=t.indexOf(u));let m=s(u,i);if(n&&!1!==m&&null!=m){const t=n(u,i,r(e,i));if(!t)return;m.constructor!==Array&&(m=[m]);const s=u.__d3plusShape__?u.translate?u.translate[0]:a(u.data,u.i):a(u,i),f=u.__d3plusShape__?u.translate?u.translate[1]:o(u.data,u.i):o(u,i);u.__d3plusShape__&&(u=u.data,i=u.i);for(let e=0;e<m.length;e++){const n=t.constructor===Array?t[e]:Object.assign({},t),a=c(u,i),o=u.labelConfig;let r=o&&o.rotate?o.rotate:void 0!==t.angle?t.angle:0;r+=a;const g=0!==a?[-1*n.x||0,-1*n.y||0]:[n.width/2,n.height/2];d.push({__d3plus__:!0,data:l?l(u,i):u,height:n.height,l:e,id:`${h(u,i)}_${e}`,r:r,rotateAnchor:g,
|
|
826
|
+
*/function Te(e){const{data:t,dataFilter:i,label:s,labelBounds:n,x:a,y:o,aes:r,rotate:c,id:h,datum:l}=e,d=[];return(i?i(t):t).forEach((e,i)=>{let u=e;e.nested&&e.key&&e.values&&(u=e.values[0],i=t.indexOf(u));let m=s(u,i);if(n&&!1!==m&&null!=m){const t=n(u,i,r(e,i));if(!t)return;m.constructor!==Array&&(m=[m]);const s=u.__d3plusShape__?u.translate?u.translate[0]:a(u.data,u.i):a(u,i),f=u.__d3plusShape__?u.translate?u.translate[1]:o(u.data,u.i):o(u,i);u.__d3plusShape__&&(u=u.data,i=u.i);for(let e=0;e<m.length;e++){const n=t.constructor===Array?t[e]:Object.assign({},t),a=c(u,i),o=u.labelConfig;let r=o&&o.rotate?o.rotate:void 0!==t.angle?t.angle:0;r+=a;const g=0!==a?[-1*n.x||0,-1*n.y||0]:[n.width/2,n.height/2];d.push({__d3plus__:!0,data:l?l(u,i):u,height:n.height,l:e,id:`${h(u,i)}_${e}`,r:r,rotateAnchor:g,
|
|
827
|
+
// Wrapping shape rides on the bounds so it stays paired with them:
|
|
828
|
+
// a shape whose `labelBounds` returns `shape: "circle"` wraps to the
|
|
829
|
+
// circle, while a chart that supplies its own rectangular bounds
|
|
830
|
+
// (no `shape`) wraps normally. Stamped under a namespaced key so it
|
|
831
|
+
// can't collide with a `shape` field a caller's own data might carry.
|
|
832
|
+
...n.shape?{__d3plusWrapShape__:n.shape}:{},text:m[e],width:n.width,x:s+n.x,y:f+n.y})}}}),d}
|
|
827
833
|
/**
|
|
828
834
|
Builds the invisible, interactive "hit area" rect for a shape datum — a
|
|
829
835
|
transparent box that can extend past the shape's own geometry (e.g. a legend
|
|
@@ -1138,7 +1144,15 @@ _sceneGeometry(e,t){return{type:"circle",cx:0,cy:0,r:Number(this.schema.r(e,t)),
|
|
|
1138
1144
|
/**
|
|
1139
1145
|
Invoked when creating a new class instance, and overrides any default parameters inherited from Shape.
|
|
1140
1146
|
@private
|
|
1141
|
-
*/constructor(){super("circle"),re(this,Ye),this._name="Circle",
|
|
1147
|
+
*/constructor(){super("circle"),re(this,Ye),this._name="Circle",
|
|
1148
|
+
// Bound the label to the full circle (diameter box) and tag it
|
|
1149
|
+
// `shape: "circle"`, so the label TextBox flows text as circle chords —
|
|
1150
|
+
// lines fill the interior, shorter near the top and bottom and full width
|
|
1151
|
+
// through the middle — rather than being capped to a square inscribed in
|
|
1152
|
+
// the circle. The `shape` hint rides on the bounds (not `labelConfig`) so a
|
|
1153
|
+
// chart that repositions the label with its own `labelBounds` (e.g. Tree's
|
|
1154
|
+
// external node labels) gets ordinary rectangular wrapping.
|
|
1155
|
+
this.schema.labelBounds=(e,t,i)=>({width:2*i.r,height:2*i.r,x:-i.r,y:-i.r,shape:"circle"}),this.schema.labelConfig=n.assign(this.schema.labelConfig,{textAnchor:"middle",verticalAlign:"middle"})}}
|
|
1142
1156
|
/** Rect's own fluent accessor schema, layered on top of Shape's. */const Xe=[{key:"height",coerce:"accessor",default:F("height")},
|
|
1143
1157
|
// Motion-trail toggle: when true, the animate layer sweeps a tapering cone
|
|
1144
1158
|
// behind each rect as it moves between frames (Timeline play), sized to the
|
|
@@ -1701,15 +1715,24 @@ o&&(i=a)}return i}
|
|
|
1701
1715
|
/**
|
|
1702
1716
|
Computes the laid-out text box for a single data point, or null when the
|
|
1703
1717
|
text is undefined or wraps to no visible lines.
|
|
1704
|
-
*/function Et(e,i,s){const a=e;let o=e.schema.text(i,s);if(void 0===o)return null;o=`${o}`.trim();const c=e.schema.fontResize(i,s),h=e.schema.lineHeight(i,s)/e.schema.fontSize(i,s);let l=c?e.schema.fontMax(i,s):e.schema.fontSize(i,s),d=c?l*h:e.schema.lineHeight(i,s),u=1,m=[],f={lines:[],truncated:!1,widths:[]};const g={"font-family":n.fontExists(e.schema.fontFamily(i,s)),"font-size":l,"font-weight":e.schema.fontWeight(i,s),"line-height":d},p=n.parseSides(e.schema.padding(i,s)),y=e.schema.height(i,s)-(p.top+p.bottom),_=e.schema.width(i,s)-(p.left+p.right),x=r.textWrap().fontFamily(g["font-family"]).fontSize(l).fontWeight(g["font-weight"]).lineHeight(d).maxLines(e.schema.maxLines(i,s)).height(y).overflow(e.schema.overflow(i,s)).width(_).split(e.schema.split),
|
|
1718
|
+
*/function Et(e,i,s){const a=e;let o=e.schema.text(i,s);if(void 0===o)return null;o=`${o}`.trim();const c=e.schema.fontResize(i,s),h=e.schema.lineHeight(i,s)/e.schema.fontSize(i,s);let l=c?e.schema.fontMax(i,s):e.schema.fontSize(i,s),d=c?l*h:e.schema.lineHeight(i,s),u=1,m=[],f={lines:[],truncated:!1,widths:[]};const g={"font-family":n.fontExists(e.schema.fontFamily(i,s)),"font-size":l,"font-weight":e.schema.fontWeight(i,s),"line-height":d},p=n.parseSides(e.schema.padding(i,s)),y=e.schema.height(i,s)-(p.top+p.bottom),_=e.schema.width(i,s)-(p.left+p.right),x=e.schema.shape(i,s),b=r.textWrap().fontFamily(g["font-family"]).fontSize(l).fontWeight(g["font-weight"]).lineHeight(d).maxLines(e.schema.maxLines(i,s)).height(y).overflow(e.schema.overflow(i,s)).shape(x).width(_).split(e.schema.split),k=e.schema.fontMax(i,s),v=e.schema.fontMin(i,s),C=e.schema.verticalAlign(i,s),S=e.schema.split(o,s);return _>v&&(y>d||c&&y>v*h)&&(c&&(l=function(e,i,s,a,o,r,c){const h=n.textWidth(o,r),l=1.165+i/s*.1,// A circle fills only ~π/4 of its bounding box, so scale the usable area
|
|
1719
|
+
// down to keep the initial font-size guess from overshooting.
|
|
1720
|
+
d=i*s*("circle"===c?Math.PI/4:1),u=t.max(h),m=t.sum(h,e=>e*a)*l;if(u>i||m>d){const s=Math.sqrt(d/m),n=i/u,a=t.min([s,n]);e=Math.floor(e*a)}const f=Math.floor(.8*s);return e>f&&(e=f),e}(l,_,y,d,S,g,x)),
|
|
1705
1721
|
/**
|
|
1706
1722
|
Figures out the lineData to be used for wrapping.
|
|
1707
1723
|
@private
|
|
1708
1724
|
*/
|
|
1709
1725
|
function e(){const i=()=>{u<1?m=[a.schema.ellipsis("",u)]:m[u-1]=a.schema.ellipsis(m[u-1],u)};
|
|
1710
1726
|
// Constraint the font size
|
|
1711
|
-
if(l=t.max([l,
|
|
1712
|
-
/** TextBox's fluent accessor schema. Config storage lives on `this.schema.<key>`. */const Ft=[{key:"ariaHidden",coerce:"const",default:L("false")},{key:"delay",coerce:"identity",default:0},{key:"duration",coerce:"identity",default:0},{key:"ellipsis",coerce:"const",default:(e,t)=>t?`${e.replace(/\.|,$/g,"")}...`:""},{key:"fontColor",coerce:"const",default:L("black")},{key:"fontFamily",coerce:"const",default:L(r.fontFamily)},{key:"fontMax",coerce:"const",default:L(50)},{key:"fontMin",coerce:"const",default:L(8)},{key:"fontOpacity",coerce:"const",default:L(1)},{key:"fontResize",coerce:"const",default:L(!1)},{key:"fontSize",coerce:"const",default:L(10)},{key:"fontStroke",coerce:"const",default:L("transparent")},{key:"fontStrokeWidth",coerce:"const",default:L(0)},{key:"fontWeight",coerce:"const",default:L(400)},{key:"height",coerce:"const",default:F("height",200)},{key:"id",coerce:"const",default:(e,t)=>e.id||`${t}`},{key:"lineHeight",coerce:"const"},{key:"maxLines",coerce:"const",default:L(null)},{key:"overflow",coerce:"const",default:L(!1)},{key:"padding",coerce:"const",default:L(0)},{key:"pointerEvents",coerce:"const",default:L("auto")},{key:"renderMode",coerce:"identity",default:"full"},{key:"rotate",coerce:"const",default:L(0)},{key:"rotateAnchor",coerce:"const",default:e=>[e.w/2,e.h/2]},
|
|
1727
|
+
if(l=t.max([l,v]),l=t.min([l,k]),c&&(d=l*h,b.fontSize(l).lineHeight(d),g["font-size"]=l,g["line-height"]=d),f=b(o),m=f.lines.filter(e=>""!==e),u=m.length,f.truncated)if(c){if(l--,l<v)return l=v,void i();e()}else i()}()),m.length?Lt(e,i,s,{lineData:m,line:u,fS:l,lH:d,w:_,h:y,vA:C,style:g,widths:f.widths,padding:p}):null}
|
|
1728
|
+
/** TextBox's fluent accessor schema. Config storage lives on `this.schema.<key>`. */const Ft=[{key:"ariaHidden",coerce:"const",default:L("false")},{key:"delay",coerce:"identity",default:0},{key:"duration",coerce:"identity",default:0},{key:"ellipsis",coerce:"const",default:(e,t)=>t?`${e.replace(/\.|,$/g,"")}...`:""},{key:"fontColor",coerce:"const",default:L("black")},{key:"fontFamily",coerce:"const",default:L(r.fontFamily)},{key:"fontMax",coerce:"const",default:L(50)},{key:"fontMin",coerce:"const",default:L(8)},{key:"fontOpacity",coerce:"const",default:L(1)},{key:"fontResize",coerce:"const",default:L(!1)},{key:"fontSize",coerce:"const",default:L(10)},{key:"fontStroke",coerce:"const",default:L("transparent")},{key:"fontStrokeWidth",coerce:"const",default:L(0)},{key:"fontWeight",coerce:"const",default:L(400)},{key:"height",coerce:"const",default:F("height",200)},{key:"id",coerce:"const",default:(e,t)=>e.id||`${t}`},{key:"lineHeight",coerce:"const"},{key:"maxLines",coerce:"const",default:L(null)},{key:"overflow",coerce:"const",default:L(!1)},{key:"padding",coerce:"const",default:L(0)},{key:"pointerEvents",coerce:"const",default:L("auto")},{key:"renderMode",coerce:"identity",default:"full"},{key:"rotate",coerce:"const",default:L(0)},{key:"rotateAnchor",coerce:"const",default:e=>[e.w/2,e.h/2]},
|
|
1729
|
+
// Bounding shape for wrapping: "square" (default) fills the full width on
|
|
1730
|
+
// every line; "circle" treats width/height as the diameter and shortens
|
|
1731
|
+
// lines near the top and bottom to keep text inside the circle. Defaults to
|
|
1732
|
+
// the label record's namespaced `__d3plusWrapShape__` (stamped from a shape's
|
|
1733
|
+
// `labelBounds`) so Circle labels wrap to the circle without callers
|
|
1734
|
+
// configuring anything, while a caller's own `shape` data field is ignored.
|
|
1735
|
+
{key:"shape",coerce:"const",default:e=>e.__d3plusWrapShape__??"square"},{key:"split",coerce:"identity",default:r.textSplit},{key:"text",coerce:"const",default:F("text")},{key:"textAnchor",coerce:"const",default:L("start")},{key:"verticalAlign",coerce:"const",default:L("top")},{key:"width",coerce:"const",default:F("width",200)},{key:"x",coerce:"const",default:F("x",0)},{key:"y",coerce:"const",default:F("y",0)}];class Wt extends j{
|
|
1713
1736
|
/**
|
|
1714
1737
|
Computes the laid-out text boxes (wrapping, font sizing, per-box position)
|
|
1715
1738
|
for the current data. Shared by render() and toScene() so both produce
|
|
@@ -2017,7 +2040,7 @@ this._portalEl.remove(),this._portalEl=void 0),this._parentEl=i,this}data(e){ret
|
|
|
2017
2040
|
@module clickLegend
|
|
2018
2041
|
On click event for all legend shapes in a Viz.
|
|
2019
2042
|
@private
|
|
2020
|
-
*/function Qt(e,i,s,n){this._select.style("cursor","auto"),this.schema.tooltip(e,i)&&this._tooltipClass.data([]).render();let a=this._id(e,i);a instanceof Array||(a=[a]);const o=this._hidden.indexOf(a[0]),r=this._solo.indexOf(a[0]),c=t.merge(this._legendClass.data().map((e,t)=>{let i=this._id(e,t);return i instanceof Array||(i=[i]),i})).length;this.schema.legendFilterInvert.bind(this)()?n.shiftKey?o<0&&!this._solo.length?(this._hidden=this._hidden.concat(a),r>=0&&(this._solo=[]),this._hidden.length===c&&(this._hidden=[]),this.render()):r>=0&&(this._solo=[],this._hidden=[],this.render()):(r<0&&this._hidden.length<c-1?(this._solo=a,this._hidden=[]):(this._solo=[],this._hidden=[]),this.render()):n.shiftKey&&r<0?(this._solo=a,this._hidden=[],this.render()):n.shiftKey||(o>=0?this._hidden.splice(o,a.length):r>=0?(this._solo=[],this._hidden=[]):this._solo.length&&r<0?(this._solo=this._solo.concat(a),this._solo.length===c&&(this._solo=[])):(this._hidden=this._hidden.concat(a),this._hidden.length===c&&(this._hidden=[])),this.render())}
|
|
2043
|
+
*/function Qt(e,i,s,n){this._select.style("cursor","auto"),this.schema.tooltip(e,i)&&this._tooltipClass.data([]).render();let a=this._id(e,i);a instanceof Array||(a=[a]);const o=this._hidden.indexOf(a[0]),r=this._solo.indexOf(a[0]),c=t.merge(this._legendClass.data().map((e,t)=>{let i=this._id(e,t);return i instanceof Array||(i=[i]),i})).length;this.schema.legendFilterInvert.bind(this)(this)?n.shiftKey?o<0&&!this._solo.length?(this._hidden=this._hidden.concat(a),r>=0&&(this._solo=[]),this._hidden.length===c&&(this._hidden=[]),this.render()):r>=0&&(this._solo=[],this._hidden=[],this.render()):(r<0&&this._hidden.length<c-1?(this._solo=a,this._hidden=[]):(this._solo=[],this._hidden=[]),this.render()):n.shiftKey&&r<0?(this._solo=a,this._hidden=[],this.render()):n.shiftKey||(o>=0?this._hidden.splice(o,a.length):r>=0?(this._solo=[],this._hidden=[]):this._solo.length&&r<0?(this._solo=this._solo.concat(a),this._solo.length===c&&(this._solo=[])):(this._hidden=this._hidden.concat(a),this._hidden.length===c&&(this._hidden=[])),this.render())}
|
|
2021
2044
|
/**
|
|
2022
2045
|
@module mouseEnter
|
|
2023
2046
|
On mouseenter event for all shapes in a Viz.
|
|
@@ -2059,7 +2082,7 @@ let s=this._hoverDatum;for(;s&&s.__d3plus__&&s.data;)s=s.data;if(s&&this._id(s)=
|
|
|
2059
2082
|
this.schema.on[e]&&// and it is not our default click.legend function
|
|
2060
2083
|
this.schema.on[e].toString()!==r),h=this.schema.on["click.legend"]&&this.schema.on["click.legend"].toString()===r,l=this._drawDepth<this.schema.groupBy.length-1;
|
|
2061
2084
|
// only show the hand cursor when the shape has a click event
|
|
2062
|
-
this._select.style("cursor",c||h&&l?"pointer":"auto");const d=this.schema.legendFilterInvert.bind(this)(),u=this._solo.includes(t),m=this._hidden.includes(t);this._tooltipClass.data([s||e]).footer(!!h&&(d?this._solo.length&&!u||m?n("Click to Highlight"):1===this._solo.length&&u||this._hidden.length===o-1?n("Click to Show All"):`${n("Click to Highlight")}<br />${n("Shift+Click to Hide")}`:this._solo.length&&!u||m?`${n("Click to Show")}<br />${n("Shift+Click to Highlight")}`:1===this._solo.length&&u||this._hidden.length===o-1?n("Click to Show All"):`${n("Click to Hide")}<br />${n("Shift+Click to Highlight")}`)).title(this.schema.legendConfig.label?this._legendClass.label():Ut.bind(this)).position(a).config(G.bind(this)(this.schema.tooltipConfig)).config(G.bind(this)(this.schema.legendTooltip)).render()}}
|
|
2085
|
+
this._select.style("cursor",c||h&&l?"pointer":"auto");const d=this.schema.legendFilterInvert.bind(this)(this),u=this._solo.includes(t),m=this._hidden.includes(t);this._tooltipClass.data([s||e]).footer(!!h&&(d?this._solo.length&&!u||m?n("Click to Highlight"):1===this._solo.length&&u||this._hidden.length===o-1?n("Click to Show All"):`${n("Click to Highlight")}<br />${n("Shift+Click to Hide")}`:this._solo.length&&!u||m?`${n("Click to Show")}<br />${n("Shift+Click to Highlight")}`:1===this._solo.length&&u||this._hidden.length===o-1?n("Click to Show All"):`${n("Click to Hide")}<br />${n("Shift+Click to Highlight")}`)).title(this.schema.legendConfig.label?this._legendClass.label():Ut.bind(this)).position(a).config(G.bind(this)(this.schema.tooltipConfig)).config(G.bind(this)(this.schema.legendTooltip)).render()}}
|
|
2063
2086
|
/**
|
|
2064
2087
|
@module mouseMoveShape
|
|
2065
2088
|
Tooltip logic for a specified data point.
|