UNPKG

g-axis

Version:
1 lines 20.3 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("d3")):"function"==typeof define&&define.amd?define(["exports","d3"],e):e(t.gAxis={},t.d3)}(this,function(t,e){"use strict";t.xDate=function(){let t;const i=new Date(1970,1,1),a=new Date(2017,6,1);let r,o,n,l,s,d,c=e.scaleTime().domain([i,a]).range([0,220]),m=!1,g="lustrum",x=!0,h=10,u=5,f=!1,p="bottom",y=[200,100],v=10,k=!1;function b(i){const a=y[0],f=y[1];function b(t){if(m){const i=c.domain(),a=c.range();return c=e.scalePoint().domain(i).range(a),{top:e.axisTop(),bottom:e.axisBottom()}[t]}return{top:e.axisTop(),bottom:e.axisBottom()}[t]}const B=b(p);if(m)B.tickSize(h).tickFormat(A(g)).scale(c),B.tickValues(c.domain().filter((t,e)=>{let i;return 0===e?t.getDay():(e>0&&(i=new Date(c.domain()[e-1])),t.getDay()!==i.getDay())}));else{B.tickSize(h).tickFormat(A(g)).scale(c);let t=c.ticks(($=g,{century:e.timeYear.every(100),jubilee:e.timeYear.every(50),decade:e.timeYear.every(10),lustrum:e.timeYear.every(5),years:e.timeYear.every(1),fiscal:e.timeYear.every(1),quarters:e.timeYear.every(1),months:e.timeMonth.every(1),weeks:e.timeWeek.every(1),daily:e.timeDay.every(1),days:e.timeDay.every(1),hours:e.timeHour.every(1)}[$]));const i=c.domain()[0].getDate(),a=c.domain()[0].getMonth();1!==i&&0!==a&&t.unshift(c.domain()[0]),"lustrum"!==g&&"decade"!==g&&"jubilee"!==g&&"century"!==g||t.push(e.timeYear(c.domain()[1])),s&&(t=c.domain()),B.tickValues(t)}var $;const w=b(p);m?w.tickSize(u).tickFormat("").scale(c):w.tickSize(u).ticks(function(t){return{century:e.timeYear.every(10),jubilee:e.timeYear.every(10),decade:e.timeYear.every(1),lustrum:e.timeYear.every(1),years:e.timeMonth.every(1),fiscal:e.timeMonth.every(1),quarters:e.timeMonth.every(3),months:e.timeDay.every(1),weeks:e.timeDay.every(1),daily:e.timeHour.every(1),days:e.timeHour.every(1),hours:e.timeMinute.every(1)}[t]}(g)).tickFormat("").scale(c),d&&B.tickValues(d),k&&B.tickFormat(k);const M=i.append("g").attr("class","highlights");if(n=i.append("g").attr("class","axis xAxis axis baseline").call(B),x&&(l=i.append("g").attr("class",()=>f===h?"axis xAxis":"axis xAxis axis baseline").call(w)),r&&(n.selectAll(".axis.xAxis text").attr("id",`${r}xLabel`),n.selectAll(".axis.xAxis line").attr("id",`${r}xTick`),x&&l.selectAll(".axis.xAxis line").attr("id",`${r}xTick`)),o){const t={tag:o.tag,hori:o.hori||"middle",vert:o.vert||"bottom",anchor:o.anchor||"middle",rotate:o.rotate||0},e=i.append("g").attr("class","axis xAxis"),r=()=>h>0&&h<v?h+.8*v:.9*v,n=(t,e)=>({toptop:0-v,topmiddle:0,topbottom:0+v,bottomtop:f,bottommiddle:f+r(),bottombottom:f+r()+1.1*v})[t+e],l=t=>({left:a-a,middle:a/2,right:a})[t];e.append("text").attr("y",n(p,t.vert)).attr("x",l(t.hori)).text(t.tag);const s=e.selectAll("text"),d=s.node().getBBox().width/2,c=s.node().getBBox().height/2,m=s.node().getBBox().x+d,g=s.node().getBBox().y+c;s.attr("transform",`rotate(${t.rotate}, ${m}, ${g})`).style("text-anchor",t.anchor)}if(t){let t=B.tickValues();const e=e=>e===t.length-1?a-c(t[e]):c(t[e+1])-c(t[e]);t=t.map((t,i)=>({date:t,width:e(i)})).filter((t,e)=>e%2==0),console.log("bands",t),M.selectAll("rect").data(t).enter().append("rect").attr("y",0).attr("height",f).attr("x",t=>c(t.date)).attr("width",t=>t.width)}n.selectAll(".domain").remove()}function A(t){const i=e.timeFormat("%Y"),a=e.timeFormat("%y"),r=e.timeFormat("%b"),o=e.timeFormat("%W"),n=e.timeFormat("%d"),l=e.timeFormat("%H:%M");return{century:e.timeFormat("%Y"),jubilee:(t,e)=>m(t,e),decade:(t,e)=>m(t,e),lustrum:(t,e)=>m(t,e),years:(t,e)=>m(t,e),fiscal:(t,e)=>(t=t,e=e,f||+i(t)%100==0||0===e?`${i(t)}/${Number(a(t))+1}`:`${a(t)}/${Number(a(t))+1}`),quarters:(t,e)=>(function(t,e){if(t.getMonth()<3&&e<4)return`Q1 ${i(t)}`;if(t.getMonth()<3)return"Q1";if(t.getMonth()>=3&&t.getMonth()<6)return"Q2";if(t.getMonth()>=6&&t.getMonth()<9)return"Q3";if(t.getMonth()>=9&&t.getMonth()<12)return"Q4";throw new Error("Invalid quarter")})(t,e),months:(t,i)=>(function(t,i){if(0===t.getMonth()||0===i){const i=e.timeFormat("%b %Y");return i(t)}return r(t)})(t,i),weeks:(t,e)=>(function(t){return t.getDate()<9?`${o(t)} ${r(t)}`:o(t)})(t),days:(t,e)=>(function(t,e){return 1===t.getDate()||0===e?`${n(t)} ${r(t)}`:n(t)})(t,e),daily:(t,e)=>(function(t,e){const i=c.domain().length-1;return 0===e?`${n(t)} ${r(t)}`:1===t.getDate()?`${r(t)}`:5===t.getDay()?`${n(t)}`:e===i?n(t):""})(t,e),hours:(t,e)=>(function(t,e){return 1===t.getHours()||0===e?`${l(t)} ${n(t)}`:l(t)})(t,e)}[t];var s,d;function m(t,e){return f||+i(t)%100==0||0===e?i(t):a(t)}}return b.align=(t=>(p=t,b)),b.banding=(e=>void 0===e?t:(t=e,b)),b.endTicks=(t=>void 0===t?s:(s=t,b)),b.label=(t=>void 0===t?o:(o=t,b)),b.plotDim=(t=>t?(y=t,b):y),b.rem=(t=>t?(v=t,b):v),b.tickFormat=(t=>(k=t,c.tickFormat(t),b)),b.tickValues=(t=>t?(d=t,b):d),b.frameName=(t=>void 0===t?r:(r=t,b)),b.intraday=(t=>void 0===t?m:(m=t,b)),b.scale=(t=>t?(c=t,b):c),b.domain=(t=>(c.domain(t),b)),b.range=(t=>(c.range(t),b)),b.fullYear=(t=>void 0===t?f:(f=t,b)),b.interval=(t=>(g=t,b)),b.tickSize=(t=>t?(h=t,b):h),b.minorTickSize=(t=>t?(u=t,b):u),b.minorAxis=(t=>void 0===t?x:(x=t,b)),b.xLabel=(t=>void 0===t?n:(n=t,b)),b.xLabelMinor=(t=>void 0===t?l:(l=t,b)),b},t.xLinear=function(){let t,i,a,r,o,n=e.scaleLinear().domain([0,100]).range([0,220]),l=50,s=5,d="bottom",c=1,m=!1,g=!1,x=0,h=[200,100],u=10,f=!1;function p(p){let y=!1;const v=n.domain()[1]-n.domain()[0],k=h[0],b=h[1];if(m){const t=n.range().reverse();n.range(t)}if(g){const t=e.scaleLog().domain(n.domain()).range(n.range());n=t}let A;v>=.5&&(A=e.format(".1f")),v<.5&&(A=e.format(".2f")),v<=.011&&(A=e.format(".3f")),v<.0011&&(A=e.format(".4f")),v<11e-5&&(A=e.format(".5f")),v<11e-6&&(A=e.format(".6f"));const B=e.format(","),$=(w=d,{top:e.axisTop(),bottom:e.axisBottom()}[w]).tickSize(l).ticks(s).scale(n).tickFormat(function(t){return!1===Number.isInteger(t/c)&&(y=!0),t/c==0?B(t/c):g?B(t/c):y?A(t/c):B(t/c)});var w;o&&$.tickValues(o),f&&$.tickFormat(f);const M=p.append("g").attr("class","highlights");if((i=p.append("g").attr("class","axis xAxis").call($)).selectAll(".tick").filter(t=>0===t||t===x).classed("baseline",!0),r&&(i.selectAll(".axis.xAxis text").attr("id",`${r}xLabel`),i.selectAll(".axis.xAxis line").attr("id",`${r}xTick`)),a){const t={tag:a.tag,hori:a.hori||"middle",vert:a.vert||"bottom",anchor:a.anchor||"middle",rotate:a.rotate||0},e=p.append("g").attr("class","axis xAxis"),i=()=>l>0&&l<u?l+.8*u:.9*u,r=(t,e)=>({toptop:0-u,topmiddle:0,topbottom:0+u,bottomtop:b,bottommiddle:b+i(),bottombottom:b+i()+1.1*u})[t+e],o=t=>({left:k-k,middle:k/2,right:k})[t];e.append("text").attr("y",r(d,t.vert)).attr("x",o(t.hori)).text(t.tag);const n=e.selectAll("text"),s=n.node().getBBox().width/2,c=n.node().getBBox().height/2,m=n.node().getBBox().x+s,g=n.node().getBBox().y+c;n.attr("transform",`rotate(${t.rotate}, ${m}, ${g})`).style("text-anchor",t.anchor)}if(t){const t=(t,e)=>t===e.length-1?k-n(e[t]):n(e[t+1])-n(e[t]),e=(o?$.tickValues():n.ticks(s)).map((e,i,a)=>({pos:e,width:t(i,a)})).filter((t,e)=>e%2==0);M.selectAll("rect").data(e).enter().append("rect").attr("y",0).attr("height",b).attr("x",t=>n(t.pos)).attr("width",t=>t.width)}i.selectAll(".tick").filter(t=>0===t||t===x).classed("baseline",!0),i.selectAll(".domain").remove()}return p.align=(t=>t?(d=t,p):d),p.banding=(e=>void 0===e?t:(t=e,p)),p.frameName=(t=>t?(r=t,p):r),p.invert=(t=>void 0===t?m:(m=t,p)),p.scale=(t=>t?(n=t,p):n),p.divisor=(t=>t?(c=t,p):c),p.domain=(t=>(n.domain(t),p)),p.label=(t=>void 0===t?a:(a=t,p)),p.plotDim=(t=>t?(h=t,p):h),p.rem=(t=>t?(u=t,p):u),p.tickValues=(t=>t?(o=t,p):o),p.logScale=(t=>void 0===t?g:(g=t,p)),p.range=(t=>(n.range(t),p)),p.tickFormat=(t=>(f=t,n.tickFormat(t),p)),p.tickSize=(t=>void 0===t?l:(l=t,p)),p.xLabel=(t=>void 0===t?i:(i=t,p)),p.numTicks=(t=>void 0===t?s:(s=t,p)),p.xAxisHighlight=(t=>(x=t,p)),p},t.xOrdinal=function(){let t,i,a,r,o="bottom",n=e.scaleBand().domain(["Oranges","Lemons","Apples","Pears"]).rangeRound([0,220]).paddingInner(.1).paddingOuter(.05),l=10,s=[200,100],d=10,c=!1;function m(m){const g=s[0],x=s[1];if(c){const t=n.domain().reverse();n.domain(t)}const h=(u=o,{top:e.axisTop(),bottom:e.axisBottom()}[u]).tickSize(l).scale(n);var u;n.domain.length>1?n.paddingInner(.1):n.paddingInner(.2);const f=m.append("g").attr("class","highlights");if(i=m.append("g").attr("class","axis xAxis").call(h),r&&(i.selectAll(".axis.xAxis text").attr("id",`${r}xLabel`),i.selectAll(".axis.xAxis line").attr("id",`${r}xTick`)),a){const t=()=>l>0&&l<d?l+.8*d:.9*d,e=(e,i)=>({toptop:0-d,topmiddle:0,topbottom:0+d,bottomtop:x,bottommiddle:x+t(),bottombottom:x+t()+1.1*d})[e+i],i=t=>({left:g-g,middle:g/2,right:g})[t],r={tag:a.tag,hori:a.hori||"middle",vert:a.vert||"bottom",anchor:a.anchor||"middle",rotate:a.rotate||0},n=m.append("g").attr("class","axis xAxis");n.append("text").attr("y",e(o,r.vert)).attr("x",i(r.hori)).text(r.tag);const s=n.selectAll("text"),c=s.node().getBBox().width/2,h=s.node().getBBox().height/2,u=s.node().getBBox().x+c,f=s.node().getBBox().y+h;s.attr("transform",`rotate(${r.rotate}, ${u}, ${f})`).style("text-anchor",r.anchor)}if(t){const t=n.domain().map(t=>({pos:t})).filter((t,e)=>e%2==1),e=n.step()/100*(100*n.paddingInner());f.selectAll("rect").data(t).enter().append("rect").attr("y",0).attr("height",x).attr("x",t=>n(t.pos)-e/2).attr("width",n.step())}i.selectAll(".domain").remove()}return m.align=(t=>t?(o=t,m):o),m.banding=(e=>void 0===e?t:(t=e,m)),m.scale=(t=>t?(n=t,m):n),m.domain=(t=>(n.domain(t),m)),m.frameName=(t=>void 0===t?r:(r=t,m)),m.invert=(t=>void 0===t?c:(c=t,m)),m.label=(t=>void 0===t?a:(a=t,m)),m.plotDim=(t=>t?(s=t,m):s),m.rem=(t=>t?(d=t,m):d),m.rangeRound=(t=>(n.rangeRound(t),m)),m.bandwidth=(t=>void 0===t?n.bandwidth():(n.bandwidth(t),m)),m.tickSize=(t=>(l=t,m)),m.paddingInner=(t=>t?(n.paddingInner(t),m):n.paddingInner()),m.paddingOuter=(t=>t?(n.paddingOuter(t),m):n.paddingOuter()),m.xLabel=(t=>void 0===t?i:(i=t,m)),m},t.yLinear=function(){let t,i,a,r,o,n=e.scaleLinear().domain([0,1e4]).range([120,0]),l="right",s=1,d=!1,c=0,m=!1,g=5,x=[120,100],h=300,u=0,f=10,p=!1;function y(y){let v=!1;const k=n.domain()[1]-n.domain()[0],b=x[0],A=x[1];if(m){const t=e.scaleLog().domain(n.domain()).range(n.range());n=t}if(d){const t=n.range().reverse();n.range(t)}let B;k>=.5&&(B=e.format(".1f")),k<.5&&(B=e.format(".2f")),k<=.011&&(B=e.format(".3f")),k<.0011&&(B=e.format(".4f")),k<11e-5&&(B=e.format(".5f")),k<11e-6&&(B=e.format(".6f"));const $=e.format(","),w=(M=l,{left:e.axisLeft(),right:e.axisRight()}[M]).ticks(g).scale(n).tickFormat(function(t){return!1===Number.isInteger(t/s)&&(v=!0),t/s==0?$(t/s):m?$(t/s):v?B(t/s):$(t/s)});var M;o&&w.tickValues(o),p&&w.tickFormat(p);const F=y.append("g").attr("class","highlights");if(i=y.append("g").attr("class","axis yAxis").call(w),!c&&i.node().getBBox)i.selectAll(".yAxis text").each(function(){c=Math.max(this.getBBox().width,c)});else if(!c){const t=e.max(i.selectAll(".yAxis text").nodes(),t=>e.select(t).text().length);c=t*f}if(h<c?i.call(w.tickSize(h)):i.call(w.tickSize(h-c)),"right"===l&&i.selectAll("text").attr("transform",`translate(${Math.round(c)},0)`),r&&(i.selectAll(".axis.yAxis text").attr("id",`${r}yLabel`),i.selectAll(".axis.yAxis line").attr("id",`${r}yTick`)),a){const t={tag:a.tag,hori:a.hori||"left",vert:a.vert||"middle",anchor:a.anchor||"middle",rotate:a.rotate||-90},e=y.append("g").attr("class","axis xAxis"),i=t=>({top:A-A,middle:A/2,bottom:A})[t],r=()=>h>0&&h<f?h/2:0,o=(t,e)=>({leftleft:0-(c+.6*f),leftmiddle:0-c/2-r(),leftright:.7*f,rightleft:b-c,rightmiddle:b+c/2+.5*f+r(),rightright:b+f+r()})[t+e];e.append("text").attr("y",i(t.vert)).attr("x",o(l,t.hori)).text(t.tag);const n=e.selectAll("text"),s=n.node().getBBox().width/2,d=n.node().getBBox().height/2,m=n.node().getBBox().x+s,g=n.node().getBBox().y+d;n.attr("transform",`rotate(${t.rotate}, ${m}, ${g})`).style("text-anchor",t.anchor)}if(t){const t=(t,e)=>0===t?A-n(e[t]):n(e[t-1])-n(e[t]),e=(o?w.tickValues():n.ticks(g)).map((e,i,a)=>({pos:e,height:t(i,a)})).filter((t,e)=>e%2==0);F.selectAll("rect").data(e).enter().append("rect").attr("x",0).attr("width",b-c).attr("y",t=>n(t.pos)).attr("height",t=>t.height)}i.selectAll(".tick").filter(t=>0===t||t===u).classed("baseline",!0),i.selectAll(".domain").remove()}return y.align=(t=>t?(l=t,y):l),y.banding=(e=>void 0===e?t:(t=e,y)),y.frameName=(t=>t?(r=t,y):r),y.scale=(t=>t?(n=t,y):n),y.divisor=(t=>t?(s=t,y):s),y.domain=(t=>(n.domain(t),y)),y.plotDim=(t=>t?(x=t,y):x),y.range=(t=>(n.range(t),y)),y.rem=(t=>t?(f=t,y):f),y.label=(t=>void 0===t?a:(a=t,y)),y.labelWidth=(t=>t?(c=t,y):c),y.logScale=(t=>void 0===t?m:(m=t,y)),y.tickFormat=(t=>(p=t,n.tickFormat(t),y)),y.tickSize=(t=>t?(h=t,y):h),y.tickValues=(t=>t?(o=t,y):o),y.yAxisHighlight=(t=>(u=t,y)),y.numTicks=(t=>(g=t,y)),y.invert=(t=>void 0===t?d:(d=t,y)),y.yLabel=(t=>void 0===t?i:(i=t,y)),y},t.yOrdinal=function(){let t,i,a,r,o="left",n=e.scaleBand().domain(["Oranges","Lemons","Apples","Pears"]).rangeRound([0,220]).paddingInner(.1).paddingOuter(.05),l=0,s=0,d=0,c=[220,100],m=10,g=!1;function x(d){const x=c[0],h=c[1];if(g){const t=n.domain().reverse();n.domain(t)}const u=(f=o,{left:e.axisLeft(),right:e.axisRight()}[f]).tickSize(s).scale(n);var f;n.domain.length>1?n.paddingInner(.1):n.paddingInner(.2);const p=d.append("g").attr("class","highlights");if(i=d.append("g").attr("class","axis yAxis").call(u),!l&&d.node().getBBox)d.selectAll(".yAxis text").each(function(){l=Math.max(this.getBBox().width,l)});else if(!l){const t=e.max(d.selectAll(".yAxis text").nodes(),t=>e.select(t).text().length);l=t*m}if(r&&(i.selectAll(".axis.yAxis text").attr("id",`${r}yLabel`),i.selectAll(".axis.xAxis line").attr("id",`${r}yTick`)),a){const t={tag:a.tag,hori:a.hori||"left",vert:a.vert||"middle",anchor:a.anchor||"middle",rotate:a.rotate||-90},e=d.append("g").attr("class","axis xAxis"),i=t=>({top:h-h,middle:h/2,bottom:h})[t],r=()=>s>0&&s<m?s/2:0,n=(t,e)=>({leftleft:0-(l+.6*m),leftmiddle:0-l/2-r(),leftright:.7*m,rightleft:x-l,rightmiddle:x+l/2+.5*m+r(),rightright:x+m+r()})[t+e];e.append("text").attr("y",i(t.vert)).attr("x",n(o,t.hori)).text(t.tag);const c=e.selectAll("text"),g=c.node().getBBox().width/2,u=c.node().getBBox().height/2,f=c.node().getBBox().x+g,p=c.node().getBBox().y+u;c.attr("transform",`rotate(${t.rotate}, ${f}, ${p})`).style("text-anchor",t.anchor)}if(t){const t=n.domain().map(t=>({pos:t})).filter((t,e)=>e%2==0),e=n.step()/100*(100*n.paddingInner());p.selectAll("rect").data(t).enter().append("rect").attr("x",0).attr("width",x-l).attr("y",t=>n(t.pos)-e/2).attr("height",n.step())}i.selectAll(".domain").remove()}return x.align=(t=>t?(o=t,x):o),x.banding=(e=>void 0===e?t:(t=e,x)),x.scale=(t=>t?(n=t,x):n),x.domain=(t=>(n.domain(t),x)),x.frameName=(t=>void 0===t?r:(r=t,x)),x.invert=(t=>void 0===t?g:(g=t,x)),x.label=(t=>void 0===t?a:(a=t,x)),x.rangeRound=(t=>(n.rangeRound(t),x)),x.bandwidth=(t=>t?(n.bandwidth(t),x):n.bandwidth()),x.labelWidth=(t=>void 0===t?l:(l=t,x)),x.yLabel=(t=>void 0===t?i:(i=t,x)),x.paddingInner=(t=>t?(n.paddingInner(t),x):n.paddingInner()),x.paddingOuter=(t=>t?(n.paddingOuter(t),x):n.paddingOuter()),x.plotDim=(t=>t?(c=t,x):c),x.rem=(t=>t?(m=t,x):m),x.tickSize=(t=>void 0===t?s:(s=t,x)),x.offset=(t=>void 0===t?d:(d=t,x)),x},t.yDate=function(){let t;const i=new Date(1970,1,1),a=new Date(2017,6,1);let r,o,n,l,s,d,c=e.scaleTime().domain([i,a]).range([0,220]),m=!1,g="lustrum",x=0,h=!0,u=[220,100],f=10,p=5,y=10,v=!1,k="left",b=!1;function A(i){const a=u[0],v=u[1];function A(t){if(m){console.log("intraday axis");const i=c.domain(),a=c.range();return c=e.scalePoint().domain(i).range(a),{left:e.axisLeft(),right:e.axisRight()}[t]}return{left:e.axisLeft(),right:e.axisRight()}[t]}const $=A(k);if(m)$.tickSize(f).tickFormat(B(g)).scale(c),$.tickValues(c.domain().filter((t,e)=>{let i;return 0===e?t.getDay():(e>0&&(i=new Date(c.domain()[e-1])),t.getDay()!==i.getDay())}));else{$.tickSize(f).tickFormat(B(g)).scale(c);let t=c.ticks((w=g,{century:e.timeYear.every(100),jubilee:e.timeYear.every(50),decade:e.timeYear.every(10),lustrum:e.timeYear.every(5),years:e.timeYear.every(1),fiscal:e.timeYear.every(1),quarters:e.timeYear.every(1),months:e.timeMonth.every(1),weeks:e.timeWeek.every(1),days:e.timeDay.every(1),hours:e.timeHour.every(1)}[w]));const i=c.domain()[0].getDate(),a=c.domain()[0].getMonth();1!==i&&0!==a&&t.unshift(c.domain()[0]),"lustrum"!==g&&"decade"!==g&&"jubilee"!==g&&"century"!==g||t.push(e.timeYear(c.domain()[1])),s&&(t=c.domain()),$.tickValues(t)}var w;const M=A(k);m?M.tickSize(p).tickFormat("").scale(c):M.tickSize(p).ticks(function(t){return{century:e.timeYear.every(10),jubilee:e.timeYear.every(10),decade:e.timeYear.every(1),lustrum:e.timeYear.every(1),years:e.timeMonth.every(1),fiscal:e.timeMonth.every(1),quarters:e.timeMonth.every(3),months:e.timeDay.every(1),weeks:e.timeDay.every(1),days:e.timeHour.every(1),hours:e.timeMinute.every(1)}[t]}(g)).tickFormat("").scale(c),d&&$.tickValues(d),b&&$.tickFormat(b);const F=i.append("g").attr("class","highlights");if(o=i.append("g").attr("class","axis yAxis axis baseline").call($),!x&&o.node().getBBox)o.selectAll(".yAxis text").each(function(){x=Math.max(this.getBBox().width,x)});else if(!x){const t=e.max(o.selectAll(".yAxis text").nodes(),t=>e.select(t).text().length);x=t*y}if(f<x?o.call($.tickSize):o.call($.tickSize(f-x)),"right"===k?o.selectAll("text").attr("transform",`translate(${Math.round(x)},0)`).style("text-anchor","end"):o.selectAll("text").style("text-anchor","end"),h&&(l=i.append("g").attr("class",()=>e.select(".chart-plot").node().getBBox().height===f?"axis yAxis":"axis yAxis axis baseline").call(M)),r&&(o.selectAll(".axis.yAxis text").attr("id",`${r}yLabel`),o.selectAll(".axis.yAxis line").attr("id",`${r}xTick`),h&&l.selectAll(".axis.yAxis line").attr("id",`${r}xTick`)),n){const t={tag:n.tag,hori:n.hori||"left",vert:n.vert||"middle",anchor:n.anchor||"middle",rotate:n.rotate||-90},e=t=>({top:v-v,middle:v/2,bottom:v})[t],r=()=>f>0&&f<y?f/2:0,o=(t,e)=>({leftleft:0-(x+.6*y),leftmiddle:0-x/2-r(),leftright:.7*y,rightleft:a-x,rightmiddle:a+x/2+.5*y+r(),rightright:a+y+r()})[t+e];i.append("g").attr("class","axis xAxis").append("text").attr("y",e(t.vert)).attr("x",o(k,t.hori)).text(t.tag)}if(t){const t=(t,e)=>t===e.length-1?v-c(e[t]):c(e[t+1])-c(e[t]),e=$.tickValues().map((e,i,a)=>({date:e,height:t(i,a)})).filter((t,e)=>e%2==0);F.selectAll("rect").data(e).enter().append("rect").attr("x",0).attr("width",()=>"left "===k?a-x:a-x-y).attr("y",t=>c(t.date)).attr("height",t=>t.height)}o.selectAll(".domain").remove()}function B(t){const i=e.timeFormat("%Y"),a=e.timeFormat("%y"),r=e.timeFormat("%b"),o=e.timeFormat("%W"),n=e.timeFormat("%d"),l=e.timeFormat("%H:%M");return{century:e.timeFormat("%Y"),jubilee:(t,e)=>c(t,e),decade:(t,e)=>c(t,e),lustrum:(t,e)=>c(t,e),years:(t,e)=>c(t,e),fiscal:(t,e)=>(t=t,e=e,v||+i(t)%100==0||0===e?`${i(t)}/${Number(a(t))+1}`:`${a(t)}/${Number(a(t))+1}`),quarters:(t,e)=>(function(t,e){if(t.getMonth()<3&&e<4)return`Q1 ${i(t)}`;if(t.getMonth()<3)return"Q1";if(t.getMonth()>=3&&t.getMonth()<6)return"Q2";if(t.getMonth()>=6&&t.getMonth()<9)return"Q3";if(t.getMonth()>=9&&t.getMonth()<12)return"Q4";throw new Error("Invalid quarter")})(t,e),months:(t,i)=>(function(t,i){if(0===t.getMonth()||0===i){const i=e.timeFormat("%b %Y");return i(t)}return r(t)})(t,i),weeks:(t,e)=>(function(t){return t.getDate()<9?`${o(t)} ${r(t)}`:o(t)})(t),days:(t,e)=>(function(t,e){return 1===t.getDate()||0===e?`${n(t)} ${r(t)}`:n(t)})(t,e),hours:(t,e)=>(function(t,e){return 1===t.getHours()||0===e?`${l(t)} ${n(t)}`:l(t)})(t,e)}[t];var s,d;function c(t,e){return v||+i(t)%100==0||0===e?i(t):a(t)}}return A.align=(t=>(k=t,A)),A.banding=(e=>void 0===e?t:(t=e,A)),A.tickFormat=(t=>(b=t,c.tickFormat(t),A)),A.endTicks=(t=>void 0===t?s:(s=t,A)),A.frameName=(t=>void 0===t?r:(r=t,A)),A.intraday=(t=>void 0===t?m:(m=t,A)),A.label=(t=>void 0===t?n:(n=t,A)),A.labelWidth=(t=>t?(x=t,A):x),A.plotDim=(t=>t?(u=t,A):u),A.scale=(t=>t?(c=t,A):c),A.tickValues=(t=>t?(d=t,A):d),A.domain=(t=>(c.domain(t),A)),A.range=(t=>(c.range(t),A)),A.fullYear=(t=>void 0===t?v:(v=t,A)),A.interval=(t=>(g=t,A)),A.tickSize=(t=>t?(f=t,A):f),A.minorTickSize=(t=>t?(p=t,A):p),A.minorAxis=(t=>void 0===t?h:(h=t,A)),A.rem=(t=>t?(y=t,A):y),A.yLabel=(t=>void 0===t?o:(o=t,A)),A.yLabelMinor=(t=>void 0===t?l:(l=t,A)),A},Object.defineProperty(t,"__esModule",{value:!0})});