@d3plus/core 3.0.6 → 3.0.8
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 +17 -17
- package/es/src/components/Timeline.js +6 -6
- package/package.json +8 -8
- package/umd/d3plus-core.full.js +6 -6
- package/umd/d3plus-core.full.js.map +1 -1
- package/umd/d3plus-core.full.min.js +4 -4
- package/umd/d3plus-core.js +6 -6
- package/umd/d3plus-core.js.map +1 -1
- package/umd/d3plus-core.min.js +4 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
@d3plus/core v3.0.
|
|
2
|
+
@d3plus/core v3.0.8
|
|
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
|
|
@@ -3472,9 +3472,9 @@ o=+a[0]==+a[1];return"brush"!==n.type&&"end"!==n.type||(this._selection="ticks"=
|
|
|
3472
3472
|
@chainable
|
|
3473
3473
|
*/render(t){var{height:n,y:e}=this._position;this._ticks&&(this._ticks=this._ticks.map(Pt)),this._data&&(this._data=this._data.map(Pt));let i=this._ticks||this._domain.map(Pt),a=(this._ticks||(r=Ss().domain(i).range([0,this._width]),i=r.ticks()),this._timeLocale||wi[this._locale]||wi["en-US"]),l=(void 0===this._userFormat&&(this._userFormat=this._tickFormat||!1),this._tickFormat=this._userFormat||(t=>Yu(t,i).replace(/^Q/g,a.quarter)));if(
|
|
3474
3474
|
// Measures size of ticks
|
|
3475
|
-
this._ticksWidth=this._width,["auto","buttons"].includes(this._buttonBehavior)){let s=0;i.forEach((t,n)=>{var{fontFamily:e,fontSize:i}=this._shapeConfig.labelConfig;let a="function"==typeof e?e(t,n):e,r="function"==typeof i?i(t,n):i;e=si().fontFamily(a).fontSize(r).lineHeight(this._shapeConfig.lineHeight?this._shapeConfig.lineHeight(t,n):void 0)(l(t));let o=e.lines.length?Math.ceil(Ot(e.lines.map(t=>Ae(t,{"font-family":a,"font-size":r}))))+r/4:0;o%2&&o++,s<o&&(s=o+2*this._buttonPadding)}),this._ticksWidth=s*i.length}var r=this._playButton?this._buttonHeight:0,o=this._width-r,o=(this._buttonBehaviorCurrent="auto"===this._buttonBehavior?this._ticksWidth<o?"buttons":"ticks":this._buttonBehavior,this._hiddenHandles="buttons"===this._buttonBehaviorCurrent&&!this._brushing);if("buttons"===this._buttonBehaviorCurrent){this._scale="ordinal";let e=Ss().domain(this._domain.map(Pt)).ticks().map(Number);this._domain=this._ticks||Array.from(Array(e[e.length-1]-e[0]+1),(t,n)=>e[0]+n).map(Pt),this._ticks=this._domain;var s=.5*this._ticksWidth/this._ticks.length,h=this._width-this._ticksWidth-r;this._paddingLeft="middle"===this._buttonAlign?h/2+r:"end"===this._buttonAlign?h+r:r,this._range=[this._paddingLeft+s,this._paddingLeft+this._ticksWidth-s]}else this._scale="time",this._domain=Hi(i),this._range=[r?1.5*r:void 0,void 0],this._paddingLeft=r;super.render(t);let u=this._outerBounds[e],c=this._d3Scale.range();h=this._brush=xg(lg).extent([[c[0],u],[c[c.length-1],u+this._outerBounds[n]]]).filter(this._brushFilter).handleSize(o?0:this._handleSize).on("start",this._brushStart.bind(this)).on("brush",this._brushBrush.bind(this)).on("end",this._brushEnd.bind(this)),s="ticks"===this._buttonBehaviorCurrent?this._availableTicks:c,t=[this._brushMin()>s.length?s[0]:s[s.length-this._brushMin()],s[s.length-1]],e=void 0===this._selection?t:this._selection instanceof Array?"buttons"===this._buttonBehaviorCurrent?this._selection.map(Pt).map(t=>c[this._ticks.map(Number).indexOf(+t)]):this._selection.map(Pt):"buttons"===this._buttonBehaviorCurrent?[c[this._ticks.map(Number).indexOf(+this._selection)]]:[this._selection],1===e.length&&e.push(e[0]),this._updateBrushLimit(e),this._brushGroup=Nt("g.brushGroup",{parent:this._group}),this._brushGroup.call(h).transition(this._transition).call(h.move,"ticks"===this._buttonBehaviorCurrent?this._updateBrushLimit(e):e),this._outerBounds.y-=this._handleSize/2,this._outerBounds.height+=this._handleSize/2,n=Nt("g.d3plus-Timeline-play",{parent:this._group});
|
|
3475
|
+
this._ticksWidth=this._width,["auto","buttons"].includes(this._buttonBehavior)){let s=0;i.forEach((t,n)=>{var{fontFamily:e,fontSize:i}=this._shapeConfig.labelConfig;let a="function"==typeof e?e(t,n):e,r="function"==typeof i?i(t,n):i;e=si().fontFamily(a).fontSize(r).lineHeight(this._shapeConfig.lineHeight?this._shapeConfig.lineHeight(t,n):void 0)(l(t));let o=e.lines.length?Math.ceil(Ot(e.lines.map(t=>Ae(t,{"font-family":a,"font-size":r}))))+r/4:0;o%2&&o++,s<o&&(s=o+2*this._buttonPadding)}),this._ticksWidth=s*i.length}var r=this._playButton?this._playButtonConfig.width||this._buttonHeight:0,o=this._width-r,o=(this._buttonBehaviorCurrent="auto"===this._buttonBehavior?this._ticksWidth<o?"buttons":"ticks":this._buttonBehavior,this._hiddenHandles="buttons"===this._buttonBehaviorCurrent&&!this._brushing);if("buttons"===this._buttonBehaviorCurrent){this._scale="ordinal";let e=Ss().domain(this._domain.map(Pt)).ticks().map(Number);this._domain=this._ticks||Array.from(Array(e[e.length-1]-e[0]+1),(t,n)=>e[0]+n).map(Pt),this._ticks=this._domain;var s=.5*this._ticksWidth/this._ticks.length,h=this._width-this._ticksWidth-r;this._paddingLeft="middle"===this._buttonAlign?h/2+r:"end"===this._buttonAlign?h+r:r,this._range=[this._paddingLeft+s,this._paddingLeft+this._ticksWidth-s]}else this._scale="time",this._domain=Hi(i),this._range=[r?1.5*r:void 0,void 0],this._paddingLeft=r;super.render(t);let u=this._outerBounds[e],c=this._d3Scale.range();h=this._brush=xg(lg).extent([[c[0],u],[c[c.length-1],u+this._outerBounds[n]]]).filter(this._brushFilter).handleSize(o?0:this._handleSize).on("start",this._brushStart.bind(this)).on("brush",this._brushBrush.bind(this)).on("end",this._brushEnd.bind(this)),s="ticks"===this._buttonBehaviorCurrent?this._availableTicks:c,t=[this._brushMin()>s.length?s[0]:s[s.length-this._brushMin()],s[s.length-1]],e=void 0===this._selection?t:this._selection instanceof Array?"buttons"===this._buttonBehaviorCurrent?this._selection.map(Pt).map(t=>c[this._ticks.map(Number).indexOf(+t)]):this._selection.map(Pt):"buttons"===this._buttonBehaviorCurrent?[c[this._ticks.map(Number).indexOf(+this._selection)]]:[this._selection],1===e.length&&e.push(e[0]),this._updateBrushLimit(e),this._brushGroup=Nt("g.brushGroup",{parent:this._group}),this._brushGroup.call(h).transition(this._transition).call(h.move,"ticks"===this._buttonBehaviorCurrent?this._updateBrushLimit(e):e),this._outerBounds.y-=this._handleSize/2,this._outerBounds.height+=this._handleSize/2,n=Nt("g.d3plus-Timeline-play",{parent:this._group});
|
|
3476
3476
|
// data Array to be used when detecting the default value
|
|
3477
|
-
return this._playButtonClass.data(this._playButton?[{x:this._paddingLeft-r,y:"buttons"===this._buttonBehaviorCurrent?"middle"===this._align?this._height/2-this._buttonHeight/2:"start"===this._align?this._margin.top:this._height-this._buttonHeight-this._margin.bottom:this._outerBounds.y,width:r,height:
|
|
3477
|
+
return this._playButtonClass.data(this._playButton?[{x:this._paddingLeft-r,y:"buttons"===this._buttonBehaviorCurrent?"middle"===this._align?this._height/2-this._buttonHeight/2:"start"===this._align?this._margin.top:this._height-this._buttonHeight-this._margin.bottom:this._outerBounds.y,width:r,height:this._buttonHeight}]:[]).select(n.node()).config(Lt.bind(this)(this._playButtonConfig)).render(),this}
|
|
3478
3478
|
/**
|
|
3479
3479
|
@memberof Timeline
|
|
3480
3480
|
@desc If *value* is specified, sets the button padding and returns the current class instance. If *value* is not specified, returns the current button padding.
|
|
@@ -3582,7 +3582,7 @@ return this._playButtonClass.data(this._playButton?[{x:this._paddingLeft-r,y:"bu
|
|
|
3582
3582
|
@private
|
|
3583
3583
|
*/constructor(){super(),this._barConfig=Et({},this._barConfig,{stroke:()=>"buttons"===this._buttonBehaviorCurrent?"transparent":wg,"stroke-width":()=>"buttons"===this._buttonBehaviorCurrent?0:1}),this._brushing=!0,this._brushFilter=t=>!t.button&&t.detail<2,this._brushMin=Bt(1),this._buttonAlign="middle",this._buttonBehavior="auto",this._buttonPadding=10,this._buttonHeight=24,this._domain=[2001,2010],this._gridSize=0,this._handleConfig={fill:Rh.light,stroke:"#228be6","stroke-width":2,rx:2,ry:2},this._handleSize=6,this._height=100,this._labelOffset=!1,this._on={},this.orient("bottom"),this._playButton=!0,this._playButtonClass=(new Wc).on("click",()=>{
|
|
3584
3584
|
// if playing, pause
|
|
3585
|
-
if(this._playTimer)clearInterval(this._playTimer),this._playTimer=!1,this._playButtonClass.render();else{let a=!0;var t=()=>{let t=this._selection||[this._domain[this._domain.length-1]];1===(t=(t=t instanceof Array?t:[t]).map(Pt).map(Number)).length&&t.push(t[0]);var n=this._ticks.map(Number),e=n.indexOf(t[0]),i=n.indexOf(t[t.length-1]);(i===n.length-1?a?this.selection([this._ticks[0],this._ticks[i-e]]):(clearInterval(this._playTimer),this._playTimer=!1,this._playButtonClass):(i+1===n.length-1&&(clearInterval(this._playTimer),this._playTimer=!1),this.selection([this._ticks[e+1],this._ticks[i+1]]))).render(),a=!1};this._playTimer=setInterval(t,this._playButtonInterval),t()}}).on("mousemove",()=>this._playButtonClass.select().style("cursor","pointer")),this._playButtonConfig={fontColor:Rh.dark,fontSize:15,text:()=>this._playTimer?"
|
|
3585
|
+
if(this._playTimer)clearInterval(this._playTimer),this._playTimer=!1,this._playButtonClass.render();else{let a=!0;var t=()=>{let t=this._selection||[this._domain[this._domain.length-1]];1===(t=(t=t instanceof Array?t:[t]).map(Pt).map(Number)).length&&t.push(t[0]);var n=this._ticks.map(Number),e=n.indexOf(t[0]),i=n.indexOf(t[t.length-1]);(i===n.length-1?a?this.selection([this._ticks[0],this._ticks[i-e]]):(clearInterval(this._playTimer),this._playTimer=!1,this._playButtonClass):(i+1===n.length-1&&(clearInterval(this._playTimer),this._playTimer=!1),this.selection([this._ticks[e+1],this._ticks[i+1]]))).render(),a=!1};this._playTimer=setInterval(t,this._playButtonInterval),t()}}).on("mousemove",()=>this._playButtonClass.select().style("cursor","pointer")),this._playButtonConfig={fontColor:Rh.dark,fontSize:15,text:()=>this._playTimer?"⏸":"⏵",textAnchor:"middle",verticalAlign:"middle"},this._playButtonInterval=1e3,this._selectionConfig={fill:"#228be6","fill-opacity":()=>"buttons"===this._buttonBehaviorCurrent?.3:1,"stroke-width":0},this._shape="Rect",this._shapeConfig=Et({},this._shapeConfig,{labelBounds:t=>"buttons"===this._buttonBehaviorCurrent?{x:t.labelBounds.x,y:-this._buttonHeight/2+1,width:t.labelBounds.width,height:this._buttonHeight}:t.labelBounds,labelConfig:{fontColor:Rh.dark,fontSize:()=>12,verticalAlign:()=>"buttons"===this._buttonBehaviorCurrent?"middle":"top"},fill:()=>"buttons"===this._buttonBehaviorCurrent?"#fff":wg,stroke:()=>"buttons"===this._buttonBehaviorCurrent?wg:"transparent",height:t=>"buttons"===this._buttonBehaviorCurrent?this._buttonHeight:t.tick?this._handleSize:0,width:t=>"buttons"===this._buttonBehaviorCurrent?this._ticksWidth/this._availableTicks.length:t.tick?this._domain.map(Number).includes(t.id)?2:1:0,y:t=>"buttons"===this._buttonBehaviorCurrent?"middle"===this._align?this._height/2:"start"===this._align?this._margin.top+this._buttonHeight/2:this._height-this._buttonHeight/2-this._margin.bottom:t.y,rx:t=>"buttons"!==this._buttonBehaviorCurrent&&this._domain.map(Number).includes(t.id)?1:0,ry:t=>"buttons"!==this._buttonBehaviorCurrent&&this._domain.map(Number).includes(t.id)?1:0}),this._snapping=!0}}var kg="top",Cg="bottom",Mg="right",Ag="left",zg="auto",Tg=[kg,Cg,Mg,Ag],Eg="start",Pg="end",Ng="clippingParents",Lg="viewport",Bg="popper",Og="reference",Dg=Tg.reduce(function(t,n){return t.concat([n+"-"+Eg,n+"-"+Pg])},[]),jg=[].concat(Tg,[zg]).reduce(function(t,n){return t.concat([n,n+"-"+Eg,n+"-"+Pg])},[]),Rg=["beforeRead","read","afterRead","beforeMain","main","afterMain","beforeWrite","write","afterWrite"];function Ig(t){return t?(t.nodeName||"").toLowerCase():null}function Fg(t){var n;return null==t?window:"[object Window]"!==t.toString()?(n=t.ownerDocument)&&n.defaultView||window:t}function Hg(t){return t instanceof Fg(t).Element||t instanceof Element}function Gg(t){return t instanceof Fg(t).HTMLElement||t instanceof HTMLElement}function Kg(t){
|
|
3586
3586
|
// IE 11 has no ShadowRoot
|
|
3587
3587
|
return"undefined"!=typeof ShadowRoot&&(t instanceof Fg(t).ShadowRoot||t instanceof ShadowRoot)}
|
|
3588
3588
|
// and applies them to the HTMLElements such as popper and arrow
|
package/umd/d3plus-core.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
@d3plus/core v3.0.
|
|
2
|
+
@d3plus/core v3.0.8
|
|
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
|
|
@@ -5829,7 +5829,7 @@
|
|
|
5829
5829
|
});
|
|
5830
5830
|
this._ticksWidth = maxLabel * ticks.length;
|
|
5831
5831
|
}
|
|
5832
|
-
const playButtonWidth = this._playButton ? this._buttonHeight : 0;
|
|
5832
|
+
const playButtonWidth = this._playButton ? this._playButtonConfig.width || this._buttonHeight : 0;
|
|
5833
5833
|
const space = this._width - playButtonWidth;
|
|
5834
5834
|
this._buttonBehaviorCurrent = this._buttonBehavior === "auto" ? this._ticksWidth < space ? "buttons" : "ticks" : this._buttonBehavior;
|
|
5835
5835
|
const hiddenHandles = this._hiddenHandles = this._buttonBehaviorCurrent === "buttons" && !this._brushing;
|
|
@@ -5895,9 +5895,9 @@
|
|
|
5895
5895
|
x: this._paddingLeft - playButtonWidth,
|
|
5896
5896
|
y: this._buttonBehaviorCurrent === "buttons" ? this._align === "middle" ? this._height / 2 - this._buttonHeight / 2 : this._align === "start" ? this._margin.top : this._height - this._buttonHeight - this._margin.bottom : this._outerBounds.y,
|
|
5897
5897
|
width: playButtonWidth,
|
|
5898
|
-
height:
|
|
5898
|
+
height: this._buttonHeight
|
|
5899
5899
|
}
|
|
5900
|
-
] : []).select(playButtonGroup.node()).config(this._playButtonConfig).render();
|
|
5900
|
+
] : []).select(playButtonGroup.node()).config(configPrep.bind(this)(this._playButtonConfig)).render();
|
|
5901
5901
|
return this;
|
|
5902
5902
|
}
|
|
5903
5903
|
/**
|
|
@@ -6118,13 +6118,13 @@
|
|
|
6118
6118
|
this._playButtonConfig = {
|
|
6119
6119
|
fontColor: color.colorDefaults.dark,
|
|
6120
6120
|
fontSize: 15,
|
|
6121
|
-
text: ()=>this._playTimer ? "
|
|
6121
|
+
text: ()=>this._playTimer ? "⏸" : "⏵",
|
|
6122
6122
|
textAnchor: "middle",
|
|
6123
6123
|
verticalAlign: "middle"
|
|
6124
6124
|
};
|
|
6125
6125
|
this._playButtonInterval = 1000;
|
|
6126
6126
|
this._selectionConfig = {
|
|
6127
|
-
|
|
6127
|
+
fill: "#228be6",
|
|
6128
6128
|
"fill-opacity": ()=>this._buttonBehaviorCurrent === "buttons" ? 0.3 : 1,
|
|
6129
6129
|
"stroke-width": 0
|
|
6130
6130
|
};
|