@d3plus/core 3.0.4 → 3.0.5
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 +80 -87
- package/es/src/charts/BoxWhisker.js +0 -4
- package/es/src/charts/Plot.js +1 -3
- package/es/src/charts/Viz.js +1 -1
- package/es/src/components/Axis.js +3 -2
- package/package.json +8 -8
- package/umd/d3plus-core.full.js +6 -7
- package/umd/d3plus-core.full.js.map +1 -1
- package/umd/d3plus-core.full.min.js +9 -9
- package/umd/d3plus-core.js +5 -6
- package/umd/d3plus-core.js.map +1 -1
- package/umd/d3plus-core.min.js +5 -5
package/umd/d3plus-core.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
@d3plus/core v3.0.
|
|
2
|
+
@d3plus/core v3.0.5
|
|
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) 2025 D3plus - https://d3plus.org
|
|
5
5
|
@license MIT
|
|
@@ -1263,11 +1263,11 @@ if(R(n[0])&&R(n[n.length-1]))this._d3ScaleNegative=this._d3Scale.copy().domain(n
|
|
|
1263
1263
|
/**
|
|
1264
1264
|
* Calculates the text wrapping and size of a given textData object.
|
|
1265
1265
|
* @param {Object} datum
|
|
1266
|
-
*/;let S=[];function l(t=1){let
|
|
1266
|
+
*/;let S=[];function l(t=1){let r=this._shapeConfig.labelConfig.fontSize,a=this._shapeConfig.labelConfig.fontFamily||H.fontFamily,o=this._shapeConfig.labelConfig.padding,e=(
|
|
1267
1267
|
/**
|
|
1268
1268
|
* Calculates the space each label would take up, given
|
|
1269
1269
|
* the provided this._space size.
|
|
1270
|
-
*/S=b.map((t,i)=>{var e="function"==typeof
|
|
1270
|
+
*/S=b.map((t,i)=>{var e="function"==typeof a?a(t,i):a,s="function"==typeof o?o(t,i):o,h="function"==typeof r?r(t,i):r,n=this._getPosition(t);return{d:t,i:i,fF:e,fP:s,fS:h,lineHeight:this._shapeConfig.lineHeight?this._shapeConfig.lineHeight(t,i):1.4*h,position:n,rotate:this._labelRotation}}),"band"===this._scale?this._d3Scale.bandwidth():S.reduce((t,i,e)=>{var i=i.position,s=e?i-(i-S[e-1].position):1===S.length?m[0]:i-(S[e+1].position-i),s=Math.abs(i-s),e=e==S.length-1?1===S.length?m[1]:i+(i-S[e-1].position):i-(i-S[e+1].position),i=Math.abs(i-e),e="point"===this._scale?1:2;return Dt.max([Dt.max([s,i])*e,t])},0)),l=(S=S.map(t=>{t.space=e-2*t.fP;var i=function(t){var{d:t,i,fF:e,fP:s,fS:h,rotate:n,space:r}=t,a=n?"width":"height",n=n?"height":"width",o=Dt.min([this._maxSize,this._width]),l=Dt.min([this._maxSize,this._height]);return(e=H.textWrap().fontFamily(e).fontSize(h).lineHeight(this._shapeConfig.lineHeight?this._shapeConfig.lineHeight(t,i):void 0))[n](c?r:o-k-f-this._margin.left-this._margin.right),e[a](c?l-k-f-this._margin.top-this._margin.bottom:r),(h=e(w(t))).lines=h.lines.filter(t=>""!==t),h.width=h.lines.length?Math.ceil(Dt.max(h.widths)):0,h.height=h.lines.length?Math.ceil(h.lines.length*e.lineHeight())+s:0,h}
|
|
1271
1271
|
/** Calculates label offsets */.bind(this)(t);return Object.assign(i,t)})).slice().reverse();S.forEach(t=>{let{fP:i,i:e,position:s}=t;var h=c?"width":"height";let n=!!e&&l.find(t=>t.i<e&&!t.truncated);if(e===S.length-1)for(;n&&s-t[h]/2-i<n.position+n[h]/2;)n.truncated=!0,n=l.find(t=>t.i<e&&!t.truncated);t.truncated=!!n&&s-t[h]/2-i<n.position+n[h]/2}),1<t&&function(h=[]){let n=0;h.forEach(t=>{var i=h[t.i-1],e=t.rotate&&c||!t.rotate&&!c?"width":"height",s=t.rotate&&c||!t.rotate&&!c?"height":"width";i?i.position+i[s]/2>t.position-t[s]/2&&(n=n?(t.offset=i[e],0):1):n=1})}.bind(this)(S)}l.bind(this)();var z=this._labelOffset&&S.some(t=>t.truncated),M=(z&&l.bind(this)(2)
|
|
1272
1272
|
/**
|
|
1273
1273
|
* "spillover" will contain the pixel spillover of the first and last label,
|
|
@@ -2922,7 +2922,7 @@ return j.select("body").on("touchstart."+this._uuid,
|
|
|
2922
2922
|
function value(d) {
|
|
2923
2923
|
return d.id;
|
|
2924
2924
|
}
|
|
2925
|
-
*/groupBy(t){return arguments.length?((this._groupByRaw=t)instanceof Array||(t=[t]),this._groupBy=t.map(t=>"function"==typeof t?t:(this._aggs[t]||(this._aggs[t]=(t,i)=>{t=Lt.unique(t.map(i)
|
|
2925
|
+
*/groupBy(t){return arguments.length?((this._groupByRaw=t)instanceof Array||(t=[t]),this._groupBy=t.map(t=>"function"==typeof t?t:(this._aggs[t]||(this._aggs[t]=(t,i)=>{t=Lt.unique(t.map(i));return 1===t.length?t[0]:t}),s(t))),this):this._groupBy}
|
|
2926
2926
|
/**
|
|
2927
2927
|
@memberof Viz
|
|
2928
2928
|
@desc If *value* is specified, sets the overall height to the specified number and returns the current class instance.
|
|
@@ -3710,7 +3710,7 @@ this._aggs[i]||this._discrete!==t||(this._aggs[i]=(t,i)=>{t=Array.from(new Set(t
|
|
|
3710
3710
|
@memberof Plot
|
|
3711
3711
|
@desc Invoked when creating a new class instance, and sets any default parameters.
|
|
3712
3712
|
@private
|
|
3713
|
-
*/constructor(){super(),this._axisPersist=!1,this._annotations=[],this._backgroundConfig={duration:0,fill:"transparent"},this._barPadding=0,this._buffer=Pt.assign({},Xt,{Bar:!1,Line:!1}),this._confidenceConfig={fill:(t,i)=>"function"==typeof this._shapeConfig.Line.stroke?this._shapeConfig.Line.stroke(t,i):this._shapeConfig.Line.stroke,fillOpacity:Ht(.5)},this._discreteCutoff=100,this._groupPadding=5,this._labelConnectorConfig={strokeDasharray:"1 1"},this._labelPosition=Ht("auto"),this._lineMarkerConfig={fill:(t,i)=>A.colorAssign(this._id(t,i)),r:Ht(3)},this._lineMarkers=!1,this._previousAnnotations={back:[],front:[]},this._previousShapes=[],this._shape=Ht("Circle"),this._shapeConfig=Pt.assign(this._shapeConfig,{Area:{label:(t,i)=>!!this._stacked&&this._drawLabel(t,i),labelBounds:(t,i,e)=>{let s=E.largestRect(e.points,{angle:Dt.range(-20,20,5)});if(!(s=!s||s.height<20||s.width<50?E.largestRect(e.points,{angle:Dt.range(-80,80,5)}):s))return null;let h=Dt.min(e.points,t=>t[0]);e=Dt.max(e.points.filter(t=>t[0]===h),t=>t[1]);return{angle:s.angle,width:s.width,height:s.height,x:s.cx-s.width/2-h,y:s.cy-s.height/2-e}},labelConfig:{fontMin:6,fontResize:!0,padding:10}},ariaLabel:(t,i)=>{let e="";return t.nested?e=""+this._drawLabel(t.data,t.i):(e=""+this._drawLabel(t,i),void 0!==this._x(t,i)&&(e+=", x: "+this._x(t,i)),void 0!==this._y(t,i)&&(e+=", y: "+this._y(t,i)),void 0!==this._x2(t,i)&&(e+=", x2: "+this._x2(t,i)),void 0!==this._y2(t,i)&&(e+=", y2: "+this._y2(t,i))),e+"."},Bar:{labelBounds(t,i,e){var s="y"===this._discrete?"width":"height",h="y"===this._discrete?"height":"width",n="x"===this._discrete.charAt(0)?"y":"x",r="y"==n,n=this._discrete.replace(this._discrete.charAt(0),n),a=this[`_${n}Axis`]._d3Scale.range(),a=Math.abs(a[1]-a[0]),n=this["_"+n](t,i)<0;return ei.bind(this)(t,i)?{[s]:a-e[s],[h]:e[h],x:r?-e.width/2:n?-a:e.width+1,y:r?n?e.height+1:-a:-e.height/2+1}:{[s]:e[s],[h]:e[h],x:r?-e.width/2:n?(this._stacked,1-e.width):-1,y:r?n?(this._stacked,1):1-e.height:-e.height/2+1}},labelConfig:{fontMax:16,fontMin:6,fontResize:!0,fontColor(t,i){return ei.bind(this)(t,i)?"transparent"===this._backgroundConfig.fill?A.colorDefaults.dark:A.colorContrast(this._backgroundConfig.fill):A.colorContrast("function"==typeof this._shapeConfig.fill?this._shapeConfig.fill(t,i):this._shapeConfig.fill)},fontStroke(t,i){return ei.bind(this)(t,i)?"transparent"===this._backgroundConfig.fill?A.colorDefaults.dark:A.colorContrast(this._backgroundConfig.fill):"transparent"},fontStrokeWidth(t,i){return ei.bind(this)(t,i)?.1:0},padding:3,textAnchor(t,i){var e="x"===this._discrete.charAt(0)?"y":"x",s="y"==e,e=this._discrete.replace(this._discrete.charAt(0),e),e=this["_"+e](t,i)<0,s=s?"middle":ei.bind(this)(t,i)?e?"end":"start":e?"start":"end";return Pt.rtl()?"start"==s?"end":"end"==s?"start":s:s},verticalAlign(t,i){var e="x"===this._discrete.charAt(0)?"y":"x",s="y"==e,e=this._discrete.replace(this._discrete.charAt(0),e),e=this["_"+e](t,i)<0;return s?ei.bind(this)(t,i)?e?"top":"bottom":e?"bottom":"top":"middle"}}},Circle:{r:Jt.bind(this)},Line:{curve:()=>this._discrete?"monotone"+this._discrete.charAt(0).toUpperCase():"linear",fill:Ht("none"),labelConfig:{fontColor:(t,i)=>{t="function"==typeof this._shapeConfig.Line.stroke?this._shapeConfig.Line.stroke(t,i):this._shapeConfig.Line.stroke;return A.colorLegible(t)},fontResize:!1,padding:5,textAnchor:"start",verticalAlign:"middle"},strokeWidth:Ht(2)},Rect:{height:t=>2*Jt.bind(this)(t),width:t=>2*Jt.bind(this)(t)}}),this._shapeOrder=["Area","Path","Bar","Box","Line","Rect","Circle"],this._shapeSort=(t,i)=>this._shapeOrder.indexOf(t)-this._shapeOrder.indexOf(i),this._sizeMax=20,this._sizeMin=5,this._sizeScale="sqrt",this._stackOffset=ii,this._stackOrder=Zt,this._timelineConfig=Pt.assign(this._timelineConfig,{brushing:!0,brushMin:()=>this._xTime||this._yTime||this._x2Time||this._y2Time?2:1}),this._x=s("x"),this._xKey="x",this._xAxis=(new et).align("end"),this._xTest=(new et).align("end").gridSize(0),this._xConfig={gridConfig:{stroke:t=>this._discrete&&"x"===this._discrete.charAt(0)||this._xAxis.range()[0]===this._xAxis._getPosition.bind(this._xAxis)(t.id)?"transparent":Yt.colors.gray[200]}},this._xCutoff=150,this._x2=s("x2"),this._x2Key="x2",this._x2Axis=(new nt).align("start"),this._x2Test=(new nt).align("start").gridSize(0),this._x2Config={
|
|
3713
|
+
*/constructor(){super(),this._axisPersist=!1,this._annotations=[],this._backgroundConfig={duration:0,fill:"transparent"},this._barPadding=0,this._buffer=Pt.assign({},Xt,{Bar:!1,Line:!1}),this._confidenceConfig={fill:(t,i)=>"function"==typeof this._shapeConfig.Line.stroke?this._shapeConfig.Line.stroke(t,i):this._shapeConfig.Line.stroke,fillOpacity:Ht(.5)},this._discreteCutoff=100,this._groupPadding=5,this._labelConnectorConfig={strokeDasharray:"1 1"},this._labelPosition=Ht("auto"),this._lineMarkerConfig={fill:(t,i)=>A.colorAssign(this._id(t,i)),r:Ht(3)},this._lineMarkers=!1,this._previousAnnotations={back:[],front:[]},this._previousShapes=[],this._shape=Ht("Circle"),this._shapeConfig=Pt.assign(this._shapeConfig,{Area:{label:(t,i)=>!!this._stacked&&this._drawLabel(t,i),labelBounds:(t,i,e)=>{let s=E.largestRect(e.points,{angle:Dt.range(-20,20,5)});if(!(s=!s||s.height<20||s.width<50?E.largestRect(e.points,{angle:Dt.range(-80,80,5)}):s))return null;let h=Dt.min(e.points,t=>t[0]);e=Dt.max(e.points.filter(t=>t[0]===h),t=>t[1]);return{angle:s.angle,width:s.width,height:s.height,x:s.cx-s.width/2-h,y:s.cy-s.height/2-e}},labelConfig:{fontMin:6,fontResize:!0,padding:10}},ariaLabel:(t,i)=>{let e="";return t.nested?e=""+this._drawLabel(t.data,t.i):(e=""+this._drawLabel(t,i),void 0!==this._x(t,i)&&(e+=", x: "+this._x(t,i)),void 0!==this._y(t,i)&&(e+=", y: "+this._y(t,i)),void 0!==this._x2(t,i)&&(e+=", x2: "+this._x2(t,i)),void 0!==this._y2(t,i)&&(e+=", y2: "+this._y2(t,i))),e+"."},Bar:{labelBounds(t,i,e){var s="y"===this._discrete?"width":"height",h="y"===this._discrete?"height":"width",n="x"===this._discrete.charAt(0)?"y":"x",r="y"==n,n=this._discrete.replace(this._discrete.charAt(0),n),a=this[`_${n}Axis`]._d3Scale.range(),a=Math.abs(a[1]-a[0]),n=this["_"+n](t,i)<0;return ei.bind(this)(t,i)?{[s]:a-e[s],[h]:e[h],x:r?-e.width/2:n?-a:e.width+1,y:r?n?e.height+1:-a:-e.height/2+1}:{[s]:e[s],[h]:e[h],x:r?-e.width/2:n?(this._stacked,1-e.width):-1,y:r?n?(this._stacked,1):1-e.height:-e.height/2+1}},labelConfig:{fontMax:16,fontMin:6,fontResize:!0,fontColor(t,i){return ei.bind(this)(t,i)?"transparent"===this._backgroundConfig.fill?A.colorDefaults.dark:A.colorContrast(this._backgroundConfig.fill):A.colorContrast("function"==typeof this._shapeConfig.fill?this._shapeConfig.fill(t,i):this._shapeConfig.fill)},fontStroke(t,i){return ei.bind(this)(t,i)?"transparent"===this._backgroundConfig.fill?A.colorDefaults.dark:A.colorContrast(this._backgroundConfig.fill):"transparent"},fontStrokeWidth(t,i){return ei.bind(this)(t,i)?.1:0},padding:3,textAnchor(t,i){var e="x"===this._discrete.charAt(0)?"y":"x",s="y"==e,e=this._discrete.replace(this._discrete.charAt(0),e),e=this["_"+e](t,i)<0,s=s?"middle":ei.bind(this)(t,i)?e?"end":"start":e?"start":"end";return Pt.rtl()?"start"==s?"end":"end"==s?"start":s:s},verticalAlign(t,i){var e="x"===this._discrete.charAt(0)?"y":"x",s="y"==e,e=this._discrete.replace(this._discrete.charAt(0),e),e=this["_"+e](t,i)<0;return s?ei.bind(this)(t,i)?e?"top":"bottom":e?"bottom":"top":"middle"}}},Circle:{r:Jt.bind(this)},Line:{curve:()=>this._discrete?"monotone"+this._discrete.charAt(0).toUpperCase():"linear",fill:Ht("none"),labelConfig:{fontColor:(t,i)=>{t="function"==typeof this._shapeConfig.Line.stroke?this._shapeConfig.Line.stroke(t,i):this._shapeConfig.Line.stroke;return A.colorLegible(t)},fontResize:!1,padding:5,textAnchor:"start",verticalAlign:"middle"},strokeWidth:Ht(2)},Rect:{height:t=>2*Jt.bind(this)(t),width:t=>2*Jt.bind(this)(t)}}),this._shapeOrder=["Area","Path","Bar","Box","Line","Rect","Circle"],this._shapeSort=(t,i)=>this._shapeOrder.indexOf(t)-this._shapeOrder.indexOf(i),this._sizeMax=20,this._sizeMin=5,this._sizeScale="sqrt",this._stackOffset=ii,this._stackOrder=Zt,this._timelineConfig=Pt.assign(this._timelineConfig,{brushing:!0,brushMin:()=>this._xTime||this._yTime||this._x2Time||this._y2Time?2:1}),this._x=s("x"),this._xKey="x",this._xAxis=(new et).align("end"),this._xTest=(new et).align("end").gridSize(0),this._xConfig={gridConfig:{stroke:t=>this._discrete&&"x"===this._discrete.charAt(0)||this._xAxis.range()[0]===this._xAxis._getPosition.bind(this._xAxis)(t.id)?"transparent":Yt.colors.gray[200]}},this._xCutoff=150,this._x2=s("x2"),this._x2Key="x2",this._x2Axis=(new nt).align("start"),this._x2Test=(new nt).align("start").gridSize(0),this._x2Config={},this._y=s("y"),this._yKey="y",this._yAxis=(new st).align("start"),this._yKey="y",this._yTest=(new st).align("start").gridSize(0),this._yConfig={gridConfig:{stroke:t=>{var i;return this._discrete&&"y"===this._discrete.charAt(0)||(i=this._yAxis.range())[i.length-1]===this._yAxis._getPosition.bind(this._yAxis)(t.id)?"transparent":Yt.colors.gray[200]}}},this._yCutoff=150,this._y2=s("y2"),this._y2Key="y2",this._y2Axis=(new ht).align("end"),this._y2Test=(new st).align("end").gridSize(0),this._y2Config={}}}class hi extends si{
|
|
3714
3714
|
/**
|
|
3715
3715
|
@memberof AreaPlot
|
|
3716
3716
|
@desc Invoked when creating a new class instance, and overrides any default parameters inherited from Plot.
|