@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
package/umd/d3plus-core.min.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
|
|
@@ -2187,9 +2187,9 @@ n=+s[0]==+s[1];return"brush"!==i.type&&"end"!==i.type||(this._selection="ticks"=
|
|
|
2187
2187
|
@chainable
|
|
2188
2188
|
*/render(t){var{height:i,y:e}=this._position;this._ticks&&(this._ticks=this._ticks.map(Pt.date)),this._data&&(this._data=this._data.map(Pt.date));let s=this._ticks||this._domain.map(Pt.date),h=(this._ticks||(n=S.scaleTime().domain(s).range([0,this._width]),s=n.ticks()),this._timeLocale||$.locale[this._locale]||$.locale["en-US"]),o=(void 0===this._userFormat&&(this._userFormat=this._tickFormat||!1),this._tickFormat=this._userFormat||(t=>Tt.formatDate(t,s).replace(/^Q/g,h.quarter)));if(
|
|
2189
2189
|
// Measures size of ticks
|
|
2190
|
-
this._ticksWidth=this._width,["auto","buttons"].includes(this._buttonBehavior)){let r=0;s.forEach((t,i)=>{var{fontFamily:e,fontSize:s}=this._shapeConfig.labelConfig;let h="function"==typeof e?e(t,i):e,n="function"==typeof s?s(t,i):s;e=H.textWrap().fontFamily(h).fontSize(n).lineHeight(this._shapeConfig.lineHeight?this._shapeConfig.lineHeight(t,i):void 0)(o(t));let a=e.lines.length?Math.ceil(Dt.max(e.lines.map(t=>Pt.textWidth(t,{"font-family":h,"font-size":n}))))+n/4:0;a%2&&a++,r<a&&(r=a+2*this._buttonPadding)}),this._ticksWidth=r*s.length}var n=this._playButton?this._buttonHeight:0,a=this._width-n,a=(this._buttonBehaviorCurrent="auto"===this._buttonBehavior?this._ticksWidth<a?"buttons":"ticks":this._buttonBehavior,this._hiddenHandles="buttons"===this._buttonBehaviorCurrent&&!this._brushing);if("buttons"===this._buttonBehaviorCurrent){this._scale="ordinal";let e=S.scaleTime().domain(this._domain.map(Pt.date)).ticks().map(Number);this._domain=this._ticks||Array.from(Array(e[e.length-1]-e[0]+1),(t,i)=>e[0]+i).map(Pt.date),this._ticks=this._domain;var r=.5*this._ticksWidth/this._ticks.length,l=this._width-this._ticksWidth-n;this._paddingLeft="middle"===this._buttonAlign?l/2+n:"end"===this._buttonAlign?l+n:n,this._range=[this._paddingLeft+r,this._paddingLeft+this._ticksWidth-r]}else this._scale="time",this._domain=Dt.extent(s),this._range=[n?1.5*n:void 0,void 0],this._paddingLeft=n;super.render(t);let _=this._outerBounds[e],d=this._d3Scale.range();l=this._brush=y.brushX().extent([[d[0],_],[d[d.length-1],_+this._outerBounds[i]]]).filter(this._brushFilter).handleSize(a?0:this._handleSize).on("start",this._brushStart.bind(this)).on("brush",this._brushBrush.bind(this)).on("end",this._brushEnd.bind(this)),r="ticks"===this._buttonBehaviorCurrent?this._availableTicks:d,t=[this._brushMin()>r.length?r[0]:r[r.length-this._brushMin()],r[r.length-1]],e=void 0===this._selection?t:this._selection instanceof Array?"buttons"===this._buttonBehaviorCurrent?this._selection.map(Pt.date).map(t=>d[this._ticks.map(Number).indexOf(+t)]):this._selection.map(Pt.date):"buttons"===this._buttonBehaviorCurrent?[d[this._ticks.map(Number).indexOf(+this._selection)]]:[this._selection],1===e.length&&e.push(e[0]),this._updateBrushLimit(e),this._brushGroup=Pt.elem("g.brushGroup",{parent:this._group}),this._brushGroup.call(l).transition(this._transition).call(l.move,"ticks"===this._buttonBehaviorCurrent?this._updateBrushLimit(e):e),this._outerBounds.y-=this._handleSize/2,this._outerBounds.height+=this._handleSize/2,i=Pt.elem("g.d3plus-Timeline-play",{parent:this._group});
|
|
2190
|
+
this._ticksWidth=this._width,["auto","buttons"].includes(this._buttonBehavior)){let r=0;s.forEach((t,i)=>{var{fontFamily:e,fontSize:s}=this._shapeConfig.labelConfig;let h="function"==typeof e?e(t,i):e,n="function"==typeof s?s(t,i):s;e=H.textWrap().fontFamily(h).fontSize(n).lineHeight(this._shapeConfig.lineHeight?this._shapeConfig.lineHeight(t,i):void 0)(o(t));let a=e.lines.length?Math.ceil(Dt.max(e.lines.map(t=>Pt.textWidth(t,{"font-family":h,"font-size":n}))))+n/4:0;a%2&&a++,r<a&&(r=a+2*this._buttonPadding)}),this._ticksWidth=r*s.length}var n=this._playButton?this._playButtonConfig.width||this._buttonHeight:0,a=this._width-n,a=(this._buttonBehaviorCurrent="auto"===this._buttonBehavior?this._ticksWidth<a?"buttons":"ticks":this._buttonBehavior,this._hiddenHandles="buttons"===this._buttonBehaviorCurrent&&!this._brushing);if("buttons"===this._buttonBehaviorCurrent){this._scale="ordinal";let e=S.scaleTime().domain(this._domain.map(Pt.date)).ticks().map(Number);this._domain=this._ticks||Array.from(Array(e[e.length-1]-e[0]+1),(t,i)=>e[0]+i).map(Pt.date),this._ticks=this._domain;var r=.5*this._ticksWidth/this._ticks.length,l=this._width-this._ticksWidth-n;this._paddingLeft="middle"===this._buttonAlign?l/2+n:"end"===this._buttonAlign?l+n:n,this._range=[this._paddingLeft+r,this._paddingLeft+this._ticksWidth-r]}else this._scale="time",this._domain=Dt.extent(s),this._range=[n?1.5*n:void 0,void 0],this._paddingLeft=n;super.render(t);let _=this._outerBounds[e],d=this._d3Scale.range();l=this._brush=y.brushX().extent([[d[0],_],[d[d.length-1],_+this._outerBounds[i]]]).filter(this._brushFilter).handleSize(a?0:this._handleSize).on("start",this._brushStart.bind(this)).on("brush",this._brushBrush.bind(this)).on("end",this._brushEnd.bind(this)),r="ticks"===this._buttonBehaviorCurrent?this._availableTicks:d,t=[this._brushMin()>r.length?r[0]:r[r.length-this._brushMin()],r[r.length-1]],e=void 0===this._selection?t:this._selection instanceof Array?"buttons"===this._buttonBehaviorCurrent?this._selection.map(Pt.date).map(t=>d[this._ticks.map(Number).indexOf(+t)]):this._selection.map(Pt.date):"buttons"===this._buttonBehaviorCurrent?[d[this._ticks.map(Number).indexOf(+this._selection)]]:[this._selection],1===e.length&&e.push(e[0]),this._updateBrushLimit(e),this._brushGroup=Pt.elem("g.brushGroup",{parent:this._group}),this._brushGroup.call(l).transition(this._transition).call(l.move,"ticks"===this._buttonBehaviorCurrent?this._updateBrushLimit(e):e),this._outerBounds.y-=this._handleSize/2,this._outerBounds.height+=this._handleSize/2,i=Pt.elem("g.d3plus-Timeline-play",{parent:this._group});
|
|
2191
2191
|
// data Array to be used when detecting the default value
|
|
2192
|
-
return this._playButtonClass.data(this._playButton?[{x:this._paddingLeft-n,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:n,height:
|
|
2192
|
+
return this._playButtonClass.data(this._playButton?[{x:this._paddingLeft-n,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:n,height:this._buttonHeight}]:[]).select(i.node()).config(jt.bind(this)(this._playButtonConfig)).render(),this}
|
|
2193
2193
|
/**
|
|
2194
2194
|
@memberof Timeline
|
|
2195
2195
|
@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.
|
|
@@ -2297,7 +2297,7 @@ return this._playButtonClass.data(this._playButton?[{x:this._paddingLeft-n,y:"bu
|
|
|
2297
2297
|
@private
|
|
2298
2298
|
*/constructor(){super(),this._barConfig=Pt.assign({},this._barConfig,{stroke:()=>"buttons"===this._buttonBehaviorCurrent?"transparent":_t,"stroke-width":()=>"buttons"===this._buttonBehaviorCurrent?0:1}),this._brushing=!0,this._brushFilter=t=>!t.button&&t.detail<2,this._brushMin=Ht(1),this._buttonAlign="middle",this._buttonBehavior="auto",this._buttonPadding=10,this._buttonHeight=24,this._domain=[2001,2010],this._gridSize=0,this._handleConfig={fill:A.colorDefaults.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 l).on("click",()=>{
|
|
2299
2299
|
// if playing, pause
|
|
2300
|
-
if(this._playTimer)clearInterval(this._playTimer),this._playTimer=!1,this._playButtonClass.render();else{let h=!0;var t=()=>{let t=this._selection||[this._domain[this._domain.length-1]];1===(t=(t=t instanceof Array?t:[t]).map(Pt.date).map(Number)).length&&t.push(t[0]);var i=this._ticks.map(Number),e=i.indexOf(t[0]),s=i.indexOf(t[t.length-1]);(s===i.length-1?h?this.selection([this._ticks[0],this._ticks[s-e]]):(clearInterval(this._playTimer),this._playTimer=!1,this._playButtonClass):(s+1===i.length-1&&(clearInterval(this._playTimer),this._playTimer=!1),this.selection([this._ticks[e+1],this._ticks[s+1]]))).render(),h=!1};this._playTimer=setInterval(t,this._playButtonInterval),t()}}).on("mousemove",()=>this._playButtonClass.select().style("cursor","pointer")),this._playButtonConfig={fontColor:A.colorDefaults.dark,fontSize:15,text:()=>this._playTimer?"
|
|
2300
|
+
if(this._playTimer)clearInterval(this._playTimer),this._playTimer=!1,this._playButtonClass.render();else{let h=!0;var t=()=>{let t=this._selection||[this._domain[this._domain.length-1]];1===(t=(t=t instanceof Array?t:[t]).map(Pt.date).map(Number)).length&&t.push(t[0]);var i=this._ticks.map(Number),e=i.indexOf(t[0]),s=i.indexOf(t[t.length-1]);(s===i.length-1?h?this.selection([this._ticks[0],this._ticks[s-e]]):(clearInterval(this._playTimer),this._playTimer=!1,this._playButtonClass):(s+1===i.length-1&&(clearInterval(this._playTimer),this._playTimer=!1),this.selection([this._ticks[e+1],this._ticks[s+1]]))).render(),h=!1};this._playTimer=setInterval(t,this._playButtonInterval),t()}}).on("mousemove",()=>this._playButtonClass.select().style("cursor","pointer")),this._playButtonConfig={fontColor:A.colorDefaults.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=Pt.assign({},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:A.colorDefaults.dark,fontSize:()=>12,verticalAlign:()=>"buttons"===this._buttonBehaviorCurrent?"middle":"top"},fill:()=>"buttons"===this._buttonBehaviorCurrent?"#fff":_t,stroke:()=>"buttons"===this._buttonBehaviorCurrent?_t:"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}}
|
|
2301
2301
|
/**
|
|
2302
2302
|
* Creates a reference element for popper.
|
|
2303
2303
|
* @param {Number[]} position
|