@fusioncharts/utils
Advanced tools
Comparing version 1.2.0 to 1.3.0
{ | ||
"name": "@fusioncharts/utils", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "Collection of utilities for FusionCharts", | ||
@@ -39,3 +39,3 @@ "author": "FusionCharts, Inc. <support@fusioncharts.com>", | ||
], | ||
"gitHead": "88ea06dfe63ec1bd21fcbf428507cf3da5e66bc7" | ||
"gitHead": "df80bc85d1505daace51d3151b03ac67a1d8afa7" | ||
} |
@@ -1,1 +0,1 @@ | ||
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule=true;exports.getCoordinates=exports.getPlotFromPixel=exports.polarToCartesian=exports.cartesianToPolar=exports.rad2Deg=exports.deg2Rad=void 0;var _pluckNumber=_interopRequireDefault(require("../pluck-number"));var deg2Rad=function deg2Rad(theta){return theta*(Math.PI/180)},rad2Deg=function rad2Deg(rad){return rad*(180/Math.PI)},cartesianToPolar=function cartesianToPolar(x,y){var r,theta;r=Math.sqrt(x*x+y*y);theta=rad2Deg(Math.atan(y/x));if(x<0&&y>=0){theta+=180}else if(x<0&&y<0){theta+=180}else if(x>0&&y<0){theta+=360}return{radius:r,theta:deg2Rad(theta)}},polarToCartesian=function polarToCartesian(r,_theta,degreeInRad){if(degreeInRad===void 0){degreeInRad=true}var x,y,theta=_theta;if(!degreeInRad){theta=deg2Rad(theta)}x=r*Math.cos(theta);y=r*Math.sin(theta);return{x:x,y:y}},getCoordinates=function getCoordinates(values,axis){var theta,scaleX=axis.getScale(),radius=values.radius,axisConfig=axis.config,centerX=axisConfig.axisDimention.centerX,centerY=axisConfig.axisDimention.centerY,point;radius=(0,_pluckNumber.default)(radius,axisConfig.radius,0);theta=scaleX.getRangeValue(values.theta);point=polarToCartesian(radius,theta);point.x+=centerX;point.y+=centerY;return point},getPlotFromPixel=function getPlotFromPixel(coordinates,axis){var x=coordinates.x,y=coordinates.y,scaleX=axis.getScale(),theta,plot;plot=cartesianToPolar(x,y);theta=scaleX.getDomainValue(plot.theta);return rad2Deg(theta)};exports.getPlotFromPixel=getPlotFromPixel;exports.getCoordinates=getCoordinates;exports.polarToCartesian=polarToCartesian;exports.cartesianToPolar=cartesianToPolar;exports.rad2Deg=rad2Deg;exports.deg2Rad=deg2Rad; | ||
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule=true;exports.radiansInAngle=exports.changeAngleBase=exports.findArc=exports.normaliseAngle=exports.pointOnCircleFromCenter=exports.getCoordinates=exports.getPlotFromPixel=exports.polarToCartesian=exports.cartesianToPolar=exports.rad2Deg=exports.deg2Rad=void 0;var _pluckNumber=_interopRequireDefault(require("../pluck-number"));var NOMRALIZE_CONSTANT=90,deg2Rad=function deg2Rad(theta){return theta*(Math.PI/180)},rad2Deg=function rad2Deg(rad){return rad*(180/Math.PI)},cartesianToPolar=function cartesianToPolar(x,y){var r,theta;r=Math.sqrt(x*x+y*y);theta=rad2Deg(Math.atan(y/x));if(x<0&&y>=0){theta+=180}else if(x<0&&y<0){theta+=180}else if(x>0&&y<0){theta+=360}return{radius:r,theta:deg2Rad(theta)}},polarToCartesian=function polarToCartesian(r,_theta,degreeInRad){if(degreeInRad===void 0){degreeInRad=true}var x,y,theta=_theta;if(!degreeInRad){theta=deg2Rad(theta)}x=r*Math.cos(theta);y=r*Math.sin(theta);return{x:x,y:y}},getCoordinates=function getCoordinates(values,axis){var theta,scaleX=axis.getScale(),radius=values.radius,axisConfig=axis.config,centerX=axisConfig.axisDimention.centerX,centerY=axisConfig.axisDimention.centerY,point;radius=(0,_pluckNumber.default)(radius,axisConfig.radius,0);theta=scaleX.getRangeValue(values.theta);point=polarToCartesian(radius,theta);point.x+=centerX;point.y+=centerY;return point},getPlotFromPixel=function getPlotFromPixel(coordinates,axis){var x=coordinates.x,y=coordinates.y,scaleX=axis.getScale(),theta,plot;plot=cartesianToPolar(x,y);theta=scaleX.getDomainValue(plot.theta);return rad2Deg(theta)},pointOnCircleFromCenter=function pointOnCircleFromCenter(centerX,centerY,radius,angleInDegrees){var angleInRadians=(angleInDegrees-90)*Math.PI/180;return{x:centerX+radius*Math.cos(angleInRadians),y:centerY+radius*Math.sin(angleInRadians)}},normaliseAngle=function normaliseAngle(angle){return angle-NOMRALIZE_CONSTANT},findArc=function findArc(startAngle,endingAngle){var endAngle,arc=0;endAngle=endingAngle>360?endingAngle%360:endingAngle<0?360+endingAngle:endingAngle;if(endAngle>startAngle){arc=endAngle-startAngle}else{arc=360-(startAngle-endAngle)}return arc},changeAngleBase=function changeAngleBase(angle){if(angle>=0&&angle<90){return Math.abs(180-angle)}else if(angle>90&&angle<=180){return Math.abs(angle-180)}else if(angle>180&&angle<270||angle>270&&angle<360){return Math.abs(360-angle+180)}else if(angle===360){return 180}return angle},radiansInAngle=function radiansInAngle(arc,radius){return arc/radius*(180/Math.PI)};exports.radiansInAngle=radiansInAngle;exports.changeAngleBase=changeAngleBase;exports.findArc=findArc;exports.normaliseAngle=normaliseAngle;exports.pointOnCircleFromCenter=pointOnCircleFromCenter;exports.getPlotFromPixel=getPlotFromPixel;exports.getCoordinates=getCoordinates;exports.polarToCartesian=polarToCartesian;exports.cartesianToPolar=cartesianToPolar;exports.rad2Deg=rad2Deg;exports.deg2Rad=deg2Rad; |
@@ -1,1 +0,1 @@ | ||
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule=true;exports.default=exports.copyScaleBin=void 0;var _inheritsLoose2=_interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));var _calendar=_interopRequireDefault(require("./calendar"));var _scaleUtils=require("../scale-utils");exports.getFloorOfDate=_scaleUtils.getFloorOfDate;exports.modifyDate=_scaleUtils.modifyDate;var _pluckNumber=_interopRequireDefault(require("../pluck-number"));var _timeBucket=require("../time-bucket");var _timeConverter=_interopRequireDefault(require("../time-converter"));var _year=_interopRequireDefault(require("../time-intervals/year"));var _clipUtils=require("../clip-utils");var _capsFirst=_interopRequireDefault(require("../string/caps-first"));var UNDEF;var DEFAULT_THRESHOLD_PIXELS=4,MAJOR="major",MINOR="minor",CONTEXT="context",YEAR="year",BLANK="",DAY_1=1e3*60*60*24,DAY_30=DAY_1*30,DAY_365=DAY_1*365,MONTHS=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],CONTEXT_SEQ=["millisecond","second","minute","hour","day","month","year"],showMonthInDayTick=true,domainToMajorIntervalRatio=[{ratio:4,index:8},{ratio:3,index:7},{ratio:2.5,index:6},{ratio:2,index:5},{ratio:1.5,index:4},{ratio:1,index:3},{ratio:.67,index:2},{ratio:.33,index:1},{ratio:0,index:0}],bimap=function bimap(domain,range,deInterpolate,reInterpolate){var deInterpolator,reInterpolator;if(domain[0]>domain[1]){deInterpolator=deInterpolate(domain[1],domain[0]);reInterpolator=reInterpolate(range[1],range[0])}else{deInterpolator=deInterpolate(domain[0],domain[1]);reInterpolator=reInterpolate(range[0],range[1])}return function(value){return reInterpolator(deInterpolator(value))}},copyScaleBin=function copyScaleBin(sourceScale,targetScale){return targetScale.setInterpolate(sourceScale.getInterpolate()).setClamp(sourceScale.getClamp()).setRangeThreshold(sourceScale._threshold).setRange(sourceScale.getRange()).setThresholdIntervals(sourceScale.thresholdIntervals).setBinMin(sourceScale.getBinMin()).setClippings(sourceScale.clippings).setFirstData(sourceScale.getFirstData()).setDomain(sourceScale.getDomain())},validate=function validate(x){return x!==null&&!isNaN(x)},niceMinorTickIndex=function niceMinorTickIndex(value){var i,len=domainToMajorIntervalRatio.length,inverse=1/value;if(inverse>4){return Infinity}for(i=0;i<len;i++){if(inverse>domainToMajorIntervalRatio[i].ratio){return domainToMajorIntervalRatio[i].index}}},contextChange=function contextChange(startDate,endDate,index,thresholdIntervals,utc){var start=(0,_scaleUtils.getFloorOfDate)(new Date(startDate),thresholdIntervals[index][0].name(),thresholdIntervals[index][1],utc),end=(0,_scaleUtils.getFloorOfDate)(new Date(endDate),thresholdIntervals[index][0].name(),thresholdIntervals[index][1],utc);if(+start!==+end){return[start,end]}return false},biSearch=function biSearch(ar,val){var start=0,end=ar.length-1,mid;while(start<=end){mid=start+Math.ceil((end-start)/2);if(val>=ar[mid].start&&val<ar[mid].end){return mid}if(ar[mid].end<=val){start=mid+1}else{end=mid-1}}return-1},dateAPI=function dateAPI(date,param,utc){return date["get"+utc+param]()},formatDate=function formatDate(x){return(x<10?"0"+x:x)+""},getFullDate=function getFullDate(date,type){return MONTHS[dateAPI(date,"Month",type)]+" "+formatDate(dateAPI(date,"Date",type))+", "+dateAPI(date,"FullYear",type)},getFullTime=function getFullTime(date,type){return formatDate(dateAPI(date,"Hours",type))+":"+formatDate(dateAPI(date,"Minutes",type))+":"+formatDate(dateAPI(date,"Seconds",type))},getNiceYearlyMajorTicks=function getNiceYearlyMajorTicks(thresholdIntervals,curMajorIndex,minDiff){var i;i=curMajorIndex;while(i-1>=0&&thresholdIntervals[i-1][0].name()==="year"&&thresholdIntervals[i-1][2]>=minDiff){i--}return i};exports.copyScaleBin=copyScaleBin;var ScaleCalendarBin=function(_ScaleCalendar){(0,_inheritsLoose2.default)(ScaleCalendarBin,_ScaleCalendar);function ScaleCalendarBin(year,month,week,day,hour,minute,second,millisecond){var _this;_this=_ScaleCalendar.call(this,year,month,week,day,hour,minute,second,millisecond)||this;_this._type=BLANK;_this.bins=[];_this.clippings=[];_this.clipIndices=[];_this.clips=[];_this.clippedDomain=[0,1];_this.applicableClippings={};return _this}var _proto=ScaleCalendarBin.prototype;_proto.getType=function getType(){return this._type};_proto.setTimeInterval=function setTimeInterval(timeIntervals){this.timeIntervals=timeIntervals;_ScaleCalendar.prototype.setTimeInterval.call(this,timeIntervals)};_proto.setUnclippedTimeIntervals=function setUnclippedTimeIntervals(unclippedTimeIntervals){this.unclippedTimeIntervals=unclippedTimeIntervals;_ScaleCalendar.prototype.setUnclippedTimeIntervals.call(this,unclippedTimeIntervals)};_proto._rescale=function _rescale(){this.output=null;this.input=null;return this};_proto.setClippings=function setClippings(clippings){this.clippings=clippings;return this};_proto.getClippings=function getClippings(){return this.clippings};_proto.showPlotOverTick=function showPlotOverTick(){var scale=this,curBin=scale._getRangeThreshold(),minBin=scale.getBinMin();if((minBin[0].name()==="millisecond"||CONTEXT_SEQ.indexOf(curBin[0].name())>-1)&&curBin[1]===1){return true}return false};_proto.getBinBounds=function getBinBounds(idx){var bin=this._getBinBounds(idx);return{startDate:+bin.start,endDate:+bin.end}};_proto.getBinIndex=function getBinIndex(curTimeStamp,enableRoundOff){if(enableRoundOff===void 0){enableRoundOff=true}var binIndex=this._getBinIndex(curTimeStamp),binBounds=this._getBinBounds(binIndex),binsArLength=this.bins.length,binMid=+binBounds.start+(binBounds.end-binBounds.start)/2,showPlotOverTick=this.showPlotOverTick();if(enableRoundOff&&showPlotOverTick&&curTimeStamp>=binMid){binIndex++;while(binIndex<binsArLength&&this.bins[binIndex].clipType===2){binIndex++}}return binIndex};_proto.calculateRangeValue=function calculateRangeValue(value){var domain=this.getDomain(),bins=this.bins,clippedDomainValue;clippedDomainValue=value<bins[0].start||value>=bins[bins.length-1].end?value:+domain[0]+this.distance(+domain[0],+value);if(!this.output){this.output=bimap(this.clippedDomain,this.getRange(),this.deInterpolate,this.interpolate)}return this.output(Number(clippedDomainValue))};_proto.getRangeValue=function getRangeValue(startValue,endValue){if(typeof startValue==="undefined"&&typeof endValue==="undefined"){return UNDEF}else if(typeof endValue==="undefined"){return this.calculateRangeValue(startValue)}if(this.showPlotOverTick()){return this.calculateRangeValue(startValue)}return(this.calculateRangeValue(startValue)+this.calculateRangeValue(endValue))/2};_proto.getDomainValue=function getDomainValue(value){if(isNaN(value)){return value}var domain=this.getDomain(),compressedDomainValue,spreadedDomainValue;if(!this.input){this.input=bimap(this.getRange(),this.clippedDomain,this.deInterpolate,this.interpolate)}compressedDomainValue=this.input(Number(value));spreadedDomainValue=this.offset(+domain[0],compressedDomainValue-domain[0]);return new Date(spreadedDomainValue)};_proto.calculateIndexOfIntervals=function calculateIndexOfIntervals(){var scale=this,intervalIndexMap,thresholdIntervals=scale.thresholdIntervals,i,len=thresholdIntervals.length;scale.intervalIndexMap=intervalIndexMap={};for(i=len-1;i>=0;i--){intervalIndexMap[thresholdIntervals[i][0].name()]=i}};_proto.getNiceMinorTickInterval=function getNiceMinorTickInterval(majorIndex,gap,domainLength){if(majorIndex===0){return-1}var scale=this,thresholdIntervals=scale.thresholdIntervals,i,minDiff=scale._getRangeThreshold()[2],density,curIntervalName=thresholdIntervals[majorIndex-1][0].name(),len,minAllowedMinorBinIndex,divisible=[];for(i=0,len=thresholdIntervals.length;i<len;i++){if(thresholdIntervals[i][2]>=minDiff){minAllowedMinorBinIndex=i;break}}for(i=majorIndex-1;i>=minAllowedMinorBinIndex;i--){if(thresholdIntervals[i][0].name()!==curIntervalName){break}if(!(thresholdIntervals[i][2]%minDiff)&&curIntervalName!=="year"){divisible.push(i)}}density=Math.min(niceMinorTickIndex(domainLength/gap),divisible.length-1);return(0,_pluckNumber.default)(divisible[density],-1)};_proto.getNiceMajorTickInterval=function getNiceMajorTickInterval(curMajorIndex,dayInMajor){if(dayInMajor===void 0){dayInMajor=false}var scale=this,thresholdIntervals=scale.thresholdIntervals,i,len=thresholdIntervals.length,curBin=scale._getRangeThreshold(),minDiff=curBin[2],scaleMode=scale.getMode();if(scaleMode==="random"){if(!dayInMajor&&thresholdIntervals[curMajorIndex][0].name()==="day"&&(thresholdIntervals[curMajorIndex][1]>1||thresholdIntervals[curMajorIndex][2]>minDiff)){for(i=curMajorIndex;i<len;i++){if(thresholdIntervals[i][0].name()!=="day"&&minDiff<thresholdIntervals[i][2]){return i}}}else{if(thresholdIntervals[curMajorIndex][0].name()==="year"){return getNiceYearlyMajorTicks(thresholdIntervals,curMajorIndex,minDiff)}for(i=curMajorIndex;i<len;i++){if(thresholdIntervals[i][2]>minDiff){return i}}}}else{if(thresholdIntervals[curMajorIndex][1]!==1||thresholdIntervals[curMajorIndex][2]<=minDiff){if(thresholdIntervals[curMajorIndex][0].name()==="year"){return getNiceYearlyMajorTicks(thresholdIntervals,curMajorIndex,minDiff)}for(i=curMajorIndex;i<len;i++){if(thresholdIntervals[i][1]===1&&thresholdIntervals[i][2]>minDiff){return i}}}}return curMajorIndex};_proto.generateContextTicks=function generateContextTicks(curMajorIndex,coincideWithMajor){if(coincideWithMajor===void 0){coincideWithMajor=false}var scale=this,thresholdIntervals=scale.thresholdIntervals,intervalIndexMap=scale.intervalIndexMap,domain=scale.getDomain(),start=domain[0],end=domain[1],majorIntervalName=thresholdIntervals[curMajorIndex][0].name(),desiredContextInterval=CONTEXT_SEQ[CONTEXT_SEQ.indexOf(majorIntervalName)+1],j,len=thresholdIntervals.length,dayStartIndex=intervalIndexMap.day,contextOfStart,contextOfEnd,contextIndex=-1,context,contextTickAr=[];if(coincideWithMajor){contextIndex=curMajorIndex}else{if(majorIntervalName==="day"&&showMonthInDayTick){desiredContextInterval=YEAR}for(j=Math.max(curMajorIndex,dayStartIndex);j<len;j++){if(thresholdIntervals[j][0].name()===desiredContextInterval){contextIndex=j;break}}}if(contextIndex>-1){contextOfStart=(0,_scaleUtils.getFloorOfDate)(new Date(start),thresholdIntervals[contextIndex][0].name(),thresholdIntervals[contextIndex][1],scale.getType());if(context=contextChange(new Date(start),new Date(end),contextIndex,thresholdIntervals,scale.getType())){contextOfEnd=context[1];context=contextOfEnd-thresholdIntervals[contextIndex][2];while(context>=+start){contextTickAr.push(new Date(context));context-=thresholdIntervals[contextIndex][2]}+start!==+contextOfStart&&contextTickAr.push(new Date(contextOfStart));contextTickAr.reverse();contextTickAr.push(new Date(contextOfEnd))}else{contextTickAr.push(contextOfStart)}scale._timeFormat.context=thresholdIntervals[contextIndex][0].name()}return contextTickAr};_proto.getClippedMinorTicks=function getClippedMinorTicks(majorStart,majorEnd,minorIndex){var bins=this.bins,i,len,binning=this._getRangeThreshold(),firstBin=bins[0],lastBin=bins[bins.length-1],_this$applicableClipp=this.applicableClippings,repeatClips=_this$applicableClipp.repeatClips,singleClips=_this$applicableClipp.singleClips,threshold=this.thresholdIntervals[minorIndex],interval=this.unclippedTimeIntervals[(0,_capsFirst.default)(binning[0].name())]||this.unclippedTimeIntervals[binning[0].name()],extendedBins=[],unClippedBins=0,ticksThatCanBeGenerated=threshold[0].range(majorStart,majorEnd,threshold[1]).length,binsBetweenTwoTicks,binsEncounteredTillNow=-1,minorTicksAr=[],clipType,binStart,binEnd;binStart=firstBin.start;binEnd=firstBin.end;while(binStart>majorStart){binStart=interval.offset(binStart,-1*binning[1]);binEnd=interval.offset(binEnd,-1*binning[1]);clipType=(0,_clipUtils.getClipType)([binStart,binEnd],repeatClips,singleClips);extendedBins.push({start:binStart,end:binEnd,clipType:clipType});if(clipType!==2){unClippedBins++}}extendedBins.reverse();for(i=0,len=bins.length;i<len;i++){if(bins[i].end<majorStart||bins[i].start>majorEnd)continue;extendedBins.push(bins[i]);if(bins[i].clipType!==2){unClippedBins++}}binStart=lastBin.start;binEnd=lastBin.end;while(binEnd<majorEnd){binStart=interval.offset(binStart,binning[1]);binEnd=interval.offset(binEnd,binning[1]);extendedBins.push({start:binStart,end:binEnd,clipType:(0,_clipUtils.getClipType)([binStart,binEnd],repeatClips,singleClips)});if(clipType!==2){unClippedBins++}}ticksThatCanBeGenerated=Math.min(ticksThatCanBeGenerated,unClippedBins)+1;binsBetweenTwoTicks=Math.floor(unClippedBins/ticksThatCanBeGenerated)||1;for(i=0,len=extendedBins.length;i<len;i++){if(extendedBins[i].clipType!==2){binsEncounteredTillNow++;if(binsEncounteredTillNow&&!(binsEncounteredTillNow%binsBetweenTwoTicks)){minorTicksAr.push(extendedBins[i].start)}}}return minorTicksAr};_proto.getMajorIntervalGap=function getMajorIntervalGap(lMajor,rMajor,majorIndex){var ticks=this,thresholdIntervals=ticks.thresholdIntervals,clippings=this.getClippings();if(!clippings.length){if(thresholdIntervals[majorIndex][0].name()==="month"){return DAY_30}else if(thresholdIntervals[majorIndex][0].name()==="year"){return DAY_365}return rMajor-lMajor}return this.distance(lMajor,rMajor)};_proto.ticks=function ticks(skipInfo,dayInMajor){if(skipInfo===void 0){skipInfo={}}var scale=this,i,j,len,thresholdIntervals=scale.thresholdIntervals,unclippedTimeIntervals=scale.getUnclippedTimeIntervals(),interval,_scale$applicableClip=scale.applicableClippings,repeatClips=_scale$applicableClip.repeatClips,singleClips=_scale$applicableClip.singleClips,domain=scale.getDomain(),curBin=this._getRangeThreshold(),majorIndex,majorIntervalName,minorIntervalName,minorIndex,majorTicksAr,minorTicksAr,minorTicksArLen,isMajortickInDomain=false,contextTickAr=[],tickValue,start=domain[0],end=domain[1],timeGap,tickAr=[],tickType=[],timeFormat,retTickAr=[],scaleType=scale.getType();if(!validate(start)||!validate(end)){scale._tickType=[];return[]}scale._timeFormat=timeFormat={};timeGap=this.distance(start,end);for(i=len=thresholdIntervals.length-1;i>=0;i--){if(Math.floor(timeGap/thresholdIntervals[i][2])>1){majorIndex=scale.getNiceMajorTickInterval(i,dayInMajor);majorIntervalName=thresholdIntervals[majorIndex][0].name();interval=unclippedTimeIntervals[(0,_capsFirst.default)(majorIntervalName)]||unclippedTimeIntervals[majorIntervalName];start=(0,_scaleUtils.getFloorOfDate)(new Date(start),majorIntervalName,thresholdIntervals[majorIndex][1],scaleType);end=(0,_scaleUtils.modifyDate)(new Date(end),majorIntervalName,thresholdIntervals[majorIndex][1],false,scaleType);end=(0,_scaleUtils.getFloorOfDate)(new Date(end),majorIntervalName,thresholdIntervals[majorIndex][1],scaleType);majorTicksAr=interval.range(+start,+end+thresholdIntervals[majorIndex][2],thresholdIntervals[majorIndex][1]);timeFormat.major=majorIntervalName;for(j=0;j<majorTicksAr.length;j++){if(+majorTicksAr[j]>=+domain[0]&&+majorTicksAr[j]<=+domain[1]){isMajortickInDomain=true}}contextTickAr=scale.generateContextTicks(majorIndex,!isMajortickInDomain)||[];break}}if(!majorTicksAr){scale._tickType=[];return tickAr}for(i=0,len=majorTicksAr.length;i<len-1;i++){tickAr.push(majorTicksAr[i]);tickType.push(MAJOR);if(thresholdIntervals[majorIndex][0].name()==="year"&&majorTicksAr.length>10){minorIndex=-1}else{minorIndex=scale.getNiceMinorTickInterval(majorIndex,scale.getMajorIntervalGap(majorTicksAr[i],majorTicksAr[i+1],majorIndex),timeGap)}if(minorIndex>-1&&!skipInfo.minor){minorIntervalName=thresholdIntervals[minorIndex][0].name();interval=unclippedTimeIntervals[(0,_capsFirst.default)(minorIntervalName)]||unclippedTimeIntervals[minorIntervalName];if(((repeatClips||[]).length||(singleClips||[]).length)&&curBin[1]===1&&curBin[0].name()===thresholdIntervals[minorIndex][0].name()){minorTicksAr=this.getClippedMinorTicks(majorTicksAr[i],majorTicksAr[i+1],minorIndex)}else{minorTicksAr=interval.range(+majorTicksAr[i],+majorTicksAr[i+1]+1,thresholdIntervals[minorIndex][1])}timeFormat.minor=thresholdIntervals[minorIndex][0].name();for(j=0,minorTicksArLen=minorTicksAr.length;j<minorTicksArLen;j++){tickValue=+minorTicksAr[j];if(j===minorTicksArLen-1&&minorTicksArLen>1){if(+this.distance(majorTicksAr[i+1],tickValue)/this.distance(tickValue,+minorTicksAr[j-1])<.5){continue}}if(tickValue!==+majorTicksAr[i]&&tickValue!==+majorTicksAr[i+1]){tickAr.push(minorTicksAr[j]);tickType.push(MINOR)}}}}tickAr.push(majorTicksAr[len-1]);tickType.push(MAJOR);if(contextTickAr.length&&!skipInfo.context){for(i=0,len=contextTickAr.length;i<len;i++){tickAr.push(contextTickAr[i]);tickType.push(CONTEXT)}}scale._tickType=[];for(i=0,len=tickAr.length;i<len;i++){if(tickType[i]!==MINOR){tickAr[i]=(0,_clipUtils.getUnclippedValue)(tickAr[i],repeatClips,singleClips)}}for(i=0,len=tickAr.length;i<len;i++){if(tickType[i]===MAJOR){if(tickAr[i]!==tickAr[i-1]){retTickAr.push(tickAr[i]);scale._tickType.push(tickType[i])}}else{retTickAr.push(tickAr[i]);scale._tickType.push(tickType[i])}}return retTickAr};_proto.setDomain=function setDomain(domain){var _ref;if(domain===void 0){domain=[]}var curDomain=this.getDomain();domain[0]>domain[1]&&(_ref=[domain[0],domain[1]],domain[1]=_ref[0],domain[0]=_ref[1],_ref);if(+curDomain[0]!==+domain[0]||+curDomain[1]!==+domain[1]){_ScaleCalendar.prototype.setDomain.call(this,domain);this.calculateBins(domain)}return this};_proto.calculateBins=function calculateBins(domain){if(domain===void 0){domain=[]}var domainStart=+domain[0],domainEnd=+domain[1],binStart,binEnd,flooredDomainStart,bin=this._getRangeThreshold(),unclippedTimeIntervals=this.getUnclippedTimeIntervals(),interval,binLength=bin&&bin[2],newBinsAr=[],clipType,i,j,len,currentTimeUnit,firstData=this.getFirstData(),clippings=this.getClippings(),clipObj,applicableClippings=[],clipIndices=[],clips=[];if(binLength){currentTimeUnit=bin[0].name();for(i=0,len=clippings.length;i<len;i++){clipObj=clippings[i];if(clipObj.to-clipObj.from>=binLength){applicableClippings.push(clipObj)}}interval=unclippedTimeIntervals[(0,_capsFirst.default)(currentTimeUnit)]||unclippedTimeIntervals[currentTimeUnit];applicableClippings=this.applicableClippings=(0,_clipUtils.segregateClips)(applicableClippings);flooredDomainStart=binStart=+_year.default.floor((0,_pluckNumber.default)(firstData,domainStart));domainStart=interval.offset(new Date(domain[0]),-3*bin[1]);domainEnd=interval.offset(new Date(domain[1]),3*bin[1]);if(interval.name()==="year"||interval.name()==="month"){if(binStart>domainStart){while(binStart>domainStart){binStart=interval.offset(binStart,-1*bin[1])}}else{while(interval.offset(binStart,bin[1])<domainStart){binStart=interval.offset(binStart,bin[1])}}}else{binStart=new Date(Math.floor((domainStart-flooredDomainStart)/binLength)*binLength+flooredDomainStart)}binEnd=interval.offset(binStart,bin[1]);for(j=0;binStart<=domainEnd;j++){clipType=(0,_clipUtils.getClipType)([+binStart,+binEnd],applicableClippings.repeatClips,applicableClippings.singleClips);newBinsAr.push({clipType:clipType,start:binStart,end:binEnd});if(clipType===2){clipIndices.push(j)}clips[j]=(clips[j-1]||0)+(clipType===2?binEnd-binStart:0);binStart=interval.offset(binStart,bin[1]);binEnd=interval.offset(binEnd,bin[1])}this.clips=clips;this.clipIndices=clipIndices;this.bins=newBinsAr;this.clippedDomain=[+domain[0],+domain[0]+this.distance(+domain[0],+domain[1])]}this.clips=clips;this.clipIndices=clipIndices;this.bins=newBinsAr;return this};_proto._getBinIndex=function _getBinIndex(_value){var value=+_value,bins=this.bins,clips=this.clips,found=false,binIndex,i;i=binIndex=biSearch(bins,value);if(bins[i]&&bins[i].clipType===2){while(i<clips.length){i++;if(clips[i]===clips[i-1]){found=true;break}}if(!found){i=binIndex;while(i>=0){i--;if(clips[i]===clips[i+1]){i+=1;found=true;break}}}}return i};_proto._getBinBounds=function _getBinBounds(index){return this.bins[index]||{}};_proto.distance=function distance(_val1,_val2){var val1=Math.min(+_val1,+_val2),val2=Math.max(+_val1,+_val2),val1Bin,val2Bin,bins=this.bins,leftExtendedBins=[],rightExtendedBins=[],applicableClippings=this.applicableClippings,curBin,firstBin,lastBin,interval,index,len,unclippedTimeIntervals=this.getUnclippedTimeIntervals(),binning=this._getRangeThreshold(),clips=this.clips,val1BinIndex=this._getBinIndex(val1),val2BinIndex=this._getBinIndex(val2),direction=_val1>_val2?-1:1,curTime=[],distance=0;firstBin=bins[0];lastBin=bins[bins.length-1];if(!binning.length){return direction*(val2-val1)}if(val1BinIndex===-1||val2BinIndex===-1){interval=unclippedTimeIntervals[(0,_capsFirst.default)(binning[0].name())]||unclippedTimeIntervals[binning[0].name()];val1BinIndex===-1&&(val1=(0,_clipUtils.getUnclippedValue)(+val1,applicableClippings.repeatClips,applicableClippings.singleClips));val2BinIndex===-1&&(val2=(0,_clipUtils.getUnclippedValue)(+val2,applicableClippings.repeatClips,applicableClippings.singleClips));if(val1<firstBin.start){curBin=firstBin;while(val1<curBin.start){curBin={start:interval.offset(curBin.start,-1*binning[1]),end:curBin.start};curBin.clipType=(0,_clipUtils.getClipType)([+curBin.start,+curBin.end],applicableClippings.repeatClips,applicableClippings.singleClips);leftExtendedBins.push(curBin)}val1Bin=curBin;val1BinIndex=leftExtendedBins.length-1}else if(val1>=lastBin.end){curBin=lastBin;while(val2>=curBin.end){curBin={end:interval.offset(curBin.end,binning[1]),start:curBin.end};curBin.clipType=(0,_clipUtils.getClipType)([+curBin.start,+curBin.end],applicableClippings.repeatClips,applicableClippings.singleClips);rightExtendedBins.push(curBin)}val1Bin=curBin;val1BinIndex=rightExtendedBins.length-1}else{val1Bin=this._getBinBounds(val1BinIndex)}index=-1;if(val2<firstBin.start){curBin=firstBin;while(val2<curBin.start){index++;if(!leftExtendedBins[index]){curBin={start:interval.offset(curBin.start,-1*binning[1]),end:curBin.start};curBin.clipType=(0,_clipUtils.getClipType)([+curBin.start,+curBin.end],applicableClippings.repeatClips,applicableClippings.singleClips);leftExtendedBins.push(curBin)}curBin=leftExtendedBins[index]}val2Bin=curBin;val2BinIndex=index}else if(val2>=lastBin.end){curBin=lastBin;while(val2>=curBin.end){index++;if(!rightExtendedBins[index]){curBin={start:curBin.end,end:interval.offset(curBin.end,binning[1])};curBin.clipType=(0,_clipUtils.getClipType)([+curBin.start,+curBin.end],applicableClippings.repeatClips,applicableClippings.singleClips);rightExtendedBins.push(curBin)}curBin=rightExtendedBins[index]}val2Bin=curBin;val2BinIndex=index}else{val2Bin=this._getBinBounds(val2BinIndex)}leftExtendedBins.reverse();curTime=val1;for(index=0,len=leftExtendedBins.length;index<len;index++){curBin=leftExtendedBins[index];if(val1>=curBin.start&&val1<curBin.end){if(val2<curBin.end){distance+=val2-val1;curTime=curBin.end;break}else{distance+=curBin.end-val1}}else if(val2>=curBin.start&&val2<curBin.end){distance+=val2-curBin.start;curTime=curBin.end;break}else{distance+=curBin.clipType===2?0:curBin.end-curBin.start}curTime=curBin.end}if(curTime<val2&&curTime<lastBin.end){for(index=0,len=bins.length;index<len;index++){curBin=bins[index];if(val1>=curBin.start&&val1<curBin.end){if(val2<curBin.end){distance+=val2-val1;curTime=curBin.end;break}else{distance+=curBin.end-val1}}else if(val2>=curBin.start&&val2<curBin.end){distance+=val2-curBin.start;curTime=curBin.end;break}else if(curBin.start>=val1){distance+=curBin.clipType===2?0:curBin.end-curBin.start;curTime=curBin.end}}}if(curTime<val2){for(index=0,len=rightExtendedBins.length;index<len;index++){curBin=rightExtendedBins[index];if(val1>=curBin.start&&val1<curBin.end){if(val2<curBin.end){distance+=val2-val1;curTime=curBin.end;break}else{distance+=curBin.end-val1}}else if(val2>=curBin.start&&val2<curBin.end){distance+=val2-curBin.start;curTime=curBin.end;break}else if(curBin.start>=val1){distance+=curBin.clipType===2?0:curBin.end-curBin.start;curTime=curBin.end}}}}else{val1Bin=this._getBinBounds(val1BinIndex);val2Bin=this._getBinBounds(val2BinIndex);if(val1Bin.start>val1){val1=val1Bin.start}else if(val1Bin.end<val1){val1=val1Bin.end}if(val2Bin.start>val2){val2=val2Bin.start}else if(val2Bin.end<val2){val2=val2Bin.end}if(val2BinIndex-val1BinIndex<=1){return(val2-val1)*direction}distance+=val1Bin.end-val1;distance+=val2-val2Bin.start;distance+=val2Bin.start-val1Bin.end;distance-=clips[val2BinIndex]-clips[val1BinIndex]}return distance*direction};_proto.offset=function offset(domainStart,distance){var remainingMS=Math.abs(+distance),curTimeStamp=+domainStart,curBinIndex=this._getBinIndex(curTimeStamp),startBin=this._getBinBounds(curBinIndex),bins=this.bins,unclippedTimeIntervals=this.getUnclippedTimeIntervals(),applicableClippings=this.applicableClippings,interval,binStart,binEnd,binning=this._getRangeThreshold(),curBin,len=this.clipIndices.length;if(!len){return Number(domainStart)+Number(distance)}if(distance>=0){if(+startBin.start>curTimeStamp){curTimeStamp=+startBin.start}if(curTimeStamp+remainingMS<startBin.end){return curTimeStamp+remainingMS}remainingMS-=+startBin.end-curTimeStamp;curTimeStamp=+startBin.end;curBinIndex++;for(;curBinIndex<bins.length;curBinIndex++){curBin=bins[curBinIndex];if(curBin.clipType!==2){if(remainingMS>=curBin.end-curBin.start){remainingMS-=curBin.end-curBin.start;curTimeStamp=+curBin.end}else{curTimeStamp+=remainingMS;remainingMS=0;break}}else{curTimeStamp=+curBin.end}}}else{if(+startBin.end<curTimeStamp){curTimeStamp=+startBin.end}if(curTimeStamp-remainingMS>=startBin.start){return curTimeStamp-remainingMS}remainingMS-=curTimeStamp-startBin.start;curTimeStamp=startBin.start;interval=unclippedTimeIntervals[(0,_capsFirst.default)(binning[0].name())]||unclippedTimeIntervals[binning[0].name()];curBin=startBin;while(remainingMS){binStart=interval.offset(curBin.start,-1*binning[1]);binEnd=curBin.start;curBin={start:binStart,end:binEnd,clipType:(0,_clipUtils.getClipType)([+binStart,+binEnd],applicableClippings.repeatClips,applicableClippings.singleClips)};if(curBin.clipType!==2){if(remainingMS>=curBin.end-curBin.start){remainingMS-=curBin.end-curBin.start;curTimeStamp=+curBin.start}else{curTimeStamp-=remainingMS;remainingMS=0}}else{curTimeStamp=+curBin.start}}}return curTimeStamp};_proto.nice=function nice(interval,count){var scale=_ScaleCalendar.prototype.nice.call(this,interval,count);this._computeRangeThreshold(DEFAULT_THRESHOLD_PIXELS);return scale};_proto.getFormattedTime=function getFormattedTime(dateInfo,customFormat){if(dateInfo===void 0){dateInfo={}}var scale=this,thresHold=scale._getRangeThreshold(),currentGrouping,timeFormat1,timeFormat2,dateRange=dateInfo.dateRange,timeFormatter,type=dateInfo.type,d1,d2,d1Str,d2Str,isSameDay,isSameMonth,isSameYear,multiplier=thresHold[1],scaleType=scale.getType();if(type==="crossline"||type==="tooltip"){currentGrouping=thresHold[0].name();if(customFormat&&customFormat[currentGrouping]){timeFormat1=timeFormat2=customFormat[currentGrouping];timeFormatter=scaleType==="UTC"?_timeConverter.default.utcFormatter(timeFormat1):_timeConverter.default.formatter(timeFormat1);d1Str=timeFormatter.format(new Date(dateRange.startDate));if(multiplier>1){timeFormatter=scaleType==="UTC"?_timeConverter.default.utcFormatter(timeFormat2):_timeConverter.default.formatter(timeFormat1);d2Str=timeFormatter.format(new Date(dateRange.endDate));return d1Str+" - "+d2Str}return d1Str}timeFormat1=timeFormat2=(0,_timeBucket.getFilterdTimeFormat)("%b %d, %Y, %I:%M:%S.%L %p",currentGrouping);if(currentGrouping==="hour"){timeFormat1=timeFormat1.replace(/%M/,"");timeFormat2=timeFormat2.replace(/%M/,"")}timeFormat1=timeFormat1.replace(/[:|.]*[\s]/g," ");timeFormat2=timeFormat2.replace(/[:|.]*[\s]/g," ");if(!timeFormat1.match(/%I/)){dateRange.endDate-=1;timeFormat1=timeFormat1.replace(/%p/,"");timeFormat2=timeFormat2.replace(/%p/,"")}d1=new Date(dateRange.startDate);d2=new Date(dateRange.endDate);isSameDay=dateAPI(d1,"Date",scaleType)===dateAPI(d2,"Date",scaleType);isSameMonth=dateAPI(d1,"Month",scaleType)===dateAPI(d2,"Month",scaleType);isSameYear=dateAPI(d1,"FullYear",scaleType)===dateAPI(d2,"FullYear",scaleType);if(multiplier>1){if(isSameYear){if(isSameMonth){if(isSameDay){if(!timeFormat1.match(/%I/)){timeFormat1=timeFormat1.replace(/%b/,"%B");timeFormat2=BLANK}else{timeFormat1=timeFormat1.replace(/%p/,"");timeFormat2=timeFormat2.replace(/%b/,"");timeFormat2=timeFormat2.replace(/%d/,"");timeFormat2=timeFormat2.replace(/%Y/,"")}}else{timeFormat1=timeFormat1.replace(/%Y/,"");if(!timeFormat1.match(/%I/)){timeFormat2=timeFormat2.replace(/%b/,"");timeFormat1=timeFormat1.replace(/%b/,"%B")}}}else{if(multiplier!==1){timeFormat1=timeFormat1.replace(/%Y/,"")}}}}else{if(!timeFormat1.match(/%I/)){timeFormat1=timeFormat1.replace(/%b/,"%B")}}timeFormat1=timeFormat1.trim();timeFormat2=timeFormat2.trim();timeFormat1=timeFormat1.replace(/^[,|\s|:]*/,"").replace(/(\W+$)/,"").replace(/([,]+[\s]*[,]+)|([\s]+[,]+)/g,",");timeFormat2=timeFormat2.replace(/^[,|\s|:]*/,"").replace(/(\W+$)/,"").replace(/([,]+[\s]*[,]+)|([\s]+[,]+)/g,",");if(!timeFormat2||multiplier===1){timeFormatter=scaleType==="UTC"?_timeConverter.default.utcFormatter(timeFormat1):_timeConverter.default.formatter(timeFormat1);d1Str=timeFormatter.format(new Date(dateRange.startDate));return d1Str.trim()}timeFormatter=scaleType==="UTC"?_timeConverter.default.utcFormatter(timeFormat1):_timeConverter.default.formatter(timeFormat1);d1Str=timeFormatter.format(new Date(dateRange.startDate));timeFormatter=scaleType==="UTC"?_timeConverter.default.utcFormatter(timeFormat2):_timeConverter.default.formatter(timeFormat2);d2Str=timeFormatter.format(new Date(dateRange.endDate));return(d1Str+" - "+d2Str).trim()}else if(type==="CRS"){d1Str=getFullDate(dateRange.startDate,scaleType)+(dateInfo.showTimeInLabel?", "+getFullTime(dateRange.startDate,scaleType):"");d2Str=getFullDate(dateRange.endDate,scaleType)+(dateInfo.showTimeInLabel?", "+getFullTime(dateRange.endDate,scaleType):"");return(d1Str+" - "+d2Str).trim()}};_proto.setBinMin=function setBinMin(minBin){this.minBin=minBin;return this};_proto.getBinMin=function getBinMin(){return this.minBin};_proto.setRangeThreshold=function setRangeThreshold(threshold){this._threshold=threshold;return this};_proto._getRangeThreshold=function _getRangeThreshold(){return this._threshold||[]};_proto.setMode=function setMode(mode){this.mode=mode};_proto.getMode=function getMode(){return this.mode};_proto.setThresholdIntervals=function setThresholdIntervals(intervals){this.thresholdIntervals=intervals;this.calculateIndexOfIntervals();return this};_proto.setFirstData=function setFirstData(val){this.binStart=val;return this};_proto.getFirstData=function getFirstData(){return this.binStart};_proto.copy=function copy(){return copyScaleBin(this,new ScaleCalendarBin)};return ScaleCalendarBin}(_calendar.default);var _default=ScaleCalendarBin;exports.default=_default; | ||
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule=true;exports.default=exports.copyScaleBin=void 0;var _inheritsLoose2=_interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));var _calendar=_interopRequireDefault(require("./calendar"));var _scaleUtils=require("../scale-utils");exports.getFloorOfDate=_scaleUtils.getFloorOfDate;exports.modifyDate=_scaleUtils.modifyDate;var _pluckNumber=_interopRequireDefault(require("../pluck-number"));var _timeBucket=require("../time-bucket");var _timeConverter=_interopRequireDefault(require("../time-converter"));var _year=_interopRequireDefault(require("../time-intervals/year"));var _clipUtils=require("../clip-utils");var _capsFirst=_interopRequireDefault(require("../string/caps-first"));var _hour=_interopRequireDefault(require("../time-intervals/hour"));var UNDEF;var DEFAULT_THRESHOLD_PIXELS=4,MAJOR="major",MINOR="minor",CONTEXT="context",YEAR="year",BLANK="",DAY_1=1e3*60*60*24,DAY_30=DAY_1*30,DAY_365=DAY_1*365,MONTHS=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],CONTEXT_SEQ=["millisecond","second","minute","hour","day","month","year"],showMonthInDayTick=true,domainToMajorIntervalRatio=[{ratio:4,index:8},{ratio:3,index:7},{ratio:2.5,index:6},{ratio:2,index:5},{ratio:1.5,index:4},{ratio:1,index:3},{ratio:.67,index:2},{ratio:.33,index:1},{ratio:0,index:0}],bimap=function bimap(domain,range,deInterpolate,reInterpolate){var deInterpolator,reInterpolator;if(domain[0]>domain[1]){deInterpolator=deInterpolate(domain[1],domain[0]);reInterpolator=reInterpolate(range[1],range[0])}else{deInterpolator=deInterpolate(domain[0],domain[1]);reInterpolator=reInterpolate(range[0],range[1])}return function(value){return reInterpolator(deInterpolator(value))}},copyScaleBin=function copyScaleBin(sourceScale,targetScale){return targetScale.setInterpolate(sourceScale.getInterpolate()).setClamp(sourceScale.getClamp()).setRangeThreshold(sourceScale._threshold).setRange(sourceScale.getRange()).setThresholdIntervals(sourceScale.thresholdIntervals).setBinMin(sourceScale.getBinMin()).setClippings(sourceScale.clippings).setFirstData(sourceScale.getFirstData()).setDomain(sourceScale.getDomain())},validate=function validate(x){return x!==null&&!isNaN(x)},niceMinorTickIndex=function niceMinorTickIndex(value){var i,len=domainToMajorIntervalRatio.length,inverse=1/value;if(inverse>4){return Infinity}for(i=0;i<len;i++){if(inverse>domainToMajorIntervalRatio[i].ratio){return domainToMajorIntervalRatio[i].index}}},contextChange=function contextChange(startDate,endDate,index,thresholdIntervals,utc){var start=(0,_scaleUtils.getFloorOfDate)(new Date(startDate),thresholdIntervals[index][0].name(),thresholdIntervals[index][1],utc),end=(0,_scaleUtils.getFloorOfDate)(new Date(endDate),thresholdIntervals[index][0].name(),thresholdIntervals[index][1],utc);if(+start!==+end){return[start,end]}return false},biSearch=function biSearch(ar,val){var start=0,end=ar.length-1,mid;while(start<=end){mid=start+Math.ceil((end-start)/2);if(val>=ar[mid].start&&val<ar[mid].end){return mid}if(ar[mid].end<=val){start=mid+1}else{end=mid-1}}return-1},dateAPI=function dateAPI(date,param,utc){return date["get"+utc+param]()},formatDate=function formatDate(x){return(x<10?"0"+x:x)+""},getFullDate=function getFullDate(date,type){return MONTHS[dateAPI(date,"Month",type)]+" "+formatDate(dateAPI(date,"Date",type))+", "+dateAPI(date,"FullYear",type)},getFullTime=function getFullTime(date,type){return formatDate(dateAPI(date,"Hours",type))+":"+formatDate(dateAPI(date,"Minutes",type))+":"+formatDate(dateAPI(date,"Seconds",type))},getNiceYearlyMajorTicks=function getNiceYearlyMajorTicks(thresholdIntervals,curMajorIndex,minDiff){var i;i=curMajorIndex;while(i-1>=0&&thresholdIntervals[i-1][0].name()==="year"&&thresholdIntervals[i-1][2]>=minDiff){i--}return i};exports.copyScaleBin=copyScaleBin;var ScaleCalendarBin=function(_ScaleCalendar){(0,_inheritsLoose2.default)(ScaleCalendarBin,_ScaleCalendar);function ScaleCalendarBin(year,month,week,day,hour,minute,second,millisecond){var _this;_this=_ScaleCalendar.call(this,year,month,week,day,hour,minute,second,millisecond)||this;_this._type=BLANK;_this.bins=[];_this.clippings=[];_this.clipIndices=[];_this.clips=[];_this.clippedDomain=[0,1];_this.applicableClippings={};return _this}var _proto=ScaleCalendarBin.prototype;_proto.getType=function getType(){return this._type};_proto.setTimeInterval=function setTimeInterval(timeIntervals){this.timeIntervals=timeIntervals;_ScaleCalendar.prototype.setTimeInterval.call(this,timeIntervals)};_proto.setUnclippedTimeIntervals=function setUnclippedTimeIntervals(unclippedTimeIntervals){this.unclippedTimeIntervals=unclippedTimeIntervals;_ScaleCalendar.prototype.setUnclippedTimeIntervals.call(this,unclippedTimeIntervals)};_proto._rescale=function _rescale(){this.output=null;this.input=null;return this};_proto.setClippings=function setClippings(clippings){this.clippings=clippings;return this};_proto.getClippings=function getClippings(){return this.clippings};_proto.showPlotOverTick=function showPlotOverTick(){var scale=this,curBin=scale._getRangeThreshold(),minBin=scale.getBinMin();if((minBin[0].name()==="millisecond"||CONTEXT_SEQ.indexOf(curBin[0].name())>-1)&&curBin[1]===1){return true}return false};_proto.getBinBounds=function getBinBounds(idx){var bin=this._getBinBounds(idx);return{startDate:+bin.start,endDate:+bin.end}};_proto.getBinIndex=function getBinIndex(curTimeStamp,enableRoundOff){if(enableRoundOff===void 0){enableRoundOff=true}var binIndex=this._getBinIndex(curTimeStamp),binBounds=this._getBinBounds(binIndex),binsArLength=this.bins.length,binMid=+binBounds.start+(binBounds.end-binBounds.start)/2,showPlotOverTick=this.showPlotOverTick();if(enableRoundOff&&showPlotOverTick&&curTimeStamp>=binMid){binIndex++;while(binIndex<binsArLength&&this.bins[binIndex].clipType===2){binIndex++}}return binIndex};_proto.calculateRangeValue=function calculateRangeValue(value){var domain=this.getDomain(),bins=this.bins,clippedDomainValue;clippedDomainValue=value<bins[0].start||value>=bins[bins.length-1].end?value:+domain[0]+this.distance(+domain[0],+value);if(!this.output){this.output=bimap(this.clippedDomain,this.getRange(),this.deInterpolate,this.interpolate)}return this.output(Number(clippedDomainValue))};_proto.getRangeValue=function getRangeValue(startValue,endValue){if(typeof startValue==="undefined"&&typeof endValue==="undefined"){return UNDEF}else if(typeof endValue==="undefined"){return this.calculateRangeValue(startValue)}if(this.showPlotOverTick()){return this.calculateRangeValue(startValue)}return(this.calculateRangeValue(startValue)+this.calculateRangeValue(endValue))/2};_proto.getDomainValue=function getDomainValue(value){if(isNaN(value)){return value}var domain=this.getDomain(),compressedDomainValue,spreadedDomainValue;if(!this.input){this.input=bimap(this.getRange(),this.clippedDomain,this.deInterpolate,this.interpolate)}compressedDomainValue=this.input(Number(value));spreadedDomainValue=this.offset(+domain[0],compressedDomainValue-domain[0]);return new Date(spreadedDomainValue)};_proto.calculateIndexOfIntervals=function calculateIndexOfIntervals(){var scale=this,intervalIndexMap,thresholdIntervals=scale.thresholdIntervals,i,len=thresholdIntervals.length;scale.intervalIndexMap=intervalIndexMap={};for(i=len-1;i>=0;i--){intervalIndexMap[thresholdIntervals[i][0].name()]=i}};_proto.getNiceMinorTickInterval=function getNiceMinorTickInterval(majorIndex,gap,domainLength){if(majorIndex===0){return-1}var scale=this,thresholdIntervals=scale.thresholdIntervals,i,minDiff=scale._getRangeThreshold()[2],density,curIntervalName=thresholdIntervals[majorIndex-1][0].name(),len,minAllowedMinorBinIndex,divisible=[];for(i=0,len=thresholdIntervals.length;i<len;i++){if(thresholdIntervals[i][2]>=minDiff){minAllowedMinorBinIndex=i;break}}for(i=majorIndex-1;i>=minAllowedMinorBinIndex;i--){if(thresholdIntervals[i][0].name()!==curIntervalName){break}if(!(thresholdIntervals[i][2]%minDiff)&&curIntervalName!=="year"){divisible.push(i)}}density=Math.min(niceMinorTickIndex(domainLength/gap),divisible.length-1);return(0,_pluckNumber.default)(divisible[density],-1)};_proto.getNiceMajorTickInterval=function getNiceMajorTickInterval(curMajorIndex,dayInMajor){if(dayInMajor===void 0){dayInMajor=false}var scale=this,thresholdIntervals=scale.thresholdIntervals,i,len=thresholdIntervals.length,curBin=scale._getRangeThreshold(),minDiff=curBin[2],scaleMode=scale.getMode();if(scaleMode==="random"){if(!dayInMajor&&thresholdIntervals[curMajorIndex][0].name()==="day"&&(thresholdIntervals[curMajorIndex][1]>1||thresholdIntervals[curMajorIndex][2]>minDiff)){for(i=curMajorIndex;i<len;i++){if(thresholdIntervals[i][0].name()!=="day"&&minDiff<thresholdIntervals[i][2]){return i}}}else{if(thresholdIntervals[curMajorIndex][0].name()==="year"){return getNiceYearlyMajorTicks(thresholdIntervals,curMajorIndex,minDiff)}for(i=curMajorIndex;i<len;i++){if(thresholdIntervals[i][2]>minDiff){return i}}}}else{if(thresholdIntervals[curMajorIndex][1]!==1||thresholdIntervals[curMajorIndex][2]<=minDiff){if(thresholdIntervals[curMajorIndex][0].name()==="year"){return getNiceYearlyMajorTicks(thresholdIntervals,curMajorIndex,minDiff)}for(i=curMajorIndex;i<len;i++){if(thresholdIntervals[i][1]===1&&thresholdIntervals[i][2]>minDiff){return i}}}}return curMajorIndex};_proto.generateContextTicks=function generateContextTicks(curMajorIndex,coincideWithMajor){if(coincideWithMajor===void 0){coincideWithMajor=false}var scale=this,thresholdIntervals=scale.thresholdIntervals,intervalIndexMap=scale.intervalIndexMap,domain=scale.getDomain(),start=domain[0],end=domain[1],majorIntervalName=thresholdIntervals[curMajorIndex][0].name(),desiredContextInterval=CONTEXT_SEQ[CONTEXT_SEQ.indexOf(majorIntervalName)+1],j,len=thresholdIntervals.length,dayStartIndex=intervalIndexMap.day,contextOfStart,contextOfEnd,contextIndex=-1,context,contextTickAr=[];if(coincideWithMajor){contextIndex=curMajorIndex}else{if(majorIntervalName==="day"&&showMonthInDayTick){desiredContextInterval=YEAR}for(j=Math.max(curMajorIndex,dayStartIndex);j<len;j++){if(thresholdIntervals[j][0].name()===desiredContextInterval){contextIndex=j;break}}}if(contextIndex>-1){contextOfStart=(0,_scaleUtils.getFloorOfDate)(new Date(start),thresholdIntervals[contextIndex][0].name(),thresholdIntervals[contextIndex][1],scale.getType());if(context=contextChange(new Date(start),new Date(end),contextIndex,thresholdIntervals,scale.getType())){contextOfEnd=context[1];context=contextOfEnd-thresholdIntervals[contextIndex][2];while(context>=+start){contextTickAr.push(new Date(context));context-=thresholdIntervals[contextIndex][2]}+start!==+contextOfStart&&contextTickAr.push(new Date(contextOfStart));contextTickAr.reverse();contextTickAr.push(new Date(contextOfEnd))}else{contextTickAr.push(contextOfStart)}scale._timeFormat.context=thresholdIntervals[contextIndex][0].name()}return contextTickAr};_proto.getClippedMinorTicks=function getClippedMinorTicks(majorStart,majorEnd,minorIndex){var bins=this.bins,i,len,binning=this._getRangeThreshold(),firstBin=bins[0],lastBin=bins[bins.length-1],_this$applicableClipp=this.applicableClippings,repeatClips=_this$applicableClipp.repeatClips,singleClips=_this$applicableClipp.singleClips,threshold=this.thresholdIntervals[minorIndex],interval=this.unclippedTimeIntervals[(0,_capsFirst.default)(binning[0].name())]||this.unclippedTimeIntervals[binning[0].name()],extendedBins=[],unClippedBins=0,ticksThatCanBeGenerated=threshold[0].range(majorStart,majorEnd,threshold[1]).length,binsBetweenTwoTicks,binsEncounteredTillNow=-1,minorTicksAr=[],clipType,binStart,binEnd;binStart=firstBin.start;binEnd=firstBin.end;while(binStart>majorStart){binStart=interval.offset(binStart,-1*binning[1]);binEnd=interval.offset(binEnd,-1*binning[1]);clipType=(0,_clipUtils.getClipType)([binStart,binEnd],repeatClips,singleClips);extendedBins.push({start:binStart,end:binEnd,clipType:clipType});if(clipType!==2){unClippedBins++}}extendedBins.reverse();for(i=0,len=bins.length;i<len;i++){if(bins[i].end<majorStart||bins[i].start>majorEnd)continue;extendedBins.push(bins[i]);if(bins[i].clipType!==2){unClippedBins++}}binStart=lastBin.start;binEnd=lastBin.end;while(binEnd<majorEnd){binStart=interval.offset(binStart,binning[1]);binEnd=interval.offset(binEnd,binning[1]);extendedBins.push({start:binStart,end:binEnd,clipType:(0,_clipUtils.getClipType)([binStart,binEnd],repeatClips,singleClips)});if(clipType!==2){unClippedBins++}}ticksThatCanBeGenerated=Math.min(ticksThatCanBeGenerated,unClippedBins)+1;binsBetweenTwoTicks=Math.floor(unClippedBins/ticksThatCanBeGenerated)||1;for(i=0,len=extendedBins.length;i<len;i++){if(extendedBins[i].clipType!==2){binsEncounteredTillNow++;if(binsEncounteredTillNow&&!(binsEncounteredTillNow%binsBetweenTwoTicks)){minorTicksAr.push(extendedBins[i].start)}}}return minorTicksAr};_proto.getMajorIntervalGap=function getMajorIntervalGap(lMajor,rMajor,majorIndex){var ticks=this,thresholdIntervals=ticks.thresholdIntervals,clippings=this.getClippings();if(!clippings.length){if(thresholdIntervals[majorIndex][0].name()==="month"){return DAY_30}else if(thresholdIntervals[majorIndex][0].name()==="year"){return DAY_365}return rMajor-lMajor}return this.distance(lMajor,rMajor)};_proto.ticks=function ticks(skipInfo,dayInMajor){if(skipInfo===void 0){skipInfo={}}var scale=this,i,j,len,thresholdIntervals=scale.thresholdIntervals,unclippedTimeIntervals=scale.getUnclippedTimeIntervals(),interval,_scale$applicableClip=scale.applicableClippings,repeatClips=_scale$applicableClip.repeatClips,singleClips=_scale$applicableClip.singleClips,domain=scale.getDomain(),curBin=this._getRangeThreshold(),majorIndex,majorIntervalName,minorIntervalName,minorIndex,majorTicksAr,minorTicksAr,minorTicksArLen,isMajortickInDomain=false,contextTickAr=[],tickValue,start=domain[0],end=domain[1],timeGap,tickAr=[],tickType=[],timeFormat,retTickAr=[],scaleType=scale.getType();if(!validate(start)||!validate(end)){scale._tickType=[];return[]}scale._timeFormat=timeFormat={};timeGap=this.distance(start,end);for(i=len=thresholdIntervals.length-1;i>=0;i--){if(Math.floor(timeGap/thresholdIntervals[i][2])>1){majorIndex=scale.getNiceMajorTickInterval(i,dayInMajor);majorIntervalName=thresholdIntervals[majorIndex][0].name();interval=unclippedTimeIntervals[(0,_capsFirst.default)(majorIntervalName)]||unclippedTimeIntervals[majorIntervalName];start=(0,_scaleUtils.getFloorOfDate)(new Date(start),majorIntervalName,thresholdIntervals[majorIndex][1],scaleType);end=(0,_scaleUtils.modifyDate)(new Date(end),majorIntervalName,thresholdIntervals[majorIndex][1],false,scaleType);end=(0,_scaleUtils.getFloorOfDate)(new Date(end),majorIntervalName,thresholdIntervals[majorIndex][1],scaleType);majorTicksAr=interval.range(+start,+end+thresholdIntervals[majorIndex][2],thresholdIntervals[majorIndex][1]);timeFormat.major=majorIntervalName;for(j=0;j<majorTicksAr.length;j++){if(+majorTicksAr[j]>=+domain[0]&&+majorTicksAr[j]<=+domain[1]){isMajortickInDomain=true}}contextTickAr=scale.generateContextTicks(majorIndex,!isMajortickInDomain)||[];break}}if(!majorTicksAr){scale._tickType=[];return tickAr}for(i=0,len=majorTicksAr.length;i<len-1;i++){tickAr.push(majorTicksAr[i]);tickType.push(MAJOR);if(thresholdIntervals[majorIndex][0].name()==="year"&&majorTicksAr.length>10){minorIndex=-1}else{minorIndex=scale.getNiceMinorTickInterval(majorIndex,scale.getMajorIntervalGap(majorTicksAr[i],majorTicksAr[i+1],majorIndex),timeGap)}if(minorIndex>-1&&!skipInfo.minor){minorIntervalName=thresholdIntervals[minorIndex][0].name();interval=unclippedTimeIntervals[(0,_capsFirst.default)(minorIntervalName)]||unclippedTimeIntervals[minorIntervalName];if(((repeatClips||[]).length||(singleClips||[]).length)&&curBin[1]===1&&curBin[0].name()===thresholdIntervals[minorIndex][0].name()){minorTicksAr=this.getClippedMinorTicks(majorTicksAr[i],majorTicksAr[i+1],minorIndex)}else{minorTicksAr=interval.range(+majorTicksAr[i],+majorTicksAr[i+1]+1,thresholdIntervals[minorIndex][1])}timeFormat.minor=thresholdIntervals[minorIndex][0].name();for(j=0,minorTicksArLen=minorTicksAr.length;j<minorTicksArLen;j++){tickValue=+minorTicksAr[j];if(j===minorTicksArLen-1&&minorTicksArLen>1){if(+this.distance(majorTicksAr[i+1],tickValue)/this.distance(tickValue,+minorTicksAr[j-1])<.5){continue}}if(tickValue!==+majorTicksAr[i]&&tickValue!==+majorTicksAr[i+1]){tickAr.push(minorTicksAr[j]);tickType.push(MINOR)}}}}tickAr.push(majorTicksAr[len-1]);tickType.push(MAJOR);if(contextTickAr.length&&!skipInfo.context){for(i=0,len=contextTickAr.length;i<len;i++){tickAr.push(contextTickAr[i]);tickType.push(CONTEXT)}}scale._tickType=[];for(i=0,len=tickAr.length;i<len;i++){if(tickType[i]!==MINOR){tickAr[i]=(0,_clipUtils.getUnclippedValue)(tickAr[i],repeatClips,singleClips)}}for(i=0,len=tickAr.length;i<len;i++){if(tickType[i]===MAJOR){if(tickAr[i]!==tickAr[i-1]){retTickAr.push(tickAr[i]);scale._tickType.push(tickType[i])}}else{retTickAr.push(tickAr[i]);scale._tickType.push(tickType[i])}}return retTickAr};_proto.setDomain=function setDomain(domain){var _ref;if(domain===void 0){domain=[]}var curDomain=this.getDomain();domain[0]>domain[1]&&(_ref=[domain[0],domain[1]],domain[1]=_ref[0],domain[0]=_ref[1],_ref);if(+curDomain[0]!==+domain[0]||+curDomain[1]!==+domain[1]){_ScaleCalendar.prototype.setDomain.call(this,domain);this.calculateBins(domain)}return this};_proto.calculateBins=function calculateBins(domain){if(domain===void 0){domain=[]}var domainStart=+domain[0],domainEnd=+domain[1],binStart,binEnd,flooredDomainStart,bin=this._getRangeThreshold(),unclippedTimeIntervals=this.getUnclippedTimeIntervals(),interval,binLength=bin&&bin[2],newBinsAr=[],clipType,i,j,len,currentTimeUnit,firstData=this.getFirstData(),clippings=this.getClippings(),clipObj,applicableClippings=[],clipIndices=[],clips=[];if(binLength){currentTimeUnit=bin[0].name();for(i=0,len=clippings.length;i<len;i++){clipObj=clippings[i];if(clipObj.to-clipObj.from>=binLength){applicableClippings.push(clipObj)}}interval=unclippedTimeIntervals[(0,_capsFirst.default)(currentTimeUnit)]||unclippedTimeIntervals[currentTimeUnit];applicableClippings=this.applicableClippings=(0,_clipUtils.segregateClips)(applicableClippings);flooredDomainStart=binStart=+_year.default.floor((0,_pluckNumber.default)(firstData,domainStart));domainStart=interval.offset(new Date(domain[0]),-3*bin[1]);domainEnd=interval.offset(new Date(domain[1]),3*bin[1]);if(interval.name()==="year"||interval.name()==="month"){if(binStart>domainStart){while(binStart>domainStart){binStart=interval.offset(binStart,-1*bin[1])}}else{while(interval.offset(binStart,bin[1])<domainStart){binStart=interval.offset(binStart,bin[1])}}}else{binStart=new Date(Math.floor((domainStart-flooredDomainStart)/binLength)*binLength+flooredDomainStart);var winterOffset=new Date(binStart.getFullYear(),0,0).getTimezoneOffset(),summerOffset=new Date(binStart.getFullYear(),6).getTimezoneOffset();if(winterOffset<summerOffset){binStart=_hour.default.offset(binStart,1)}}binEnd=interval.offset(binStart,bin[1]);for(j=0;binStart<=domainEnd;j++){clipType=(0,_clipUtils.getClipType)([+binStart,+binEnd],applicableClippings.repeatClips,applicableClippings.singleClips);newBinsAr.push({clipType:clipType,start:binStart,end:binEnd});if(clipType===2){clipIndices.push(j)}clips[j]=(clips[j-1]||0)+(clipType===2?binEnd-binStart:0);binStart=interval.offset(binStart,bin[1]);binEnd=interval.offset(binEnd,bin[1])}this.clips=clips;this.clipIndices=clipIndices;this.bins=newBinsAr;this.clippedDomain=[+domain[0],+domain[0]+this.distance(+domain[0],+domain[1])]}this.clips=clips;this.clipIndices=clipIndices;this.bins=newBinsAr;return this};_proto._getBinIndex=function _getBinIndex(_value){var value=+_value,bins=this.bins,clips=this.clips,found=false,binIndex,i;i=binIndex=biSearch(bins,value);if(bins[i]&&bins[i].clipType===2){while(i<clips.length){i++;if(clips[i]===clips[i-1]){found=true;break}}if(!found){i=binIndex;while(i>=0){i--;if(clips[i]===clips[i+1]){i+=1;found=true;break}}}}return i};_proto._getBinBounds=function _getBinBounds(index){return this.bins[index]||{}};_proto.distance=function distance(_val1,_val2){var val1=Math.min(+_val1,+_val2),val2=Math.max(+_val1,+_val2),val1Bin,val2Bin,bins=this.bins,leftExtendedBins=[],rightExtendedBins=[],applicableClippings=this.applicableClippings,curBin,firstBin,lastBin,interval,index,len,unclippedTimeIntervals=this.getUnclippedTimeIntervals(),binning=this._getRangeThreshold(),clips=this.clips,val1BinIndex=this._getBinIndex(val1),val2BinIndex=this._getBinIndex(val2),direction=_val1>_val2?-1:1,curTime=[],distance=0;firstBin=bins[0];lastBin=bins[bins.length-1];if(!binning.length){return direction*(val2-val1)}if(val1BinIndex===-1||val2BinIndex===-1){interval=unclippedTimeIntervals[(0,_capsFirst.default)(binning[0].name())]||unclippedTimeIntervals[binning[0].name()];val1BinIndex===-1&&(val1=(0,_clipUtils.getUnclippedValue)(+val1,applicableClippings.repeatClips,applicableClippings.singleClips));val2BinIndex===-1&&(val2=(0,_clipUtils.getUnclippedValue)(+val2,applicableClippings.repeatClips,applicableClippings.singleClips));if(val1<firstBin.start){curBin=firstBin;while(val1<curBin.start){curBin={start:interval.offset(curBin.start,-1*binning[1]),end:curBin.start};curBin.clipType=(0,_clipUtils.getClipType)([+curBin.start,+curBin.end],applicableClippings.repeatClips,applicableClippings.singleClips);leftExtendedBins.push(curBin)}val1Bin=curBin;val1BinIndex=leftExtendedBins.length-1}else if(val1>=lastBin.end){curBin=lastBin;while(val2>=curBin.end){curBin={end:interval.offset(curBin.end,binning[1]),start:curBin.end};curBin.clipType=(0,_clipUtils.getClipType)([+curBin.start,+curBin.end],applicableClippings.repeatClips,applicableClippings.singleClips);rightExtendedBins.push(curBin)}val1Bin=curBin;val1BinIndex=rightExtendedBins.length-1}else{val1Bin=this._getBinBounds(val1BinIndex)}index=-1;if(val2<firstBin.start){curBin=firstBin;while(val2<curBin.start){index++;if(!leftExtendedBins[index]){curBin={start:interval.offset(curBin.start,-1*binning[1]),end:curBin.start};curBin.clipType=(0,_clipUtils.getClipType)([+curBin.start,+curBin.end],applicableClippings.repeatClips,applicableClippings.singleClips);leftExtendedBins.push(curBin)}curBin=leftExtendedBins[index]}val2Bin=curBin;val2BinIndex=index}else if(val2>=lastBin.end){curBin=lastBin;while(val2>=curBin.end){index++;if(!rightExtendedBins[index]){curBin={start:curBin.end,end:interval.offset(curBin.end,binning[1])};curBin.clipType=(0,_clipUtils.getClipType)([+curBin.start,+curBin.end],applicableClippings.repeatClips,applicableClippings.singleClips);rightExtendedBins.push(curBin)}curBin=rightExtendedBins[index]}val2Bin=curBin;val2BinIndex=index}else{val2Bin=this._getBinBounds(val2BinIndex)}leftExtendedBins.reverse();curTime=val1;for(index=0,len=leftExtendedBins.length;index<len;index++){curBin=leftExtendedBins[index];if(val1>=curBin.start&&val1<curBin.end){if(val2<curBin.end){distance+=val2-val1;curTime=curBin.end;break}else{distance+=curBin.end-val1}}else if(val2>=curBin.start&&val2<curBin.end){distance+=val2-curBin.start;curTime=curBin.end;break}else{distance+=curBin.clipType===2?0:curBin.end-curBin.start}curTime=curBin.end}if(curTime<val2&&curTime<lastBin.end){for(index=0,len=bins.length;index<len;index++){curBin=bins[index];if(val1>=curBin.start&&val1<curBin.end){if(val2<curBin.end){distance+=val2-val1;curTime=curBin.end;break}else{distance+=curBin.end-val1}}else if(val2>=curBin.start&&val2<curBin.end){distance+=val2-curBin.start;curTime=curBin.end;break}else if(curBin.start>=val1){distance+=curBin.clipType===2?0:curBin.end-curBin.start;curTime=curBin.end}}}if(curTime<val2){for(index=0,len=rightExtendedBins.length;index<len;index++){curBin=rightExtendedBins[index];if(val1>=curBin.start&&val1<curBin.end){if(val2<curBin.end){distance+=val2-val1;curTime=curBin.end;break}else{distance+=curBin.end-val1}}else if(val2>=curBin.start&&val2<curBin.end){distance+=val2-curBin.start;curTime=curBin.end;break}else if(curBin.start>=val1){distance+=curBin.clipType===2?0:curBin.end-curBin.start;curTime=curBin.end}}}}else{val1Bin=this._getBinBounds(val1BinIndex);val2Bin=this._getBinBounds(val2BinIndex);if(val1Bin.start>val1){val1=val1Bin.start}else if(val1Bin.end<val1){val1=val1Bin.end}if(val2Bin.start>val2){val2=val2Bin.start}else if(val2Bin.end<val2){val2=val2Bin.end}if(val2BinIndex-val1BinIndex<=1){return(val2-val1)*direction}distance+=val1Bin.end-val1;distance+=val2-val2Bin.start;distance+=val2Bin.start-val1Bin.end;distance-=clips[val2BinIndex]-clips[val1BinIndex]}return distance*direction};_proto.offset=function offset(domainStart,distance){var remainingMS=Math.abs(+distance),curTimeStamp=+domainStart,curBinIndex=this._getBinIndex(curTimeStamp),startBin=this._getBinBounds(curBinIndex),bins=this.bins,unclippedTimeIntervals=this.getUnclippedTimeIntervals(),applicableClippings=this.applicableClippings,interval,binStart,binEnd,binning=this._getRangeThreshold(),curBin,len=this.clipIndices.length;if(!len){return Number(domainStart)+Number(distance)}if(distance>=0){if(+startBin.start>curTimeStamp){curTimeStamp=+startBin.start}if(curTimeStamp+remainingMS<startBin.end){return curTimeStamp+remainingMS}remainingMS-=+startBin.end-curTimeStamp;curTimeStamp=+startBin.end;curBinIndex++;for(;curBinIndex<bins.length;curBinIndex++){curBin=bins[curBinIndex];if(curBin.clipType!==2){if(remainingMS>=curBin.end-curBin.start){remainingMS-=curBin.end-curBin.start;curTimeStamp=+curBin.end}else{curTimeStamp+=remainingMS;remainingMS=0;break}}else{curTimeStamp=+curBin.end}}}else{if(+startBin.end<curTimeStamp){curTimeStamp=+startBin.end}if(curTimeStamp-remainingMS>=startBin.start){return curTimeStamp-remainingMS}remainingMS-=curTimeStamp-startBin.start;curTimeStamp=startBin.start;interval=unclippedTimeIntervals[(0,_capsFirst.default)(binning[0].name())]||unclippedTimeIntervals[binning[0].name()];curBin=startBin;while(remainingMS){binStart=interval.offset(curBin.start,-1*binning[1]);binEnd=curBin.start;curBin={start:binStart,end:binEnd,clipType:(0,_clipUtils.getClipType)([+binStart,+binEnd],applicableClippings.repeatClips,applicableClippings.singleClips)};if(curBin.clipType!==2){if(remainingMS>=curBin.end-curBin.start){remainingMS-=curBin.end-curBin.start;curTimeStamp=+curBin.start}else{curTimeStamp-=remainingMS;remainingMS=0}}else{curTimeStamp=+curBin.start}}}return curTimeStamp};_proto.nice=function nice(interval,count){var scale=_ScaleCalendar.prototype.nice.call(this,interval,count);this._computeRangeThreshold(DEFAULT_THRESHOLD_PIXELS);return scale};_proto.getFormattedTime=function getFormattedTime(dateInfo,customFormat){if(dateInfo===void 0){dateInfo={}}var scale=this,thresHold=scale._getRangeThreshold(),currentGrouping,timeFormat1,timeFormat2,dateRange=dateInfo.dateRange,timeFormatter,type=dateInfo.type,d1,d2,d1Str,d2Str,isSameDay,isSameMonth,isSameYear,multiplier=thresHold[1],scaleType=scale.getType();if(type==="crossline"||type==="tooltip"){currentGrouping=thresHold[0].name();if(customFormat&&customFormat[currentGrouping]){timeFormat1=timeFormat2=customFormat[currentGrouping];timeFormatter=scaleType==="UTC"?_timeConverter.default.utcFormatter(timeFormat1):_timeConverter.default.formatter(timeFormat1);d1Str=timeFormatter.format(new Date(dateRange.startDate));if(multiplier>1){timeFormatter=scaleType==="UTC"?_timeConverter.default.utcFormatter(timeFormat2):_timeConverter.default.formatter(timeFormat1);d2Str=timeFormatter.format(new Date(dateRange.endDate));return d1Str+" - "+d2Str}return d1Str}timeFormat1=timeFormat2=(0,_timeBucket.getFilterdTimeFormat)("%b %d, %Y, %I:%M:%S.%L %p",currentGrouping);if(currentGrouping==="hour"){timeFormat1=timeFormat1.replace(/%M/,"");timeFormat2=timeFormat2.replace(/%M/,"")}timeFormat1=timeFormat1.replace(/[:|.]*[\s]/g," ");timeFormat2=timeFormat2.replace(/[:|.]*[\s]/g," ");if(!timeFormat1.match(/%I/)){dateRange.endDate-=1;timeFormat1=timeFormat1.replace(/%p/,"");timeFormat2=timeFormat2.replace(/%p/,"")}d1=new Date(dateRange.startDate);d2=new Date(dateRange.endDate);isSameDay=dateAPI(d1,"Date",scaleType)===dateAPI(d2,"Date",scaleType);isSameMonth=dateAPI(d1,"Month",scaleType)===dateAPI(d2,"Month",scaleType);isSameYear=dateAPI(d1,"FullYear",scaleType)===dateAPI(d2,"FullYear",scaleType);if(multiplier>1){if(isSameYear){if(isSameMonth){if(isSameDay){if(!timeFormat1.match(/%I/)){timeFormat1=timeFormat1.replace(/%b/,"%B");timeFormat2=BLANK}else{timeFormat1=timeFormat1.replace(/%p/,"");timeFormat2=timeFormat2.replace(/%b/,"");timeFormat2=timeFormat2.replace(/%d/,"");timeFormat2=timeFormat2.replace(/%Y/,"")}}else{timeFormat1=timeFormat1.replace(/%Y/,"");if(!timeFormat1.match(/%I/)){timeFormat2=timeFormat2.replace(/%b/,"");timeFormat1=timeFormat1.replace(/%b/,"%B")}}}else{if(multiplier!==1){timeFormat1=timeFormat1.replace(/%Y/,"")}}}}else{if(!timeFormat1.match(/%I/)){timeFormat1=timeFormat1.replace(/%b/,"%B")}}timeFormat1=timeFormat1.trim();timeFormat2=timeFormat2.trim();timeFormat1=timeFormat1.replace(/^[,|\s|:]*/,"").replace(/(\W+$)/,"").replace(/([,]+[\s]*[,]+)|([\s]+[,]+)/g,",");timeFormat2=timeFormat2.replace(/^[,|\s|:]*/,"").replace(/(\W+$)/,"").replace(/([,]+[\s]*[,]+)|([\s]+[,]+)/g,",");if(!timeFormat2||multiplier===1){timeFormatter=scaleType==="UTC"?_timeConverter.default.utcFormatter(timeFormat1):_timeConverter.default.formatter(timeFormat1);d1Str=timeFormatter.format(new Date(dateRange.startDate));return d1Str.trim()}timeFormatter=scaleType==="UTC"?_timeConverter.default.utcFormatter(timeFormat1):_timeConverter.default.formatter(timeFormat1);d1Str=timeFormatter.format(new Date(dateRange.startDate));timeFormatter=scaleType==="UTC"?_timeConverter.default.utcFormatter(timeFormat2):_timeConverter.default.formatter(timeFormat2);d2Str=timeFormatter.format(new Date(dateRange.endDate));return(d1Str+" - "+d2Str).trim()}else if(type==="CRS"){d1Str=getFullDate(dateRange.startDate,scaleType)+(dateInfo.showTimeInLabel?", "+getFullTime(dateRange.startDate,scaleType):"");d2Str=getFullDate(dateRange.endDate,scaleType)+(dateInfo.showTimeInLabel?", "+getFullTime(dateRange.endDate,scaleType):"");return(d1Str+" - "+d2Str).trim()}};_proto.setBinMin=function setBinMin(minBin){this.minBin=minBin;return this};_proto.getBinMin=function getBinMin(){return this.minBin};_proto.setRangeThreshold=function setRangeThreshold(threshold){this._threshold=threshold;return this};_proto._getRangeThreshold=function _getRangeThreshold(){return this._threshold||[]};_proto.setMode=function setMode(mode){this.mode=mode};_proto.getMode=function getMode(){return this.mode};_proto.setThresholdIntervals=function setThresholdIntervals(intervals){this.thresholdIntervals=intervals;this.calculateIndexOfIntervals();return this};_proto.setFirstData=function setFirstData(val){this.binStart=val;return this};_proto.getFirstData=function getFirstData(){return this.binStart};_proto.copy=function copy(){return copyScaleBin(this,new ScaleCalendarBin)};return ScaleCalendarBin}(_calendar.default);var _default=ScaleCalendarBin;exports.default=_default; |
@@ -1,1 +0,1 @@ | ||
"use strict";var _interopRequireWildcard=require("@babel/runtime/helpers/interopRequireWildcard");var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule=true;exports.default=exports.TimeConverter=void 0;var _timeFormatter=_interopRequireDefault(require("./time-formatter.js"));var _timeParser=_interopRequireWildcard(require("./time-parser.js"));var _week=require("../time-intervals/week.js");var _week2=require("../time-intervals/utc/week.js");var _day=_interopRequireDefault(require("../time-intervals/day.js"));var _year=_interopRequireDefault(require("../time-intervals/year.js"));var _day2=_interopRequireDefault(require("../time-intervals/utc/day.js"));var _year2=_interopRequireDefault(require("../time-intervals/utc/year.js"));var _enUS=_interopRequireDefault(require("./locales/en-US.js"));var numberRe=/^\s*\d+/,quarterRe=/^\s*Q\d+/,percentRe=/^%/,requoteRe=/[\\^$*+?|[\]().{}]/g,pad=function pad(value,fill,width){var sign=value<0?"-":"",string=(sign?-value:value)+"",length=string.length,padStr=length<width?new Array(width-length+1).join(fill)+string:string;return sign+padStr},requote=function requote(s){return s.replace(requoteRe,"\\$&")},formatRe=function formatRe(names){return new RegExp("^(?:"+names.map(requote).join("|")+")","i")},formatLookup=function formatLookup(names){var map={},i=-1,n=names.length;while(++i<n){map[names[i].toLowerCase()]=i}return map},parseWeekdayNumberSunday=function parseWeekdayNumberSunday(d,string,i){var n=numberRe.exec(string.slice(i,i+1));return n?(d.w=+n[0],i+n[0].length):-1},parseWeekdayNumberMonday=function parseWeekdayNumberMonday(d,string,i){var n=numberRe.exec(string.slice(i,i+1));return n?(d.u=+n[0],i+n[0].length):-1},parseWeekNumberSunday=function parseWeekNumberSunday(d,string,i){var n=numberRe.exec(string.slice(i,i+2));return n?(d.U=+n[0],i+n[0].length):-1},parseWeekNumberISO=function parseWeekNumberISO(d,string,i){var n=numberRe.exec(string.slice(i,i+2));return n?(d.V=+n[0],i+n[0].length):-1},parseWeekNumberMonday=function parseWeekNumberMonday(d,string,i){var n=numberRe.exec(string.slice(i,i+2));return n?(d.W=+n[0],i+n[0].length):-1},parseQuarter=function parseQuarter(d,string,i){var n=quarterRe.exec(string.slice(i,i+2));return n?(d.m=(n[0][1]-1)*3,i+n[0].length):-1},parseFullYear=function parseFullYear(d,string,i){var n=numberRe.exec(string.slice(i,i+4));return n?(d.y=+n[0],i+n[0].length):-1},parseYear=function parseYear(d,string,i){var n=numberRe.exec(string.slice(i,i+2));return n?(d.y=+n[0]+(+n[0]>68?1900:2e3),i+n[0].length):-1},parseZone=function parseZone(d,string,i){var n=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(string.slice(i,i+6));return n?(d.Z=n[1]?0:-(n[2]+(n[3]||"00")),i+n[0].length):-1},parseMonthNumber=function parseMonthNumber(d,string,i){var n=numberRe.exec(string.slice(i,i+2));return n?(d.m=n[0]-1,i+n[0].length):-1},parseDayOfMonth=function parseDayOfMonth(d,string,i){var n=numberRe.exec(string.slice(i,i+2));return n?(d.d=+n[0],i+n[0].length):-1},parseDayOfYear=function parseDayOfYear(d,string,i){var n=numberRe.exec(string.slice(i,i+3));return n?(d.m=0,d.d=+n[0],i+n[0].length):-1},parseHour24=function parseHour24(d,string,i){var n=numberRe.exec(string.slice(i,i+2));return n?(d.H=+n[0],i+n[0].length):-1},parseMinutes=function parseMinutes(d,string,i){var n=numberRe.exec(string.slice(i,i+2));return n?(d.M=+n[0],i+n[0].length):-1},parseSeconds=function parseSeconds(d,string,i){var n=numberRe.exec(string.slice(i,i+2));return n?(d.S=+n[0],i+n[0].length):-1},parseMilliseconds=function parseMilliseconds(d,string,i){var n=numberRe.exec(string.slice(i,i+3));return n?(d.L=+n[0],i+n[0].length):-1},parseMicroseconds=function parseMicroseconds(d,string,i){var n=numberRe.exec(string.slice(i,i+6));return n?(d.L=Math.floor(n[0]/1e3),i+n[0].length):-1},parseLiteralPercent=function parseLiteralPercent(d,string,i){var n=percentRe.exec(string.slice(i,i+1));return n?i+n[0].length:-1},parseUnixTimestamp=function parseUnixTimestamp(d,string,i){var n=numberRe.exec(string.slice(i));return n?(d.Q=+n[0],i+n[0].length):-1},parseUnixTimestampSeconds=function parseUnixTimestampSeconds(d,string,i){var n=numberRe.exec(string.slice(i));return n?(d.Q=+n[0]*1e3,i+n[0].length):-1},formatDayOfMonth=function formatDayOfMonth(d,p){return pad(d.getDate(),p,2)},formatHour24=function formatHour24(d,p){return pad(d.getHours(),p,2)},formatHour12=function formatHour12(d,p){return pad(d.getHours()%12||12,p,2)},formatDayOfYear=function formatDayOfYear(d,p){return pad(1+_day.default.count(_year.default.floor(d),d),p,3)},formatMilliseconds=function formatMilliseconds(d,p){return pad(d.getMilliseconds(),p,3)},formatMicroseconds=function formatMicroseconds(d,p){return formatMilliseconds(d,p)+"000"},formatMonthNumber=function formatMonthNumber(d,p){return pad(d.getMonth()+1,p,2)},formatMinutes=function formatMinutes(d,p){return pad(d.getMinutes(),p,2)},formatSeconds=function formatSeconds(d,p){return pad(d.getSeconds(),p,2)},formatQuarter=function formatQuarter(d,p){return"Q"+Math.ceil((d.getMonth()+1)/3)},formatWeekdayNumberMonday=function formatWeekdayNumberMonday(d){var day=d.getDay();return day===0?7:day},formatWeekNumberSunday=function formatWeekNumberSunday(d,p){return pad(_week.sunday.count(_year.default.floor(d),d),p,2)},formatWeekNumberISO=function formatWeekNumberISO(_d,p){var d=_d,day=d.getDay();d=day>=4||day===0?_week.thursday.floor(d):_week.thursday.ceil(d);return pad(_week.thursday.count(_year.default.floor(d),d)+(_year.default.floor(d).getDay()===4),p,2)},formatWeekdayNumberSunday=function formatWeekdayNumberSunday(d){return d.getDay()},formatWeekNumberMonday=function formatWeekNumberMonday(d,p){return pad(_week.monday.count(_year.default.floor(d),d),p,2)},formatYear=function formatYear(d,p){return pad(d.getFullYear()%100,p,2)},formatFullYear=function formatFullYear(d,p){return pad(d.getFullYear()%1e4,p,4)},formatZone=function formatZone(d){var z=d.getTimezoneOffset();return(z>0?"-":(z*=-1,"+"))+pad(z/60|0,"0",2)+pad(z%60,"0",2)},formatUTCDayOfMonth=function formatUTCDayOfMonth(d,p){return pad(d.getUTCDate(),p,2)},formatUTCHour24=function formatUTCHour24(d,p){return pad(d.getUTCHours(),p,2)},formatUTCHour12=function formatUTCHour12(d,p){return pad(d.getUTCHours()%12||12,p,2)},formatUTCDayOfYear=function formatUTCDayOfYear(d,p){return pad(1+_day2.default.count(_year2.default.floor(d),d),p,3)},formatUTCMilliseconds=function formatUTCMilliseconds(d,p){return pad(d.getUTCMilliseconds(),p,3)},formatUTCMicroseconds=function formatUTCMicroseconds(d,p){return formatUTCMilliseconds(d,p)+"000"},formatUTCMonthNumber=function formatUTCMonthNumber(d,p){return pad(d.getUTCMonth()+1,p,2)},formatUTCMinutes=function formatUTCMinutes(d,p){return pad(d.getUTCMinutes(),p,2)},formatUTCSeconds=function formatUTCSeconds(d,p){return pad(d.getUTCSeconds(),p,2)},formatUTCQuarter=function formatUTCQuarter(d,p){return"Q"+Math.ceil((d.getUTCMonth()+1)/3)},formatUTCWeekdayNumberMonday=function formatUTCWeekdayNumberMonday(d){var dow=d.getUTCDay();return dow===0?7:dow},formatUTCWeekNumberSunday=function formatUTCWeekNumberSunday(d,p){return pad(_week2.utcSunday.count(_year2.default.floor(d),d),p,2)},formatUTCWeekNumberISO=function formatUTCWeekNumberISO(_d,p){var d=_d,day=d.getUTCDay();d=day>=4||day===0?_week2.utcThursday.floor(d):_week2.utcThursday.ceil(d);return pad(_week2.utcThursday.count(_year2.default.floor(d),d)+(_year2.default.floor(d).getUTCDay()===4),p,2)},formatUTCWeekdayNumberSunday=function formatUTCWeekdayNumberSunday(d){return d.getUTCDay()},formatUTCWeekNumberMonday=function formatUTCWeekNumberMonday(d,p){return pad(_week2.utcMonday.count(_year2.default.floor(d),d),p,2)},formatUTCYear=function formatUTCYear(d,p){return pad(d.getUTCFullYear()%100,p,2)},formatUTCFullYear=function formatUTCFullYear(d,p){return pad(d.getUTCFullYear()%1e4,p,4)},formatUTCZone=function formatUTCZone(){return"+0000"},formatLiteralPercent=function formatLiteralPercent(){return"%"},formatUnixTimestamp=function formatUnixTimestamp(d){return+d},formatUnixTimestampSeconds=function formatUnixTimestampSeconds(d){return Math.floor(+d/1e3)};var TimeConverter=function(){function TimeConverter(locale){var _this=this;var localeDateTime=locale.dateTime,localeDate=locale.date,localeTime=locale.time,localePeriods=locale.periods,localeWeekdays=locale.days,localeShortWeekdays=locale.shortDays,localeMonths=locale.months,localeShortMonths=locale.shortMonths,periodRe=formatRe(localePeriods),periodLookup=formatLookup(localePeriods),weekdayRe=formatRe(localeWeekdays),weekdayLookup=formatLookup(localeWeekdays),shortWeekdayRe=formatRe(localeShortWeekdays),shortWeekdayLookup=formatLookup(localeShortWeekdays),monthRe=formatRe(localeMonths),monthLookup=formatLookup(localeMonths),shortMonthRe=formatRe(localeShortMonths),shortMonthLookup=formatLookup(localeShortMonths);this._formats={a:function a(d){return localeShortWeekdays[d.getDay()]},A:function A(d){return localeWeekdays[d.getDay()]},b:function b(d){return localeShortMonths[d.getMonth()]},B:function B(d){return localeMonths[d.getMonth()]},d:formatDayOfMonth,e:formatDayOfMonth,f:formatMicroseconds,H:formatHour24,I:formatHour12,j:formatDayOfYear,L:formatMilliseconds,m:formatMonthNumber,M:formatMinutes,p:function p(d){return localePeriods[+(d.getHours()>=12)]},q:formatQuarter,Q:formatUnixTimestamp,s:formatUnixTimestampSeconds,S:formatSeconds,u:formatWeekdayNumberMonday,U:formatWeekNumberSunday,V:formatWeekNumberISO,w:formatWeekdayNumberSunday,W:formatWeekNumberMonday,y:formatYear,Y:formatFullYear,Z:formatZone,"%":formatLiteralPercent};this._utcFormats={a:function a(d){return localeShortWeekdays[d.getUTCDay()]},A:function A(d){return localeWeekdays[d.getUTCDay()]},b:function b(d){return localeShortMonths[d.getUTCMonth()]},B:function B(d){return localeMonths[d.getUTCMonth()]},d:formatUTCDayOfMonth,e:formatUTCDayOfMonth,f:formatUTCMicroseconds,H:formatUTCHour24,I:formatUTCHour12,j:formatUTCDayOfYear,L:formatUTCMilliseconds,m:formatUTCMonthNumber,M:formatUTCMinutes,p:function p(d){return localePeriods[+(d.getUTCHours()>=12)]},q:formatUTCQuarter,Q:formatUnixTimestamp,s:formatUnixTimestampSeconds,S:formatUTCSeconds,u:formatUTCWeekdayNumberMonday,U:formatUTCWeekNumberSunday,V:formatUTCWeekNumberISO,w:formatUTCWeekdayNumberSunday,W:formatUTCWeekNumberMonday,y:formatUTCYear,Y:formatUTCFullYear,Z:formatUTCZone,"%":formatLiteralPercent};this._parses={a:function a(d,string,i){var n=shortWeekdayRe.exec(string.slice(i));if(n){d.w=shortWeekdayLookup[n[0].toLowerCase()];return i+n[0].length}return-1},A:function A(d,string,i){var n=weekdayRe.exec(string.slice(i));if(n){d.w=weekdayLookup[n[0].toLowerCase()];return i+n[0].length}return-1},b:function b(d,string,i){var n=shortMonthRe.exec(string.slice(i));if(n){d.m=shortMonthLookup[n[0].toLowerCase()];return i+n[0].length}return-1},B:function B(d,string,i){var n=monthRe.exec(string.slice(i));if(n){d.m=monthLookup[n[0].toLowerCase()];return i+n[0].length}return-1},c:null,d:parseDayOfMonth,e:parseDayOfMonth,f:parseMicroseconds,H:parseHour24,I:parseHour24,j:parseDayOfYear,L:parseMilliseconds,m:parseMonthNumber,M:parseMinutes,p:function p(d,string,i){var n=periodRe.exec(string.slice(i));if(n){d.p=periodLookup[n[0].toLowerCase()];return i+n[0].length}return-1},Q:parseUnixTimestamp,q:parseQuarter,s:parseUnixTimestampSeconds,S:parseSeconds,u:parseWeekdayNumberMonday,U:parseWeekNumberSunday,V:parseWeekNumberISO,w:parseWeekdayNumberSunday,W:parseWeekNumberMonday,x:null,X:null,y:parseYear,Y:parseFullYear,Z:parseZone,"%":parseLiteralPercent};this._formats.x=function(d){return new _timeFormatter.default(localeDate,_this._formats).format(d)};this._formats.X=function(d){return new _timeFormatter.default(localeTime,_this._formats).format(d)};this._formats.c=function(d){return new _timeFormatter.default(localeDateTime,_this._formats).format(d)};this._utcFormats.x=function(d){return new _timeFormatter.default(localeDate,_this._utcFormats).format(d)};this._utcFormats.X=function(d){return new _timeFormatter.default(localeTime,_this._utcFormats).format(d)};this._utcFormats.c=function(d){return new _timeFormatter.default(localeDateTime,_this._utcFormats).format(d)};this._parses.c=function(d,string,i){return new _timeParser.default(localeDateTime,_this._parses).parseSpecifier(d,string,i)};this._parses.x=function(d,string,i){return new _timeParser.default(localeDate,_this._parses).parseSpecifier(d,string,i)};this._parses.X=function(d,string,i){return new _timeParser.default(localeTime,_this._parses).parseSpecifier(d,string,i)}}var _proto=TimeConverter.prototype;_proto.formatter=function formatter(specifier){if(specifier===void 0){specifier=""}return new _timeFormatter.default(specifier.toString(),this._formats)};_proto.utcFormatter=function utcFormatter(specifier){if(specifier===void 0){specifier=""}return new _timeFormatter.default(specifier.toString(),this._utcFormats)};_proto.parser=function parser(_specifier){var specifier=_specifier;return new _timeParser.default(specifier+="",this._parses,(function(d){if(d.y>=0&&d.y<100){var date=new Date(-1,d.m,d.d,d.H,d.M,d.S,d.L);date.setFullYear(d.y);return date}return new Date(d.y,d.m,d.d,d.H,d.M,d.S,d.L)}))};_proto.utcParser=function utcParser(_specifier){var specifier=_specifier;return new _timeParser.default(specifier+="",this._parses,_timeParser.utcDate)};return TimeConverter}();exports.TimeConverter=TimeConverter;var _default=new TimeConverter(_enUS.default);exports.default=_default; | ||
"use strict";var _interopRequireWildcard=require("@babel/runtime/helpers/interopRequireWildcard");var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule=true;exports.default=exports.TimeConverter=void 0;var _timeFormatter=_interopRequireDefault(require("./time-formatter.js"));var _timeParser=_interopRequireWildcard(require("./time-parser.js"));var _week=require("../time-intervals/week.js");var _week2=require("../time-intervals/utc/week.js");var _hour=_interopRequireDefault(require("../time-intervals/hour.js"));var _day=_interopRequireDefault(require("../time-intervals/day.js"));var _year=_interopRequireDefault(require("../time-intervals/year.js"));var _day2=_interopRequireDefault(require("../time-intervals/utc/day.js"));var _year2=_interopRequireDefault(require("../time-intervals/utc/year.js"));var _enUS=_interopRequireDefault(require("./locales/en-US.js"));var numberRe=/^\s*\d+/,quarterRe=/^\s*Q\d+/,percentRe=/^%/,requoteRe=/[\\^$*+?|[\]().{}]/g,pad=function pad(value,fill,width){var sign=value<0?"-":"",string=(sign?-value:value)+"",length=string.length,padStr=length<width?new Array(width-length+1).join(fill)+string:string;return sign+padStr},requote=function requote(s){return s.replace(requoteRe,"\\$&")},formatRe=function formatRe(names){return new RegExp("^(?:"+names.map(requote).join("|")+")","i")},formatLookup=function formatLookup(names){var map={},i=-1,n=names.length;while(++i<n){map[names[i].toLowerCase()]=i}return map},parseWeekdayNumberSunday=function parseWeekdayNumberSunday(d,string,i){var n=numberRe.exec(string.slice(i,i+1));return n?(d.w=+n[0],i+n[0].length):-1},parseWeekdayNumberMonday=function parseWeekdayNumberMonday(d,string,i){var n=numberRe.exec(string.slice(i,i+1));return n?(d.u=+n[0],i+n[0].length):-1},parseWeekNumberSunday=function parseWeekNumberSunday(d,string,i){var n=numberRe.exec(string.slice(i,i+2));return n?(d.U=+n[0],i+n[0].length):-1},parseWeekNumberISO=function parseWeekNumberISO(d,string,i){var n=numberRe.exec(string.slice(i,i+2));return n?(d.V=+n[0],i+n[0].length):-1},parseWeekNumberMonday=function parseWeekNumberMonday(d,string,i){var n=numberRe.exec(string.slice(i,i+2));return n?(d.W=+n[0],i+n[0].length):-1},parseQuarter=function parseQuarter(d,string,i){var n=quarterRe.exec(string.slice(i,i+2));return n?(d.m=(n[0][1]-1)*3,i+n[0].length):-1},parseFullYear=function parseFullYear(d,string,i){var n=numberRe.exec(string.slice(i,i+4));return n?(d.y=+n[0],i+n[0].length):-1},parseYear=function parseYear(d,string,i){var n=numberRe.exec(string.slice(i,i+2));return n?(d.y=+n[0]+(+n[0]>68?1900:2e3),i+n[0].length):-1},parseZone=function parseZone(d,string,i){var n=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(string.slice(i,i+6));return n?(d.Z=n[1]?0:-(n[2]+(n[3]||"00")),i+n[0].length):-1},parseMonthNumber=function parseMonthNumber(d,string,i){var n=numberRe.exec(string.slice(i,i+2));return n?(d.m=n[0]-1,i+n[0].length):-1},parseDayOfMonth=function parseDayOfMonth(d,string,i){var n=numberRe.exec(string.slice(i,i+2));return n?(d.d=+n[0],i+n[0].length):-1},parseDayOfYear=function parseDayOfYear(d,string,i){var n=numberRe.exec(string.slice(i,i+3));return n?(d.m=0,d.d=+n[0],i+n[0].length):-1},parseHour24=function parseHour24(d,string,i){var n=numberRe.exec(string.slice(i,i+2));return n?(d.H=+n[0],i+n[0].length):-1},parseMinutes=function parseMinutes(d,string,i){var n=numberRe.exec(string.slice(i,i+2));return n?(d.M=+n[0],i+n[0].length):-1},parseSeconds=function parseSeconds(d,string,i){var n=numberRe.exec(string.slice(i,i+2));return n?(d.S=+n[0],i+n[0].length):-1},parseMilliseconds=function parseMilliseconds(d,string,i){var n=numberRe.exec(string.slice(i,i+3));return n?(d.L=+n[0],i+n[0].length):-1},parseMicroseconds=function parseMicroseconds(d,string,i){var n=numberRe.exec(string.slice(i,i+6));return n?(d.L=Math.floor(n[0]/1e3),i+n[0].length):-1},parseLiteralPercent=function parseLiteralPercent(d,string,i){var n=percentRe.exec(string.slice(i,i+1));return n?i+n[0].length:-1},parseUnixTimestamp=function parseUnixTimestamp(d,string,i){var n=numberRe.exec(string.slice(i));return n?(d.Q=+n[0],i+n[0].length):-1},parseUnixTimestampSeconds=function parseUnixTimestampSeconds(d,string,i){var n=numberRe.exec(string.slice(i));return n?(d.Q=+n[0]*1e3,i+n[0].length):-1},formatDayOfMonth=function formatDayOfMonth(d,p){return pad(d.getDate(),p,2)},formatHour24=function formatHour24(d,p){return pad(d.getHours(),p,2)},formatHour12=function formatHour12(d,p){return pad(d.getHours()%12||12,p,2)},formatDayOfYear=function formatDayOfYear(d,p){return pad(1+_day.default.count(_year.default.floor(d),d),p,3)},formatMilliseconds=function formatMilliseconds(d,p){return pad(d.getMilliseconds(),p,3)},formatMicroseconds=function formatMicroseconds(d,p){return formatMilliseconds(d,p)+"000"},formatMonthNumber=function formatMonthNumber(d,p){return pad(d.getMonth()+1,p,2)},formatMinutes=function formatMinutes(d,p){return pad(d.getMinutes(),p,2)},formatSeconds=function formatSeconds(d,p){return pad(d.getSeconds(),p,2)},formatQuarter=function formatQuarter(d,p){return"Q"+Math.ceil((d.getMonth()+1)/3)},formatWeekdayNumberMonday=function formatWeekdayNumberMonday(d){var day=d.getDay();return day===0?7:day},formatWeekNumberSunday=function formatWeekNumberSunday(d,p){return pad(_week.sunday.count(_year.default.floor(d),d),p,2)},formatWeekNumberISO=function formatWeekNumberISO(_d,p){var d=_d,day=d.getDay();d=day>=4||day===0?_week.thursday.floor(d):_week.thursday.ceil(d);return pad(_week.thursday.count(_year.default.floor(d),d)+(_year.default.floor(d).getDay()===4),p,2)},formatWeekdayNumberSunday=function formatWeekdayNumberSunday(d){return d.getDay()},formatWeekNumberMonday=function formatWeekNumberMonday(d,p){return pad(_week.monday.count(_year.default.floor(d),d),p,2)},formatYear=function formatYear(d,p){return pad(d.getFullYear()%100,p,2)},formatFullYear=function formatFullYear(d,p){return pad(d.getFullYear()%1e4,p,4)},formatZone=function formatZone(d){var z=d.getTimezoneOffset();return(z>0?"-":(z*=-1,"+"))+pad(z/60|0,"0",2)+pad(z%60,"0",2)},formatUTCDayOfMonth=function formatUTCDayOfMonth(d,p){return pad(d.getUTCDate(),p,2)},formatUTCHour24=function formatUTCHour24(d,p){return pad(d.getUTCHours(),p,2)},formatUTCHour12=function formatUTCHour12(d,p){return pad(d.getUTCHours()%12||12,p,2)},formatUTCDayOfYear=function formatUTCDayOfYear(d,p){return pad(1+_day2.default.count(_year2.default.floor(d),d),p,3)},formatUTCMilliseconds=function formatUTCMilliseconds(d,p){return pad(d.getUTCMilliseconds(),p,3)},formatUTCMicroseconds=function formatUTCMicroseconds(d,p){return formatUTCMilliseconds(d,p)+"000"},formatUTCMonthNumber=function formatUTCMonthNumber(d,p){return pad(d.getUTCMonth()+1,p,2)},formatUTCMinutes=function formatUTCMinutes(d,p){return pad(d.getUTCMinutes(),p,2)},formatUTCSeconds=function formatUTCSeconds(d,p){return pad(d.getUTCSeconds(),p,2)},formatUTCQuarter=function formatUTCQuarter(d,p){return"Q"+Math.ceil((d.getUTCMonth()+1)/3)},formatUTCWeekdayNumberMonday=function formatUTCWeekdayNumberMonday(d){var dow=d.getUTCDay();return dow===0?7:dow},formatUTCWeekNumberSunday=function formatUTCWeekNumberSunday(d,p){return pad(_week2.utcSunday.count(_year2.default.floor(d),d),p,2)},formatUTCWeekNumberISO=function formatUTCWeekNumberISO(_d,p){var d=_d,day=d.getUTCDay();d=day>=4||day===0?_week2.utcThursday.floor(d):_week2.utcThursday.ceil(d);return pad(_week2.utcThursday.count(_year2.default.floor(d),d)+(_year2.default.floor(d).getUTCDay()===4),p,2)},formatUTCWeekdayNumberSunday=function formatUTCWeekdayNumberSunday(d){return d.getUTCDay()},formatUTCWeekNumberMonday=function formatUTCWeekNumberMonday(d,p){return pad(_week2.utcMonday.count(_year2.default.floor(d),d),p,2)},formatUTCYear=function formatUTCYear(d,p){return pad(d.getUTCFullYear()%100,p,2)},formatUTCFullYear=function formatUTCFullYear(d,p){return pad(d.getUTCFullYear()%1e4,p,4)},formatUTCZone=function formatUTCZone(){return"+0000"},formatLiteralPercent=function formatLiteralPercent(){return"%"},formatUnixTimestamp=function formatUnixTimestamp(d){return+d},formatUnixTimestampSeconds=function formatUnixTimestampSeconds(d){return Math.floor(+d/1e3)};var TimeConverter=function(){function TimeConverter(locale){var _this=this;var localeDateTime=locale.dateTime,localeDate=locale.date,localeTime=locale.time,localePeriods=locale.periods,localeWeekdays=locale.days,localeShortWeekdays=locale.shortDays,localeMonths=locale.months,localeShortMonths=locale.shortMonths,periodRe=formatRe(localePeriods),periodLookup=formatLookup(localePeriods),weekdayRe=formatRe(localeWeekdays),weekdayLookup=formatLookup(localeWeekdays),shortWeekdayRe=formatRe(localeShortWeekdays),shortWeekdayLookup=formatLookup(localeShortWeekdays),monthRe=formatRe(localeMonths),monthLookup=formatLookup(localeMonths),shortMonthRe=formatRe(localeShortMonths),shortMonthLookup=formatLookup(localeShortMonths);this._formats={a:function a(d){return localeShortWeekdays[d.getDay()]},A:function A(d){return localeWeekdays[d.getDay()]},b:function b(d){return localeShortMonths[d.getMonth()]},B:function B(d){return localeMonths[d.getMonth()]},d:formatDayOfMonth,e:formatDayOfMonth,f:formatMicroseconds,H:formatHour24,I:formatHour12,j:formatDayOfYear,L:formatMilliseconds,m:formatMonthNumber,M:formatMinutes,p:function p(d){return localePeriods[+(d.getHours()>=12)]},q:formatQuarter,Q:formatUnixTimestamp,s:formatUnixTimestampSeconds,S:formatSeconds,u:formatWeekdayNumberMonday,U:formatWeekNumberSunday,V:formatWeekNumberISO,w:formatWeekdayNumberSunday,W:formatWeekNumberMonday,y:formatYear,Y:formatFullYear,Z:formatZone,"%":formatLiteralPercent};this._utcFormats={a:function a(d){return localeShortWeekdays[d.getUTCDay()]},A:function A(d){return localeWeekdays[d.getUTCDay()]},b:function b(d){return localeShortMonths[d.getUTCMonth()]},B:function B(d){return localeMonths[d.getUTCMonth()]},d:formatUTCDayOfMonth,e:formatUTCDayOfMonth,f:formatUTCMicroseconds,H:formatUTCHour24,I:formatUTCHour12,j:formatUTCDayOfYear,L:formatUTCMilliseconds,m:formatUTCMonthNumber,M:formatUTCMinutes,p:function p(d){return localePeriods[+(d.getUTCHours()>=12)]},q:formatUTCQuarter,Q:formatUnixTimestamp,s:formatUnixTimestampSeconds,S:formatUTCSeconds,u:formatUTCWeekdayNumberMonday,U:formatUTCWeekNumberSunday,V:formatUTCWeekNumberISO,w:formatUTCWeekdayNumberSunday,W:formatUTCWeekNumberMonday,y:formatUTCYear,Y:formatUTCFullYear,Z:formatUTCZone,"%":formatLiteralPercent};this._parses={a:function a(d,string,i){var n=shortWeekdayRe.exec(string.slice(i));if(n){d.w=shortWeekdayLookup[n[0].toLowerCase()];return i+n[0].length}return-1},A:function A(d,string,i){var n=weekdayRe.exec(string.slice(i));if(n){d.w=weekdayLookup[n[0].toLowerCase()];return i+n[0].length}return-1},b:function b(d,string,i){var n=shortMonthRe.exec(string.slice(i));if(n){d.m=shortMonthLookup[n[0].toLowerCase()];return i+n[0].length}return-1},B:function B(d,string,i){var n=monthRe.exec(string.slice(i));if(n){d.m=monthLookup[n[0].toLowerCase()];return i+n[0].length}return-1},c:null,d:parseDayOfMonth,e:parseDayOfMonth,f:parseMicroseconds,H:parseHour24,I:parseHour24,j:parseDayOfYear,L:parseMilliseconds,m:parseMonthNumber,M:parseMinutes,p:function p(d,string,i){var n=periodRe.exec(string.slice(i));if(n){d.p=periodLookup[n[0].toLowerCase()];return i+n[0].length}return-1},Q:parseUnixTimestamp,q:parseQuarter,s:parseUnixTimestampSeconds,S:parseSeconds,u:parseWeekdayNumberMonday,U:parseWeekNumberSunday,V:parseWeekNumberISO,w:parseWeekdayNumberSunday,W:parseWeekNumberMonday,x:null,X:null,y:parseYear,Y:parseFullYear,Z:parseZone,"%":parseLiteralPercent};this._formats.x=function(d){return new _timeFormatter.default(localeDate,_this._formats).format(d)};this._formats.X=function(d){return new _timeFormatter.default(localeTime,_this._formats).format(d)};this._formats.c=function(d){return new _timeFormatter.default(localeDateTime,_this._formats).format(d)};this._utcFormats.x=function(d){return new _timeFormatter.default(localeDate,_this._utcFormats).format(d)};this._utcFormats.X=function(d){return new _timeFormatter.default(localeTime,_this._utcFormats).format(d)};this._utcFormats.c=function(d){return new _timeFormatter.default(localeDateTime,_this._utcFormats).format(d)};this._parses.c=function(d,string,i){return new _timeParser.default(localeDateTime,_this._parses).parseSpecifier(d,string,i)};this._parses.x=function(d,string,i){return new _timeParser.default(localeDate,_this._parses).parseSpecifier(d,string,i)};this._parses.X=function(d,string,i){return new _timeParser.default(localeTime,_this._parses).parseSpecifier(d,string,i)}}var _proto=TimeConverter.prototype;_proto.formatter=function formatter(specifier){if(specifier===void 0){specifier=""}return new _timeFormatter.default(specifier.toString(),this._formats)};_proto.utcFormatter=function utcFormatter(specifier){if(specifier===void 0){specifier=""}return new _timeFormatter.default(specifier.toString(),this._utcFormats)};_proto.parser=function parser(_specifier){var specifier=_specifier;return new _timeParser.default(specifier+="",this._parses,(function(d){var date;if(d.y>=0&&d.y<100){date=new Date(-1,d.m,d.d,d.H,d.M,d.S,d.L);date.setFullYear(d.y);return date}date=new Date(d.y,d.m,d.d,d.H,d.M,d.S,d.L);var winterOffset=new Date(d.y,0).getTimezoneOffset(),summerOffset=new Date(d.y,6).getTimezoneOffset(),dateOffset=new Date(d.y,d.m,d.d,d.H,d.M,d.S,d.L).getTimezoneOffset();if(summerOffset===winterOffset){return date}if(winterOffset>summerOffset&&winterOffset!==dateOffset){date=_hour.default.offset(date,1)}return date}))};_proto.utcParser=function utcParser(_specifier){var specifier=_specifier;return new _timeParser.default(specifier+="",this._parses,_timeParser.utcDate)};return TimeConverter}();exports.TimeConverter=TimeConverter;var _default=new TimeConverter(_enUS.default);exports.default=_default; |
@@ -1,1 +0,1 @@ | ||
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule=true;exports.yearObj=exports.default=void 0;var _timeIntervalYear=_interopRequireDefault(require("./time-interval-year.js"));var _durations=require("./durations.js");var _timeIntervalclip=require("./time-intervalclip");var yearObj={name:"year",floor:function floor(d,clippedDates,timeUniverse){d.setMonth(0,1);return new Date(Number((0,_timeIntervalclip.getFloor)(new Date(Number(d.setHours(0,0,0,0))),clippedDates,timeUniverse)))},offset:function offset(d,s,clippedDates,timeUniverse){var isPositiveOffset=s>0,dateObj={date:new Date(Number(d))},cloneDate=new Date(Number(dateObj.date));return new Date(Number(isPositiveOffset?(0,_timeIntervalclip.clampDownDateWithinClip)(dateObj.date,new Date(Number(cloneDate.setFullYear(cloneDate.getFullYear()+s))),clippedDates,timeUniverse):(0,_timeIntervalclip.clampUpDateWithinClip)(dateObj.date,new Date(Number(cloneDate.setFullYear(cloneDate.getFullYear()+s))),clippedDates,timeUniverse)))},count:function count(s,e,clippedDates){var clipArray=(0,_timeIntervalclip.getValidDatesWithin)(clippedDates,s,e),clipDuration=0,clipDates=(0,_timeIntervalclip.getClampRangesAround)(clippedDates,e);clipArray=(0,_timeIntervalclip.getClipArray)(clipDates,clipArray);clipArray.forEach((function(date){clipDuration+=Number(date.to)-Number(date.from)}));return e.getFullYear()-s.getFullYear()-Math.floor(clipDuration/_durations.durationYear)},field:function field(d,clippedDates,timeUniverse){var dateObj={date:new Date(Number(d))},cloneDate=new Date(Number(dateObj.date)),clipArray=[],floorDate,clipDuration=0;cloneDate.setFullYear(0);floorDate=(0,_timeIntervalclip.getFloor)(new Date(Number(cloneDate)),clippedDates,timeUniverse);clipArray=(0,_timeIntervalclip.getValidDatesWithin)(clippedDates,new Date(Number(floorDate)),dateObj.date);clipArray.forEach((function(date){clipDuration+=Number(date.to)-Number(date.from)}));return d.getFullYear()-floorDate.getFullYear()-Math.floor(clipDuration/_durations.durationYear)}},year=new _timeIntervalYear.default(yearObj);exports.yearObj=yearObj;var _default=year;exports.default=_default; | ||
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule=true;exports.yearObj=exports.default=void 0;var _timeIntervalYear=_interopRequireDefault(require("./time-interval-year.js"));var _durations=require("./durations.js");var _timeIntervalclip=require("./time-intervalclip");var yearObj={name:"year",floor:function floor(d,clippedDates,timeUniverse){var yearFloor;d.setMonth(0,1);yearFloor=new Date(Number((0,_timeIntervalclip.getFloor)(new Date(Number(d.setHours(0,0,0,0))),clippedDates,timeUniverse)));return yearFloor},offset:function offset(d,s,clippedDates,timeUniverse){var isPositiveOffset=s>0,dateObj={date:new Date(Number(d))},cloneDate=new Date(Number(dateObj.date));return new Date(Number(isPositiveOffset?(0,_timeIntervalclip.clampDownDateWithinClip)(dateObj.date,new Date(Number(cloneDate.setFullYear(cloneDate.getFullYear()+s))),clippedDates,timeUniverse):(0,_timeIntervalclip.clampUpDateWithinClip)(dateObj.date,new Date(Number(cloneDate.setFullYear(cloneDate.getFullYear()+s))),clippedDates,timeUniverse)))},count:function count(s,e,clippedDates){var clipArray=(0,_timeIntervalclip.getValidDatesWithin)(clippedDates,s,e),clipDuration=0,clipDates=(0,_timeIntervalclip.getClampRangesAround)(clippedDates,e);clipArray=(0,_timeIntervalclip.getClipArray)(clipDates,clipArray);clipArray.forEach((function(date){clipDuration+=Number(date.to)-Number(date.from)}));return e.getFullYear()-s.getFullYear()-Math.floor(clipDuration/_durations.durationYear)},field:function field(d,clippedDates,timeUniverse){var dateObj={date:new Date(Number(d))},cloneDate=new Date(Number(dateObj.date)),clipArray=[],floorDate,clipDuration=0;cloneDate.setFullYear(0);floorDate=(0,_timeIntervalclip.getFloor)(new Date(Number(cloneDate)),clippedDates,timeUniverse);clipArray=(0,_timeIntervalclip.getValidDatesWithin)(clippedDates,new Date(Number(floorDate)),dateObj.date);clipArray.forEach((function(date){clipDuration+=Number(date.to)-Number(date.from)}));return d.getFullYear()-floorDate.getFullYear()-Math.floor(clipDuration/_durations.durationYear)}},year=new _timeIntervalYear.default(yearObj);exports.yearObj=yearObj;var _default=year;exports.default=_default; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
506390
2