From 56a467d882545923bb4c17c933f01fee6d1da621 Mon Sep 17 00:00:00 2001 From: Daniel Quathamer Date: Fri, 13 May 2022 09:06:22 +0200 Subject: [PATCH] Obervable plot integrated, refactoring JS #3 --- superx/xml/js/d3/plot-0.4.3-license.txt | 13 + superx/xml/js/d3/plot.js | 2 + superx/xml/js/d3/viz_functions.js | 508 +++++++++++++++++------- superx/xml/viz_html_chart.xsl | 59 ++- 4 files changed, 439 insertions(+), 143 deletions(-) create mode 100644 superx/xml/js/d3/plot-0.4.3-license.txt create mode 100644 superx/xml/js/d3/plot.js diff --git a/superx/xml/js/d3/plot-0.4.3-license.txt b/superx/xml/js/d3/plot-0.4.3-license.txt new file mode 100644 index 0000000..3d39082 --- /dev/null +++ b/superx/xml/js/d3/plot-0.4.3-license.txt @@ -0,0 +1,13 @@ +Copyright 2020-2022 Observable, Inc. + +Permission to use, copy, modify, and/or distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright notice +and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. diff --git a/superx/xml/js/d3/plot.js b/superx/xml/js/d3/plot.js new file mode 100644 index 0000000..880bef6 --- /dev/null +++ b/superx/xml/js/d3/plot.js @@ -0,0 +1,2 @@ +// @observablehq/plot v0.4.3 Copyright 2020-2022 Observable, Inc. +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("d3@7.4.4/dist/d3.min.js")):"function"==typeof define&&define.amd?define(["exports","d3@7.4.4/dist/d3.min.js"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Plot=t.Plot||{},t.d3)}(this,(function(t,e){"use strict";function n(t,e){if(t instanceof Date||(t=new Date(+t)),isNaN(t))return"function"==typeof e?e(t):e;const n=t.getUTCHours(),o=t.getUTCMinutes(),i=t.getUTCSeconds(),a=t.getUTCMilliseconds();return`${s=t.getUTCFullYear(),s<0?`-${r(-s,6)}`:s>9999?`+${r(s,6)}`:r(s,4)}-${r(t.getUTCMonth()+1,2)}-${r(t.getUTCDate(),2)}${n||o||i||a?`T${r(n,2)}:${r(o,2)}${i||a?`:${r(i,2)}${a?`.${r(a,3)}`:""}`:""}Z`:""}`;var s}function r(t,e){return`${t}`.padStart(e,"0")}const o=/^(?:[-+]\d{2})?\d{4}(?:-\d{2}(?:-\d{2})?)?(?:T\d{2}:\d{2}(?::\d{2}(?:\.\d{3})?)?(?:Z|[-+]\d{2}:?\d{2})?)?$/;function i(t,e){return o.test(t+="")?new Date(t):"function"==typeof e?e(t):e}const a=Object.getPrototypeOf(Uint8Array),s=Object.prototype.toString;function l(t,e,n){const r=void 0===n?Array:n,o=typeof e;return"string"===o?r.from(t,c(e)):"function"===o?r.from(t,e):"number"===o||e instanceof Date||"boolean"===o?r.from(t,v(e)):e&&"function"==typeof e.transform?M(e.transform(t),n):M(e,n)}const c=t=>e=>e[t],u=(t,e)=>e,f={transform:t=>t},d=()=>1,h=t=>null==t?t:`${t}`,p=t=>null==t?t:+t,m=t=>null==t?t:!!t,y=t=>t?t[0]:void 0,g=t=>t?t[1]:void 0,v=t=>()=>t;function x(t){const n=+`${t}`.slice(1)/100;return(t,r)=>e.quantile(t,n,r)}function w(t,e){return void 0===t&&(t=e),null===t?[void 0,"none"]:V(t)?[void 0,t]:[t,void 0]}function b(t,e){return void 0===t&&(t=e),null===t||"number"==typeof t?[void 0,t]:[t,void 0]}function k(t,e,n){if(null!=t)return $(t,e,n)}function $(t,e,n){const r=`${t}`.toLowerCase();if(!n.includes(r))throw new Error(`invalid ${e}: ${t}`);return r}function M(t,e){return null==t?t:void 0===e?t instanceof Array||t instanceof a?t:Array.from(t):t instanceof e?t:e.from(t)}function L(t){return t?.toString===s}function A(t){return L(t)&&(void 0!==t.type||void 0!==t.domain)}function R(t){return L(t)&&"function"!=typeof t.transform}function B(t,e,n,r=f){return void 0===e&&void 0===n?(e=0,n=void 0===t?r:t):void 0===e?e=void 0===t?0:t:void 0===n&&(n=void 0===t?0:t),[e,n]}function O(t,e){return void 0===t&&void 0===e?[y,g]:[t,e]}function C({z:t,fill:e,stroke:n}={}){return void 0===t&&([t]=w(e)),void 0===t&&([t]=w(n)),t}function S(t){return Uint32Array.from(t,u)}function z(t,e){return S(t).filter((n=>e(t[n],n,t)))}function N(t,e){return Array.from(e,(e=>t[e]))}function E(t){return null!==t&&"object"==typeof t?t.valueOf():t}function T(t,e){if(void 0!==e[t])return e[t];switch(t){case"x1":case"x2":t="x";break;case"y1":case"y2":t="y"}return e[t]}function D(t){let e;return[{transform:()=>e,label:Y(t)},t=>e=t]}function W(t){return null==t?[t]:D(t)}function Y(t,e){return"string"==typeof t?t:t&&void 0!==t.label?t.label:e}function P(t,e){return{transform(n){const r=t.transform(n),o=e.transform(n);return j(r)||j(o)?Array.from(r,((t,e)=>new Date((+r[e]+ +o[e])/2))):Float64Array.from(r,((t,e)=>(+r[e]+ +o[e])/2))},label:t.label}}function q(t){return void 0===t||R(t)?t:{value:t}}function _(t){for(const e of t)if(null!=e)return"object"!=typeof e||e instanceof Date}function F(t){for(const e of t){if(null==e)continue;const t=typeof e;return"string"===t||"boolean"===t}}function j(t){for(const e of t)if(null!=e)return e instanceof Date}function I(t){for(const e of t)if(null!=e)return"string"==typeof e&&isNaN(e)&&i(e)}function G(t){for(const e of t)if(null!=e&&""!==e)return"string"==typeof e&&!isNaN(e)}function X(t,e){for(const n of t)if(null!=n)return e(n)}function U(t,e){for(const n of t)if(null!=n&&!e(n))return!1;return!0}function V(t){return"string"==typeof t&&("none"===(t=t.toLowerCase().trim())||"currentcolor"===t||t.startsWith("url(")&&t.endsWith(")")||t.startsWith("var(")&&t.endsWith(")")||null!==e.color(t))}function H(t){return null==t||Z(t)}function Z(t){return/^\s*none\s*$/i.test(t)}const Q=new Map([["asterisk",e.symbolAsterisk],["circle",e.symbolCircle],["cross",e.symbolCross],["diamond",e.symbolDiamond],["diamond2",e.symbolDiamond2],["plus",e.symbolPlus],["square",e.symbolSquare],["square2",e.symbolSquare2],["star",e.symbolStar],["times",e.symbolX],["triangle",e.symbolTriangle],["triangle2",e.symbolTriangle2],["wye",e.symbolWye]]);function J(t){return t&&"function"==typeof t.draw}function K(t){return!!J(t)||"string"==typeof t&&Q.has(t.toLowerCase())}function tt(t){if(null==t||J(t))return t;const e=Q.get(`${t}`.toLowerCase());if(e)return e;throw new Error(`invalid symbol: ${t}`)}function et(t="middle"){return $(t,"frameAnchor",["middle","top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"])}function nt(t){if(null==t)return;const n=t[0],r=t[t.length-1];return e.descending(n,r)}function rt(t){let e,n={};return(...r)=>((n.length!==r.length||n.some(((t,e)=>t!==r[e])))&&(n=r,e=t(...r)),e)}const ot=rt((t=>new Intl.NumberFormat(t))),it=rt(((t,e)=>new Intl.DateTimeFormat(t,{timeZone:"UTC",month:e}))),at=rt(((t,e)=>new Intl.DateTimeFormat(t,{timeZone:"UTC",weekday:e})));function st(t){return n(t,"Invalid Date")}const lt=function(t="en-US"){const e=function(t="en-US"){const e=ot(t);return t=>null==t||isNaN(t)?void 0:e.format(t)}(t);return t=>(t instanceof Date?st:"number"==typeof t?e:h)(t)}(),ct=Math.PI/180;function ut(t){return null!=t&&!Number.isNaN(t)}function ft(t,n){return ut(n)-ut(t)||e.ascending(t,n)}function dt(t){return null!=t&&""!=`${t}`}function ht(t){return isFinite(t)?t:NaN}function pt(t){return t>0&&isFinite(t)?t:NaN}function mt(t){return t<0&&isFinite(t)?t:NaN}let yt=0;function gt(t){console.warn(t),++yt}const vt="undefined"!=typeof window&&window.devicePixelRatio>1?0:.5;let xt=0;function wt(t,e){e&&t.text((t=>lt(e[t])))}function bt(t,e){e&&t.text((([t])=>lt(e[t])))}function kt(t,{target:e},{ariaLabel:n,title:r,fill:o,fillOpacity:i,stroke:a,strokeOpacity:s,strokeWidth:l,opacity:c,href:u}){n&&Bt(t,"aria-label",(t=>n[t])),o&&Bt(t,"fill",(t=>o[t])),i&&Bt(t,"fill-opacity",(t=>i[t])),a&&Bt(t,"stroke",(t=>a[t])),s&&Bt(t,"stroke-opacity",(t=>s[t])),l&&Bt(t,"stroke-width",(t=>l[t])),c&&Bt(t,"opacity",(t=>c[t])),u&&Rt(t,(t=>u[t]),e),function(t,e){e&&t.filter((t=>dt(e[t]))).append("title").call(wt,e)}(t,r)}function $t(t,{target:e},{ariaLabel:n,title:r,fill:o,fillOpacity:i,stroke:a,strokeOpacity:s,strokeWidth:l,opacity:c,href:u}){n&&Bt(t,"aria-label",(([t])=>n[t])),o&&Bt(t,"fill",(([t])=>o[t])),i&&Bt(t,"fill-opacity",(([t])=>i[t])),a&&Bt(t,"stroke",(([t])=>a[t])),s&&Bt(t,"stroke-opacity",(([t])=>s[t])),l&&Bt(t,"stroke-width",(([t])=>l[t])),c&&Bt(t,"opacity",(([t])=>c[t])),u&&Rt(t,(([t])=>u[t]),e),function(t,e){e&&t.filter((([t])=>dt(e[t]))).append("title").call(bt,e)}(t,r)}function*Mt(t,n,{z:r},o){const{z:i}=o,a=function({ariaLabel:t,title:e,fill:n,fillOpacity:r,stroke:o,strokeOpacity:i,strokeWidth:a,opacity:s,href:l}){return[t,e,n,r,o,i,a,s,l].filter((t=>void 0!==t))}(o),s=[...n,...a];for(const n of i?function(t,n,r){const o=e.group(t,(t=>n[t]));return void 0===r&&o.size>t.length>>1&>("Warning: the implicit z channel has high cardinality. This may occur when the fill or stroke channel is associated with quantitative data rather than ordinal or categorical data. You can suppress this warning by setting the z option explicitly; if this data represents a single series, set z to null."),o.values()}(t,i,r):[t]){let t,e;t:for(const r of n){for(const t of s)if(!ut(t[r])){e&&e.push(-1);continue t}if(void 0!==t){e.push(r);for(let n=0;nE(t[r]))),e=[r];continue t}}}else e&&(yield e),t=a.map((t=>E(t[r]))),e=[r]}e&&(yield e)}}function Lt(t,e,{width:n,height:r,marginLeft:o,marginRight:i,marginTop:a,marginBottom:s}){if(Bt(t,"aria-label",e.ariaLabel),Bt(t,"aria-description",e.ariaDescription),Bt(t,"aria-hidden",e.ariaHidden),Bt(t,"fill",e.fill),Bt(t,"fill-opacity",e.fillOpacity),Bt(t,"stroke",e.stroke),Bt(t,"stroke-width",e.strokeWidth),Bt(t,"stroke-opacity",e.strokeOpacity),Bt(t,"stroke-linejoin",e.strokeLinejoin),Bt(t,"stroke-linecap",e.strokeLinecap),Bt(t,"stroke-miterlimit",e.strokeMiterlimit),Bt(t,"stroke-dasharray",e.strokeDasharray),Bt(t,"stroke-dashoffset",e.strokeDashoffset),Bt(t,"shape-rendering",e.shapeRendering),Bt(t,"paint-order",e.paintOrder),"frame"===e.clip){const e="plot-clip-"+ ++xt;t.attr("clip-path",`url(#${e})`).append("clipPath").attr("id",e).append("rect").attr("x",o).attr("y",a).attr("width",n-i-o).attr("height",r-a-s)}}function At(t,e){!function(t,e,n){null!=n&&t.style(e,n)}(t,"mix-blend-mode",e.mixBlendMode),Bt(t,"opacity",e.opacity)}function Rt(t,n,r){t.each((function(t){const o=n(t);if(null!=o){const t=document.createElementNS(e.namespaces.svg,"a");t.setAttributeNS(e.namespaces.xlink,"href",o),null!=r&&t.setAttribute("target",r),this.parentNode.insertBefore(t,this).appendChild(this)}}))}function Bt(t,e,n){null!=n&&t.attr(e,n)}function Ot(t,e,n,r,o){e&&e.bandwidth&&(r+=e.bandwidth()/2),n&&n.bandwidth&&(o+=n.bandwidth()/2),(r||o)&&t.attr("transform",`translate(${r},${o})`)}function Ct(t,e){if((t=h(t))!==e)return t}function St(t,e){if((t=p(t))!==e)return t}const zt=/^-?([_a-z]|[\240-\377]|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])([_a-z0-9-]|[\240-\377]|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])*$/;function Nt(t){if(void 0===t)return`plot-${Math.random().toString(16).slice(2)}`;if(t=`${t}`,!zt.test(t))throw new Error(`invalid class name: ${t}`);return t}function Et(t,e){if("string"==typeof e)t.property("style",e);else if(null!=e)for(const n of t)Object.assign(n.style,e)}function Tt({frameAnchor:t},{width:e,height:n,marginTop:r,marginRight:o,marginBottom:i,marginLeft:a}){return[/left$/.test(t)?a:/right$/.test(t)?e-o:(a+e-o)/2,/^top/.test(t)?r:/^bottom/.test(t)?n-i:(r+n-i)/2]}class Dt{constructor({name:t="x",axis:e,ticks:n,tickSize:r=("fx"===t?0:6),tickPadding:o=(0===r?9:3),tickFormat:i,fontVariant:a,grid:s,label:l,labelAnchor:c,labelOffset:u,line:f,tickRotate:d,ariaLabel:y,ariaDescription:g}={}){this.name=t,this.axis=$(e,"axis",["top","bottom"]),this.ticks=Pt(n),this.tickSize=p(r),this.tickPadding=p(o),this.tickFormat=qt(i),this.fontVariant=Ct(a,"normal"),this.grid=m(s),this.label=h(l),this.labelAnchor=k(c,"labelAnchor",["center","left","right"]),this.labelOffset=p(u),this.line=m(f),this.tickRotate=p(d),this.ariaLabel=h(y),this.ariaDescription=h(g)}render(t,{[this.name]:n,fy:r},{width:o,height:i,marginTop:a,marginRight:s,marginBottom:l,marginLeft:c,offsetLeft:u=0,facetMarginTop:f,facetMarginBottom:d,labelMarginLeft:h=0,labelMarginRight:p=0}){const{axis:m,fontVariant:y,grid:g,label:v,labelAnchor:x,labelOffset:w,line:b,name:k,tickRotate:$}=this,M="top"===m?-1:1,L=M*("x"===k?0:"top"===m?a-f:l-d)+("top"===m?a:i-l);return e.create("svg:g").call(Yt,this).attr("transform",`translate(${u},${L})`).call(Ft("top"===m?e.axisTop:e.axisBottom,n,this)).call(jt,$).attr("font-size",null).attr("font-family",null).attr("font-variant",y).call(b?()=>{}:t=>t.select(".domain").remove()).call(g?r?function(t,e,n){const r=e.bandwidth(),o=e.domain();return i=>i.selectAll(".tick").append("path").attr("stroke","currentColor").attr("stroke-opacity",.1).attr("d",(t?N(o,t):o).map((t=>`M0,${e(t)+n}v${r}`)).join(""))}(t,r,-L):(A=M*(l+a-i),t=>t.selectAll(".tick line").clone(!0).attr("stroke-opacity",.1).attr("y2",A)):()=>{}).call(v?t=>t.append("text").attr("fill","currentColor").attr("transform",`translate(${"center"===x?(o+c-s)/2:"right"===x?o+p:-h},${w*M})`).attr("dy","top"===m?"1em":"-0.32em").attr("text-anchor","center"===x?"middle":"right"===x?"end":"start").text(v):()=>{}).node();var A}}class Wt{constructor({name:t="y",axis:e,ticks:n,tickSize:r=("fy"===t?0:6),tickPadding:o=(0===r?9:3),tickFormat:i,fontVariant:a,grid:s,label:l,labelAnchor:c,labelOffset:u,line:f,tickRotate:d,ariaLabel:y,ariaDescription:g}={}){this.name=t,this.axis=$(e,"axis",["left","right"]),this.ticks=Pt(n),this.tickSize=p(r),this.tickPadding=p(o),this.tickFormat=qt(i),this.fontVariant=Ct(a,"normal"),this.grid=m(s),this.label=h(l),this.labelAnchor=k(c,"labelAnchor",["center","top","bottom"]),this.labelOffset=p(u),this.line=m(f),this.tickRotate=p(d),this.ariaLabel=h(y),this.ariaDescription=h(g)}render(t,{[this.name]:n,fx:r},{width:o,height:i,marginTop:a,marginRight:s,marginBottom:l,marginLeft:c,offsetTop:u=0,facetMarginLeft:f,facetMarginRight:d}){const{axis:h,fontVariant:p,grid:m,label:y,labelAnchor:g,labelOffset:v,line:x,name:w,tickRotate:b}=this,k="left"===h?-1:1,$=k*("y"===w?0:"left"===h?c-f:s-d)+("right"===h?o-s:c);return e.create("svg:g").call(Yt,this).attr("transform",`translate(${$},${u})`).call(Ft("right"===h?e.axisRight:e.axisLeft,n,this)).call(jt,b).attr("font-size",null).attr("font-family",null).attr("font-variant",p).call(x?()=>{}:t=>t.select(".domain").remove()).call(m?r?function(t,e,n){const r=e.bandwidth(),o=e.domain();return i=>i.selectAll(".tick").append("path").attr("stroke","currentColor").attr("stroke-opacity",.1).attr("d",(t?N(o,t):o).map((t=>`M${e(t)+n},0h${r}`)).join(""))}(t,r,-$):(M=k*(c+s-o),t=>t.selectAll(".tick line").clone(!0).attr("stroke-opacity",.1).attr("x2",M)):()=>{}).call(y?t=>t.append("text").attr("fill","currentColor").attr("transform",`translate(${v*k},${"center"===g?(i+a-l)/2:"bottom"===g?i-l:a})${"center"===g?" rotate(-90)":""}`).attr("dy","center"===g?"right"===h?"-0.32em":"0.75em":"bottom"===g?"1.4em":"-1em").attr("text-anchor","center"===g?"middle":"right"===h?"end":"start").text(y):()=>{}).node();var M}}function Yt(t,{name:e,label:n,ariaLabel:r=`${e}-axis`,ariaDescription:o=n}){Bt(t,"aria-label",r),Bt(t,"aria-description",o)}function Pt(t){return null===t?[]:t}function qt(t){return null===t?()=>null:t}function _t(t,n){return void 0===t?j(n)?st:h:"function"==typeof t?t:("string"==typeof t?j(n)?e.utcFormat:e.format:v)(t)}function Ft(t,e,{ticks:n,tickSize:r,tickPadding:o,tickFormat:i}){return e.tickFormat||(i=_t(i,e.domain())),t(e).ticks(Array.isArray(n)?null:n,"function"==typeof i?null:i).tickFormat("function"==typeof i?i:null).tickSizeInner(r).tickSizeOuter(0).tickPadding(o).tickValues(Array.isArray(n)?n:null)}function jt(t,e){if(e=+e)for(const n of t.selectAll("text")){const t=+n.getAttribute("x"),r=+n.getAttribute("y");if(Math.abs(r)>Math.abs(t)){const t=Math.sign(r);n.setAttribute("transform",`translate(0, ${r+4*t*Math.cos(e*ct)}) rotate(${e})`),n.setAttribute("text-anchor",Math.abs(e)<10?"middle":e<0^t>0?"start":"end")}else{const r=Math.sign(t);n.setAttribute("transform",`translate(${t+4*r*Math.abs(Math.sin(e*ct))}, 0) rotate(${e})`),n.setAttribute("text-anchor",Math.abs(e)>60?"middle":r>0?"start":"end")}n.removeAttribute("x"),n.removeAttribute("y"),n.setAttribute("dy","0.32em")}}const It=Symbol("position"),Gt=Symbol("color"),Xt=Symbol("radius"),Ut=Symbol("length"),Vt=Symbol("opacity"),Ht=Symbol("symbol"),Zt=new Map([["x",It],["y",It],["fx",It],["fy",It],["r",Xt],["color",Gt],["opacity",Vt],["symbol",Ht],["length",Ut]]),Qt=new Map([["accent",e.schemeAccent],["category10",e.schemeCategory10],["dark2",e.schemeDark2],["paired",e.schemePaired],["pastel1",e.schemePastel1],["pastel2",e.schemePastel2],["set1",e.schemeSet1],["set2",e.schemeSet2],["set3",e.schemeSet3],["tableau10",e.schemeTableau10],["brbg",Kt(e.schemeBrBG,e.interpolateBrBG)],["prgn",Kt(e.schemePRGn,e.interpolatePRGn)],["piyg",Kt(e.schemePiYG,e.interpolatePiYG)],["puor",Kt(e.schemePuOr,e.interpolatePuOr)],["rdbu",Kt(e.schemeRdBu,e.interpolateRdBu)],["rdgy",Kt(e.schemeRdGy,e.interpolateRdGy)],["rdylbu",Kt(e.schemeRdYlBu,e.interpolateRdYlBu)],["rdylgn",Kt(e.schemeRdYlGn,e.interpolateRdYlGn)],["spectral",Kt(e.schemeSpectral,e.interpolateSpectral)],["burd",te(e.schemeRdBu,e.interpolateRdBu)],["buylrd",te(e.schemeRdYlBu,e.interpolateRdYlBu)],["blues",Jt(e.schemeBlues,e.interpolateBlues)],["greens",Jt(e.schemeGreens,e.interpolateGreens)],["greys",Jt(e.schemeGreys,e.interpolateGreys)],["oranges",Jt(e.schemeOranges,e.interpolateOranges)],["purples",Jt(e.schemePurples,e.interpolatePurples)],["reds",Jt(e.schemeReds,e.interpolateReds)],["turbo",ee(e.interpolateTurbo)],["viridis",ee(e.interpolateViridis)],["magma",ee(e.interpolateMagma)],["inferno",ee(e.interpolateInferno)],["plasma",ee(e.interpolatePlasma)],["cividis",ee(e.interpolateCividis)],["cubehelix",ee(e.interpolateCubehelixDefault)],["warm",ee(e.interpolateWarm)],["cool",ee(e.interpolateCool)],["bugn",Jt(e.schemeBuGn,e.interpolateBuGn)],["bupu",Jt(e.schemeBuPu,e.interpolateBuPu)],["gnbu",Jt(e.schemeGnBu,e.interpolateGnBu)],["orrd",Jt(e.schemeOrRd,e.interpolateOrRd)],["pubu",Jt(e.schemePuBu,e.interpolatePuBu)],["pubugn",Jt(e.schemePuBuGn,e.interpolatePuBuGn)],["purd",Jt(e.schemePuRd,e.interpolatePuRd)],["rdpu",Jt(e.schemeRdPu,e.interpolateRdPu)],["ylgn",Jt(e.schemeYlGn,e.interpolateYlGn)],["ylgnbu",Jt(e.schemeYlGnBu,e.interpolateYlGnBu)],["ylorbr",Jt(e.schemeYlOrBr,e.interpolateYlOrBr)],["ylorrd",Jt(e.schemeYlOrRd,e.interpolateYlOrRd)],["rainbow",ne(e.interpolateRainbow)],["sinebow",ne(e.interpolateSinebow)]]);function Jt(t,n){return({length:r})=>1===r?[t[3][1]]:2===r?[t[3][1],t[3][2]]:(r=Math.max(3,Math.floor(r)))>9?e.quantize(n,r):t[r]}function Kt(t,n){return({length:r})=>2===r?[t[3][0],t[3][2]]:(r=Math.max(3,Math.floor(r)))>11?e.quantize(n,r):t[r]}function te(t,n){return({length:r})=>2===r?[t[3][2],t[3][0]]:(r=Math.max(3,Math.floor(r)))>11?e.quantize((t=>n(1-t)),r):t[r].slice().reverse()}function ee(t){return({length:n})=>e.quantize(t,Math.max(2,Math.floor(n)))}function ne(t){return({length:n})=>e.quantize(t,Math.floor(n)+1).slice(0,-1)}function re(t){const e=`${t}`.toLowerCase();if(!Qt.has(e))throw new Error(`unknown scheme: ${e}`);return Qt.get(e)}function oe(t,e){const n=re(t),r="function"==typeof n?n({length:e}):n;return r.length!==e?r.slice(0,e):r}const ie=new Map([["brbg",e.interpolateBrBG],["prgn",e.interpolatePRGn],["piyg",e.interpolatePiYG],["puor",e.interpolatePuOr],["rdbu",e.interpolateRdBu],["rdgy",e.interpolateRdGy],["rdylbu",e.interpolateRdYlBu],["rdylgn",e.interpolateRdYlGn],["spectral",e.interpolateSpectral],["burd",t=>e.interpolateRdBu(1-t)],["buylrd",t=>e.interpolateRdYlBu(1-t)],["blues",e.interpolateBlues],["greens",e.interpolateGreens],["greys",e.interpolateGreys],["purples",e.interpolatePurples],["reds",e.interpolateReds],["oranges",e.interpolateOranges],["turbo",e.interpolateTurbo],["viridis",e.interpolateViridis],["magma",e.interpolateMagma],["inferno",e.interpolateInferno],["plasma",e.interpolatePlasma],["cividis",e.interpolateCividis],["cubehelix",e.interpolateCubehelixDefault],["warm",e.interpolateWarm],["cool",e.interpolateCool],["bugn",e.interpolateBuGn],["bupu",e.interpolateBuPu],["gnbu",e.interpolateGnBu],["orrd",e.interpolateOrRd],["pubugn",e.interpolatePuBuGn],["pubu",e.interpolatePuBu],["purd",e.interpolatePuRd],["rdpu",e.interpolateRdPu],["ylgnbu",e.interpolateYlGnBu],["ylgn",e.interpolateYlGn],["ylorbr",e.interpolateYlOrBr],["ylorrd",e.interpolateYlOrRd],["rainbow",e.interpolateRainbow],["sinebow",e.interpolateSinebow]]);function ae(t){const e=`${t}`.toLowerCase();if(!ie.has(e))throw new Error(`unknown scheme: ${e}`);return ie.get(e)}const se=t=>e=>t(1-e),le=[0,1],ce=new Map([["number",e.interpolateNumber],["rgb",e.interpolateRgb],["hsl",e.interpolateHsl],["hcl",e.interpolateHcl],["lab",e.interpolateLab]]);function ue(t){const e=`${t}`.toLowerCase();if(!ce.has(e))throw new Error(`unknown interpolator: ${e}`);return ce.get(e)}function fe(t,n,r,{type:o,nice:i,clamp:a,zero:s,domain:l=me(t,r),unknown:c,round:u,scheme:f,range:d=(Zt.get(t)===Xt?ge(r,l):Zt.get(t)===Ut?ve(r,l):Zt.get(t)===Vt?le:void 0),interpolate:h=(Zt.get(t)===Gt?null==f&&void 0!==d?e.interpolateRgb:ae(void 0!==f?f:"cyclical"===o?"rainbow":"turbo"):u?e.interpolateRound:e.interpolateNumber),reverse:p}){if("cyclical"!==o&&"sequential"!==o||(o="linear"),p=!!p,"function"!=typeof h&&(h=ue(h)),1===h.length?(p&&(h=se(h),p=!1),void 0===d&&2===(d=Float64Array.from(l,((t,e)=>e/(l.length-1)))).length&&(d=le),n.interpolate((d===le?v:be)(h))):n.interpolate(h),s){const[t,n]=e.extent(l);(t>0||n<0)&&(nt(l=Array.from(l))<0?l[l.length-1]=0:l[0]=0)}return p&&(l=e.reverse(l)),n.domain(l).unknown(c),i&&(n.nice(!0===i?void 0:i),l=n.domain()),void 0!==d&&n.range(d),a&&n.clamp(a),{type:o,domain:l,range:d,scale:n,interpolate:h}}function de(t,n,{exponent:r=1,...o}){return fe(t,e.scalePow().exponent(r),n,{...o,type:"pow"})}function he(t,n,{domain:r=[0],unknown:o,scheme:i="rdylbu",interpolate:a,range:s=(void 0!==a?e.quantize(a,r.length+1):Zt.get(t)===Gt?oe(i,r.length+1):void 0),reverse:l}){const c=nt(M(r));if(!e.pairs(r).every((([t,n])=>function(t,n,r){const o=e.descending(t,n);return 0===o||o===r}(t,n,c))))throw new Error(`the ${t} scale has a non-monotonic domain`);return l&&(s=e.reverse(s)),{type:"threshold",scale:e.scaleThreshold(c<0?e.reverse(r):r,void 0===s?[]:s).unknown(o),domain:r,range:s}}function pe(t,n=ht){return t.length?[e.min(t,(({value:t})=>void 0===t?t:e.min(t,n))),e.max(t,(({value:t})=>void 0===t?t:e.max(t,n)))]:[0,1]}function me(t,e){const n=Zt.get(t);return(n===Xt||n===Vt||n===Ut?ye:pe)(e)}function ye(t){return[0,t.length?e.max(t,(({value:t})=>void 0===t?t:e.max(t,ht))):1]}function ge(t,n){const r=e.quantile(t,.5,(({value:t})=>void 0===t?NaN:e.quantile(t,.25,pt))),o=n.map((t=>3*Math.sqrt(t/r))),i=30/e.max(o);return i<1?o.map((t=>t*i)):o}function ve(t,n){const r=e.median(t,(({value:t})=>void 0===t?NaN:e.median(t,Math.abs))),o=n.map((t=>12*t/r)),i=60/e.max(o);return i<1?o.map((t=>t*i)):o}function xe(t){for(const{value:e}of t)if(void 0!==e)for(let n of e){if(n=+n,n>0)return pe(t,pt);if(n<0)return pe(t,mt)}return[1,10]}function we(t){const e=[];for(const{value:n}of t)if(void 0!==n)for(const t of n)e.push(t);return e}function be(t){return(e,n)=>r=>t(e+r*(n-e))}function ke(t,n,r,o,{type:i,nice:a,clamp:s,domain:l=pe(o),unknown:c,pivot:u=0,scheme:f,range:d,symmetric:h=!0,interpolate:p=(Zt.get(t)===Gt?null==f&&void 0!==d?e.interpolateRgb:ae(void 0!==f?f:"rdbu"):e.interpolateNumber),reverse:m}){u=+u;let[y,g]=l;if(y=Math.min(y,u),g=Math.max(g,u),"function"!=typeof p&&(p=ue(p)),void 0!==d&&(p=1===p.length?be(p)(...d):e.piecewise(p,d)),m&&(p=se(p)),h){const t=r.apply(u),e=t-r.apply(y),n=r.apply(g)-t;en&&(g=r.invert(t+e))}return n.domain([y,u,g]).unknown(c).interpolator(p),s&&n.clamp(s),a&&n.nice(a),{type:i,domain:[y,g],pivot:u,interpolate:p,scale:n}}function $e(t,n,{exponent:r=1,...o}){return ke(t,e.scaleDivergingPow().exponent(r=+r),function(t){return.5===t?Re:{apply:e=>Math.sign(e)*Math.pow(Math.abs(e),t),invert:e=>Math.sign(e)*Math.pow(Math.abs(e),1/t)}}(r),n,{...o,type:"diverging-pow"})}function Me(t,n,{constant:r=1,...o}){return ke(t,e.scaleDivergingSymlog().constant(r=+r),function(t){return{apply:e=>Math.sign(e)*Math.log1p(Math.abs(e/t)),invert:e=>Math.sign(e)*Math.expm1(Math.abs(e))*t}}(r),n,o)}const Le={apply:t=>t,invert:t=>t},Ae={apply:Math.log,invert:Math.exp},Re={apply:t=>Math.sign(t)*Math.sqrt(Math.abs(t)),invert:t=>Math.sign(t)*(t*t)};function Be(t,e,n,r){return fe(t,e,n,r)}const Oe=Symbol("ordinal");function Ce(t,n,{type:r,domain:o=Ne(n),range:i,reverse:a,hint:s}){return"categorical"!==r&&r!==Oe||(r="ordinal"),a&&(o=e.reverse(o)),t.domain(o),void 0!==i&&("function"==typeof i&&(i=i(o)),t.range(i)),{type:r,domain:o,range:i,scale:t,hint:s}}function Se(t,n,{type:r,domain:o=Ne(n),range:i,scheme:a,unknown:s,...l}){let c;if(Zt.get(t)===Ht)c=function(t){const e={};for(const{hint:n}of t)for(const t of["fill","stroke"]){const r=n[t];t in e?e[t]!==r&&(e[t]=void 0):e[t]=r}return e}(n),i=void 0===i?function(t){return H(t.fill)?e.symbolsStroke:e.symbolsFill}(c):Array.from(i,tt);else if(Zt.get(t)===Gt&&(void 0!==i||"ordinal"!==r&&r!==Oe||(i=function(t,e="greys"){const n=new Set,[r,o]=oe(e,2);for(const e of t)if(null!=e)if(!0===e)n.add(o);else{if(!1!==e)return;n.add(r)}return[...n]}(o,a),void 0!==i&&(a=void 0)),void 0===a&&void 0===i&&(a="ordinal"===r?"turbo":"tableau10"),void 0!==a))if(void 0!==i){const t=ae(a),n=i[0],r=i[1]-i[0];i=({length:o})=>e.quantize((e=>t(n+r*e)),o)}else i=re(a);if(s===e.scaleImplicit)throw new Error("implicit unknown is not supported");return Ce(e.scaleOrdinal().unknown(s),n,{...l,type:r,domain:o,range:i,hint:c})}function ze(t,e,n){let{round:r}=n;return void 0!==r&&t.round(r=!!r),(t=Ce(t,e,n)).round=r,t}function Ne(t){const n=new e.InternSet;for(const{value:e,domain:r}of t){if(void 0!==r)return r();if(void 0!==e)for(const t of e)n.add(t)}return e.sort(n,ft)}function Ee(t,e){if(void 0===t.range){const{insetLeft:n,insetRight:r}=t,{width:o,marginLeft:i=0,marginRight:a=0}=e,s=i+n,l=o-a-r;t.range=[s,Math.max(s,l)],je(t)||(t.range=We(t)),t.scale.range(t.range)}De(t)}function Te(t,e){if(void 0===t.range){const{insetTop:n,insetBottom:r}=t,{height:o,marginTop:i=0,marginBottom:a=0}=e,s=i+n,l=o-a-r;t.range=[Math.max(s,l),s],je(t)?t.range.reverse():t.range=We(t),t.scale.range(t.range)}De(t)}function De(t){void 0===t.round&&function({type:t}){return"point"===t||"band"===t}(t)&&function({scale:t}){const e=t.domain().length,[n,r]=t.range(),o=t.paddingInner?t.paddingInner():1,i=t.paddingOuter?t.paddingOuter():t.padding(),a=e-o,s=Math.abs(r-n)/Math.max(1,a+2*i);return(s-Math.floor(s))*a}(t)<=30&&t.scale.round(!0)}function We(t){const e=t.scale.domain().length+function({type:t}){return"threshold"===t}(t);if(!(e>2))return t.range;const[n,r]=t.range;return Array.from({length:e},((t,o)=>n+o/(e-1)*(r-n)))}function Ye(t,e,n){return Pe(t,void 0===n?void 0:[{hint:n}],{...e})}function Pe(t,n=[],r={}){const o=function(t,e,{type:n,domain:r,range:o,scheme:i}){if("fx"===t||"fy"===t)return"band";for(const{type:t}of e)if(void 0!==t)if(void 0===n)n=t;else if(n!==t)throw new Error(`scale incompatible with channel: ${n} !== ${t}`);if(void 0!==n)return n;if(void 0===r&&!e.some((({value:t})=>void 0!==t)))return;const a=Zt.get(t);if(a===Gt&&void 0===o&&void 0===i&&Fe(r,e,V))return"identity";if(a===Ht&&void 0===o&&Fe(r,e,K))return"identity";if(a===Xt)return"sqrt";if(a===Vt||a===Ut)return"linear";if(a===Ht)return"ordinal";if((r||o||[]).length>2)return _e(a);if(void 0!==r)return F(r)?_e(a):j(r)?"utc":"linear";const s=e.map((({value:t})=>t)).filter((t=>void 0!==t));return s.some(F)?_e(a):s.some(j)?"utc":"linear"}(t,n,r);if(void 0===r.type&&void 0===r.domain&&void 0===r.range&&"fx"!==t&&"fy"!==t&&je({type:o})){const e=n.map((({value:t})=>t)).filter((t=>void 0!==t));e.some(j)?gt(`Warning: some data associated with the ${t} scale are dates. Dates are typically associated with a "utc" or "time" scale rather than a "${qe(o)}" scale. If you are using a bar mark, you probably want a rect mark with the interval option instead; if you are using a group transform, you probably want a bin transform instead. If you want to treat this data as ordinal, you can suppress this warning by setting the type of the ${t} scale to "${qe(o)}".`):e.some(I)?gt(`Warning: some data associated with the ${t} scale are strings that appear to be dates (e.g., YYYY-MM-DD). If these strings represent dates, you should parse them to Date objects. Dates are typically associated with a "utc" or "time" scale rather than a "${qe(o)}" scale. If you are using a bar mark, you probably want a rect mark with the interval option instead; if you are using a group transform, you probably want a bin transform instead. If you want to treat this data as ordinal, you can suppress this warning by setting the type of the ${t} scale to "${qe(o)}".`):e.some(G)&>(`Warning: some data associated with the ${t} scale are strings that appear to be numbers. If these strings represent numbers, you should parse or coerce them to numbers. Numbers are typically associated with a "linear" scale rather than a "${qe(o)}" scale. If you want to treat this data as ordinal, you can suppress this warning by setting the type of the ${t} scale to "${qe(o)}".`)}switch(r.type=o,o){case"diverging":case"diverging-sqrt":case"diverging-pow":case"diverging-log":case"diverging-symlog":case"cyclical":case"sequential":case"linear":case"sqrt":case"threshold":case"quantile":case"pow":case"log":case"symlog":r=Ue(n,r,He,Float64Array);break;case"identity":switch(Zt.get(t)){case It:r=Ue(n,r,He,Float64Array);break;case Ht:r=Ue(n,r,tt)}break;case"utc":case"time":r=Ue(n,r,Ze)}switch(o){case"diverging":return function(t,n,r){return ke(t,e.scaleDiverging(),Le,n,r)}(t,n,r);case"diverging-sqrt":return function(t,e,n){return $e(t,e,{...n,exponent:.5})}(t,n,r);case"diverging-pow":return $e(t,n,r);case"diverging-log":return function(t,n,{base:r=10,pivot:o=1,domain:i=pe(n,o<0?mt:pt),...a}){return ke(t,e.scaleDivergingLog().base(r=+r),Ae,n,{domain:i,pivot:o,...a})}(t,n,r);case"diverging-symlog":return Me(t,n,r);case"categorical":case"ordinal":case Oe:return Se(t,n,r);case"cyclical":case"sequential":case"linear":return function(t,n,r){return fe(t,e.scaleLinear(),n,r)}(t,n,r);case"sqrt":return function(t,e,n){return de(t,e,{...n,exponent:.5})}(t,n,r);case"threshold":return he(t,0,r);case"quantile":return function(t,n,{range:r,quantiles:o=(void 0===r?5:(r=[...r]).length),n:i=o,scheme:a="rdylbu",domain:s=we(n),interpolate:l,reverse:c}){return void 0===r&&(r=void 0!==l?e.quantize(l,i):Zt.get(t)===Gt?oe(a,i):void 0),he(t,0,{domain:e.scaleQuantile(s,void 0===r?{length:i}:r).quantiles(),range:r,reverse:c})}(t,n,r);case"quantize":return function(t,n,{range:r,n:o=(void 0===r?5:(r=[...r]).length),scheme:i="rdylbu",domain:a=me(t,n),interpolate:s,reverse:l}){const[c,u]=e.extent(a);let f;return void 0===r?(f=e.ticks(c,u,o),f[0]<=c&&f.splice(0,1),f[f.length-1]>=u&&f.pop(),o=f.length+1,r=void 0!==s?e.quantize(s,o):Zt.get(t)===Gt?oe(i,o):void 0):(f=e.quantize(e.interpolateNumber(c,u),o+1).slice(1,-1),c instanceof Date&&(f=f.map((t=>new Date(t))))),nt(M(a))<0&&f.reverse(),he(t,0,{domain:f,range:r,reverse:l})}(t,n,r);case"pow":return de(t,n,r);case"log":return function(t,n,{base:r=10,domain:o=xe(n),...i}){return fe(t,e.scaleLog().base(r),n,{...i,domain:o})}(t,n,r);case"symlog":return function(t,n,{constant:r=1,...o}){return fe(t,e.scaleSymlog().constant(r),n,o)}(t,n,r);case"utc":return function(t,n,r){return Be(t,e.scaleUtc(),n,r)}(t,n,r);case"time":return function(t,n,r){return Be(t,e.scaleTime(),n,r)}(t,n,r);case"point":return function(t,n,{align:r=.5,padding:o=.5,...i}){return ze(e.scalePoint().align(r).padding(o),n,i)}(0,n,r);case"band":return function(t,n,{align:r=.5,padding:o=.1,paddingInner:i=o,paddingOuter:a=("fx"===t||"fy"===t?0:o),...s}){return ze(e.scaleBand().align(r).paddingInner(i).paddingOuter(a),n,s)}(t,n,r);case"identity":return Zt.get(t)===It?{type:"identity",scale:e.scaleIdentity()}:{type:"identity"};case void 0:return;default:throw new Error(`unknown scale type: ${o}`)}}function qe(t){return"symbol"==typeof t?t.description:t}function _e(t){switch(t){case It:return"point";case Gt:return Oe;default:return"ordinal"}}function Fe(t,e,n){return void 0!==t?X(t,n)&&U(t,n):e.some((({value:t})=>void 0!==t&&X(t,n)))&&e.every((({value:t})=>void 0===t||U(t,n)))}function je({type:t}){return"ordinal"===t||"point"===t||"band"===t||t===Oe}function Ie({range:t,domain:e=t}){return Math.sign(nt(e))*Math.sign(nt(t))}function Ge(t,e){const n=Object.create(null);for(let[r,{value:o,scale:i}]of t)void 0!==r&&(void 0!==i&&(i=e[i],void 0!==i&&(o=Array.from(o,i))),n[r]=o);return n}function Xe(t){const e=t.domain(),n=t(e[0]);for(let r=1,o=e.length;rt,invert:t=>t};const c=t.unknown?t.unknown():void 0;return{type:e,domain:Array.from(n),...void 0!==r&&{range:Array.from(r)},...void 0!==a&&{transform:a},...s&&{percent:s},...void 0!==o&&{label:o},...void 0!==c&&{unknown:c},...void 0!==i&&{interpolate:i},...t.clamp&&{clamp:t.clamp()},...void 0!==l&&{pivot:l,symmetric:!1},...t.base&&{base:t.base()},...t.exponent&&{exponent:t.exponent()},...t.constant&&{constant:t.constant()},...t.align&&{align:t.align(),round:t.round()},...t.padding&&(t.paddingInner?{paddingInner:t.paddingInner(),paddingOuter:t.paddingOuter()}:{padding:t.padding()}),...t.bandwidth&&{bandwidth:t.bandwidth(),step:t.step()},apply:e=>t(e),...t.invert&&{invert:e=>t.invert(e)}}}function Je(t,n,r){if(void 0===n.ticks){const[o,i]=e.extent(t.scale.range());n.ticks=(i-o)/r}}function Ke(t,e,n){void 0===t.labelAnchor&&(t.labelAnchor=je(e)?"center":Ie(e)<0?"left":"right"),void 0===t.label&&(t.label=nn(n,e,t,"x")),e.label=t.label}function tn(t,e,n,r){void 0===t.labelAnchor&&(t.labelAnchor=je(n)?"center":e&&"top"===e.axis?"bottom":"top"),void 0===t.label&&(t.label=nn(r,n,t,"y")),n.label=t.label}function en(t,e,n,r){r&&(e.label=r.label),void 0===e.label&&(e.label=nn(n,e,null,t))}function nn(t=[],e,n,r){let o;for(const{label:e}of t)if(void 0!==e)if(void 0===o)o=e;else if(o!==e)return;if(void 0!==o){if(function({type:t}){return"time"===t||"utc"===t}(e)&&/^(date|time|year)$/i.test(o))return;if(!je(e)&&(e.percent&&(o=`${o} (%)`),"x"===r||"y"===r)){const t=Ie(e);t&&(o="x"===r||n&&"center"===n.labelAnchor?"x"===r==t<0?`← ${o}`:`${o} →`:`${t<0?"↑ ":"↓ "}${o}`)}}return o}function rn(t){return je(t)?void 0:"tabular-nums"}function on({filter:t,sort:e,reverse:n,transform:r,...o}={},i){return void 0===r&&(null!=t&&(r=sn(t)),null==e||R(e)||(r=an(r,cn(e))),n&&(r=an(r,ln))),{...o,...R(e)&&{sort:e},transform:an(r,i)}}function an(t,e){return null==t?null===e?void 0:e:null==e?null===t?void 0:t:(n,r)=>(({data:n,facets:r}=t(n,r)),e(M(n),r))}function sn(t){return(e,n)=>{const r=l(e,t);return{data:e,facets:n.map((t=>t.filter((t=>r[t]))))}}}function ln(t,e){return{data:t,facets:e.map((t=>t.slice().reverse()))}}function cn(t){return("function"==typeof t&&1!==t.length?un:fn)(t)}function un(t){return(e,n)=>{const r=(n,r)=>t(e[n],e[r]);return{data:e,facets:n.map((t=>t.slice().sort(r)))}}}function fn(t){return(e,n)=>{const r=l(e,t),o=(t,e)=>ft(r[t],r[e]);return{data:e,facets:n.map((t=>t.slice().sort(o)))}}}function dn(t,e){return mn(null,null,t,e)}function hn(t={y:"count"},e={}){const{x:n=f}=e;if(null==n)throw new Error("missing channel: x");return mn(n,null,t,e)}function pn(t={x:"count"},e={}){const{y:n=f}=e;if(null==n)throw new Error("missing channel: y");return mn(null,n,t,e)}function mn(t,e,{data:n=Ln,filter:r,sort:o,reverse:i,...a}={},s={}){a=gn(a,s),n=bn(n,f),o=null==o?void 0:vn("sort",o,s),r=null==r?void 0:xn("filter",r,s);const[c,u]=W(t),[d,h]=W(e),{z:p,fill:m,stroke:y,x1:g,x2:v,y1:x,y2:b,...k}=s,[$,M]=W(p),[L]=w(m),[A]=w(y),[R=m,B]=W(L),[O=y,C]=W(A);return{..."z"in s&&{z:$||p},..."fill"in s&&{fill:R||m},..."stroke"in s&&{stroke:O||y},...on(k,((s,c)=>{const f=l(s,t),d=l(s,e),m=l(s,p),y=l(s,L),g=l(s,A),v=kn(a,m,y,g),x=[],w=[],b=f&&u([]),k=d&&h([]),$=m&&M([]),R=y&&B([]),O=g&&C([]);let S=0;for(const t of a)t.initialize(s);o&&o.initialize(s),r&&r.initialize(s);for(const t of c){const e=[];for(const e of a)e.scope("facet",t);o&&o.scope("facet",t),r&&r.scope("facet",t);for(const[i,l]of wn(t,v))for(const[t,c]of wn(l,d))for(const[l,u]of wn(c,f))if(!r||r.reduce(u)){e.push(S++),w.push(n.reduce(u,s)),f&&b.push(l),d&&k.push(t),m&&$.push(v===m?i:m[u[0]]),y&&R.push(v===y?i:y[u[0]]),g&&O.push(v===g?i:g[u[0]]);for(const t of a)t.reduce(u);o&&o.reduce(u)}x.push(e)}return $n(x,o,i),{data:w,facets:x}})),...!yn(a,"x")&&(c?{x:c}:{x1:g,x2:v}),...!yn(a,"y")&&(d?{y:d}:{y1:x,y2:b}),...Object.fromEntries(a.map((({name:t,output:e})=>[t,e])))}}function yn(t,...e){for(const{name:n}of t)if(e.includes(n))return!0;return!1}function gn(t,e){const n=Object.entries(t);return null!=e.title&&void 0===t.title&&n.push(["title",Rn]),null!=e.href&&void 0===t.href&&n.push(["href",An]),n.map((([t,n])=>null==n?{name:t,initialize(){},scope(){},reduce(){}}:vn(t,n,e)))}function vn(t,e,n){const r=xn(t,e,n),[o,i]=D(r.label);let a;return{name:t,output:o,initialize(t){r.initialize(t),a=i([])},scope(t,e){r.scope(t,e)},reduce(t,e){a.push(r.reduce(t,e))}}}function xn(t,e,n){const r=T(t,n),o=bn(e,r);let i,a;return{label:Y(o===On?null:r,o.label),initialize(t){i=void 0===r?t:l(t,r),"data"===o.scope&&(a=o.reduce(S(t),i))},scope(t,e){o.scope===t&&(a=o.reduce(e,i))},reduce:(t,e)=>null==o.scope?o.reduce(t,i,e):o.reduce(t,i,a,e)}}function wn(t,n){return n?e.sort(e.group(t,(t=>n[t])),y):[[,t]]}function bn(t,n){if(t&&"function"==typeof t.reduce)return t;if("function"==typeof t)return r=t,{reduce:(t,e,n)=>r(N(e,t),n)};var r;if(/^p\d{2}$/i.test(t))return Mn(x(t));switch(`${t}`.toLowerCase()){case"first":return An;case"last":return Bn;case"count":return On;case"distinct":return Cn;case"sum":return null==n?On:Sn;case"proportion":return zn(n,"data");case"proportion-facet":return zn(n,"facet");case"deviation":return Mn(e.deviation);case"min":return Mn(e.min);case"min-index":return Mn(e.minIndex);case"max":return Mn(e.max);case"max-index":return Mn(e.maxIndex);case"mean":return Mn(e.mean);case"median":return Mn(e.median);case"variance":return Mn(e.variance);case"mode":return Mn(e.mode);case"x":return En;case"x1":return Dn;case"x2":return Wn;case"y":return Tn;case"y1":return Yn;case"y2":return Pn}throw new Error(`invalid reduce: ${t}`)}function kn(t,e,n,r){return function(...t){for(const e of t)if(void 0!==e)return e}(t.some((t=>"z"===t.name))?void 0:e,t.some((t=>"fill"===t.name))?void 0:n,t.some((t=>"stroke"===t.name))?void 0:r)}function $n(t,e,n){if(e){const n=e.output.transform(),r=(t,e)=>ft(n[t],n[e]);t.forEach((t=>t.sort(r)))}n&&t.forEach((t=>t.reverse()))}function Mn(t){return{reduce:(e,n)=>t(e,(t=>n[t]))}}const Ln={reduce:(t,e)=>N(e,t)},An={reduce:(t,e)=>e[t[0]]},Rn={reduce(t,n){const r=e.sort(e.rollup(t,(t=>t.length),(t=>n[t])),g),o=r.slice(-5).reverse();if(o.length`${t} (${e.toLocaleString("en-US")})`)).join("\n")}},Bn={reduce:(t,e)=>e[t[t.length-1]]},On={label:"Frequency",reduce:t=>t.length},Cn={label:"Distinct",reduce:(t,n)=>{const r=new e.InternSet;for(const e of t)r.add(n[e]);return r.size}},Sn=Mn(e.sum);function zn(t,n){return null==t?{scope:n,label:"Frequency",reduce:(t,e,n=1)=>t.length/n}:{scope:n,reduce:(t,n,r=1)=>e.sum(t,(t=>n[t]))/r}}function Nn(t,e){const n=(+t+ +e)/2;return t instanceof Date?new Date(n):n}const En={reduce:(t,e,{x1:n,x2:r})=>Nn(n,r)},Tn={reduce:(t,e,{y1:n,y2:r})=>Nn(n,r)},Dn={reduce:(t,e,{x1:n})=>n},Wn={reduce:(t,e,{x2:n})=>n},Yn={reduce:(t,e,{y1:n})=>n},Pn={reduce:(t,e,{y2:n})=>n};function qn(t,{scale:e,type:n,value:r,filter:o,hint:i}){return{scale:e,type:n,value:l(t,r),label:Y(r),filter:o,hint:i}}function _n(t,e,n){const r=Fn(t,e),o=Fn(t,n);return Float64Array.from(o,((t,e)=>Math.abs(t-r[e])))}function Fn(t,e,n){let r=t.find((([t])=>t===e));if(r||void 0===n||(r=t.find((([t])=>t===n))),r)return r[1].value;throw new Error(`missing channel: ${e}`)}function jn([t,n],[r,o]){return e.ascending(n,o)||e.ascending(t,r)}function In([t,n],[r,o]){return e.descending(n,o)||e.ascending(t,r)}function Gn({y:t,fy:e,fx:n}){const r=e?e.scale.domain().length:1,o=t?je(t)?t.scale.domain().length:Math.max(7,17/r):1;return!(!t&&!e)*Math.max(1,Math.min(60,o*r))*20+30*!!n+60}function Xn(t,{label:n=t.label,tickSize:r=6,width:o=240,height:i=44+r,marginTop:a=18,marginRight:s=0,marginBottom:l=16+r,marginLeft:c=0,style:u,ticks:f=(o-c-s)/64,tickFormat:d,fontVariant:h=rn(t),round:p=!0,className:m}){m=Nt(m),null===d&&(d=()=>null);const y=e.create("svg").attr("class",m).attr("font-family","system-ui, sans-serif").attr("font-size",10).attr("width",o).attr("height",i).attr("viewBox",`0 0 ${o} ${i}`).call((t=>t.append("style").text(`\n .${m} {\n display: block;\n background: white;\n height: auto;\n height: intrinsic;\n max-width: 100%;\n overflow: visible;\n }\n .${m} text {\n white-space: pre;\n }\n `))).call(Et,u);let g,v=t=>t.selectAll(".tick line").attr("y1",a+l-i);const x=p?(t,e)=>t.rangeRound(e):(t,e)=>t.range(e),{type:w,domain:b,range:k,interpolate:$,scale:M,pivot:L}=t;if($){const t=void 0===k?$:e.piecewise(1===$.length?be($):$,k);g=x(M.copy(),e.quantize(e.interpolateNumber(c,o-s),Math.min(b.length+(void 0!==L),void 0===k?1/0:k.length))),y.append("image").attr("x",c).attr("y",a).attr("width",o-c-s).attr("height",i-a-l).attr("preserveAspectRatio","none").attr("xlink:href",function(t,n=256){const r=e.create("canvas").attr("width",n).attr("height",1).node(),o=r.getContext("2d");for(let e=0;et:"string"==typeof d?e.format(d):d;g=x(e.scaleLinear().domain([-1,k.length-1]),[c,o-s]),y.append("g").selectAll().data(k).enter().append("rect").attr("x",((t,e)=>g(e-1))).attr("y",a).attr("width",((t,e)=>g(e)-g(e-1))).attr("height",i-a-l).attr("fill",(t=>t)),f=Array.from(t,((t,e)=>e)),d=e=>n(t[e],e)}else g=x(e.scaleBand().domain(b),[c,o-s]),y.append("g").selectAll().data(b).enter().append("rect").attr("x",g).attr("y",a).attr("width",Math.max(0,g.bandwidth()-1)).attr("height",i-a-l).attr("fill",M),v=()=>{};return y.append("g").attr("transform",`translate(0,${i-l})`).call(e.axisBottom(g).ticks(Array.isArray(f)?null:f,"string"==typeof d?d:void 0).tickFormat("function"==typeof d?d:void 0).tickSize(r).tickValues(Array.isArray(f)?f:null)).attr("font-size",null).attr("font-family",null).attr("font-variant",Ct(h,"normal")).call(v).call((t=>t.select(".domain").remove())).call(void 0===n?()=>{}:t=>t.append("text").attr("x",c).attr("y",a+l-i-6).attr("fill","currentColor").attr("text-anchor","start").attr("font-weight","bold").text(n)),y.node()}function Un(t,e){if(null==e)return e;const n=t(e);if(!n)throw new Error(`scale not found: ${e}`);return n}function Vn(t,{columns:n,tickFormat:r,fontVariant:o=rn(t),swatchSize:i=15,swatchWidth:a=i,swatchHeight:s=i,marginLeft:l=0,className:c,style:u,width:f}={},d,h){c=Nt(c),r=_t(r,t.domain);const p=e.create("div").attr("class",c).attr("style",`\n --swatchWidth: ${+a}px;\n --swatchHeight: ${+s}px;\n `);let m;return null!=n?(m=`\n .${c}-swatch {\n display: flex;\n align-items: center;\n break-inside: avoid;\n padding-bottom: 1px;\n }\n .${c}-swatch::before {\n flex-shrink: 0;\n }\n .${c}-label {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n `,p.style("columns",n).selectAll().data(t.domain).enter().append("div").attr("class",`${c}-swatch`).call(d,t).call((t=>t.append("div").attr("class",`${c}-label`).attr("title",r).text(r)))):(m=`\n .${c} {\n display: flex;\n align-items: center;\n min-height: 33px;\n flex-wrap: wrap;\n }\n .${c}-swatch {\n display: inline-flex;\n align-items: center;\n margin-right: 1em;\n }\n `,p.selectAll().data(t.domain).enter().append("span").attr("class",`${c}-swatch`).call(d,t).append((function(){return document.createTextNode(r.apply(this,arguments))}))),p.call((t=>t.insert("style","*").text(`\n .${c} {\n font-family: system-ui, sans-serif;\n font-size: 10px;\n margin-bottom: 0.5em;${void 0===l?"":`\n margin-left: ${+l}px;`}${void 0===f?"":`\n width: ${f}px;`}\n }\n ${h(c)}\n ${m}\n `))).style("font-variant",Ct(o,"normal")).call(Et,u).node()}const Hn=new Map([["symbol",function(t,{fill:n=(void 0!==t.hint?.fill?t.hint.fill:"none"),fillOpacity:r=1,stroke:o=(void 0!==t.hint?.stroke?t.hint.stroke:H(n)?"currentColor":"none"),strokeOpacity:i=1,strokeWidth:a=1.5,r:s=4.5,...l}={},c){const[u,f]=w(n),[d,h]=w(o),p=Un(c,u),m=Un(c,d),y=s*s*Math.PI;return r=b(r)[1],i=b(i)[1],a=b(a)[1],Vn(t,l,(n=>n.append("svg").attr("viewBox","-8 -8 16 16").attr("fill","color"===u?t=>p.scale(t):null).attr("stroke","color"===d?t=>m.scale(t):null).append("path").attr("d",(n=>{const r=e.path();return t.scale(n).draw(r,y),r}))),(t=>`.${t}-swatch > svg {\n width: var(--swatchWidth);\n height: var(--swatchHeight);\n margin-right: 0.5em;\n overflow: visible;\n fill: ${f};\n fill-opacity: ${r};\n stroke: ${h};\n stroke-width: ${a}px;\n stroke-opacity: ${i};\n }`))}],["color",Qn],["opacity",function({type:t,interpolate:n,...r},{legend:o=!0,color:i=e.rgb(0,0,0),...a}){if(!n)throw new Error(`${t} opacity scales are not supported`);!0===o&&(o="ramp");if("ramp"!==`${o}`.toLowerCase())throw new Error(`${o} opacity legends are not supported`);return Qn({type:t,...r,interpolate:Jn(i)},{legend:o,...a})}]]);function Zn({label:t,ticks:e,tickFormat:n}={},r={}){return{label:t,ticks:e,tickFormat:n,...r}}function Qn(t,{legend:e=!0,...n}){if(!0===e&&(e="ordinal"===t.type?"swatches":"ramp"),void 0!==t.domain)switch(`${e}`.toLowerCase()){case"swatches":return function(t,e){return Vn(t,e,(e=>e.style("--color",t.scale)),(t=>`.${t}-swatch::before {\n content: "";\n width: var(--swatchWidth);\n height: var(--swatchHeight);\n margin-right: 0.5em;\n background: var(--color);\n }`))}(t,n);case"ramp":return Xn(t,n);default:throw new Error(`unknown legend type: ${e}`)}}function Jn(t){const{r:n,g:r,b:o}=e.rgb(t)||e.rgb(0,0,0);return t=>`rgba(${n},${r},${o},${t})`}function Kn(t={}){const{facet:n,style:r,caption:o,ariaLabel:i,ariaDescription:a}=t,s=Nt(t.className),l=void 0===t.marks?[]:t.marks.flat(1/0).map(nr),c=new Map,u=new Map;let f,d,h,p,m;if(void 0!==n){const{x:t,y:e}=n;if(null!=t||null!=e){const r=M(n.data);if(h=[],null!=t){const e=qn(r,{value:t,scale:"fx"});h.push(["fx",e]),u.set("fx",[e])}if(null!=e){const t=qn(r,{value:e,scale:"fy"});h.push(["fy",t]),u.set("fy",[t])}d=S(r),y=d,f=((v=h).length>1?ar:ir)(y,...v),p=Array.from(f,g)}}var y,v;for(const t of l){if(c.has(t))throw new Error("duplicate mark; each mark must be unique");const r=void 0===f?void 0:"auto"===t.facet?t.data===n.data?p:void 0:"include"===t.facet?p:"exclude"===t.facet?m||(m=p.map((t=>Uint32Array.from(e.difference(d,t))))):void 0,{index:o,channels:i}=t.initialize(r,h);for(const[,t]of i){const{scale:e}=t;if(void 0!==e){const n=u.get(e);void 0!==n?n.push(t):u.set(e,[t])}}c.set(t,{index:o,channels:i,faceted:void 0!==r})}for(const[e,n]of u){const{percent:r,transform:o=(r?t=>100*t:void 0)}=t[e]||{};if(null!=o)for(const t of n)t.value=Array.from(t.value,o)}const x=function(t,{inset:e=0,insetTop:n=e,insetRight:r=e,insetBottom:o=e,insetLeft:i=e,round:a,nice:s,clamp:l,align:c,padding:u,...f}={}){const d={};for(const e of Zt.keys()){const h=t.get(e),p=f[e];if(h||p){const t=Pe(e,h,{round:Zt.get(e)===It?a:void 0,nice:s,clamp:l,align:c,padding:u,...p});if(t){let{percent:a,transform:s,inset:l,insetTop:c=(void 0!==l?l:"y"===e?n:0),insetRight:u=(void 0!==l?l:"x"===e?r:0),insetBottom:f=(void 0!==l?l:"y"===e?o:0),insetLeft:h=(void 0!==l?l:"x"===e?i:0)}=p||{};if(null==s)s=void 0;else if("function"!=typeof s)throw new Error("invalid scale transform; not a function");t.percent=!!a,t.transform=s,"x"===e||"fx"===e?(t.insetLeft=+h,t.insetRight=+u):"y"!==e&&"fy"!==e||(t.insetTop=+c,t.insetBottom=+f),d[e]=t}}}return d}(u,t),w=function(t){return Object.fromEntries(Object.entries(t).map((([t,{scale:e}])=>[t,e])))}(x),b=function({x:t,y:e,fx:n,fy:r},{x:o={},y:i={},fx:a={},fy:s={},axis:l=!0,grid:c,line:u,label:f,facet:{axis:d=l,grid:h,label:p=f}={}}={}){let{axis:m=l}=o,{axis:y=l}=i,{axis:g=d}=a,{axis:v=d}=s;return t?!0===m&&(m="bottom"):m=null,e?!0===y&&(y="left"):y=null,n?!0===g&&(g="bottom"===m?"top":"bottom"):g=null,r?!0===v&&(v="left"===y?"right":"left"):v=null,{...m&&{x:new Dt({grid:c,line:u,label:f,fontVariant:rn(t),...o,axis:m})},...y&&{y:new Wt({grid:c,line:u,label:f,fontVariant:rn(e),...i,axis:y})},...g&&{fx:new Dt({name:"fx",grid:h,label:p,...a,axis:g})},...v&&{fy:new Wt({name:"fy",grid:h,label:p,...s,axis:v})}}}(x,t),k=function(t,{x:{axis:e}={},y:{axis:n}={},fx:{axis:r}={},fy:{axis:o}={}},{width:i=640,height:a=Gn(t),facet:{margin:s,marginTop:l=(void 0!==s?s:"top"===r?30:0),marginRight:c=(void 0!==s?s:"right"===o?40:0),marginBottom:u=(void 0!==s?s:"bottom"===r?30:0),marginLeft:f=(void 0!==s?s:"left"===o?40:0)}={},margin:d,marginTop:h=(void 0!==d?d:Math.max(("top"===e?30:0)+l,n||o?20:.5-vt)),marginRight:p=(void 0!==d?d:Math.max(("right"===n?40:0)+c,e||r?20:.5+vt)),marginBottom:m=(void 0!==d?d:Math.max(("bottom"===e?30:0)+u,n||o?20:.5+vt)),marginLeft:y=(void 0!==d?d:Math.max(("left"===n?40:0)+f,e||r?20:.5-vt))}={}){return{width:i,height:a,marginTop:h,marginRight:p,marginBottom:m,marginLeft:y,facetMarginTop:l,facetMarginRight:c,facetMarginBottom:u,facetMarginLeft:f}}(x,b,t);!function({x:t,y:e,fx:n,fy:r},o){n&&Ee(n,o),r&&Te(r,o),t&&Ee(t,n?{width:n.scale.bandwidth()}:o),e&&Te(e,r?{height:r.scale.bandwidth()}:o)}(x,k),function(t,e,{x:n,y:r,fx:o,fy:i},a,s){if(o&&(Ke(o,e.fx,t.get("fx")),void 0===o.labelOffset)){const{facetMarginTop:t,facetMarginBottom:e}=a;o.labelOffset="top"===o.axis?t:e}if(i&&(tn(i,o,e.fy,t.get("fy")),void 0===i.labelOffset)){const{facetMarginLeft:t,facetMarginRight:e}=a;i.labelOffset="left"===i.axis?t:e}if(n&&(Ke(n,e.x,t.get("x")),void 0===n.labelOffset)){const{marginTop:t,marginBottom:e,facetMarginTop:r,facetMarginBottom:o}=a;n.labelOffset="top"===n.axis?t-r:e-o}if(r&&(tn(r,n,e.y,t.get("y")),void 0===r.labelOffset)){const{marginRight:t,marginLeft:e,facetMarginLeft:n,facetMarginRight:o}=a;r.labelOffset="left"===r.axis?e-n:t-o}for(const[n,r]of Zt)r!==It&&e[n]&&en(n,e[n],t.get(n),s[n])}(u,x,b,k,t),function({x:t,y:e,fx:n,fy:r},{x:o,y:i,fx:a,fy:s}){a&&Je(n,a,80),s&&Je(r,s,35),o&&Je(t,o,80),i&&Je(e,i,35)}(x,b);for(const t of c.values())t.values=Ge(t.channels,w);const{width:$,height:L}=k,A=e.create("svg").attr("class",s).attr("fill","currentColor").attr("font-family","system-ui, sans-serif").attr("font-size",10).attr("text-anchor","middle").attr("width",$).attr("height",L).attr("viewBox",`0 0 ${$} ${L}`).attr("aria-label",i).attr("aria-description",a).call((t=>t.append("style").text(`\n .${s} {\n display: block;\n background: white;\n height: auto;\n height: intrinsic;\n max-width: 100%;\n }\n .${s} text,\n .${s} tspan {\n white-space: pre;\n }\n `))).call(Et,r).node(),{fx:R,fy:B}=w,O=b[void 0!==f&&B?"fy":"y"],C=b[void 0!==f&&R?"fx":"x"];if(O&&A.appendChild(O.render(null,w,k)),C&&A.appendChild(C.render(null,w,k)),void 0!==f){const t=B&&B.domain(),n=R&&R.domain(),r=B&&{marginTop:0,marginBottom:0,height:B.bandwidth()},o=R&&{marginRight:0,marginLeft:0,width:R.bandwidth()},i={...k,...o,...r},a=function(t){return new(t.length>1?lr:sr)}(h);f.forEach((([t],e)=>a.set(t,e)));const s=e.select(A);if(B&&b.y){const e=b.y,o=or(e),i="bottom"===e.labelAnchor?t.length-1:"center"===e.labelAnchor?t.length>>1:0;s.selectAll().data(t).enter().append(((t,s)=>(s===i?e:o).render(R&&z(n,(e=>a.has([e,t]))),w,{...k,...r,offsetTop:B(t)})))}if(R&&b.x){const e=b.x,r=or(e),i="right"===e.labelAnchor?n.length-1:"center"===e.labelAnchor?n.length>>1:0,{marginLeft:l,marginRight:c}=k;s.selectAll().data(n).enter().append(((n,s)=>(s===i?e:r).render(B&&z(t,(t=>a.has([n,t]))),w,{...k,...o,labelMarginLeft:l,labelMarginRight:c,offsetLeft:R(n)})))}s.selectAll().data(function({fx:t,fy:n}){return t&&n?e.cross(t.domain(),n.domain()):t?t.domain():n.domain()}(w).filter(a.has,a)).enter().append("g").attr("aria-label","facet").attr("transform",function(t,e){return t&&e?([n,r])=>`translate(${t(n)},${e(r)})`:t?e=>`translate(${t(e)},0)`:t=>`translate(0,${e(t)})`}(R,B)).each((function(t){const e=a.get(t);for(const[t,{channels:n,values:r,index:o,faceted:a}]of c){const s=t.filter(a?o[e]:o,n,r),l=t.render(s,w,r,i);null!=l&&this.appendChild(l)}}))}else for(const[t,{channels:e,values:n,index:r}]of c){const o=t.filter(r,e,n),i=t.render(o,w,n,k);null!=i&&A.appendChild(i)}let N=A;const E=function(t,e){const n=[];for(const[r,o]of Hn){const i=e[r];if(i?.legend&&r in t){const e=o(t[r],Zn(t[r],i),(e=>t[e]));null!=e&&n.push(e)}}return n}(x,t);if((null!=o||E.length>0)&&(N=document.createElement("figure"),N.style.maxWidth="initial",N.append(...E,A),null!=o)){const t=document.createElement("figcaption");t.append(o),N.append(t)}N.scale=function(t){return e=>{if(!Zt.has(e=`${e}`))throw new Error(`unknown scale: ${e}`);return e in t?Qe(t[e]):void 0}}(x),N.legend=function(t,e={}){return(n,r)=>{if(!Hn.has(n))throw new Error(`unknown legend type: ${n}`);if(n in t)return Hn.get(n)(t[n],Zn(e[n],r),(e=>t[e]))}}(x,t);const T=function(){const t=yt;return yt=0,t}();return T>0&&e.select(A).append("text").attr("x",$).attr("y",20).attr("dy","-1em").attr("text-anchor","end").attr("font-family","initial").text("⚠️").append("title").text(`${T.toLocaleString("en-US")} warning${1===T?"":"s"}. Please check the console.`),N}class tr{constructor(t,e=[],n={},r){const{facet:o="auto",sort:i,dx:a,dy:s,clip:l}=n,c=new Set;this.data=t,this.sort=R(i)?i:null,this.facet=null==o||!1===o?null:$(!0===o?"include":o,"facet",["auto","include","exclude"]);const{transform:u}=on(n);this.transform=u,void 0!==r&&(e=function(t,{title:e,href:n,ariaLabel:r,ariaDescription:o,ariaHidden:i,target:a,fill:s,fillOpacity:l,stroke:c,strokeWidth:u,strokeOpacity:f,strokeLinejoin:d,strokeLinecap:p,strokeMiterlimit:m,strokeDasharray:y,strokeDashoffset:g,opacity:v,mixBlendMode:x,paintOrder:k,shapeRendering:$},M,{ariaLabel:L,fill:A="currentColor",fillOpacity:R,stroke:B="none",strokeOpacity:O,strokeWidth:C,strokeLinecap:S,strokeLinejoin:z,strokeMiterlimit:N,paintOrder:E}){null===A&&(s=null,l=null),null===B&&(c=null,f=null),H(A)?H(B)||H(s)||(B="none"):H(B)&&!H(c)&&(A="none");const[T,D]=w(s,A),[W,Y]=b(l,R),[P,q]=w(c,B),[_,F]=b(f,O),[j,I]=b(v);Z(q)||(void 0===u&&(u=C),void 0===p&&(p=S),void 0===d&&(d=z),void 0!==m||/^\s*round\s*$/i.test(d)||(m=N),Z(D)||void 0!==k||(k=E));const[G,X]=b(u);return null!==A&&(t.fill=Ct(D,"currentColor"),t.fillOpacity=St(Y,1)),null!==B&&(t.stroke=Ct(q,"none"),t.strokeWidth=St(X,1),t.strokeOpacity=St(F,1),t.strokeLinejoin=Ct(d,"miter"),t.strokeLinecap=Ct(p,"butt"),t.strokeMiterlimit=St(m,4),t.strokeDasharray=Ct(y,"none"),t.strokeDashoffset=Ct(g,"0")),t.target=h(a),t.ariaLabel=h(L),t.ariaDescription=h(o),t.ariaHidden=h(i),t.opacity=St(I,1),t.mixBlendMode=Ct(x,"normal"),t.paintOrder=Ct(k,"normal"),t.shapeRendering=Ct($,"auto"),[...M,{name:"title",value:e,optional:!0},{name:"href",value:n,optional:!0},{name:"ariaLabel",value:r,optional:!0},{name:"fill",value:T,scale:"color",optional:!0},{name:"fillOpacity",value:W,scale:"opacity",optional:!0},{name:"stroke",value:P,scale:"color",optional:!0},{name:"strokeOpacity",value:_,scale:"opacity",optional:!0},{name:"strokeWidth",value:G,optional:!0},{name:"opacity",value:j,scale:"opacity",optional:!0}]}(this,n,e,r)),this.channels=e.filter((t=>{const{name:e,value:n,optional:r}=t;if(null==n){if(r)return!1;throw new Error(`missing channel value: ${e}`)}if(null==e)throw new Error("missing channel name");const o=`${e}`;if("__proto__"===o)throw new Error(`illegal channel name: ${o}`);if(c.has(o))throw new Error(`duplicate channel: ${o}`);return c.add(o),!0})),this.dx=+a||0,this.dy=+s||0,this.clip=function(t){if(!0===t)return"frame";if(null==t||!1===t)return!1;throw new Error(`invalid clip method: ${t}`)}(l)}initialize(t,n){let r=M(this.data),o=void 0===t&&null!=r?S(r):t;void 0!==r&&void 0!==this.transform&&(void 0===t&&(o=o.length?[o]:[]),({facets:o,data:r}=this.transform(r,o)),r=M(r),void 0===t&&o.length&&([o]=o));const i=this.channels.map((t=>{const{name:e}=t;return[null==e?void 0:`${e}`,qn(r,t)]}));return null!=this.sort&&function(t,n,r,o){const{reverse:i,reduce:a=!0,limit:s}=o;for(const l in o){if(!Zt.has(l))continue;let{value:c,reverse:u=i,reduce:f=a,limit:d=s}=q(o[l]);if(void 0===u&&(u="width"===c||"height"===c),null==f||!1===f)continue;const h=t.find((([,{scale:t}])=>t===l))||n&&n.find((([,{scale:t}])=>t===l));if(!h)throw new Error(`missing channel for scale: ${l}`);const p=h[1].value,[m=0,g=1/0]=d&&"function"==typeof d[Symbol.iterator]?d:d<0?[d]:[0,d];if(null==c)h[1].domain=()=>{let t=p;return u&&(t=t.slice().reverse()),0===m&&g===1/0||(t=t.slice(m,g)),t};else{const n="data"===c?r:"height"===c?_n(t,"y1","y2"):"width"===c?_n(t,"x1","x2"):Fn(t,c,"y"===c?"y2":"x"===c?"x2":void 0),o=bn(!0===f?"max":f,n);h[1].domain=()=>{let t=e.rollup(S(p),(t=>o.reduce(t,n)),(t=>p[t]));return t=e.sort(t,u?In:jn),0===m&&g===1/0||(t=t.slice(m,g)),t.map(y)}}}}(i,n,r,this.sort),{index:o,channels:i}}filter(t,e,n){for(const[r,{filter:o=ut}]of e)if(void 0!==r&&null!==o){const e=n[r];t=t.filter((t=>o(e[t])))}return t}plot({marks:t=[],...e}={}){return Kn({...e,marks:[...t,this]})}}function er(...t){return t.plot=tr.prototype.plot,t}function nr(t){return t instanceof tr?t:new rr(t)}class rr extends tr{constructor(t){if(super(),null!=t){if("function"!=typeof t)throw new TypeError("invalid mark; missing render function");this.render=t}}render(){}}function or(t){return void 0===t||void 0===t.label?t:Object.assign(Object.create(t),{label:void 0})}function ir(t,[,{value:n}]){return e.groups(t,(t=>n[t]))}function ar(t,[,{value:n}],[,{value:r}]){return e.groups(t,(t=>n[t]),(t=>r[t])).flatMap((([t,e])=>e.map((([e,n])=>[[t,e],n]))))}class sr{constructor(){this._=new e.InternMap}has(t){return this._.has(t)}get(t){return this._.get(t)}set(t,e){return this._.set(t,e),this}}class lr extends sr{has([t,e]){const n=super.get(t);return!!n&&n.has(e)}get([t,e]){const n=super.get(t);return n&&n.get(e)}set([t,n],r){const o=super.get(t);return o?o.set(n,r):super.set(t,new e.InternMap([[n,r]])),this}}const cr=new Map([["basis",e.curveBasis],["basis-closed",e.curveBasisClosed],["basis-open",e.curveBasisOpen],["bundle",e.curveBundle],["bump-x",e.curveBumpX],["bump-y",e.curveBumpY],["cardinal",e.curveCardinal],["cardinal-closed",e.curveCardinalClosed],["cardinal-open",e.curveCardinalOpen],["catmull-rom",e.curveCatmullRom],["catmull-rom-closed",e.curveCatmullRomClosed],["catmull-rom-open",e.curveCatmullRomOpen],["linear",e.curveLinear],["linear-closed",e.curveLinearClosed],["monotone-x",e.curveMonotoneX],["monotone-y",e.curveMonotoneY],["natural",e.curveNatural],["step",e.curveStep],["step-after",e.curveStepAfter],["step-before",e.curveStepBefore]]);function ur(t=e.curveLinear,n){if("function"==typeof t)return t;const r=cr.get(`${t}`.toLowerCase());if(!r)throw new Error(`unknown curve: ${t}`);if(void 0!==n)switch(r){case e.curveBundle:return r.beta(n);case e.curveCardinalClosed:case e.curveCardinalOpen:case e.curveCardinal:return r.tension(n);case e.curveCatmullRomClosed:case e.curveCatmullRomOpen:case e.curveCatmullRom:return r.alpha(n)}return r}function fr({inset:t,insetLeft:e,insetRight:n,...r}={}){return[e,n]=hr(t,e,n),{inset:t,insetLeft:e,insetRight:n,...r}}function dr({inset:t,insetTop:e,insetBottom:n,...r}={}){return[e,n]=hr(t,e,n),{inset:t,insetTop:e,insetBottom:n,...r}}function hr(t,e,n){return void 0===t&&void 0===e&&void 0===n?vt?[1,0]:[.5,.5]:[e,n]}function pr(t){if(null!=t){if("number"==typeof t){const n=t;return{floor:t=>n*Math.floor(t/n),offset:t=>t+n,range:(t,r)=>e.range(Math.ceil(t/n),r/n).map((t=>n*t))}}if("function"!=typeof t.floor||"function"!=typeof t.offset)throw new Error("invalid interval; missing floor or offset function");return t}}function mr(t,e,n,r){const{[t]:o,[`${t}1`]:i,[`${t}2`]:a}=n,{value:s,interval:c}=function(t,{interval:e}){return(t={...q(t)}).interval=pr(void 0===t.interval?e:t.interval),t}(o,n);if(null==s||null==c&&!r)return n;const u=Y(o);if(null==c){let e;const r={transform:t=>e||(e=l(t,s)),label:u};return{...n,[t]:void 0,[`${t}1`]:void 0===i?r:i,[`${t}2`]:void 0===a?r:a}}let f;const d=t=>f||(f=l(t,s).map((t=>c.floor(t))));return e({...n,[t]:void 0,[`${t}1`]:void 0===i?{transform:d,label:u}:i,[`${t}2`]:void 0===a?{transform:t=>d(t).map((t=>c.offset(t))),label:u}:a})}function yr(t={}){return mr("x",fr,t,!0)}function gr(t={}){return mr("y",dr,t,!0)}function vr(t={}){return mr("x",fr,t)}function xr(t={}){return mr("y",dr,t)}function wr(t={y:"count"},e={}){[t,e]=Ar(t,e);const{x:n,y:r}=e;return Lr(Rr(n,e,f),null,null,r,t,fr(e))}function br(t={x:"count"},e={}){[t,e]=Ar(t,e);const{x:n,y:r}=e;return Lr(null,Rr(r,e,f),n,null,t,dr(e))}function kr(t,e,n){return null==n?.interval?n:t({[e]:void 0===n?.reduce?An:n.reduce,filter:null},n)}function $r(t){return kr(wr,"y",t)}function Mr(t){return kr(br,"x",t)}function Lr(t,e,n,r,{data:o=Ln,filter:i=On,sort:a,reverse:s,...c}={},u={}){t=Br(t),e=Br(e),c=gn(c,u),o=bn(o,f),a=null==a?void 0:vn("sort",a,u),i=null==i?void 0:xn("filter",i,u),null!=n&&yn(c,"x","x1","x2")&&(n=null),null!=r&&yn(c,"y","y1","y2")&&(r=null);const[d,h]=W(t),[p,m]=W(t),[y,g]=W(e),[v,x]=W(e),[b,k]=null!=n?[n,"x"]:null!=r?[r,"y"]:[],[$,M]=W(b),{x:L,y:A,z:R,fill:B,stroke:O,x1:C,x2:S,y1:z,y2:N,domain:E,cumulative:T,thresholds:D,interval:Y,...q}=u,[_,F]=W(R),[j]=w(B),[I]=w(O),[G=B,X]=W(j),[U=O,V]=W(I);return{..."z"in u&&{z:_||R},..."fill"in u&&{fill:G||B},..."stroke"in u&&{stroke:U||O},...on(q,((n,r)=>{const u=l(n,b),f=l(n,R),d=l(n,j),p=l(n,I),y=kn(c,f,d,p),v=[],w=[],k=u&&M([]),$=f&&F([]),L=d&&X([]),A=p&&V([]),B=t?t(n):[[,,t=>t]],O=e?e(n):[[,,t=>t]],C=t&&h([]),S=t&&m([]),z=e&&g([]),N=e&&x([]);let E=0;for(const t of c)t.initialize(n);a&&a.initialize(n),i&&i.initialize(n);for(const t of r){const e=[];for(const e of c)e.scope("facet",t);a&&a.scope("facet",t),i&&i.scope("facet",t);for(const[r,s]of wn(t,y))for(const[t,l]of wn(s,u))for(const[s,h,m]of B){const g=m(l);for(const[l,m,v]of O){const x={x1:s,x2:h,y1:l,y2:m},b=v(g);if(!i||i.reduce(b,x)){e.push(E++),w.push(o.reduce(b,n,x)),u&&k.push(t),f&&$.push(y===f?r:f[b[0]]),d&&L.push(y===d?r:d[b[0]]),p&&A.push(y===p?r:p[b[0]]),C&&(C.push(s),S.push(h)),z&&(z.push(l),N.push(m));for(const t of c)t.reduce(b,x);a&&a.reduce(b)}}}v.push(e)}return $n(v,a,s),{data:w,facets:v}})),...!yn(c,"x")&&(d?{x1:d,x2:p,x:P(d,p)}:{x:L,x1:C,x2:S}),...!yn(c,"y")&&(y?{y1:y,y2:v,y:P(y,v)}:{y:A,y1:z,y2:N}),...$&&{[k]:$},...Object.fromEntries(c.map((({name:t,output:e})=>[t,e])))}}function Ar({cumulative:t,domain:e,thresholds:n,interval:r,...o},i){return[o,{cumulative:t,domain:e,thresholds:n,interval:r,...i}]}function Rr(t,{cumulative:n,domain:r,thresholds:o,interval:i},a){return void 0===(t={...q(t)}).domain&&(t.domain=r),void 0===t.cumulative&&(t.cumulative=n),void 0===t.thresholds&&(t.thresholds=o),void 0===t.interval&&(t.interval=i),void 0===t.value&&(t.value=a),t.thresholds=function(t,n){if(void 0===t)return void 0===n?Or:function(t){if(!Cr(t=pr(t)))throw new Error(`invalid interval: ${t}`);return t}(n);if("string"==typeof t){switch(t.toLowerCase()){case"freedman-diaconis":return e.thresholdFreedmanDiaconis;case"scott":return e.thresholdScott;case"sturges":return e.thresholdSturges;case"auto":return Or}throw new Error(`invalid thresholds: ${t}`)}return t}(t.thresholds,t.interval),t}function Br(t){if(null==t)return;const{value:n,cumulative:r,domain:o=e.extent,thresholds:i}=t,a=t=>{let a=l(t,n,Array);const s=e.bin().value((t=>a[t]));if(j(a)||(function(t){return Cr(t)&&"function"==typeof t&&t()instanceof Date}(c=i)||c&&c[Symbol.iterator]&&j(c))){a=a.map(Ze);let[t,n]="function"==typeof o?o(a):o,r="function"!=typeof i||Cr(i)?i:i(a,t,n);"number"==typeof r&&(r=e.utcTickInterval(t,n,r)),Cr(r)&&(o===e.extent&&(t=r.floor(t),n=r.ceil(new Date(+n+1))),r=r.range(t,n)),s.thresholds(r).domain([t,n])}else{a=a.map(He);let t=o,n=i;if(Cr(n)){let[r,o]="function"==typeof t?t(a):t;t===e.extent&&(r=n.floor(r),o=n.offset(n.floor(o)),t=[r,o]),n=n.range(r,o)}s.thresholds(n).domain(t)}var c;let u=s(S(t)).map(Sr);return r&&(u=(r<0?u.reverse():u).map(zr)),u.map(Nr)};return a.label=Y(n),a}function Or(t,n,r){return Math.min(200,e.thresholdScott(t,n,r))}function Cr(t){return!!t&&"function"==typeof t.range}function Sr(t){return[t,new Set(t)]}function zr([t],e,n){return[t,{get size(){for(let t=0;t<=e;++t)if(n[t][1].size)return 1;return 0},has(t){for(let r=0;r<=e;++r)if(n[r][1].has(t))return!0;return!1}}]}function Nr([{x0:t,x1:e},n]){return[t,e,n.size?t=>t.filter(n.has,n):Er]}function Er(){return new Uint32Array(0)}function Tr(t={}){const{x:e,x1:n,x2:r}=t;return void 0===n&&void 0===r&&void 0===e?{...t,x:f}:t}function Dr(t={}){const{y:e,y1:n,y2:r}=t;return void 0===n&&void 0===r&&void 0===e?{...t,y:f}:t}function Wr(t={},e={}){1===arguments.length&&([t,e]=_r(t));const{y1:n,y:r=n,x:o,...i}=e,[a,s,l,c]=Fr(r,o,"x",t,i);return{...a,y1:n,y:s,x1:l,x2:c,x:P(l,c)}}function Yr(t={},e={}){1===arguments.length&&([t,e]=_r(t));const{x1:n,x:r=n,y:o,...i}=e,[a,s,l,c]=Fr(r,o,"y",t,i);return{...a,x1:n,x:s,y1:l,y2:c,y:P(l,c)}}function Pr({x:t,x1:e,x2:n,...r}={}){return void 0===e&&void 0===n?Wr({x:t,...r}):([e,n]=B(t,e,n),{...r,x1:e,x2:n})}function qr({y:t,y1:e,y2:n,...r}={}){return void 0===e&&void 0===n?Yr({y:t,...r}):([e,n]=B(t,e,n),{...r,y1:e,y2:n})}function _r(t){const{offset:e,order:n,reverse:r,...o}=t;return[{offset:e,order:n,reverse:r},o]}function Fr(t,n=d,r,{offset:o,order:i,reverse:a},s){const u=C(s),[f,h]=W(t),[p,m]=D(n),[y,g]=D(n);return o=function(t){if(null==t)return;if("function"==typeof t)return t;switch(`${t}`.toLowerCase()){case"expand":case"normalize":return Ir;case"center":case"silhouette":return Gr;case"wiggle":return Xr}throw new Error(`unknown offset: ${t}`)}(o),i=function(t,e,n){if(void 0===t&&e===Xr)return Kr;if(null==t)return;if("string"==typeof t){switch(t.toLowerCase()){case"value":case n:return Hr;case"z":return Zr;case"sum":return Qr;case"appearance":return Jr;case"inside-out":return Kr}return to(c(t))}if("function"==typeof t)return to(t);if(Array.isArray(t))return r=t,(t,e,n,o)=>eo(o,r);var r;throw new Error(`invalid order: ${t}`)}(i,o,r),[on(s,((r,s)=>{const c=null==t?void 0:h(l(r,t)),f=l(r,n,Float64Array),d=l(r,u),p=i&&i(r,c,f,d),y=r.length,v=m(new Float64Array(y)),x=g(new Float64Array(y)),w=[];for(const t of s){const n=c?Array.from(e.group(t,(t=>c[t])).values()):[t];p&&no(n,p);for(const t of n){let e=0,n=0;a&&t.reverse();for(const r of t){const t=f[r];t<0?e=x[r]=(v[r]=e)+t:t>0?n=x[r]=(v[r]=n)+t:x[r]=v[r]=n}}w.push(n)}return o&&o(w,v,x,d),{data:r,facets:s}})),f,p,y]}function jr(t,e){let n=0,r=0;for(const o of t){const t=e[o];tr&&(r=t)}return[n,r]}function Ir(t,e,n){for(const r of t)for(const t of r){const[r,o]=jr(t,n);for(const i of t){const t=1/(o-r||1);e[i]=t*(e[i]-r),n[i]=t*(n[i]-r)}}}function Gr(t,e,n){for(const r of t){for(const t of r){const[r,o]=jr(t,n);for(const i of t){const t=(o+r)/2;e[i]-=t,n[i]-=t}}Ur(r,e,n)}Vr(t,e,n)}function Xr(t,n,r,o){for(const i of t){const t=new e.InternMap;let a=0;for(const s of i){let i=-1;const l=s.map((t=>Math.abs(r[t]-n[t]))),c=s.map((e=>{i=o?o[e]:++i;const a=r[e]-n[e],s=t.has(i)?a-t.get(i):0;return t.set(i,a),s})),u=[0,...e.cumsum(c)];for(const t of s)n[t]+=a,r[t]+=a;const f=e.sum(l);f&&(a-=e.sum(l,((t,e)=>(c[e]/2+u[e])*t))/f)}Ur(i,n,r)}Vr(t,n,r)}function Ur(t,n,r){const o=e.min(t,(t=>e.min(t,(t=>n[t]))));for(const e of t)for(const t of e)n[t]-=o,r[t]-=o}function Vr(t,n,r){const o=t.length;if(1===o)return;const i=t.map((t=>t.flat())),a=i.map((t=>(e.min(t,(t=>n[t]))+e.max(t,(t=>r[t])))/2)),s=e.min(a);for(let t=0;te.sum(t,(t=>r[t]))),(t=>o[t])))}function Jr(t,n,r,o){return eo(o,e.groupSort(S(t),(t=>n[e.greatest(t,(t=>r[t]))]),(t=>o[t])))}function Kr(t,n,r,o){const i=S(t),a=e.groupSort(i,(t=>n[e.greatest(t,(t=>r[t]))]),(t=>o[t])),s=e.rollup(i,(t=>e.sum(t,(t=>r[t]))),(t=>o[t])),l=[],c=[];let u=0;for(const t of a)u<0?(u+=s.get(t),l.push(t)):(u-=s.get(t),c.push(t));return eo(o,c.reverse().concat(l))}function to(t){return e=>l(e,t)}function eo(t,n){return n=new e.InternMap(n.map(((t,e)=>[t,e]))),t.map((t=>n.get(t)))}function no(t,e){for(const n of t)n.sort(((t,n)=>ft(e[t],e[n])))}const ro={ariaLabel:"area",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:1};class oo extends tr{constructor(t,e={}){const{x1:n,y1:r,x2:o,y2:i,z:a,curve:s,tension:l}=e;super(t,[{name:"x1",value:n,scale:"x"},{name:"y1",value:r,scale:"y"},{name:"x2",value:o,scale:"x",optional:!0},{name:"y2",value:i,scale:"y",optional:!0},{name:"z",value:C(e),optional:!0}],e,ro),this.z=a,this.curve=ur(s,l)}filter(t){return t}render(t,{x:n,y:r},o,i){const{x1:a,y1:s,x2:l=a,y2:c=s}=o,{dx:u,dy:f}=this;return e.create("svg:g").call(Lt,this,i).call(Ot,n,r,u,f).call((n=>n.selectAll().data(Mt(t,[a,s,l,c],this,o)).enter().append("path").call(At,this).call($t,this,o).attr("d",e.area().curve(this.curve).defined((t=>t>=0)).x0((t=>a[t])).y0((t=>s[t])).x1((t=>l[t])).y1((t=>c[t]))))).node()}}function io(t,e){const{x:n=u,...r}=$r(e);return new oo(t,qr(Dr({...r,x1:n,x2:void 0})))}function ao(t,{marker:e,markerStart:n=e,markerMid:r=e,markerEnd:o=e}={}){t.markerStart=so(n),t.markerMid=so(r),t.markerEnd=so(o)}function so(t){if(null==t||!1===t)return null;if(!0===t)return uo;if("function"==typeof t)return t;switch(`${t}`.toLowerCase()){case"none":return null;case"arrow":return lo;case"dot":return co;case"circle":case"circle-fill":return uo;case"circle-stroke":return fo}throw new Error(`invalid marker: ${t}`)}function lo(t){return e.create("svg:marker").attr("viewBox","-5 -5 10 10").attr("markerWidth",6.67).attr("markerHeight",6.67).attr("orient","auto").attr("fill","none").attr("stroke",t).attr("stroke-width",1.5).attr("stroke-linecap","round").attr("stroke-linejoin","round").call((t=>t.append("path").attr("d","M-1.5,-3l3,3l-3,3"))).node()}function co(t){return e.create("svg:marker").attr("viewBox","-5 -5 10 10").attr("markerWidth",6.67).attr("markerHeight",6.67).attr("fill",t).attr("stroke","none").call((t=>t.append("circle").attr("r",2.5))).node()}function uo(t){return e.create("svg:marker").attr("viewBox","-5 -5 10 10").attr("markerWidth",6.67).attr("markerHeight",6.67).attr("fill",t).attr("stroke","white").attr("stroke-width",1.5).call((t=>t.append("circle").attr("r",3))).node()}function fo(t){return e.create("svg:marker").attr("viewBox","-5 -5 10 10").attr("markerWidth",6.67).attr("markerHeight",6.67).attr("fill","white").attr("stroke",t).attr("stroke-width",1.5).call((t=>t.append("circle").attr("r",3))).node()}let ho=0;function po(t,e,{stroke:n}){return yo(t,e,n&&(t=>n[t]))}function mo(t,e,{stroke:n}){return yo(t,e,n&&(([t])=>n[t]))}function yo(t,{markerStart:e,markerMid:n,markerEnd:r,stroke:o},i=(()=>o)){const a=new Map;function s(t){return function(e){const n=i(e);let r=a.get(t);r||a.set(t,r=new Map);let o=r.get(n);if(!o){const e=this.parentNode.insertBefore(t(n),this),i="plot-marker-"+ ++ho;e.setAttribute("id",i),r.set(n,o=`url(#${i})`)}return o}}e&&t.attr("marker-start",s(e)),n&&t.attr("marker-mid",s(n)),r&&t.attr("marker-end",s(r))}const go={ariaLabel:"link",fill:"none",stroke:"currentColor",strokeMiterlimit:1};class vo extends tr{constructor(t,e={}){const{x1:n,y1:r,x2:o,y2:i,curve:a,tension:s}=e;super(t,[{name:"x1",value:n,scale:"x"},{name:"y1",value:r,scale:"y"},{name:"x2",value:o,scale:"x",optional:!0},{name:"y2",value:i,scale:"y",optional:!0}],e,go),this.curve=ur(a,s),ao(this,e)}render(t,{x:n,y:r},o,i){const{x1:a,y1:s,x2:l=a,y2:c=s}=o,{dx:u,dy:f,curve:d}=this;return e.create("svg:g").call(Lt,this,i).call(Ot,n,r,vt+u,vt+f).call((n=>n.selectAll().data(t).enter().append("path").call(At,this).attr("d",(t=>{const n=e.path(),r=d(n);return r.lineStart(),r.point(a[t],s[t]),r.point(l[t],c[t]),r.lineEnd(),n})).call(kt,this,o).call(po,this,o))).node()}}function xo(t,{x:e,x1:n,x2:r,y:o,y1:i,y2:a,...s}={}){return[n,r]=wo(e,n,r),[i,a]=wo(o,i,a),new vo(t,{...s,x1:n,x2:r,y1:i,y2:a})}function wo(t,e,n){if(void 0===t){if(void 0===e){if(void 0!==n)return[n]}else if(void 0===n)return[e]}else{if(void 0===e)return void 0===n?[t]:[t,n];if(void 0===n)return[t,e]}return[e,n]}const bo={ariaLabel:"arrow",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeMiterlimit:1,strokeWidth:1.5};class ko extends tr{constructor(t,e={}){const{x1:n,y1:r,x2:o,y2:i,bend:a=0,headAngle:s=60,headLength:l=8,inset:c=0,insetStart:u=c,insetEnd:f=c}=e;super(t,[{name:"x1",value:n,scale:"x"},{name:"y1",value:r,scale:"y"},{name:"x2",value:o,scale:"x",optional:!0},{name:"y2",value:i,scale:"y",optional:!0}],e,bo),this.bend=!0===a?22.5:Math.max(-90,Math.min(90,a)),this.headAngle=+s,this.headLength=+l,this.insetStart=+u,this.insetEnd=+f}render(t,{x:n,y:r},o,i){const{x1:a,y1:s,x2:l=a,y2:c=s,SW:u}=o,{dx:f,dy:d,strokeWidth:h,bend:p,headAngle:m,headLength:y,insetStart:g,insetEnd:v}=this,x=u?t=>u[t]:()=>h,w=p*ct,b=m*ct/2,k=y/1.5;return e.create("svg:g").call(Lt,this,i).call(Ot,n,r,vt+f,vt+d).call((e=>e.selectAll().data(t).enter().append("path").call(At,this).attr("d",(t=>{let e=a[t],n=s[t],r=l[t],o=c[t];const i=Math.hypot(r-e,o-n);if(i<=g+v)return null;let u=Math.atan2(o-n,r-e);const f=Math.min(k*x(t),i/3),d=Math.hypot(i/Math.tan(w),i)/2;if(g||v)if(d<1e5){const t=Math.sign(w),[i,a]=function([t,e],[n,r],o,i){const a=n-t,s=r-e,l=Math.hypot(a,s),c=i*Math.sqrt(o*o-l*l/4)/l;return[(t+n)/2-s*c,(e+r)/2+a*c]}([e,n],[r,o],d,t);if(g&&([e,n]=$o([i,a,d],[e,n,g],-t*Math.sign(g))),v){const[e,n]=$o([i,a,d],[r,o,v],t*Math.sign(v));u+=Math.atan2(n-a,e-i)-Math.atan2(o-a,r-i),r=e,o=n}}else{const t=r-e,i=o-n,a=Math.hypot(t,i);g&&(e+=t/a*g,n+=i/a*g),v&&(r-=t/a*v,o-=i/a*v)}const h=u+w,p=h+b,m=h-b,y=r-f*Math.cos(p),$=o-f*Math.sin(p),M=r-f*Math.cos(m),L=o-f*Math.sin(m);return`M${e},${n}${d<1e5?`A${d},${d} 0,0,${w>0?1:0} `:"L"}${r},${o}M${y},${$}L${r},${o}L${M},${L}`})).call(kt,this,o))).node()}}function $o([t,e,n],[r,o,i],a){const s=r-t,l=o-e,c=Math.hypot(s,l),u=(s*s+l*l-i*i+n*n)/(2*c),f=a*Math.sqrt(n*n-u*u);return[t+(s*u+l*f)/c,e+(l*u-s*f)/c]}class Mo extends tr{constructor(t,e,n={},r){super(t,e,n,r);const{inset:o=0,insetTop:i=o,insetRight:a=o,insetBottom:s=o,insetLeft:l=o,rx:c,ry:u}=n;this.insetTop=p(i),this.insetRight=p(a),this.insetBottom=p(s),this.insetLeft=p(l),this.rx=Ct(c,"auto"),this.ry=Ct(u,"auto")}render(t,n,r,o){const{dx:i,dy:a,rx:s,ry:l}=this;return e.create("svg:g").call(Lt,this,o).call(this._transform,n,i,a).call((e=>e.selectAll().data(t).enter().append("rect").call(At,this).attr("x",this._x(n,r,o)).attr("width",this._width(n,r,o)).attr("y",this._y(n,r,o)).attr("height",this._height(n,r,o)).call(Bt,"rx",s).call(Bt,"ry",l).call(kt,this,r))).node()}_x(t,{x:e},{marginLeft:n}){const{insetLeft:r}=this;return e?t=>e[t]+r:n+r}_y(t,{y:e},{marginTop:n}){const{insetTop:r}=this;return e?t=>e[t]+r:n+r}_width({x:t},{x:e},{marginRight:n,marginLeft:r,width:o}){const{insetLeft:i,insetRight:a}=this,s=e?t.bandwidth():o-n-r;return Math.max(0,s-i-a)}_height({y:t},{y:e},{marginTop:n,marginBottom:r,height:o}){const{insetTop:i,insetBottom:a}=this,s=e?t.bandwidth():o-n-r;return Math.max(0,s-i-a)}}const Lo={ariaLabel:"bar"};class Ao extends Mo{constructor(t,e={}){const{x1:n,x2:r,y:o}=e;super(t,[{name:"x1",value:n,scale:"x"},{name:"x2",value:r,scale:"x"},{name:"y",value:o,scale:"y",type:"band",optional:!0}],e,Lo)}_transform(t,{x:e},n,r){t.call(Ot,e,null,n,r)}_x({x:t},{x1:e,x2:n},{marginLeft:r}){const{insetLeft:o}=this;return Xe(t)?r+o:t=>Math.min(e[t],n[t])+o}_width({x:t},{x1:e,x2:n},{marginRight:r,marginLeft:o,width:i}){const{insetLeft:a,insetRight:s}=this;return Xe(t)?i-r-o-a-s:t=>Math.max(0,Math.abs(n[t]-e[t])-a-s)}}class Ro extends Mo{constructor(t,e={}){const{x:n,y1:r,y2:o}=e;super(t,[{name:"y1",value:r,scale:"y"},{name:"y2",value:o,scale:"y"},{name:"x",value:n,scale:"x",type:"band",optional:!0}],e,Lo)}_transform(t,{y:e},n,r){t.call(Ot,null,e,n,r)}_y({y:t},{y1:e,y2:n},{marginTop:r}){const{insetTop:o}=this;return Xe(t)?r+o:t=>Math.min(e[t],n[t])+o}_height({y:t},{y1:e,y2:n},{marginTop:r,marginBottom:o,height:i}){const{insetTop:a,insetBottom:s}=this;return Xe(t)?i-r-o-a-s:t=>Math.max(0,Math.abs(n[t]-e[t])-a-s)}}function Bo(t,e={y:u,x2:f}){return new Ao(t,Pr(vr(Tr(e))))}function Oo(t,e={x:u,y2:f}){return new Ro(t,qr(xr(Dr(e))))}function Co(t,e={}){return zo(Object.fromEntries(["x","x1","x2"].filter((t=>null!=e[t])).map((e=>[e,t]))),e)}function So(t,e={}){return zo(Object.fromEntries(["y","y1","y2"].filter((t=>null!=e[t])).map((e=>[e,t]))),e)}function zo(t={},n={}){const r=C(n),o=Object.entries(t).map((([t,e])=>{const r=T(t,n);if(null==r)throw new Error(`missing channel: ${t}`);const[o,i]=D(r);return{key:t,input:r,output:o,setOutput:i,map:No(e)}}));return{...on(n,((t,n)=>{const i=l(t,r),a=o.map((({input:e})=>l(t,e))),s=o.map((({setOutput:e})=>e(new Array(t.length))));for(const t of n)for(const n of i?e.group(t,(t=>i[t])).values():[t])o.forEach((({map:t},e)=>t.map(n,a[e],s[e])));return{data:t,facets:n}})),...Object.fromEntries(o.map((({key:t,output:e})=>[t,e])))}}function No(t){if(t&&"function"==typeof t.map)return t;if("function"==typeof t)return To(t);switch(`${t}`.toLowerCase()){case"cumsum":return Do;case"rank":return To(e.rank);case"quantile":return To(Eo)}throw new Error(`invalid map: ${t}`)}function Eo(t){const n=e.count(t)-1;return e.rank(t).map((t=>t/n))}function To(t){return{map(e,n,r){const o=t(N(n,e));if(o.length!==e.length)throw new Error("map function returned a mismatched length");for(let t=0,n=e.length;t"symbol"===t));if(y){const t=m.find((({name:t})=>"fill"===t)),e=m.find((({name:t})=>"stroke"===t));y.hint={fill:t?t.value===y.value?"color":"currentColor":this.fill,stroke:e?e.value===y.value?"color":"currentColor":this.stroke}}}render(t,{x:n,y:r},o,i){const{x:a,y:s,r:l,rotate:c,symbol:u}=o,{dx:f,dy:d}=this,[h,p]=Tt(this,i),m=this.symbol===e.symbolCircle;return e.create("svg:g").call(Lt,this,i).call(Ot,n,r,vt+f,vt+d).call((n=>n.selectAll().data(t).enter().append(m?"circle":"path").call(At,this).call(m?t=>{t.attr("cx",a?t=>a[t]:h).attr("cy",s?t=>s[t]:p).attr("r",l?t=>l[t]:this.r)}:t=>{const n=a&&s?t=>`translate(${a[t]},${s[t]})`:a?t=>`translate(${a[t]},${p})`:s?t=>`translate(${h},${s[t]})`:()=>`translate(${h},${p})`;t.attr("transform",c?t=>`${n(t)} rotate(${c[t]})`:this.rotate?t=>`${n(t)} rotate(${this.rotate})`:n).attr("d",(t=>{const n=e.path(),r=l?l[t]:this.r;return(u?u[t]:this.symbol).draw(n,r*r*Math.PI),n}))}).call(kt,this,o))).node()}}function Po(t,{x:e,y:n,...r}={}){return void 0===r.frameAnchor&&([e,n]=O(e,n)),new Yo(t,{...r,x:e,y:n})}const qo={ariaLabel:"rule",fill:null,stroke:"currentColor"};class _o extends tr{constructor(t,e={}){const{x:n,y1:r,y2:o,inset:i=0,insetTop:a=i,insetBottom:s=i}=e;super(t,[{name:"x",value:n,scale:"x",optional:!0},{name:"y1",value:r,scale:"y",optional:!0},{name:"y2",value:o,scale:"y",optional:!0}],e,qo),this.insetTop=p(a),this.insetBottom=p(s)}render(t,{x:n,y:r},o,i){const{x:a,y1:s,y2:l}=o,{width:c,height:u,marginTop:f,marginRight:d,marginLeft:h,marginBottom:p}=i,{insetTop:m,insetBottom:y}=this;return e.create("svg:g").call(Lt,this,i).call(Ot,a&&n,null,vt,0).call((e=>e.selectAll().data(t).enter().append("line").call(At,this).attr("x1",a?t=>a[t]:(h+c-d)/2).attr("x2",a?t=>a[t]:(h+c-d)/2).attr("y1",s&&!Xe(r)?t=>s[t]+m:f+m).attr("y2",l&&!Xe(r)?r.bandwidth?t=>l[t]+r.bandwidth()-y:t=>l[t]-y:u-p-y).call(kt,this,o))).node()}}class Fo extends tr{constructor(t,e={}){const{x1:n,x2:r,y:o,inset:i=0,insetRight:a=i,insetLeft:s=i}=e;super(t,[{name:"y",value:o,scale:"y",optional:!0},{name:"x1",value:n,scale:"x",optional:!0},{name:"x2",value:r,scale:"x",optional:!0}],e,qo),this.insetRight=p(a),this.insetLeft=p(s)}render(t,{x:n,y:r},o,i){const{y:a,x1:s,x2:l}=o,{width:c,height:u,marginTop:f,marginRight:d,marginLeft:h,marginBottom:p}=i,{insetLeft:m,insetRight:y,dx:g,dy:v}=this;return e.create("svg:g").call(Lt,this,i).call(Ot,null,a&&r,g,vt+v).call((e=>e.selectAll().data(t).enter().append("line").call(At,this).attr("x1",s&&!Xe(n)?t=>s[t]+m:h+m).attr("x2",l&&!Xe(n)?n.bandwidth?t=>l[t]+n.bandwidth()-y:t=>l[t]-y:c-d-y).attr("y1",a?t=>a[t]:(f+u-p)/2).attr("y2",a?t=>a[t]:(f+u-p)/2).call(kt,this,o))).node()}}function jo(t,e){let{x:n=f,y:r,y1:o,y2:i,...a}=xr(e);return[o,i]=Go(r,o,i),new _o(t,{...a,x:n,y1:o,y2:i})}function Io(t,e){let{y:n=f,x:r,x1:o,x2:i,...a}=vr(e);return[o,i]=Go(r,o,i),new Fo(t,{...a,y:n,x1:o,x2:i})}function Go(t,e,n){if(void 0===t){if(void 0===e){if(void 0!==n)return[0,n]}else if(void 0===n)return[0,e]}else{if(void 0===e)return void 0===n?[0,t]:[t,n];if(void 0===n)return[t,e]}return[e,n]}const Xo={ariaLabel:"tick",fill:null,stroke:"currentColor"};class Uo extends tr{constructor(t,e,n){super(t,e,n,Xo)}render(t,n,r,o){const{dx:i,dy:a}=this;return e.create("svg:g").call(Lt,this,o).call(this._transform,n,i,a).call((e=>e.selectAll().data(t).enter().append("line").call(At,this).attr("x1",this._x1(n,r,o)).attr("x2",this._x2(n,r,o)).attr("y1",this._y1(n,r,o)).attr("y2",this._y2(n,r,o)).call(kt,this,r))).node()}}class Vo extends Uo{constructor(t,e={}){const{x:n,y:r,inset:o=0,insetTop:i=o,insetBottom:a=o}=e;super(t,[{name:"x",value:n,scale:"x"},{name:"y",value:r,scale:"y",type:"band",optional:!0}],e),this.insetTop=p(i),this.insetBottom=p(a)}_transform(t,{x:e},n,r){t.call(Ot,e,null,vt+n,r)}_x1(t,{x:e}){return t=>e[t]}_x2(t,{x:e}){return t=>e[t]}_y1(t,{y:e},{marginTop:n}){const{insetTop:r}=this;return e?t=>e[t]+r:n+r}_y2({y:t},{y:e},{height:n,marginBottom:r}){const{insetBottom:o}=this;return e?n=>e[n]+t.bandwidth()-o:n-r-o}}class Ho extends Uo{constructor(t,e={}){const{x:n,y:r,inset:o=0,insetRight:i=o,insetLeft:a=o}=e;super(t,[{name:"y",value:r,scale:"y"},{name:"x",value:n,scale:"x",type:"band",optional:!0}],e),this.insetRight=p(i),this.insetLeft=p(a)}_transform(t,{y:e},n,r){t.call(Ot,null,e,n,vt+r)}_x1(t,{x:e},{marginLeft:n}){const{insetLeft:r}=this;return e?t=>e[t]+r:n+r}_x2({x:t},{x:e},{width:n,marginRight:r}){const{insetRight:o}=this;return e?n=>e[n]+t.bandwidth()-o:n-r-o}_y1(t,{y:e}){return t=>e[t]}_y2(t,{y:e}){return t=>e[t]}}function Zo(t,{x:e=f,...n}={}){return new Vo(t,{...n,x:e})}function Qo(t,{y:e=f,...n}={}){return new Ho(t,{...n,y:e})}function Jo(t){const e=Ko(t),n=ti(t);return t.map((t=>tn?t:NaN))}function Ko(t,n){const r=2.5*ei(t,n)-1.5*ni(t,n);return e.min(t,(t=>t>=r?t:NaN))}function ti(t,n){const r=2.5*ni(t,n)-1.5*ei(t,n);return e.max(t,(t=>t<=r?t:NaN))}function ei(t,n){return e.quantile(t,.25,n)}function ni(t,n){return e.quantile(t,.75,n)}const ri={ariaLabel:"cell"};class oi extends Mo{constructor(t,{x:e,y:n,...r}={}){super(t,[{name:"x",value:e,scale:"x",type:"band",optional:!0},{name:"y",value:n,scale:"y",type:"band",optional:!0}],r,ri)}_transform(){}}const ii={ariaLabel:"frame",fill:"none",stroke:"currentColor"};class ai extends tr{constructor(t={}){const{inset:e=0,insetTop:n=e,insetRight:r=e,insetBottom:o=e,insetLeft:i=e}=t;super(void 0,void 0,t,ii),this.insetTop=p(n),this.insetRight=p(r),this.insetBottom=p(o),this.insetLeft=p(i)}render(t,n,r,o){const{marginTop:i,marginRight:a,marginBottom:s,marginLeft:l,width:c,height:u}=o,{insetTop:f,insetRight:d,insetBottom:h,insetLeft:p,dx:m,dy:y}=this;return e.create("svg:rect").call(Lt,this,o).call(At,this).call(Ot,null,null,vt+m,vt+y).attr("x",l+p).attr("y",i+f).attr("width",c-l-a-p-d).attr("height",u-i-s-f-h).node()}}const si={ariaLabel:"image",fill:null,stroke:null};class li extends tr{constructor(t,e={}){let{x:n,y:r,width:o,height:i,src:a,preserveAspectRatio:s,crossOrigin:l,frameAnchor:c}=e;void 0===o&&void 0!==i?o=i:void 0===i&&void 0!==o&&(i=o);const[u,f]="string"==typeof(d=a)&&(function(t){return/^\.*\//.test(t)}(d)||function(t){return/^(blob|data|file|http|https):/i.test(t)}(d))?[void 0,d]:[d,void 0];var d;const[p,m]=b(o,16),[y,g]=b(i,16);super(t,[{name:"x",value:n,scale:"x",optional:!0},{name:"y",value:r,scale:"y",optional:!0},{name:"width",value:p,filter:pt,optional:!0},{name:"height",value:y,filter:pt,optional:!0},{name:"src",value:u,optional:!0}],e,si),this.src=f,this.width=m,this.height=g,this.preserveAspectRatio=Ct(s,"xMidYMid"),this.crossOrigin=h(l),this.frameAnchor=et(c)}render(t,{x:n,y:r},o,i){const{x:a,y:s,width:l,height:c,src:u}=o,{dx:f,dy:d}=this,[h,p]=Tt(this,i);return e.create("svg:g").call(Lt,this,i).call(Ot,n,r,vt+f,vt+d).call((e=>e.selectAll().data(t).enter().append("image").call(At,this).attr("x",l&&a?t=>a[t]-l[t]/2:l?t=>h-l[t]/2:a?t=>a[t]-this.width/2:h-this.width/2).attr("y",c&&s?t=>s[t]-c[t]/2:c?t=>p-c[t]/2:s?t=>s[t]-this.height/2:p-this.height/2).attr("width",l?t=>l[t]:this.width).attr("height",c?t=>c[t]:this.height).call(Bt,"href",u?t=>u[t]:this.src).call(Bt,"preserveAspectRatio",this.preserveAspectRatio).call(Bt,"crossorigin",this.crossOrigin).call(kt,this,o))).node()}}const ci={ariaLabel:"line",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:1};class ui extends tr{constructor(t,e={}){const{x:n,y:r,z:o,curve:i,tension:a}=e;super(t,[{name:"x",value:n,scale:"x"},{name:"y",value:r,scale:"y"},{name:"z",value:C(e),optional:!0}],e,ci),this.z=o,this.curve=ur(i,a),ao(this,e)}filter(t){return t}render(t,{x:n,y:r},o,i){const{x:a,y:s}=o,{dx:l,dy:c}=this;return e.create("svg:g").call(Lt,this,i).call(Ot,n,r,vt+l,vt+c).call((n=>n.selectAll().data(Mt(t,[a,s],this,o)).enter().append("path").call(At,this).call($t,this,o).call(mo,this,o).attr("d",e.line().curve(this.curve).defined((t=>t>=0)).x((t=>a[t])).y((t=>s[t]))))).node()}}const fi={ariaLabel:"rect"};class di extends tr{constructor(t,e={}){const{x1:n,y1:r,x2:o,y2:i,inset:a=0,insetTop:s=a,insetRight:l=a,insetBottom:c=a,insetLeft:u=a,rx:f,ry:d}=e;super(t,[{name:"x1",value:n,scale:"x",optional:!0},{name:"y1",value:r,scale:"y",optional:!0},{name:"x2",value:o,scale:"x",optional:!0},{name:"y2",value:i,scale:"y",optional:!0}],e,fi),this.insetTop=p(s),this.insetRight=p(l),this.insetBottom=p(c),this.insetLeft=p(u),this.rx=Ct(f,"auto"),this.ry=Ct(d,"auto")}render(t,{x:n,y:r},o,i){const{x1:a,y1:s,x2:l,y2:c}=o,{marginTop:u,marginRight:f,marginBottom:d,marginLeft:h,width:p,height:m}=i,{insetTop:y,insetRight:g,insetBottom:v,insetLeft:x,dx:w,dy:b,rx:k,ry:$}=this;return e.create("svg:g").call(Lt,this,i).call(Ot,a&&l?n:null,s&&c?r:null,w,b).call((e=>e.selectAll().data(t).enter().append("rect").call(At,this).attr("x",a&&l&&!Xe(n)?t=>Math.min(a[t],l[t])+x:h+x).attr("y",s&&c&&!Xe(r)?t=>Math.min(s[t],c[t])+y:u+y).attr("width",a&&l&&!Xe(n)?t=>Math.max(0,Math.abs(l[t]-a[t])-x-g):p-f-h-g-x).attr("height",s&&c&&!Xe(r)?t=>Math.max(0,Math.abs(s[t]-c[t])-y-v):m-u-d-y-v).call(Bt,"rx",k).call(Bt,"ry",$).call(kt,this,o))).node()}}const hi={ariaLabel:"text",strokeLinejoin:"round",strokeWidth:3,paintOrder:"stroke"};class pi extends tr{constructor(t,e={}){const{x:n,y:r,text:o=(null!=t&&_(t)?f:u),frameAnchor:i,textAnchor:a=(/right$/i.test(i)?"end":/left$/i.test(i)?"start":"middle"),lineAnchor:s=(/^top/i.test(i)?"top":/^bottom/i.test(i)?"bottom":"middle"),lineHeight:c=1,lineWidth:d=1/0,monospace:p,fontFamily:m=(p?"ui-monospace, monospace":void 0),fontSize:y,fontStyle:g,fontVariant:v,fontWeight:x,rotate:w}=e,[k,M]=b(w,0),[L,A]=function(t){return null==t||"number"==typeof t?[void 0,t]:"string"!=typeof t?[t,void 0]:(t=t.trim().toLowerCase(),vi.has(t)||/^[+-]?\d*\.?\d+(e[+-]?\d+)?(\w*|%)$/.test(t)?[void 0,t]:[t,void 0])}(y);var R;super(t,[{name:"x",value:n,scale:"x",optional:!0},{name:"y",value:r,scale:"y",optional:!0},{name:"fontSize",value:L,optional:!0},{name:"rotate",value:(R=k,null==R?null:{transform:t=>l(t,R,Float64Array),label:Y(R)}),optional:!0},{name:"text",value:o,filter:dt}],e,hi),this.rotate=M,this.textAnchor=Ct(a,"middle"),this.lineAnchor=$(s,"lineAnchor",["top","middle","bottom"]),this.lineHeight=+c,this.lineWidth=+d,this.monospace=!!p,this.fontFamily=h(m),this.fontSize=A,this.fontStyle=h(g),this.fontVariant=h(v),this.fontWeight=h(x),this.frameAnchor=et(i)}render(t,{x:n,y:r},o,i){const{x:a,y:s,rotate:l,text:c,fontSize:u}=o,{dx:f,dy:d,rotate:h}=this,[p,m]=Tt(this,i);return e.create("svg:g").call(Lt,this,i).call(gi,this,c,i).call(Ot,n,r,vt+f,vt+d).call((e=>e.selectAll().data(t).enter().append("text").call(At,this).call(mi,this,c).attr("transform",l?a&&s?t=>`translate(${a[t]},${s[t]}) rotate(${l[t]})`:a?t=>`translate(${a[t]},${m}) rotate(${l[t]})`:s?t=>`translate(${p},${s[t]}) rotate(${l[t]})`:t=>`translate(${p},${m}) rotate(${l[t]})`:h?a&&s?t=>`translate(${a[t]},${s[t]}) rotate(${h})`:a?t=>`translate(${a[t]},${m}) rotate(${h})`:s?t=>`translate(${p},${s[t]}) rotate(${h})`:`translate(${p},${m}) rotate(${h})`:a&&s?t=>`translate(${a[t]},${s[t]})`:a?t=>`translate(${a[t]},${m})`:s?t=>`translate(${p},${s[t]})`:`translate(${p},${m})`).call(Bt,"font-size",u&&(t=>u[t])).call(kt,this,o))).node()}}function mi(t,{monospace:n,lineAnchor:r,lineHeight:o,lineWidth:i},a){if(!a)return;const s=isFinite(i)?n?t=>xi(t,i,ki):t=>xi(t,100*i,bi):t=>t.split(/\r\n?|\n/g);t.each((function(t){const n=s(lt(a[t])),i=n.length,l="top"===r?.71:"bottom"===r?1-i:(164-100*i)/200;if(i>1)for(let t=0;tn-e)){const r=[];let o,i=0;for(const[a,s,l]of function*(t){let e=0,n=0;const r=t.length;for(;no&&n(t,o,s)>e&&(r.push(t.slice(o,i)),o=a),l?(r.push(t.slice(o,s)),o=void 0):i=s;return r}const wi={a:56,b:63,c:57,d:63,e:58,f:37,g:62,h:60,i:26,j:26,k:55,l:26,m:88,n:60,o:60,p:62,q:62,r:39,s:54,t:38,u:60,v:55,w:79,x:54,y:55,z:55,A:69,B:67,C:73,D:74,E:61,F:58,G:76,H:75,I:28,J:55,K:67,L:58,M:89,N:75,O:78,P:65,Q:78,R:67,S:65,T:65,U:75,V:69,W:98,X:69,Y:67,Z:67,0:64,1:48,2:62,3:64,4:66,5:63,6:65,7:58,8:65,9:65," ":29,"!":32,'"':49,"'":31,"(":39,")":39,",":31,"-":48,".":31,"/":32,":":31,";":31,"?":52,"‘":31,"’":31,"“":47,"”":47};function bi(t,e,n){let r=0;for(let o=e;o=55296&&e<=56319){const e=t.charCodeAt(o+1);e>=56320&&e<=57343&&++o}}return r}function ki(t,e,n){return n-e}function $i({path:t=f,delimiter:n,frameAnchor:r,treeLayout:o=e.tree,treeSort:i,treeSeparation:a,treeAnchor:s,...c}={}){s=Li(s),i=Bi(i),void 0===r&&(r=s.frameAnchor);const u=Ci(n),h=Ii(c,zi),[p,m]=D(),[y,g]=D();return{x:p,y:y,frameAnchor:r,...on(c,((n,r)=>{const c=u(l(n,t)),f=m([]),p=g([]);let y=-1;const v=[],x=[],w=e.stratify().path((t=>c[t])),b=o();b.nodeSize&&b.nodeSize([1,1]),b.separation&&void 0!==a&&b.separation(a??d);for(const t of h)t[ji]=t[_i]([]);for(const t of r){const e=[],r=w(t.filter((t=>null!=c[t]))).each((t=>t.data=n[t.data]));null!=i&&r.sort(i),b(r);for(const t of r.descendants()){e.push(++y),v[y]=t.data,s.position(t,y,f,p);for(const e of h)e[ji][y]=e[Fi](t)}x.push(e)}return{data:v,facets:x}})),...Object.fromEntries(h)}}function Mi({path:t=f,delimiter:n,curve:r="bump-x",stroke:o="#555",strokeWidth:i=1.5,strokeOpacity:a=.5,treeLayout:s=e.tree,treeSort:c,treeSeparation:u,treeAnchor:h,...p}={}){h=Li(h),c=Bi(c),p={curve:r,stroke:o,strokeWidth:i,strokeOpacity:a,...p};const m=Ci(n),y=Ii(p,Ni),[g,v]=D(),[x,w]=D(),[b,k]=D(),[$,M]=D();return{x1:g,x2:x,y1:b,y2:$,...on(p,((n,r)=>{const o=m(l(n,t)),i=v([]),a=w([]),f=k([]),p=M([]);let g=-1;const x=[],b=[],$=e.stratify().path((t=>o[t])),L=s();L.nodeSize&&L.nodeSize([1,1]),L.separation&&void 0!==u&&L.separation(u??d);for(const t of y)t[ji]=t[_i]([]);for(const t of r){const e=[],r=$(t.filter((t=>null!=o[t]))).each((t=>t.data=n[t.data]));null!=c&&r.sort(c),L(r);for(const{source:t,target:n}of r.links()){e.push(++g),x[g]=n.data,h.position(t,g,i,f),h.position(n,g,a,p);for(const e of y)e[ji][g]=e[Fi](n,t)}b.push(e)}return{data:x,facets:b}})),...Object.fromEntries(y)}}function Li(t="left"){switch(`${t}`.trim().toLowerCase()){case"left":return Ai;case"right":return Ri}throw new Error(`invalid tree anchor: ${t}`)}const Ai={frameAnchor:"left",dx:6,position({x:t,y:e},n,r,o){r[n]=e,o[n]=-t}},Ri={frameAnchor:"right",dx:-6,position({x:t,y:e},n,r,o){r[n]=-e,o[n]=-t}};function Bi(t){return null==t||"function"==typeof t?t:`${t}`.trim().toLowerCase().startsWith("node:")?Oi(zi(t)):Oi(function(t){return e=>e.data?.[t]}(t))}function Oi(t){return(e,n)=>ft(t(e),t(n))}function Ci(t="/"){return"/"==`${t}`?t=>t:e=>{return e.map((n=t,r="/",n=new RegExp(function(t){return`${t}`.replace(/[\\^$*+?.()|[\]{}]/g,"\\$&")}(n),"g"),t=>null==t?null:`${t}`.replace(n,r)));var n,r}}function Si(t){return L(t)&&"function"==typeof t.node}function zi(t){if(Si(t))return t.node;if((t=`${t}`.trim().toLowerCase()).startsWith("node:")){switch(t){case"node:name":return Ti;case"node:path":return Ei;case"node:internal":return Yi;case"node:depth":return Di;case"node:height":return Wi}throw new Error(`invalid node value: ${t}`)}}function Ni(t){if(Si(t))return t.node;if(L(e=t)&&"function"==typeof e.link)return t.link;var e;if((t=`${t}`.trim().toLowerCase()).startsWith("node:")||t.startsWith("parent:")){switch(t){case"parent:name":return Pi(Ti);case"parent:path":return Pi(Ei);case"parent:depth":return Pi(Di);case"parent:height":return Pi(Wi);case"node:name":return Ti;case"node:path":return Ei;case"node:internal":return Yi;case"node:depth":return Di;case"node:height":return Wi}throw new Error(`invalid link value: ${t}`)}}function Ei(t){return t.id}function Ti(t){return function(t){let e=t.length;for(;--e>0&&!qi(t,e););return t.slice(e+1)}(t.id)}function Di(t){return t.depth}function Wi(t){return t.height}function Yi(t){return!!t.children}function Pi(t){return(e,n)=>null==n?void 0:t(n)}function qi(t,e){if("/"===t[e]){let n=0;for(;e>0&&"\\"===t[--e];)++n;if(0==(1&n))return!0}return!1}const _i=2,Fi=3,ji=4;function Ii(t,e){const n=[];for(const r in t){const o=t[r],i=e(o);void 0!==i&&n.push([r,...D(o),i])}return n}function Gi(t,{fill:e,stroke:n,strokeWidth:r,strokeOpacity:o,strokeLinejoin:i,strokeLinecap:a,strokeMiterlimit:s,strokeDasharray:l,strokeDashoffset:c,marker:u,markerStart:f=u,markerEnd:d=u,dot:h=H(f)&&H(d),text:p="node:name",textStroke:m="white",title:y="node:path",dx:g,dy:v,...x}={}){return void 0===g&&(g=Li(x.treeAnchor).dx),er(xo(t,Mi({markerStart:f,markerEnd:d,stroke:void 0!==n?n:void 0===e?"node:internal":e,strokeWidth:r,strokeOpacity:o,strokeLinejoin:i,strokeLinecap:a,strokeMiterlimit:s,strokeDasharray:l,strokeDashoffset:c,...x})),h?Po(t,$i({fill:void 0===e?"node:internal":e,title:y,...x})):null,null!=p?yi(t,$i({text:p,fill:void 0===e?"currentColor":e,stroke:m,dx:g,dy:v,title:y,...x})):null)}const Xi={ariaLabel:"vector",fill:null,stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round"};class Ui extends tr{constructor(t,e={}){const{x:n,y:r,length:o,rotate:i,anchor:a="middle",frameAnchor:s}=e,[l,c]=b(o,12),[u,f]=b(i,0);super(t,[{name:"x",value:n,scale:"x",optional:!0},{name:"y",value:r,scale:"y",optional:!0},{name:"length",value:l,scale:"length",optional:!0},{name:"rotate",value:u,optional:!0}],e,Xi),this.length=c,this.rotate=f,this.anchor=$(a,"anchor",["start","middle","end"]),this.frameAnchor=et(s)}render(t,{x:n,y:r},o,i){const{x:a,y:s,length:l,rotate:c}=o,{dx:u,dy:f,length:d,rotate:h,anchor:p}=this,[m,y]=Tt(this,i),g=l?t=>l[t]:()=>d,v=c?t=>c[t]:()=>h,x=a?t=>a[t]:()=>m,w=s?t=>s[t]:()=>y,b="start"===p?0:"end"===p?1:.5;return e.create("svg:g").attr("fill","none").call(Lt,this,i).call(Ot,n,r,vt+u,vt+f).call((e=>e.selectAll().data(t).enter().append("path").call(At,this).attr("d",(t=>{const e=g(t),n=v(t)*ct,r=Math.sin(n)*e,o=-Math.cos(n)*e,i=(r+o)/5,a=(r-o)/5;return`M${x(t)-r*b},${w(t)-o*b}l${r},${o}m${-a},${-i}l${a},${i}l${-i},${a}`})).call(kt,this,o))).node()}}function Vi(t){if(void 0===t)return Ji;if("function"==typeof t)return Hi(((e,n)=>t(N(n,e))));if(/^p\d{2}$/i.test(t))return Zi(x(t));switch(`${t}`.toLowerCase()){case"deviation":return ta;case"first":return Ji;case"last":return Ki;case"max":return ea;case"mean":return na;case"median":return ra;case"min":return oa;case"sum":return ia;case"extent":return Qi}throw new Error(`invalid basis: ${t}`)}function Hi(t){return{map(e,n,r){const o=+t(e,n);for(const t of e)r[t]=null===n[t]?NaN:n[t]/o}}}function Zi(t){return Hi(((e,n)=>t(e,(t=>n[t]))))}const Qi={map(t,n,r){const[o,i]=e.extent(t,(t=>n[t])),a=i-o;for(const e of t)r[e]=null===n[e]?NaN:(n[e]-o)/a}},Ji=Hi(((t,e)=>{for(let n=0;n{for(let n=t.length-1;n>=0;--n){const r=e[t[n]];if(ut(r))return r}})),ta={map(t,n,r){const o=e.mean(t,(t=>n[t])),i=e.deviation(t,(t=>n[t]));for(const e of t)r[e]=null===n[e]?NaN:i?(n[e]-o)/i:0}},ea=Zi(e.max),na=Zi(e.mean),ra=Zi(e.median),oa=Zi(e.min),ia=Zi(e.sum);function aa(t={}){"number"==typeof t&&(t={k:t});let{k:n,reduce:r,shift:o,anchor:i}=t;if(void 0===i&&void 0!==o&&(i=function(t){switch(`${t}`.toLowerCase()){case"centered":return"middle";case"leading":return"start";case"trailing":return"end"}throw new Error(`invalid shift: ${t}`)}(o),gt(`Warning: the shift option is deprecated; please use anchor "${i}" instead.`)),!((n=Math.floor(n))>0))throw new Error(`invalid k: ${n}`);return function(t="mean"){if("string"==typeof t){if(/^p\d{2}$/i.test(t))return sa(x(t));switch(t.toLowerCase()){case"deviation":return sa(e.deviation);case"max":return sa(e.max);case"mean":return ca;case"median":return sa(e.median);case"min":return sa(e.min);case"mode":return sa(e.mode);case"sum":return la;case"variance":return sa(e.variance);case"difference":return ua;case"ratio":return fa;case"first":return da;case"last":return ha}}if("function"!=typeof t)throw new Error(`invalid reduce: ${t}`);return sa(t)}(r)(n,function(t="middle",e){switch(`${t}`.toLowerCase()){case"middle":return e-1>>1;case"start":return 0;case"end":return e-1}throw new Error(`invalid anchor: ${t}`)}(i,n))}function sa(t){return(e,n)=>({map(r,o,i){const a=Float64Array.from(r,(t=>null===o[t]?NaN:o[t]));let s=0;for(let t=0;tn[t]))}function*wa(t,n){yield e.greatest(t,(t=>n[t]))}function ba(t,n,r){if(null!=t){if(null==r[t])throw new Error(`missing channel: ${t}`);t=r[t]}const o=C(r);return on(r,((r,i)=>{const a=l(r,o),s=l(r,t),c=[];for(const t of i){const r=[];for(const o of a?e.group(t,(t=>a[t])).values():[t])for(const t of n(o,s))r.push(t);c.push(r)}return{data:r,facets:c}}))}t.Area=oo,t.Arrow=ko,t.BarX=Ao,t.BarY=Ro,t.Cell=oi,t.Dot=Yo,t.Frame=ai,t.Image=li,t.Line=ui,t.Link=vo,t.Mark=tr,t.Rect=di,t.RuleX=_o,t.RuleY=Fo,t.Text=pi,t.TickX=Vo,t.TickY=Ho,t.Vector=Ui,t.area=function(t,e){return void 0===e?io(t,{x:y,y:g}):new oo(t,e)},t.areaX=function(t,e){const{y:n=u,...r}=Mr(e);return new oo(t,Pr(Tr({...r,y1:n,y2:void 0})))},t.areaY=io,t.arrow=function(t,{x:e,x1:n,x2:r,y:o,y1:i,y2:a,...s}={}){return[n,r]=wo(e,n,r),[i,a]=wo(o,i,a),new ko(t,{...s,x1:n,x2:r,y1:i,y2:a})},t.barX=Bo,t.barY=Oo,t.bin=function(t={fill:"count"},e={}){[t,e]=Ar(t,e);const{x:n,y:r}=function(t){let{x:e,y:n}=t;return e=Rr(e,t),n=Rr(n,t),[e.value,n.value]=O(e.value,n.value),{x:e,y:n}}(e);return Lr(n,r,null,null,t,fr(dr(e)))},t.binX=wr,t.binY=br,t.boxX=function(t,{x:e={transform:t=>t},y:n=null,fill:r="#ccc",fillOpacity:o,stroke:i="currentColor",strokeOpacity:a,strokeWidth:s=2,...l}={}){const c=null!=n?pn:dn;return er(Io(t,c({x1:Ko,x2:ti},{x:e,y:n,stroke:i,strokeOpacity:a,...l})),Bo(t,c({x1:"p25",x2:"p75"},{x:e,y:n,fill:r,fillOpacity:o,...l})),Zo(t,c({x:"p50"},{x:e,y:n,stroke:i,strokeOpacity:a,strokeWidth:s,...l})),Po(t,zo({x:Jo},{x:e,y:n,z:n,stroke:i,strokeOpacity:a,...l})))},t.boxY=function(t,{y:e={transform:t=>t},x:n=null,fill:r="#ccc",fillOpacity:o,stroke:i="currentColor",strokeOpacity:a,strokeWidth:s=2,...l}={}){const c=null!=n?hn:dn;return er(jo(t,c({y1:Ko,y2:ti},{x:n,y:e,stroke:i,strokeOpacity:a,...l})),Oo(t,c({y1:"p25",y2:"p75"},{x:n,y:e,fill:r,fillOpacity:o,...l})),Qo(t,c({y:"p50"},{x:n,y:e,stroke:i,strokeOpacity:a,strokeWidth:s,...l})),Po(t,zo({y:Jo},{x:n,y:e,z:n,stroke:i,strokeOpacity:a,...l})))},t.cell=function(t,{x:e,y:n,...r}={}){return[e,n]=O(e,n),new oi(t,{...r,x:e,y:n})},t.cellX=function(t,{x:e=u,fill:n,stroke:r,...o}={}){return void 0===n&&void 0===w(r)[0]&&(n=f),new oi(t,{...o,x:e,fill:n,stroke:r})},t.cellY=function(t,{y:e=u,fill:n,stroke:r,...o}={}){return void 0===n&&void 0===w(r)[0]&&(n=f),new oi(t,{...o,y:e,fill:n,stroke:r})},t.cluster=function(t,n){return Gi(t,{...n,treeLayout:e.cluster})},t.column=D,t.dot=Po,t.dotX=function(t,{x:e=f,...n}={}){return new Yo(t,{...n,x:e})},t.dotY=function(t,{y:e=f,...n}={}){return new Yo(t,{...n,y:e})},t.filter=function(t,e){return on(e,sn(t))},t.formatIsoDate=st,t.formatMonth=function(t="en-US",e="short"){const n=it(t,e);return t=>null==t||isNaN(t=new Date(Date.UTC(2e3,+t)))?void 0:n.format(t)},t.formatWeekday=function(t="en-US",e="short"){const n=at(t,e);return t=>null==t||isNaN(t=new Date(Date.UTC(2001,0,+t)))?void 0:n.format(t)},t.frame=function(t){return new ai(t)},t.group=function(t={fill:"count"},e={}){let{x:n,y:r}=e;if([n,r]=O(n,r),null==n)throw new Error("missing channel: x");if(null==r)throw new Error("missing channel: y");return mn(n,r,t,e)},t.groupX=hn,t.groupY=pn,t.groupZ=dn,t.image=function(t,{x:e,y:n,...r}={}){return void 0===r.frameAnchor&&([e,n]=O(e,n)),new li(t,{...r,x:e,y:n})},t.legend=function(t={}){for(const[e,n]of Hn){const r=t[e];if(A(r)){let o;if("symbol"===e){const{fill:e,stroke:n=(void 0===e&&A(t.color)?"color":void 0)}=t;o={fill:e,stroke:n}}return n(Ye(e,r,o),Zn(r,t),(e=>A(t[e])?Ye(e,t[e]):null))}}throw new Error("unknown legend type; no scale found")},t.line=function(t,{x:e,y:n,...r}={}){return[e,n]=O(e,n),new ui(t,{...r,x:e,y:n})},t.lineX=function(t,{x:e=f,y:n=u,...r}={}){return new ui(t,Mr({...r,x:e,y:n}))},t.lineY=function(t,{x:e=u,y:n=f,...r}={}){return new ui(t,$r({...r,x:e,y:n}))},t.link=xo,t.map=zo,t.mapX=Co,t.mapY=So,t.marks=er,t.normalize=Vi,t.normalizeX=function(t,e){return 1===arguments.length&&({basis:t,...e}=t),Co(Vi(t),e)},t.normalizeY=function(t,e){return 1===arguments.length&&({basis:t,...e}=t),So(Vi(t),e)},t.plot=Kn,t.rect=function(t,e){return new di(t,yr(gr(e)))},t.rectX=function(t,e={y:u,interval:1,x2:f}){return new di(t,Pr(gr(Tr(e))))},t.rectY=function(t,e={x:u,interval:1,y2:f}){return new di(t,qr(yr(Dr(e))))},t.reverse=function(t){return on(t,ln)},t.ruleX=jo,t.ruleY=Io,t.scale=function(t={}){let e;for(const n in t)if(Zt.has(n)&&A(t[n])){if(void 0!==e)throw new Error("ambiguous scale definition; multiple scales found");e=Qe(Ye(n,t[n]))}if(void 0===e)throw new Error("invalid scale definition; no scale found");return e},t.select=function(t,e={}){if("string"==typeof t)switch(t.toLowerCase()){case"first":return ma(e);case"last":return ya(e)}if("function"==typeof t)return ba(null,t,e);let n,r;for(n in t){if(void 0!==r)throw new Error("ambiguous selector; multiple inputs");r=pa(t[n])}if(void 0===r)throw new Error(`invalid selector: ${t}`);return ba(n,r,e)},t.selectFirst=ma,t.selectLast=ya,t.selectMaxX=function(t){return ba("x",wa,t)},t.selectMaxY=function(t){return ba("y",wa,t)},t.selectMinX=function(t){return ba("x",xa,t)},t.selectMinY=function(t){return ba("y",xa,t)},t.shuffle=function({seed:t,...n}={}){return on(n,fn(null==t?Math.random:e.randomLcg(t)))},t.sort=function(t,e){return on(e,cn(t))},t.stackX=Wr,t.stackX1=function(t={},e={}){1===arguments.length&&([t,e]=_r(t));const{y1:n,y:r=n,x:o}=e,[i,a,s]=Fr(r,o,"x",t,e);return{...i,y1:n,y:a,x:s}},t.stackX2=function(t={},e={}){1===arguments.length&&([t,e]=_r(t));const{y1:n,y:r=n,x:o}=e,[i,a,,s]=Fr(r,o,"x",t,e);return{...i,y1:n,y:a,x:s}},t.stackY=Yr,t.stackY1=function(t={},e={}){1===arguments.length&&([t,e]=_r(t));const{x1:n,x:r=n,y:o}=e,[i,a,s]=Fr(r,o,"y",t,e);return{...i,x1:n,x:a,y:s}},t.stackY2=function(t={},e={}){1===arguments.length&&([t,e]=_r(t));const{x1:n,x:r=n,y:o}=e,[i,a,,s]=Fr(r,o,"y",t,e);return{...i,x1:n,x:a,y:s}},t.text=yi,t.textX=function(t,{x:e=f,...n}={}){return new pi(t,{...n,x:e})},t.textY=function(t,{y:e=f,...n}={}){return new pi(t,{...n,y:e})},t.tickX=Zo,t.tickY=Qo,t.transform=on,t.tree=Gi,t.treeLink=Mi,t.treeNode=$i,t.valueof=l,t.vector=function(t,{x:e,y:n,...r}={}){return void 0===r.frameAnchor&&([e,n]=O(e,n)),new Ui(t,{...r,x:e,y:n})},t.vectorX=function(t,{x:e=f,...n}={}){return new Ui(t,{...n,x:e})},t.vectorY=function(t,{y:e=f,...n}={}){return new Ui(t,{...n,y:e})},t.version="0.4.3",t.window=aa,t.windowX=function(t={},e){return 1===arguments.length&&(e=t),Co(aa(t),e)},t.windowY=function(t={},e){return 1===arguments.length&&(e=t),So(aa(t),e)},Object.defineProperty(t,"__esModule",{value:!0})})); diff --git a/superx/xml/js/d3/viz_functions.js b/superx/xml/js/d3/viz_functions.js index 209839d..f37ec4e 100644 --- a/superx/xml/js/d3/viz_functions.js +++ b/superx/xml/js/d3/viz_functions.js @@ -8,51 +8,189 @@ this.value=value; } -function fillSelectFields() -{ -fillSelectOptions("viz_category_dim",false); -fillSelectOptions("viz_measure_dim",true); +function chartPropertyValue(nr,name,value,isDefault ) + { +this.nr=nr; +this.name=name; +this.value=value; +this.isDefault=isDefault; + +} + +function chartProperty(name,caption,isDynamic,isMeasure,isOptional,staticValues,defaultValue) + { +this.name=name; +this.caption=caption; +this.isDynamic=isDynamic; +this.isMeasure=isMeasure; +this.staticValues=staticValues; +this.isOptional=isOptional; +this.defaultValue=defaultValue; +this.getValueResultset = function () { + var valueOptions=[]; + var optionCounter=0; + if(isDynamic) + { + for(var j=0;j < rsMetaData.length;j++) + { + var isDefault=false; + if(rsMetaData[j].colcaption.trim() !="" && + (isMeasure==false || rsMetaData[j].coltype == 4 || rsMetaData[j].coltype == 3) + ) + { + if(rsMetaData[j].colcaption==defaultValue) + isDefault=true; + var o=new chartPropertyValue(rsMetaData[j].nr,rsMetaData[j].colcaption,rsMetaData[j].colcaption,isDefault); + valueOptions[optionCounter]=o; + optionCounter++; + } + } + } + else + { + var staticValuesArray = staticValues.split(/\|/); + for(var k=0;k < staticValuesArray.length;k++) + { + var isDefault=false; + if(rsMetaData[j].colcaption==defaultValue) + isDefault=true; + var o=new chartPropertyValue(k,staticValuesArray[k],staticValuesArray[k],isDefault); + valueOptions[k]=o; + } + } + return valueOptions; + } +} +function prepareChartProperties(chartType) +{ +var chartProperties=[]; +switch (chartType) { + case "bar_x": + chartProperties=prepareBarXForm(); + break; + case "line": + chartProperties=prepareLineForm(); + break; + default: + return false; + break; + } +renderForm("chartProperties",chartProperties,commonChartProperties); return true; } -function fillSelectOptions(fldSelectId,typeMeasureWanted) +function prepareBarXForm() +{ + var chartProperties=[]; + var propertyCounter=0; + var myProp= new chartProperty("viz_category_dim","Kategorie-Dimension",true,false,false,null,null); + chartProperties[0]=myProp; + var myProp= new chartProperty("viz_measure_dim","Maß",true,true,false,null,null); + chartProperties[1]=myProp; + +return chartProperties; +} + +function prepareLineForm() +{ + var chartProperties=[]; + var propertyCounter=0; + var myProp= new chartProperty("viz_category_dim","X-Achse",true,false,false,null,null); + chartProperties[0]=myProp; + var myProp= new chartProperty("viz_measure_dim","Y-Achse",true,true,false,null,null); + chartProperties[1]=myProp; + +return chartProperties; +} + +function renderForm(formDiv,chartProperties,myCommonChartProperties) +{ + //first empty form: + var myForm=document.getElementById(formDiv); + while (myForm.firstChild) { + myForm.removeChild(myForm.firstChild); + } + //now fill it: + const tabElem = document.createElement("table"); + myForm.appendChild(tabElem); + for(var k=0;k < chartProperties.length;k++) + { + const rowElem = document.createElement("tr"); + const tdCap = document.createElement("td"); + const textnode = document.createTextNode(chartProperties[k].caption); + tdCap.appendChild(textnode); + const tdSelElem = document.createElement("td"); + const selElem = document.createElement("select"); + selElem.name=chartProperties[k].name; + selElem.id=chartProperties[k].name; + fillSelectOptions(selElem,chartProperties[k].getValueResultset()); + tdSelElem.appendChild(selElem); + rowElem.appendChild(tdCap); + rowElem.appendChild(tdSelElem); + //here values, and then: + tabElem.appendChild( rowElem); + } + /* + const rowElem = document.createElement("tr"); + const tdCap = document.createElement("td"); + const textnode = document.createTextNode("Breite"); + tdCap.appendChild(textnode); + const tdInpElem = document.createElement("td"); + const inpElem = document.createElement("input"); + inpElem.id="viz_width"; + inpElem.name="viz_width"; + inpElem.type="text"; + inpElem.value="800"; + tdInpElem.appendChild(inpElem); + rowElem.appendChild(tdCap); + rowElem.appendChild(tdInpElem); + tabElem.appendChild(rowElem); + */ + myForm.appendChild(tabElem); + + //TODO: myCommonChartProperties auf separatem TAB +} + + + +function fillSelectOptions(myCombo,chartPropertyValues) { var optionCounter=0; -var myCombo=document.getElementById(fldSelectId); +var selectedOption=null; while (myCombo.firstChild) { myCombo.removeChild(myCombo.firstChild); } -for(var j=0;j < rsMetaData.length;j++) -{ -if(rsMetaData[j].colcaption.trim() !="" && -(typeMeasureWanted==false || rsMetaData[j].coltype == 4 || rsMetaData[j].coltype == 3) - -) +for(var j=0;j < chartPropertyValues.length;j++) { - var o=new Option(rsMetaData[j].colcaption,rsMetaData[j].nr,null,null); + if(chartPropertyValues[j].isDefault) + selectedOption=j; + + var o=new Option(chartPropertyValues[j].name,chartPropertyValues[j].nr,null,null); myCombo.options[optionCounter]=o; optionCounter++; } +if(selectedOption!=null) + myCombo.selectedIndex=selectedOption; } -} -function createChart() -{ - -chartType=document.getElementById("viz_chart_type").value; -if(document.getElementById("viz_category_dim").value=="" || - document.getElementById("viz_measure_dim").value=="" ) +/* alt:*/ +function fillSelectFields() { - alert("Bitte wählen Sie eine Kategorie und ein Maß"); - return false; +fillSelectOptions("viz_category_dim",false); +fillSelectOptions("viz_measure_dim",true); + + +return true; } + +function prepareData() +{ var data=[]; //TODO: filld3ArrayofObjects -var colcount=rsMetaData.length; var rowcount=rs.length; var colnrOfCategorydimName=document.getElementById("viz_category_dim").value; var colnrOfMeasure=document.getElementById("viz_measure_dim").value; @@ -73,133 +211,197 @@ for(j=1;j d.value)]).range([0, chartWidth]); -var y = d3.scaleBand().domain(data.map(d => d.nr)).range([0, barHeight * data.length]); +chartType=document.getElementById("viz_chart_type").value; +/* +if(document.getElementById("viz_category_dim").value=="" || + document.getElementById("viz_measure_dim").value=="" ) +{ + alert("Bitte wählen Sie eine Kategorie und ein Maß"); + return false; +} +*/ +var data=[]; +data=prepareData(); + + var valueLabelWidth = getCommonChartProperty("valueLabelWidth"); + var fontFamily=getCommonChartProperty("fontFamily"); + var gridLabelHeight = getCommonChartProperty("gridLabelHeight"); + var gridChartOffset = getCommonChartProperty("gridChartOffset"); + var chartWidth=getCommonChartProperty("chartWidth"); + var fontSize=getCommonChartProperty("fontSize"); -var svg = d3.select("#chartDiv").append("svg") + document.getElementById("chartDiv").innerHTML=""; //reset canvas + var svg = d3.select("#chartDiv").append("svg") .attr("width", chartWidth) //maxBarWidth + barLabelWidth + valueLabelWidth) - .attr("height", y.range()[1]) - .attr("font-family", "sans-serif") + //.attr("height", y.range()[1]) + .attr("font-family", fontFamily) .attr("font-size", fontSize) .attr("text-anchor", "start") .attr("id", "chartSVG") - + ; + +switch (chartType) +{ + case "bar_x": + makeBarX(svg,data); + //makeBarY(svg,data); + break; + case "line": + makeLine(svg,data); + break; + default: + alert("Please select a chart type"); + break; +} + +} -; +function makeBarX(svg,data) +{ + var barHeight = 18; + var barLabelWidth = 500; + var barLabelPadding = 10; + var maxBarWidth = maxValue; + var fontSize=getCommonChartProperty("fontSize"); + var chartWidth=getCommonChartProperty("chartWidth"); + var maxValue=d3.max(data, d => d.value); + var maxLenName=d3.max(data, d => d.name.length); + var maxLenNamePx=maxLenName*fontSize; + var x = d3.scaleLinear().domain([0, d3.max(data, d => d.value)]).range([0, chartWidth]); + var y = d3.scaleBand().domain(data.map(d => d.nr)).range([0, barHeight * data.length]); + const bar = svg.selectAll("g") + .data(data) + .join("g") + .attr("transform", d => `translate(${maxLenNamePx},${y(d.nr)})`) + ; + + bar.append("rect") + .attr("fill", "steelblue") + .on("mouseover",function(){ + d3.select(this).attr("fill", "red"); + }) + .on("mouseout",function(){ + d3.select(this).attr("fill", "steelblue"); + }) + .transition() + .duration(750) + .delay(function(d, i) { return i * 10; }) + .attr("width", d => x(d.value)) //x) + .attr("height", y.bandwidth() - 1) -const bar = svg.selectAll("g") - .data(data) - .join("g") - .attr("transform", d => `translate(${maxLenNamePx},${y(d.nr)})`) - ; - - bar.append("rect") - .attr("fill", "steelblue") - .on("mouseover",function(){ - d3.select(this).attr("fill", "red"); - }) - .on("mouseout",function(){ - d3.select(this).attr("fill", "steelblue"); - }) - .transition() - .duration(750) - .delay(function(d, i) { return i * 10; }) - .attr("width", d => x(d.value)) //x) - .attr("height", y.bandwidth() - 1) - -; -//value label: - bar.append("text") - .attr("fill", "white") - .attr("x", d => x(d.value)/2) - .attr("y", (y.bandwidth() - 1) / 2) - .attr("dy", "0.35em") - .attr("text-anchor","middle") - .text(d => d.value); -//label: - bar.append("text") - .attr("fill", "black") - .attr("x", 0) - .attr("y", (y.bandwidth() - 1) / 2) - .attr("dy", "0.35em") - .attr("text-anchor","end") - .text(d => d.name); - - -} -else { - //line chart: - - -// set the dimensions and margins of the graph -var margin = {top: 10, right: 30, bottom: 30, left: 60}, - width = 1224 - margin.left - margin.right, - height = 600 - margin.top - margin.bottom; - -var y = d3.scaleLinear().domain([0, d3.max(data, d => d.value)]).range([height, 0 ]); -var x = d3.scaleBand().domain(data.map(d => d.name)).range([0, width]); -var svg = d3.select("#chart").append("svg") - .attr("width", width + margin.left + margin.right) - .attr("height", height + margin.top + margin.bottom) //y.range()[1]) - .attr("font-family", "sans-serif") - .attr("font-size", "10") - .attr("text-anchor", "end") - -; - -svg.append("g") -//.attr("transform","translate(" + margin.left + "," + margin.top + ")") - .attr("transform", "translate(0," + height + ")") - .attr("class", "x axis") - .call(d3.axisBottom(x)); - - // Add Y axis - var y = d3.scaleLinear() - .domain([0, d3.max(data, function(d) { return +d.value; })]) - .range([ height, 0 ]); - svg.append("g") - .call(d3.axisLeft(y)); - - // Add the line - svg.append("path") - .datum(data) - .attr("fill", "none") - .attr("stroke", "steelblue") - .attr("stroke-width", 1.5) - .attr("d", d3.line() - .x(function(d) { return x(d.name) }) - .y(function(d) { return y(d.value) }) - ) + ; + //value label: + bar.append("text") + .attr("fill", "white") + .attr("x", d => x(d.value)/2) + .attr("y", (y.bandwidth() - 1) / 2) + .attr("dy", "0.35em") + .attr("text-anchor","middle") + .text(d => d.value); + //label: + bar.append("text") + .attr("fill", "black") + .attr("x", 0) + .attr("y", (y.bandwidth() - 1) / 2) + .attr("dy", "0.35em") + .attr("text-anchor","end") + .text(d => d.name); +} +function makeLine(svg,data) { +var options = { + marginBottom:100, + x: { + tickRotate: -45, + ticks: 5, + tickSize: 5, + line: true, + tickPadding: 10, + labelAnchor: "left", + labelOffset: 0, + nice: true, + label: "My label", + type:"point" + }, + // set y axis options + y: { + grid:true + }, + sort: "nr", + // define the marks we will use, dots and a line + marks: [ + Plot.line(data, {x: "name", y: "value",curve:"linear"}), + Plot.dot(data, {x: "name", y: "value" }) + ] + +}; + + + document.getElementById("chartDiv").appendChild(Plot.plot(options)); } +function makeBarY(svg,data) { +var options = { + marginBottom:100, + x: { + tickRotate: -45, + ticks: 5, + tickSize: 5, + line: true, + tickPadding: 10, + labelAnchor: "left", + labelOffset: 0, + nice: true, + label: "My label" + + }, + // set y axis options + y: { + grid:true + }, + sort: "nr", + // define the marks we will use, dots and a line + marks: [ + //Plot.barY(data, Plot.groupX({x: "name", y: "value" })) + Plot.barY( + data, + Plot.groupX( + { y: "sum" }, + { + x: "name", + y: "value", + sort: {x:"nr"}, + filter: null + } + ) + ) + ] + //Plot.dot(data, {x: "nr", y: "value",sort: { x: "nr" } }) + + +}; + + + document.getElementById("chartDiv").appendChild(Plot.plot(options)); } +function getCommonChartProperty(name) +{ + var propertyValue=""; + for (var i=0;i+d.A )( data ); + var height=400; + var scX = d3.scaleBand().padding( 0.2 ).round( true ) + .range( [15, 515] ).domain( histo ); + + var scY = d3.scaleLinear().range( [height, 0] ) + .domain( [0, d3.max( histo, d=>d.length ) ] ).nice(); + + var g = d3.select("#chartDiv").append("svg") + .append( "g" ).attr( "transform", "translate( 40,50 )" ) + + g.selectAll( "rect" ).data( histo ).enter() + .append( "rect" ).attr( "width", scX.bandwidth() ) + .attr( "x", scX ).attr( "y", d=>scY(d.length) ) + .attr( "height", d => height-scY(d.length) ) + .attr( "fill", "red" ).attr( "fill-opacity", 0.2 ) + .attr( "stroke", "red" ).attr( "stroke-width", 2 ) + + g.selectAll( "text" ).data( histo ).enter().append( "text" ) + .attr( "text-anchor", "middle" ) + .attr( "font-family", "sans-serif" ) + .attr( "font-size", 14 ) + .attr( "x", d => scX(d)+0.5*scX.bandwidth() ) + .attr( "y", 225 ) + .text( d=>(d.x0+d.x1)/2 ); + + g.append( "g" ).call( d3.axisLeft(scY) ); + } ); +} diff --git a/superx/xml/viz_html_chart.xsl b/superx/xml/viz_html_chart.xsl index 1331b3d..5eb779a 100644 --- a/superx/xml/viz_html_chart.xsl +++ b/superx/xml/viz_html_chart.xsl @@ -84,7 +84,8 @@ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:HtmlUtils="de.superx.util -