@graphysdk/viz-engine 1.9.0-beta.1790336418293 → 1.9.0-beta.1790336628799
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/graph-config.cjs +1 -1
- package/dist/graph-config.mjs +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/graph-config.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./annotations-Dy-Gx6J6.cjs"),s=require("./spec-builder-CQ5p2Jzs.cjs");var J=10,Q=["normal","italic","oblique"],ee=/^(\d*\.?\d+)(px|em)$/,G=/^\d*\.?\d+$/,te=1,re=1e3,oe={normal:400,bold:700},z=e=>Q.includes(e),V=e=>{const t=ee.exec(e.trim());return t===null||t[1]===void 0||t[2]===void 0?null:{value:Number.parseFloat(t[1]),unit:t[2]==="px"?"px":"em"}},Y=e=>{const t=e.trim(),r=oe[t];if(r!==void 0)return r;if(!G.test(t))return null;const o=Number.parseFloat(t);return o>=te&&o<=re?o:null},X=e=>{const t=e.trim();return G.test(t)?Number.parseFloat(t):null},x=e=>e.unit==="em"?e.value*10:e.value,K=e=>{const t=e.trim().replace(/\s*\/\s*/g,"/").split(/\s+/);let r="normal",o=400,i=0;for(;i<t.length;){const p=t[i];if(p===void 0)return null;if(p==="normal")i++;else if(z(p))r=p,i++;else{const m=Y(p);if(m===null)break;o=m,i++}}const n=t[i];if(n===void 0)return null;const[l="",c]=n.split("/"),u=V(l);if(u===null)return null;const d=c===void 0?null:X(c),v=t.slice(i+1).join(" ").trim();return v===""?null:{style:r,weight:o,size:u,family:v,...d!==null?{lineHeight:d}:{}}};function ie(e){const t=[];for(const r of e??[]){if(r.type==="shape"&&t.push(s.style.annotation.shape({fill:r.fillColor,fillAlpha:r.fillOpacity,strokeWidth:r.strokeWidth},{annotation:r.id})),r.type==="arrow"&&(t.push(s.style.annotation.arrow({...r.color===void 0?{}:{stroke:r.color},strokeWidth:a.ARROW_STROKE_WIDTHS_PX[r.thickness],dashArray:a.DASH_PRESETS.arrow[r.lineStyle]},{annotation:r.id})),r.hasStickerStyle&&t.push(s.style.annotation.arrow.outline(a.ARROW_STICKER_DECLARATIONS,{annotation:r.id}))),r.type==="difference-arrow"){const o=a.DIFFERENCE_ARROW_SIZE_DECLARATIONS[r.size];t.push(s.style.annotation.differenceArrow({...r.color===void 0?{}:{stroke:r.color},...o.arrow},{annotation:r.id}),s.style.annotation.differenceArrow.label(o.label,{annotation:r.id}))}r.type==="text"&&r.backgroundColor!==void 0&&t.push(s.style.annotation.text({fill:r.backgroundColor,...r.backgroundColorStyle==="fade"?{fillAlpha:a.TEXT_ANNOTATION_FADE_ALPHA}:{}},{annotation:r.id})),r.type==="image"&&r.opacity!==void 0&&t.push(s.style.annotation.image({alpha:r.opacity},{annotation:r.id}))}return t}function ne(e){const t=[],r=e?.defaultAnnotationShapeFill;return typeof r=="string"&&t.push(s.style.annotation.shape({fill:r})),t}function se(e){const t=e?.defaultAnnotationArrowStroke;return typeof t=="string"?{annotationArrow:t}:void 0}var ae="#%_ENCODED_%#",$=e=>{if(!e.startsWith(ae))return e;try{const{value:t}=JSON.parse(e.slice(13));return typeof t=="string"?t:e}catch{return e}},le=({annotations:e,dataset:t,mapping:r,seriesVariables:o})=>{const i=[],n=[],l=[],c=[],u=[],d=[],v=[],p=[],m={dataset:t,...ce(r,o)};for(const h of e??[])switch(h.type){case"difference-arrow":{const f=ue(h,m);f!==null&&i.push(f);break}case"shape":n.push(de(h));break;case"arrow":l.push(me(h));break;case"highlight":break;case"text":c.push(pe(h));break;case"image":u.push(fe(h));break;case"sticker":{const f=ve(h,m);f!==null&&d.push(f);break}case"tooltip":{const f=ye(h,m);if(f===null)break;f.kind==="pinnedNumber"?v.push(f.value):p.push(f.value);break}default:throw new a.InternalError({message:`Unsupported annotation type: ${h.type}`})}return{differenceArrows:i,shapes:n,arrows:l,textAnnotations:c,images:u,stickers:d,pinnedNumbers:v,comments:p}},ce=(e,t)=>{const r=a.readVariableName(e.x),o=a.readVariableName(e.group)??a.readVariableName(e.color),i=r!==null&&r!=="",n=o==="key"||t.length>=2;return{anchorVariable:i?r:o,groupIsSeriesKey:n}},ue=(e,t)=>{const r=T(t,e.start),o=T(t,e.end);return r===null||o===null?null:{id:e.id,start:r,end:o,label:e.show,labelCrossPosition:e.labelPosition}},de=e=>({id:e.id,kind:e.shape,zOrder:e.layer==="abovePlot"?"foreground":"background",region:{anchorType:"panel",x:e.x,y:e.y,width:e.width,height:e.height}}),fe=e=>({id:e.id,src:e.src,zOrder:e.layer==="abovePlot"?"foreground":"background",region:{anchorType:"panel",x:e.x,y:e.y,width:e.width,height:e.height},fit:e.fit}),pe=e=>({id:e.id,content:e.content,at:{anchorType:"panel",x:e.x,y:e.y},width:e.width,align:"top-left"}),ve=(e,t)=>{const r=T(t,e);return r===null?null:{id:e.id,at:{anchorType:"observation",...r},sticker:e.sticker}},ye=(e,t)=>{const r=T(t,e);return r===null?null:e.caption===null||e.caption===void 0?{kind:"pinnedNumber",value:{id:e.id,at:r}}:{kind:"comment",value:{id:e.id,at:r,content:e.caption}}},me=e=>({id:e.id,start:{anchorType:"panel",x:e.startX,y:e.startY},end:{anchorType:"panel",x:e.endX,y:e.endY},startArrowheadStyle:e.startArrowheadStyle,endArrowheadStyle:e.endArrowheadStyle}),T=(e,t)=>{if(!a.isDefined(t))return null;const{dataset:r,anchorVariable:o,groupIsSeriesKey:i}=e;if(o===null)return null;const n=he(t,o,r);return n===null?null:i?a.isDefined(t.columnKey)?{anchorValue:n,groupValue:$(t.columnKey)}:null:{anchorValue:n,groupValue:void 0}},he=(e,t,r)=>!a.isDefined(e.rowIndex)||!r.hasVariable(t)?null:r.getValues(t)[e.rowIndex]??null;function be({palette:e,overrides:t,ctx:r}){const o=j(e,t,r);if(o!==void 0)return{type:"styles",defaults:[s.style.geom.bar({fill:o}),s.style.geom.line({stroke:o}),s.style.geom.area({fill:o}),s.style.geom.point({fill:o}),s.style.geom.tile({fill:o})]}}function ge(e,t,r=void 0){const o=[...e?.defaults??[],...t??[]],i=[...e?.overrides??[],...r??[]];if(!(e===void 0&&o.length===0&&i.length===0))return{...e,type:"styles",defaults:o,...i.length===0?{}:{overrides:i}}}function Se(e,t){return t===void 0?e:{...e,type:"styles",tokens:{...e?.tokens,...t}}}function ke(e){return e?.highlightStyle===void 0?[]:e.highlightStyle==="gray"?[s.style.geom({saturation:0,alpha:.6},{state:"dimmed"})]:[s.style.geom({alpha:a.DEFAULT_DIMMED_ALPHA},{state:"dimmed"})]}function j(e,t,r){const o=e.type==="custom"?r.customPalettes?.[e.id]:void 0,i=t?.[1];if(i?.hex!==void 0)return i.hex;if(i?.id!==void 0){const n=o?.find(l=>l.id===i.id)?.hex;if(n!==void 0)return n}if(e.type!=="default")return e.type==="custom"?o?.[0]?.hex:a.resolvePaletteRange(e)[0]}var Ae=["lilac","neon_pink","blackberry","sun","iceland","sunset","ultraviolet","purple","ice_cream","mint","cool","fresh"],Ee="#E5E5E5",F=.1,C={light:.05,dark:.1},Te={lilac:"#C9C0F7",neon_pink:"#E04A95",blackberry:"#9F9FED",sun:"#FCDB61",iceland:"#29CDA8",sunset:"#FCDB62",ultraviolet:"#D167D8",purple:"#BBADFD",ice_cream:"#FC7E91",mint:"#25CDA5",cool:"#3F8EEB",fresh:"#A4A4EE"};function Le({appearance:e,themeOverrides:t,palette:r,overrides:o,ctx:i}){const n=j(r,o,i)??"#B84737",l=[],c=Ne(e?.border,n),u=_e(e,t,n),d=B(e?.textStyle?.body?.fontId,i.fontList),v=e?.textStyle?.body?.color,p={...u===void 0?{}:{fill:u},...c,...e?.hasRoundedCorners===!1?{cornerRadius:0}:{},...d===void 0?{}:{fontFamily:d},...typeof v=="string"?{textColor:v}:{},...e?.textScale===void 0?{}:{textScale:e.textScale}};Object.keys(p).length>0&&l.push(s.style.graph(p));const m=B(e?.textStyle?.heading?.fontId,i.fontList),h=e?.textStyle?.heading?.color;m!==void 0&&l.push(s.style.heading({fontFamily:m})),typeof h=="string"&&l.push(s.style.heading.h1({textColor:h})),typeof v=="string"&&l.push(s.style.heading.h2({textColor:v}),s.style.caption({textColor:v}),s.style.source({textColor:v}),s.style.source.link({textColor:v}));const f=t?.gridLineColor;return typeof f=="string"&&l.push(s.style.gridLine({stroke:f}),s.style.tickLine({stroke:f}),s.style.panelBorder({stroke:f})),l}function _e(e,t,r){if(e?.backgroundModifier==="tint")return{light:I(a.DEFAULT_GRAPH_BACKGROUND.light,r,C.light),dark:I(a.DEFAULT_GRAPH_BACKGROUND.dark,r,C.dark)};const o=t?.graphBackground;return typeof o=="string"?o:void 0}function Ne(e,t){if(!e?.style)return{};if(e.style==="none")return{strokeWidth:0};const r=e.width??0;if(e.style==="gray")return{stroke:Ee,strokeWidth:r};if(e.style==="preset")return e.color===void 0||!Ve(e.color)?{}:{stroke:Te[e.color],strokeWidth:r};if(e.style==="custom")return e.color===void 0?{}:{stroke:e.color,strokeWidth:r};const o=e.color??t;return e.style==="tinted"?{stroke:{light:xe(o,F),dark:De(o,F)},strokeWidth:r}:{stroke:o,strokeWidth:r}}function B(e,t){if(!(e===void 0||t===void 0))return t.find(r=>r.id===e)?.fontFamily}var Ve=e=>Ae.includes(e),I=(e,t,r)=>`color-mix(in srgb, ${e}, ${t} ${r*100}%)`,xe=(e,t)=>`hsl(from ${e} h s calc(l * ${1+t}))`,De=(e,t)=>`hsl(from ${e} h s calc(l * ${1-t}))`,we={x:"top",y:"left"},Re=new Set(["pie","donut"]);function Pe(e,t=!1,r){return s.config({legend:Fe(e.legend,r?.legend),axes:Be(e.axes,t,r?.axes),headline:Ie(e),numberFormat:He(e.appearance),content:Ue(e.content)}).config}function Fe(e,t){if(!(!e&&!t))return{...e?{position:e.position}:void 0,...t}}function H(e,t,r){return!t&&r===void 0?{}:{...t?.isHidden!==void 0?{isVisible:!t.isHidden}:void 0,...t?.label!==void 0?{label:t.label}:void 0,...t?.isReversed?{position:we[e]}:void 0,...t?.tickDisplayMode?{ticks:{mode:t.tickDisplayMode}}:void 0,...r!==void 0?{grid:{isVisible:r}}:void 0}}function Ce(e){return{...e.label!==void 0?{label:e.label}:void 0}}function Be(e,t=!1,r){if(!e&&!r)return;const o=H("x",e?.x,e?.showGridLines),i=H("y",e?.y,e?.showGridLines);return{x:{...t?i:o,...r?.x},y:{...t?o:i,...r?.y},...e?.y2?{ySecondary:Ce(e.y2)}:void 0}}function Ie(e){const{headlineNumbers:t,options:r,type:o}=e,i=o!==void 0&&Re.has(o)?r?.pieTotalPosition:void 0;if(t===void 0&&i===void 0)return;const n={};return t?.show!==void 0&&(n.show=t.show),t?.compareWith!==void 0&&(n.compareWith=t.compareWith),t?.size!==void 0&&(n.size=t.size),i!==void 0&&(n.show="total",n.position=i==="center"?"center":"above"),n}function He(e){if(e?.numberFormat)return{decimals:e.numberFormat.decimalPlaces,abbreviation:e.numberFormat.abbreviation}}function Ue(e){if(!e)return;const t={};e.title!==void 0&&(t.title=e.title),e.isTitleHidden!==void 0&&(t.isTitleVisible=!e.isTitleHidden),e.subtitle!==void 0&&(t.subtitle=e.subtitle),e.isSubtitleHidden!==void 0&&(t.isSubtitleVisible=!e.isSubtitleHidden),e.caption!==void 0&&(t.caption=e.caption),e.isCaptionHidden!==void 0&&(t.isCaptionVisible=!e.isCaptionHidden);const r=We(e.source);return r!==void 0&&(t.source=r),e.isSourceHidden!==void 0&&(t.isSourceVisible=!e.isSourceHidden),e.brandMark!==void 0&&(t.brandMark={...e.brandMark},e.brandMark.enabled!==void 0&&(t.isBrandMarkVisible=e.brandMark.enabled)),e.isBrandMarkHidden!==void 0&&e.brandMark?.enabled===void 0&&(t.isBrandMarkVisible=!e.isBrandMarkHidden),t}function We(e){if(!e)return;const t={};return e.label!==void 0&&(t.label=e.label),e.url!==void 0&&(t.url=e.url),Object.keys(t).length===0?void 0:t}var D=a.prefixInternalVariable("constantY"),Me=.15,Oe=(e,t,r,o)=>qe[t](e,r,o),w=e=>{const t=a.inferXVariable(e),{numeric:r}=e.groupVariableNamesByType(),o=r.filter(i=>i!==t);return o.length<=1?{transforms:[],mapping:{x:t,y:o[0]??""},seriesVariables:o}:{transforms:[s.transform.reshape({keep:[t],keyName:"key",valueName:a.DEFAULT_RESHAPE_VALUE_NAME})],mapping:{x:t,y:a.DEFAULT_RESHAPE_VALUE_NAME,color:"key"},seriesVariables:o}},R=e=>{const t=e.appearance?.seriesStyles;if(!t||e.seriesVariables.length===0)return{mapping:{},scales:[]};if(!e.seriesVariables.some(o=>a.isDefined(t[o]?.lineStyle)))return{mapping:{},scales:[]};if(e.seriesVariables.length===1){const o=e.seriesVariables[0];if(!o)return{mapping:{},scales:[]};const i=t[o]?.lineStyle;return i?{mapping:{lineType:{value:i}},scales:[]}:{mapping:{},scales:[]}}const r=e.seriesVariables.map(o=>t[o]?.lineStyle??"solid");return{mapping:{lineType:"key"},scales:[s.scale.lineType.discrete({domain:e.seriesVariables,range:r})]}},Ge=e=>{const{categorical:t,temporal:r,numeric:o}=e.groupVariableNamesByType(),i=o[0];if(!a.isDefined(i))throw new a.UserInputError({code:"INVALID_DATA_SHAPE",message:"No first numeric variable found",suggestion:"Provide at least one numeric column for this chart type."});const n=o.slice(1);return n.length===0?{...q(),mapping:{x:i,y:D,label:t[0]}}:n.length===1?{transforms:[],scales:[],mapping:{x:i,y:n[0]??"",label:t[0]}}:{transforms:[s.transform.reshape({keep:[i,...t,...r],keyName:"key",valueName:a.DEFAULT_RESHAPE_VALUE_NAME})],scales:[],mapping:{x:i,y:a.DEFAULT_RESHAPE_VALUE_NAME,label:t[0],color:"key"}}},q=()=>({transforms:[s.transform.constant({variableName:D,type:"categorical",value:""})],scales:[s.scale.y.discrete()]}),ze=e=>{const{categorical:t,temporal:r,numeric:o}=e.groupVariableNamesByType();let i,n;if(a.isDefined(t[0])&&a.isDefined(o[0]))i=t[0],n=o[0];else if(a.isDefined(r[0])&&a.isDefined(o[0]))i=r[0],n=o[0];else if(a.isDefined(o[0])&&a.isDefined(o[1]))i=o[0],n=o[1];else throw new a.UserInputError({code:"INVALID_DATA_SHAPE",message:"No label or value variable found",suggestion:"Provide a label column and a numeric value column for this chart type."});return{x:"",y:n,color:i}},Z=(e,t,r)=>{const{transforms:o,mapping:i,seriesVariables:n}=w(e.dataset),l=R({appearance:r,seriesVariables:n}),c=n.length<=1,u=[a.geom.line({params:{curve:t?.isSmoothLine?"smooth":"linear",missingValues:t?.missingValues}})],d=[];return c&&(t?.showFill??!0)&&d.push(s.style.geom.line({fillAlpha:Me})),typeof t?.lineThickness=="number"&&d.push(s.style.geom.line({strokeWidth:t.lineThickness})),t?.showPoints&&(u.push(a.geom.point({interactive:!1})),typeof t.pointSize=="number"&&d.push(s.style.geom.point({size:t.pointSize}))),{layers:u,coords:s.coord.cartesian(),mapping:{...i,...l.mapping},scales:l.scales,transforms:o,seriesVariables:n,styleDefaults:d}},Ye=(e,t,r)=>{const{transforms:o,mapping:i,seriesVariables:n}=w(e.dataset),l=R({appearance:r,seriesVariables:n}),c=[a.geom.area({position:"stack",params:{curve:t?.isSmoothLine?"smooth":"linear",missingValues:t?.missingValues}})],u=[];return typeof t?.lineThickness=="number"&&u.push(s.style.geom.area({strokeWidth:t.lineThickness})),t?.showPoints&&(c.push(a.geom.point({position:"stack",interactive:!1})),typeof t.pointSize=="number"&&u.push(s.style.geom.point({size:t.pointSize}))),{layers:c,coords:s.coord.cartesian(),mapping:{...i,...l.mapping},scales:l.scales,transforms:o,seriesVariables:n,styleDefaults:u}},S=(e,t,r,o,i)=>{const{transforms:n,mapping:l,seriesVariables:c}=w(e.dataset),u=[...n];if(o?.sortBars){const d=a.readVariableName(l.y);d!==null&&d!==""&&u.push(s.transform.sort({variableName:d,direction:"desc"}))}if(!i?.useSingleColorForBars){const d=a.inferXVariable(e.dataset),{numeric:v}=e.dataset.groupVariableNamesByType();v.filter(p=>p!==d).length===1&&e.dataset.getType(d)==="categorical"&&(l.color=d)}return{layers:[a.geom.bar({position:t})],coords:r,mapping:l,scales:[],transforms:u,seriesVariables:c}},U=(e,t)=>({layers:[a.geom.bar({position:"fill"})],coords:s.coord.polar({theta:"y",innerRadius:t==="donut"?.55:0}),mapping:ze(e.dataset),scales:[],seriesVariables:[]}),Xe=e=>{const{transforms:t,scales:r,mapping:o}=Ge(e.dataset);return{layers:[a.geom.point()],coords:s.coord.cartesian(),mapping:o,scales:r,transforms:t,seriesVariables:[]}},Ke=e=>{const{numeric:t,categorical:r}=e.dataset.groupVariableNamesByType(),o=t[0];if(!a.isDefined(o))throw new a.UserInputError({code:"INVALID_DATA_SHAPE",message:"No first numeric variable found",suggestion:"Provide at least one numeric column for this chart type."});const i=a.isDefined(t[1])?{transforms:[],scales:[]}:q(),n={x:o,y:t[1]??D,size:t[2],label:r[0]},l=[...i.scales];return a.isDefined(n.size)&&l.push(s.scale.size.continuous()),{layers:[a.geom.point()],coords:s.coord.cartesian(),mapping:n,scales:l,transforms:i.transforms,seriesVariables:[]}},$e=e=>{const t=a.inferXVariable(e.dataset),{numeric:r}=e.dataset.groupVariableNamesByType(),o=r.filter(i=>i!==t);return{transforms:[s.transform.reshape({keep:[t],keyName:"key",valueName:a.DEFAULT_RESHAPE_VALUE_NAME}),s.transform.filter({variableName:a.DEFAULT_RESHAPE_VALUE_NAME,operator:"neq",value:null})],layers:[a.geom.tile()],coords:s.coord.cartesian(),mapping:{x:t,y:"key",color:a.DEFAULT_RESHAPE_VALUE_NAME},scales:[s.scale.color.continuous()],seriesVariables:o,config:{legend:{position:"none"},axes:{x:{position:"top"},y:{position:"left"}}}}},L=(e,t,r)=>{const o=r?.seriesStyles?.[e]?.lineStyle;return a.geom.line({transforms:[s.transform.constant({variableName:a.LAYER_LABEL_VARIABLES.line,type:"categorical",value:e})],aes:{y:e,color:a.LAYER_LABEL_VARIABLES.line,...o?{lineType:{value:o}}:{}},...t?{yScaleType:"secondary"}:void 0})},je=(e,t,r)=>{const{numeric:o}=e.dataset.groupVariableNamesByType(),i=a.inferXVariable(e.dataset),n=a.readFoldKeepVariables(e.dataset,i),l=o.filter(f=>f!==i),c=s.COMBO_BAR_POSITIONS[t?.comboType??"grouped-bars"],u=c===null;if(l.length===1)return u?Z(e,t,r):S(e,"dodge",s.coord.cartesian(),t,r);const d=e.axes?.hasDualYAxis===!0,v=u?[]:l.slice(0,-1),p=u?l:l.slice(-1),m=[],h=[];if(c!==null&&v.length>0){const f=v.length===1?v[0]:null;a.isDefined(f)?m.push(a.geom.bar({transforms:[s.transform.constant({variableName:a.LAYER_LABEL_VARIABLES.bar,type:"categorical",value:f})],aes:{y:f,color:a.LAYER_LABEL_VARIABLES.bar},position:c})):m.push(a.geom.bar({transforms:[s.transform.reshape({keep:n,reshape:v,keyName:"key",valueName:a.DEFAULT_RESHAPE_VALUE_NAME})],aes:{y:a.DEFAULT_RESHAPE_VALUE_NAME,color:"key"},position:c}))}if(u&&p.length>=2){const f=d?p.slice(0,-1):p,P=f.length===1?f[0]:null;if(a.isDefined(P))m.push(L(P,!1,r));else{const k=R({appearance:r,seriesVariables:f});m.push(a.geom.line({transforms:[s.transform.reshape({keep:n,reshape:f,keyName:"key",valueName:a.DEFAULT_RESHAPE_VALUE_NAME})],aes:{y:a.DEFAULT_RESHAPE_VALUE_NAME,color:"key",...k.mapping}})),h.push(...k.scales)}if(d){const k=p[p.length-1];a.isDefined(k)&&m.push(L(k,!0,r))}}else for(const f of p)m.push(L(f,d,r));return{layers:m,coords:s.coord.cartesian(),mapping:{x:i},scales:h,seriesVariables:l}},E=e=>()=>{throw new a.UserInputError({code:"UNSUPPORTED_GRAPH_TYPE",message:`Unsupported graph type: ${e}`,context:{requested:e}})},qe={line:(e,t,r)=>Z(e,t,r),areaStacked:(e,t,r)=>Ye(e,t,r),bar:(e,t,r)=>S(e,"dodge",s.coord.flip(),t,r),barStacked:(e,t,r)=>S(e,"stack",s.coord.flip(),t,r),barStackedFill:(e,t,r)=>S(e,"fill",s.coord.flip(),t,r),column:(e,t,r)=>S(e,"dodge",s.coord.cartesian(),t,r),columnStacked:(e,t,r)=>S(e,"stack",s.coord.cartesian(),t,r),columnStackedFill:(e,t,r)=>S(e,"fill",s.coord.cartesian(),t,r),pie:e=>U(e,"pie"),donut:e=>U(e,"donut"),scatter:e=>Xe(e),bubble:e=>Ke(e),combo:(e,t,r)=>je(e,t,r),funnel:E("funnel"),heatmap:e=>$e(e),waterfall:E("waterfall"),mekko:E("mekko"),table:E("table")},Ze=new a.TransformRegistry,Je=["key",a.prefixInternalVariable("lineSeriesLabel"),a.prefixInternalVariable("barSeriesLabel")];function Qe(e){const t=e.annotations??[],r=tt(e.mapping),o=ot(e.dataset,e.transforms,e.layers),i=[];for(const n of t){if(n.type!=="highlight")continue;const l=rt({annotation:n,rowIdentityVariable:r,dataset:e.dataset,compiledVariableNames:o});l!==null&&i.push({type:"highlight",id:n.id,predicate:l,scope:et(n.highlight,e.mapping)})}return i}function et(e,t){const r=a.readVariableName(t.x);return!(r!==null&&r!=="")&&e==="x-value"?"series":e}function tt(e){const t=a.readVariableName(e.x);return t!==null&&t!==""?t:a.readVariableName(e.color)}function rt({annotation:e,rowIdentityVariable:t,dataset:r,compiledVariableNames:o}){switch(e.highlight){case"x-value":return W(e,t,r);case"series":return M(e,o);case"data-point":{const i=W(e,t,r),n=M(e,o);return i===null&&n===null?null:i===null?n:n===null?i:{and:[i,n]}}}}function W(e,t,r){if(t===null)return null;const o=it(e,t,r);return o===null?null:{variable:t,eq:o}}function M(e,t){const r=e.columnKey;if(!a.isDefined(r))return null;const o=Je.filter(i=>t.includes(i));return o.length===0?null:{or:o.map(i=>({variable:i,eq:r}))}}function ot(e,t,r){const o=[...e.getVariableNames()],i=n=>{for(const l of n){const{getIntroducedVariables:c}=Ze.get(l.transformType),u=c?.(l);u&&o.push(...u)}};i(t);for(const n of r)i(n.transforms??[]);return o}function it(e,t,r){return e.rowValue!==void 0?e.rowValue:!a.isDefined(e.rowIndex)||!r.getVariableNames().includes(t)?null:r.getValues(t)[e.rowIndex]??null}function nt(e,t,r){const{colorScheme:o,customPalettes:i}=r;if(i&&e&&i[e])return{type:"custom",id:e};if(e?.startsWith("preset:pastel"))return{type:"pastel",variant:_(t)};if(e?.startsWith("preset:graphy"))return{type:"graphy",variant:_(t)};if(e?.startsWith("preset:mono:")){const n=e.slice(12);if(st(n))return{type:"mono",base:n,variant:o}}if(e?.startsWith("preset:neon:")){const n=e.slice(12);if(at(n))return{type:"neon",base:n,variant:_(t)}}return{type:"default"}}function _(e){if(e==="waterfall")return"waterfall"}function st(e){return a.MONO_BASES.includes(e)}function at(e){return a.NEON_BASES.includes(e)}function lt({axes:e,palette:t,overrides:r,isFlipped:o}){const i=[];return i.push(O("x",o?e?.y:e?.x)),i.push(O("y",o?e?.x:e?.y)),i.push(s.scale.color.palette({palette:t,overrides:r})),i}function O(e,t){return t?.scaleType==="logarithmic"||t?.min!==void 0||t?.max!==void 0?t.scaleType==="logarithmic"?s.scale[e].log({domainMin:t.min??void 0,domainMax:t.max??void 0}):s.scale[e]({domainMin:t.min??void 0,domainMax:t.max??void 0}):s.scale[e]()}function ct(e){if(!e)return;const t={};for(const[r,o]of Object.entries(e)){if(!r.startsWith("series"))continue;const i=Number.parseInt(r.slice(6));if(Number.isNaN(i))continue;const n={hex:o.customColor,id:o.paletteColorId};(n.hex!==void 0||n.id!==void 0)&&(t[i]=n)}return Object.keys(t).length>0?t:void 0}function ut(e){const t=[],r=g(e?.fontAxisLabel);r!==void 0&&t.push(s.style.axisLabel(r));const o=St(e);o!==void 0&&t.push(s.style.tickLabel(o));const i=g(e?.fontGoalLineLabel);return i!==void 0&&t.push(s.style.geom.rule.label(i)),t.push(...ht(e)),t.push(...dt(e)),t.push(...vt(e)),t.push(...bt(e)),t}function dt(e){const t=[],r=pt(e);r!==void 0&&t.push(s.style.tooltip(r));const o=A(g(e?.fontTooltipHeading),y(e?.tooltipHeadingTextColor));o!==void 0&&t.push(s.style.tooltip.heading(o));const i=g(e?.fontTooltipLabel),n=A(i,y(e?.tooltipLabelTextColor));n!==void 0&&t.push(s.style.tooltip.label(n));const l=A(i,y(e?.tooltipValueTextColor));l!==void 0&&t.push(s.style.tooltip.value(l));const c=y(e?.tooltipPrimaryRowColor);c!==void 0&&t.push(s.style.tooltip.primaryRow({fill:c}));const u=ft(e);return u!==void 0&&t.push(s.style.annotation.pinnedNumber.label(u),s.style.annotation.comment.label(u)),t}var ft=e=>{const t=y(e?.tooltipBackground),r=y(e?.tooltipBorderColor),o={...A(g(e?.fontMiniTooltipLabel),y(e?.tooltipValueTextColor)),...t===void 0?{}:{fill:t},...r===void 0?{}:{stroke:r}};return Object.keys(o).length===0?void 0:o},pt=e=>{const t=y(e?.tooltipBackground),r=y(e?.tooltipBorderColor),o=b(e?.tooltipBorderWidth),i=b(e?.tooltipBorderRadius),n=b(e?.tooltipPaddingBlock),l=b(e?.tooltipPaddingInline),c=typeof e?.tooltipShadow=="string"?gt(e.tooltipShadow)??void 0:void 0,u={...t===void 0?{}:{fill:t},...r===void 0?{}:{stroke:r},...o===void 0?{}:{strokeWidth:o},...i===void 0?{}:{cornerRadius:i},...n===void 0?{}:{paddingBlock:n},...l===void 0?{}:{paddingInline:l},...c===void 0?{}:{shadow:c}};return Object.keys(u).length===0?void 0:u};function vt(e){const t=[],r=b(e?.legendItemGap);r!==void 0&&t.push(s.style.legend({gap:r}));const o=g(e?.fontLegendLabel),i=y(e?.legendTextColor),n=A(o,i),l=yt(e,n);l!==void 0&&t.push(s.style.legendItem(l));const c=mt(e);return c!==void 0&&t.push(s.style.legendItem.swatch({size:c})),n!==void 0&&t.push(s.style.directLabel(n)),t}var yt=(e,t)=>{const r=y(e?.legendBackground),o=y(e?.legendBorderColor),i=b(e?.legendPillBorderWidth),n=b(e?.legendPillPaddingInline),l=b(e?.legendPillPaddingBlock),c={...t,...r===void 0?{}:{fill:r},...o===void 0?{}:{stroke:o},...i===void 0?{}:{strokeWidth:i},...n===void 0?{}:{paddingInline:n},...l===void 0?{}:{paddingBlock:l}};return Object.keys(c).length===0?void 0:c},mt=e=>{const t=b(e?.legendSwatchWidth);return b(e?.legendSwatchHeight)??t},A=(e,t)=>{if(!(e===void 0&&t===void 0))return{...e,...t===void 0?{}:{textColor:t}}};function ht(e){const t=y(e?.dataLabelTextColor),r=y(e?.stackTotalTextColor),o=[["observation",g(e?.fontDataLabel),t],["category",g(e?.fontCategoryLabel),t],["aggregate",g(e?.fontStackTotal),r]],i=[];for(const[d,v,p]of o)v===void 0&&p===void 0||i.push(s.style.dataLabel[d]({...v,...p===void 0?{}:{textColor:p}}));const n=y(e?.dataLabelInsideTextColor);n!==void 0&&(i.push(s.style.dataLabel.observation.inside({textColor:n})),i.push(s.style.dataLabel.category.inside({textColor:n})));const l=y(e?.dataLabelOutsideBackground);l!==void 0&&(i.push(s.style.dataLabel.observation.outside({fill:l})),i.push(s.style.dataLabel.category.outside({fill:l})));const c=y(e?.stackTotalBackground),u=y(e?.stackTotalStroke);return(c!==void 0||u!==void 0)&&i.push(s.style.dataLabel.aggregate({...c===void 0?{}:{fill:c},...u===void 0?{}:{stroke:u}})),i}function bt(e){const t=[],r=y(e?.trendPositiveColor),o=y(e?.trendNegativeColor),i=y(e?.trendNeutralColor);return r!==void 0&&t.push(s.style.headlineItem.trend.up({textColor:r})),o!==void 0&&t.push(s.style.headlineItem.trend.down({textColor:o})),i!==void 0&&t.push(s.style.headlineItem.trend.flat({textColor:i})),t}function y(e){if(!(typeof e!="string"||e.trim().length===0))return e}function gt(e){const t=e.trim();if(t==="none")return"none";const r=t.split(/\s+/),o=N(r[0]),i=N(r[1]),n=N(r[2]),l=r.slice(3).join(" ");return o===null||i===null||n===null||l.length===0?null:{offsetX:o,offsetY:i,blur:n,color:l}}var N=e=>{if(e===void 0)return null;const t=/^(-?\d*\.?\d+)(px)?$/.exec(e);if(t?.[1]===void 0)return null;const r=Number.parseFloat(t[1]);return Number.isFinite(r)?r:null};function g(e){if(typeof e!="string")return;const t=K(e);if(t!==null)return{fontFamily:t.family,fontSize:x(t.size),fontWeight:t.weight,...t.lineHeight===void 0?{}:{lineHeight:t.lineHeight}}}function St(e){const t=g(e?.fontTickLabel),r=b(e?.tickLabelOffset);if(!(t===void 0&&r===void 0))return{...t,...r===void 0?{}:{offset:r}}}function b(e){if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(typeof e!="string")return;const t=V(e);return t===null?void 0:x(t)}var kt=new Set(["column","columnStacked","columnStackedFill","bar","barStacked","barStackedFill","line","areaStacked","scatter","bubble","funnel","combo"]),At=new Set(["column","columnStacked","columnStackedFill","bar","barStacked","barStackedFill","line","areaStacked","combo"]);function Et(e,t,r={}){return Tt(a.parseDataset(t),e,r)}function Tt(e,t,r={}){const o=t.type??"column",i=Oe({dataset:e,axes:t.axes},o,t.options??void 0,t.appearance??void 0),n=i.coords.coordType==="flip",l=i.transforms??[],c=nt(t.appearance?.paletteId,o,r),u=ct(t.appearance?.seriesStyles);return{mapping:i.mapping,layers:Lt(o,t,i.layers,i.coords,i.mapping,i.seriesVariables),scales:[...lt({axes:t.axes,palette:c,overrides:u,isFlipped:n}),...i.scales],styles:Se(ge(be({palette:c,overrides:u,ctx:r}),[...i.styleDefaults??[],...ke(t.appearance??void 0),...Le({appearance:t.appearance??void 0,themeOverrides:t.themeOverrides,palette:c,overrides:u,ctx:r}),...ut(t.themeOverrides),...ne(t.themeOverrides)],ie(t.annotations)),se(t.themeOverrides)),transforms:l,highlights:Qe({annotations:t.annotations,dataset:e,mapping:i.mapping,transforms:l,layers:i.layers}),annotations:le({annotations:t.annotations,dataset:e,mapping:i.mapping,seriesVariables:i.seriesVariables}),coords:i.coords,config:Pe(t,n,i.config)}}function Lt(e,t,r,o,i,n){const l=Dt(t.dataLabels),c=l===void 0?r:r.filter(d=>d.interactive!==!1).map(d=>({...d,dataLabels:{...l,...d.dataLabels}})),u=t.axes?.hasDualYAxis??!1;return[...c,..._t({type:e,trendline:t.referenceLines?.trendline,coords:o,mapping:i}),...Nt({type:e,hasDualYAxis:u,goalLine:t.referenceLines?.goalLine,coords:o}),...xt({type:e,hasDualYAxis:u,averageLine:t.referenceLines?.averageLine,coords:o,mapping:i,seriesVariables:n})]}function _t({type:e,trendline:t,coords:r,mapping:o}){return t===void 0?[]:kt.has(e)?r.coordType==="polar"?[]:o.y===void 0?[]:[a.geom.line({aes:{lineType:{value:"dashed"}},stat:s.stat.smooth({method:t}),interactive:!1})]:[]}function Nt({type:e,hasDualYAxis:t,goalLine:r,coords:o}){if(!Vt(r))return[];if(o.coordType==="polar")return[];const i=o.coordType==="flip"?"end":"start";return[a.geom.rule({aes:{y:{value:r.target}},params:{labelPosition:i,label:r.label??"Goal"},yScaleType:e==="combo"&&t?"secondary":"primary",interactive:!1})]}function Vt(e){return e!==void 0&&Number.isFinite(e.target)}function xt({type:e,hasDualYAxis:t,averageLine:r,coords:o,mapping:i,seriesVariables:n}){if(r===void 0)return[];if(!At.has(e))return[];if(o.coordType==="polar")return[];const l=$(r.columnKey);if(!n.includes(l))return[];const c=i.color==="key",u=c?a.DEFAULT_RESHAPE_VALUE_NAME:l,d=c?[s.transform.filter({variableName:"key",operator:"eq",value:l})]:[];return[a.geom.rule({aes:{y:u,color:void 0,group:void 0,lineType:void 0},stat:s.stat.mean(),transforms:d,params:{label:"Average",labelPosition:o.coordType==="flip"?"end":"start"},yScaleType:e==="combo"&&t?"secondary":"primary",interactive:!1})]}function Dt(e){if(!e)return;const t={};return e.showDataLabels!==void 0&&(t.showDataLabels=e.showDataLabels),e.dataLabelFormat!==void 0&&(t.format=e.dataLabelFormat),e.showStackTotals!==void 0&&(t.showStackTotals=e.showStackTotals),e.showCategoryLabels!==void 0&&(t.showCategoryLabels=e.showCategoryLabels),Object.keys(t).length===0?void 0:t}var wt=[.8,1,1.2,1.4,1.6,1.8,2,2.5,3,4];exports.CHART_TEXT_SCALES=wt;exports.ROOT_FONT_SIZE_PX=J;exports.convertGraphConfig=Et;exports.isFontStyle=z;exports.parseFontLength=V;exports.parseFontShorthand=K;exports.parseFontWeight=Y;exports.parseUnitlessLineHeight=X;exports.toPixels=x;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./annotations-Dy-Gx6J6.cjs"),s=require("./spec-builder-CQ5p2Jzs.cjs");var J=10,Q=["normal","italic","oblique"],ee=/^(\d*\.?\d+)(px|em)$/,G=/^\d*\.?\d+$/,te=1,re=1e3,oe={normal:400,bold:700},z=e=>Q.includes(e),V=e=>{const t=ee.exec(e.trim());return t===null||t[1]===void 0||t[2]===void 0?null:{value:Number.parseFloat(t[1]),unit:t[2]==="px"?"px":"em"}},Y=e=>{const t=e.trim(),r=oe[t];if(r!==void 0)return r;if(!G.test(t))return null;const o=Number.parseFloat(t);return o>=te&&o<=re?o:null},X=e=>{const t=e.trim();return G.test(t)?Number.parseFloat(t):null},x=e=>e.unit==="em"?e.value*10:e.value,K=e=>{const t=e.trim().replace(/\s*\/\s*/g,"/").split(/\s+/);let r="normal",o=400,i=0;for(;i<t.length;){const p=t[i];if(p===void 0)return null;if(p==="normal")i++;else if(z(p))r=p,i++;else{const m=Y(p);if(m===null)break;o=m,i++}}const n=t[i];if(n===void 0)return null;const[l="",c]=n.split("/"),u=V(l);if(u===null)return null;const d=c===void 0?null:X(c),v=t.slice(i+1).join(" ").trim();return v===""?null:{style:r,weight:o,size:u,family:v,...d!==null?{lineHeight:d}:{}}};function ie(e){const t=[];for(const r of e??[]){if(r.type==="shape"&&t.push(s.style.annotation.shape({fill:r.fillColor,fillAlpha:r.fillOpacity,strokeWidth:r.strokeWidth},{annotation:r.id})),r.type==="arrow"&&(t.push(s.style.annotation.arrow({...r.color===void 0?{}:{stroke:r.color},strokeWidth:a.ARROW_STROKE_WIDTHS_PX[r.thickness],dashArray:a.DASH_PRESETS.arrow[r.lineStyle]},{annotation:r.id})),r.hasStickerStyle&&t.push(s.style.annotation.arrow.outline(a.ARROW_STICKER_DECLARATIONS,{annotation:r.id}))),r.type==="difference-arrow"){const o=a.DIFFERENCE_ARROW_SIZE_DECLARATIONS[r.size];t.push(s.style.annotation.differenceArrow({...r.color===void 0?{}:{stroke:r.color},...o.arrow},{annotation:r.id}),s.style.annotation.differenceArrow.label(o.label,{annotation:r.id}))}r.type==="text"&&r.backgroundColor!==void 0&&t.push(s.style.annotation.text({fill:r.backgroundColor,...r.backgroundColorStyle==="fade"?{fillAlpha:a.TEXT_ANNOTATION_FADE_ALPHA}:{}},{annotation:r.id})),r.type==="image"&&r.opacity!==void 0&&t.push(s.style.annotation.image({alpha:r.opacity},{annotation:r.id}))}return t}function ne(e){const t=[],r=e?.defaultAnnotationShapeFill;return typeof r=="string"&&t.push(s.style.annotation.shape({fill:r})),t}function se(e){const t=e?.defaultAnnotationArrowStroke;return typeof t=="string"?{annotationArrow:t}:void 0}var ae="#%_ENCODED_%#",$=e=>{if(!e.startsWith(ae))return e;try{const{value:t}=JSON.parse(e.slice(13));return typeof t=="string"?t:e}catch{return e}},le=({annotations:e,dataset:t,mapping:r,seriesVariables:o})=>{const i=[],n=[],l=[],c=[],u=[],d=[],v=[],p=[],m={dataset:t,...ce(r,o)};for(const h of e??[])switch(h.type){case"difference-arrow":{const f=ue(h,m);f!==null&&i.push(f);break}case"shape":n.push(de(h));break;case"arrow":l.push(me(h));break;case"highlight":break;case"text":c.push(pe(h));break;case"image":u.push(fe(h));break;case"sticker":{const f=ve(h,m);f!==null&&d.push(f);break}case"tooltip":{const f=ye(h,m);if(f===null)break;f.kind==="pinnedNumber"?v.push(f.value):p.push(f.value);break}default:throw new a.InternalError({message:`Unsupported annotation type: ${h.type}`})}return{differenceArrows:i,shapes:n,arrows:l,textAnnotations:c,images:u,stickers:d,pinnedNumbers:v,comments:p}},ce=(e,t)=>{const r=a.readVariableName(e.x),o=a.readVariableName(e.group)??a.readVariableName(e.color),i=r!==null&&r!=="",n=o==="key"||t.length>=2;return{anchorVariable:i?r:o,groupIsSeriesKey:n}},ue=(e,t)=>{const r=T(t,e.start),o=T(t,e.end);return r===null||o===null?null:{id:e.id,start:r,end:o,label:e.show,labelCrossPosition:e.labelPosition}},de=e=>({id:e.id,kind:e.shape,zOrder:e.layer==="abovePlot"?"foreground":"background",region:{anchorType:"panel",x:e.x,y:e.y,width:e.width,height:e.height}}),fe=e=>({id:e.id,src:e.src,zOrder:e.layer==="abovePlot"?"foreground":"background",region:{anchorType:"panel",x:e.x,y:e.y,width:e.width,height:e.height},fit:e.fit}),pe=e=>({id:e.id,content:e.content,at:{anchorType:"panel",x:e.x,y:e.y},width:e.width,align:"top-left"}),ve=(e,t)=>{const r=T(t,e);return r===null?null:{id:e.id,at:{anchorType:"observation",...r},sticker:e.sticker}},ye=(e,t)=>{const r=T(t,e);return r===null?null:e.caption===null||e.caption===void 0?{kind:"pinnedNumber",value:{id:e.id,at:r}}:{kind:"comment",value:{id:e.id,at:r,content:e.caption}}},me=e=>({id:e.id,start:{anchorType:"panel",x:e.startX,y:e.startY},end:{anchorType:"panel",x:e.endX,y:e.endY},startArrowheadStyle:e.startArrowheadStyle,endArrowheadStyle:e.endArrowheadStyle}),T=(e,t)=>{if(!a.isDefined(t))return null;const{dataset:r,anchorVariable:o,groupIsSeriesKey:i}=e;if(o===null)return null;const n=he(t,o,r);return n===null?null:i?a.isDefined(t.columnKey)?{anchorValue:n,groupValue:$(t.columnKey)}:null:{anchorValue:n,groupValue:void 0}},he=(e,t,r)=>!a.isDefined(e.rowIndex)||!r.hasVariable(t)?null:r.getValues(t)[e.rowIndex]??null;function be({palette:e,overrides:t,ctx:r}){const o=j(e,t,r);if(o!==void 0)return{type:"styles",defaults:[s.style.geom.bar({fill:o}),s.style.geom.line({stroke:o}),s.style.geom.area({fill:o}),s.style.geom.point({fill:o}),s.style.geom.tile({fill:o})]}}function ge(e,t,r=void 0){const o=[...e?.defaults??[],...t??[]],i=[...e?.overrides??[],...r??[]];if(!(e===void 0&&o.length===0&&i.length===0))return{...e,type:"styles",defaults:o,...i.length===0?{}:{overrides:i}}}function Se(e,t){return t===void 0?e:{...e,type:"styles",tokens:{...e?.tokens,...t}}}function ke(e){return e?.highlightStyle===void 0?[]:e.highlightStyle==="gray"?[s.style.geom({saturation:0,alpha:.6},{state:"dimmed"})]:[s.style.geom({alpha:a.DEFAULT_DIMMED_ALPHA},{state:"dimmed"})]}function j(e,t,r){const o=e.type==="custom"?r.customPalettes?.[e.id]:void 0,i=t?.[1];if(i?.hex!==void 0)return i.hex;if(i?.id!==void 0){const n=o?.find(l=>l.id===i.id)?.hex;if(n!==void 0)return n}if(e.type!=="default")return e.type==="custom"?o?.[0]?.hex:a.resolvePaletteRange(e)[0]}var Ae=["lilac","neon_pink","blackberry","sun","iceland","sunset","ultraviolet","purple","ice_cream","mint","cool","fresh"],Ee="#E5E5E5",F=.1,C={light:.05,dark:.1},Te={lilac:"#C9C0F7",neon_pink:"#E04A95",blackberry:"#9F9FED",sun:"#FCDB61",iceland:"#29CDA8",sunset:"#FCDB62",ultraviolet:"#D167D8",purple:"#BBADFD",ice_cream:"#FC7E91",mint:"#25CDA5",cool:"#3F8EEB",fresh:"#A4A4EE"};function Le({appearance:e,themeOverrides:t,palette:r,overrides:o,ctx:i}){const n=j(r,o,i)??"#B84737",l=[],c=Ne(e?.border,n),u=_e(e,t,n),d=B(e?.textStyle?.body?.fontId,i.fontList),v=e?.textStyle?.body?.color,p={...u===void 0?{}:{fill:u},...c,...e?.hasRoundedCorners===!1?{cornerRadius:0}:{},...d===void 0?{}:{fontFamily:d},...typeof v=="string"?{textColor:v}:{},...e?.textScale===void 0?{}:{textScale:e.textScale}};Object.keys(p).length>0&&l.push(s.style.graph(p));const m=B(e?.textStyle?.heading?.fontId,i.fontList),h=e?.textStyle?.heading?.color;m!==void 0&&l.push(s.style.heading({fontFamily:m})),typeof h=="string"&&l.push(s.style.heading.h1({textColor:h})),typeof v=="string"&&l.push(s.style.heading.h2({textColor:v}),s.style.caption({textColor:v}),s.style.source({textColor:v}),s.style.source.link({textColor:v}));const f=t?.gridLineColor;return typeof f=="string"&&l.push(s.style.gridLine({stroke:f}),s.style.tickLine({stroke:f}),s.style.panelBorder({stroke:f})),l}function _e(e,t,r){if(e?.backgroundModifier==="tint")return{light:I(a.DEFAULT_GRAPH_BACKGROUND.light,r,C.light),dark:I(a.DEFAULT_GRAPH_BACKGROUND.dark,r,C.dark)};const o=t?.graphBackground;return typeof o=="string"?o:void 0}function Ne(e,t){if(!e?.style)return{};if(e.style==="none")return{strokeWidth:0};const r=e.width??0;if(e.style==="gray")return{stroke:Ee,strokeWidth:r};if(e.style==="preset")return e.color===void 0||!Ve(e.color)?{}:{stroke:Te[e.color],strokeWidth:r};if(e.style==="custom")return e.color===void 0?{}:{stroke:e.color,strokeWidth:r};const o=e.color??t;return e.style==="tinted"?{stroke:{light:xe(o,F),dark:De(o,F)},strokeWidth:r}:{stroke:o,strokeWidth:r}}function B(e,t){if(!(e===void 0||t===void 0))return t.find(r=>r.id===e)?.fontFamily}var Ve=e=>Ae.includes(e),I=(e,t,r)=>`color-mix(in srgb, ${e}, ${t} ${r*100}%)`,xe=(e,t)=>`hsl(from ${e} h s calc(l * ${1+t}))`,De=(e,t)=>`hsl(from ${e} h s calc(l * ${1-t}))`,we={x:"top",y:"left"},Re=new Set(["pie","donut"]);function Pe(e,t=!1,r){return s.config({legend:Fe(e.legend,r?.legend),axes:Be(e.axes,t,r?.axes),headline:Ie(e),numberFormat:He(e.appearance),content:Ue(e.content)}).config}function Fe(e,t){if(!(!e&&!t))return{...e?{position:e.position}:void 0,...t}}function H(e,t,r){return!t&&r===void 0?{}:{...t?.isHidden!==void 0?{isVisible:!t.isHidden}:void 0,...t?.label!==void 0?{label:t.label}:void 0,...t?.isReversed?{position:we[e]}:void 0,...t?.tickDisplayMode?{ticks:{mode:t.tickDisplayMode}}:void 0,...r!==void 0?{grid:{isVisible:r}}:void 0}}function Ce(e){return{...e.label!==void 0?{label:e.label}:void 0}}function Be(e,t=!1,r){if(!e&&!r)return;const o=H("x",e?.x,e?.showGridLines),i=H("y",e?.y,e?.showGridLines);return{x:{...t?i:o,...r?.x},y:{...t?o:i,...r?.y},...e?.y2?{ySecondary:Ce(e.y2)}:void 0}}function Ie(e){const{headlineNumbers:t,options:r,type:o}=e,i=o!==void 0&&Re.has(o)?r?.pieTotalPosition:void 0;if(t===void 0&&i===void 0)return;const n={};return t?.show!==void 0&&(n.show=t.show),t?.compareWith!==void 0&&(n.compareWith=t.compareWith),t?.size!==void 0&&(n.size=t.size),i!==void 0&&(n.show="total",n.position=i==="center"?"center":"above"),n}function He(e){if(e?.numberFormat)return{decimals:e.numberFormat.decimalPlaces,abbreviation:e.numberFormat.abbreviation}}function Ue(e){if(!e)return;const t={};e.title!==void 0&&(t.title=e.title),e.isTitleHidden!==void 0&&(t.isTitleVisible=!e.isTitleHidden),e.subtitle!==void 0&&(t.subtitle=e.subtitle),e.isSubtitleHidden!==void 0&&(t.isSubtitleVisible=!e.isSubtitleHidden),e.caption!==void 0&&(t.caption=e.caption),e.isCaptionHidden!==void 0&&(t.isCaptionVisible=!e.isCaptionHidden);const r=We(e.source);return r!==void 0&&(t.source=r),e.isSourceHidden!==void 0&&(t.isSourceVisible=!e.isSourceHidden),e.brandMark!==void 0&&(t.brandMark={...e.brandMark},e.brandMark.enabled!==void 0&&(t.isBrandMarkVisible=e.brandMark.enabled)),e.isBrandMarkHidden!==void 0&&e.brandMark?.enabled===void 0&&(t.isBrandMarkVisible=!e.isBrandMarkHidden),t}function We(e){if(!e)return;const t={};return e.label!==void 0&&(t.label=e.label),e.url!==void 0&&(t.url=e.url),Object.keys(t).length===0?void 0:t}var D=a.prefixInternalVariable("constantY"),Me=.15,Oe=(e,t,r,o)=>qe[t](e,r,o),w=e=>{const t=a.inferXVariable(e),{numeric:r}=e.groupVariableNamesByType(),o=r.filter(i=>i!==t);return o.length<=1?{transforms:[],mapping:{x:t,y:o[0]??""},seriesVariables:o}:{transforms:[s.transform.reshape({keep:[t],keyName:"key",valueName:a.DEFAULT_RESHAPE_VALUE_NAME})],mapping:{x:t,y:a.DEFAULT_RESHAPE_VALUE_NAME,color:"key"},seriesVariables:o}},R=e=>{const t=e.appearance?.seriesStyles;if(!t||e.seriesVariables.length===0)return{mapping:{},scales:[]};if(!e.seriesVariables.some(o=>a.isDefined(t[o]?.lineStyle)))return{mapping:{},scales:[]};if(e.seriesVariables.length===1){const o=e.seriesVariables[0];if(!o)return{mapping:{},scales:[]};const i=t[o]?.lineStyle;return i?{mapping:{lineType:{value:i}},scales:[]}:{mapping:{},scales:[]}}const r=e.seriesVariables.map(o=>t[o]?.lineStyle??"solid");return{mapping:{lineType:"key"},scales:[s.scale.lineType.discrete({domain:e.seriesVariables,range:r})]}},Ge=e=>{const{categorical:t,temporal:r,numeric:o}=e.groupVariableNamesByType(),i=o[0];if(!a.isDefined(i))throw new a.UserInputError({code:"INVALID_DATA_SHAPE",message:"No first numeric variable found",suggestion:"Provide at least one numeric column for this chart type."});const n=o.slice(1);return n.length===0?{...q(),mapping:{x:i,y:D,label:t[0]}}:n.length===1?{transforms:[],scales:[],mapping:{x:i,y:n[0]??"",label:t[0]}}:{transforms:[s.transform.reshape({keep:[i,...t,...r],keyName:"key",valueName:a.DEFAULT_RESHAPE_VALUE_NAME})],scales:[],mapping:{x:i,y:a.DEFAULT_RESHAPE_VALUE_NAME,label:t[0],color:"key"}}},q=()=>({transforms:[s.transform.constant({variableName:D,type:"categorical",value:""})],scales:[s.scale.y.discrete()]}),ze=e=>{const{categorical:t,temporal:r,numeric:o}=e.groupVariableNamesByType();let i,n;if(a.isDefined(t[0])&&a.isDefined(o[0]))i=t[0],n=o[0];else if(a.isDefined(r[0])&&a.isDefined(o[0]))i=r[0],n=o[0];else if(a.isDefined(o[0])&&a.isDefined(o[1]))i=o[0],n=o[1];else throw new a.UserInputError({code:"INVALID_DATA_SHAPE",message:"No label or value variable found",suggestion:"Provide a label column and a numeric value column for this chart type."});return{x:"",y:n,color:i}},Z=(e,t,r)=>{const{transforms:o,mapping:i,seriesVariables:n}=w(e.dataset),l=R({appearance:r,seriesVariables:n}),c=n.length<=1,u=[a.geom.line({params:{curve:t?.isSmoothLine?"smooth":"linear",missingValues:t?.missingValues}})],d=[];return c&&(t?.showFill??!0)&&d.push(s.style.geom.line({fillAlpha:Me})),typeof t?.lineThickness=="number"&&d.push(s.style.geom.line({strokeWidth:t.lineThickness})),t?.showPoints&&(u.push(a.geom.point({interactive:!1})),typeof t.pointSize=="number"&&d.push(s.style.geom.point({size:t.pointSize}))),{layers:u,coords:s.coord.cartesian(),mapping:{...i,...l.mapping},scales:l.scales,transforms:o,seriesVariables:n,styleDefaults:d}},Ye=(e,t,r)=>{const{transforms:o,mapping:i,seriesVariables:n}=w(e.dataset),l=R({appearance:r,seriesVariables:n}),c=[a.geom.area({position:"stack",params:{curve:t?.isSmoothLine?"smooth":"linear",missingValues:t?.missingValues}})],u=[];return typeof t?.lineThickness=="number"&&u.push(s.style.geom.area({strokeWidth:t.lineThickness})),t?.showPoints&&(c.push(a.geom.point({position:"stack",interactive:!1})),typeof t.pointSize=="number"&&u.push(s.style.geom.point({size:t.pointSize}))),{layers:c,coords:s.coord.cartesian(),mapping:{...i,...l.mapping},scales:l.scales,transforms:o,seriesVariables:n,styleDefaults:u}},S=(e,t,r,o,i)=>{const{transforms:n,mapping:l,seriesVariables:c}=w(e.dataset),u=[...n];if(o?.sortBars){const d=a.readVariableName(l.y);d!==null&&d!==""&&u.push(s.transform.sort({variableName:d,direction:"desc"}))}if(!i?.useSingleColorForBars){const d=a.inferXVariable(e.dataset),{numeric:v}=e.dataset.groupVariableNamesByType();v.filter(p=>p!==d).length===1&&e.dataset.getType(d)==="categorical"&&(l.color=d)}return{layers:[a.geom.bar({position:t})],coords:r,mapping:l,scales:[],transforms:u,seriesVariables:c}},U=(e,t)=>({layers:[a.geom.bar({position:"fill"})],coords:s.coord.polar({theta:"y",innerRadius:t==="donut"?.55:0}),mapping:ze(e.dataset),scales:[],seriesVariables:[]}),Xe=e=>{const{transforms:t,scales:r,mapping:o}=Ge(e.dataset);return{layers:[a.geom.point()],coords:s.coord.cartesian(),mapping:o,scales:r,transforms:t,seriesVariables:[]}},Ke=e=>{const{numeric:t,categorical:r}=e.dataset.groupVariableNamesByType(),o=t[0];if(!a.isDefined(o))throw new a.UserInputError({code:"INVALID_DATA_SHAPE",message:"No first numeric variable found",suggestion:"Provide at least one numeric column for this chart type."});const i=a.isDefined(t[1])?{transforms:[],scales:[]}:q(),n={x:o,y:t[1]??D,size:t[2],label:r[0]},l=[...i.scales];return a.isDefined(n.size)&&l.push(s.scale.size.continuous()),{layers:[a.geom.point()],coords:s.coord.cartesian(),mapping:n,scales:l,transforms:i.transforms,seriesVariables:[]}},$e=e=>{const t=a.inferXVariable(e.dataset),{numeric:r}=e.dataset.groupVariableNamesByType(),o=r.filter(i=>i!==t);return{transforms:[s.transform.reshape({keep:[t],keyName:"key",valueName:a.DEFAULT_RESHAPE_VALUE_NAME}),s.transform.filter({variableName:a.DEFAULT_RESHAPE_VALUE_NAME,operator:"neq",value:null})],layers:[a.geom.tile()],coords:s.coord.cartesian(),mapping:{x:t,y:"key",color:a.DEFAULT_RESHAPE_VALUE_NAME},scales:[s.scale.color.continuous()],seriesVariables:o,config:{legend:{position:"none"},axes:{x:{position:"top"},y:{position:"left"}}}}},L=(e,t,r)=>{const o=r?.seriesStyles?.[e]?.lineStyle;return a.geom.line({transforms:[s.transform.constant({variableName:a.LAYER_LABEL_VARIABLES.line,type:"categorical",value:e})],aes:{y:e,color:a.LAYER_LABEL_VARIABLES.line,...o?{lineType:{value:o}}:{}},...t?{yScaleType:"secondary"}:void 0})},je=(e,t,r)=>{const{numeric:o}=e.dataset.groupVariableNamesByType(),i=a.inferXVariable(e.dataset),n=a.readFoldKeepVariables(e.dataset,i),l=o.filter(f=>f!==i),c=s.COMBO_BAR_POSITIONS[t?.comboType??"grouped-bars"],u=c===null;if(l.length===1)return u?Z(e,t,r):S(e,"dodge",s.coord.cartesian(),t,r);const d=e.axes?.hasDualYAxis===!0,v=u?[]:l.slice(0,-1),p=u?l:l.slice(-1),m=[],h=[];if(c!==null&&v.length>0){const f=v.length===1?v[0]:null;a.isDefined(f)?m.push(a.geom.bar({transforms:[s.transform.constant({variableName:a.LAYER_LABEL_VARIABLES.bar,type:"categorical",value:f})],aes:{y:f,color:a.LAYER_LABEL_VARIABLES.bar},position:c})):m.push(a.geom.bar({transforms:[s.transform.reshape({keep:n,reshape:v,keyName:"key",valueName:a.DEFAULT_RESHAPE_VALUE_NAME})],aes:{y:a.DEFAULT_RESHAPE_VALUE_NAME,color:"key"},position:c}))}if(u&&p.length>=2){const f=d?p.slice(0,-1):p,P=f.length===1?f[0]:null;if(a.isDefined(P))m.push(L(P,!1,r));else{const k=R({appearance:r,seriesVariables:f});m.push(a.geom.line({transforms:[s.transform.reshape({keep:n,reshape:f,keyName:"key",valueName:a.DEFAULT_RESHAPE_VALUE_NAME})],aes:{y:a.DEFAULT_RESHAPE_VALUE_NAME,color:"key",...k.mapping}})),h.push(...k.scales)}if(d){const k=p[p.length-1];a.isDefined(k)&&m.push(L(k,!0,r))}}else for(const f of p)m.push(L(f,d,r));return{layers:m,coords:s.coord.cartesian(),mapping:{x:i},scales:h,seriesVariables:l}},E=e=>()=>{throw new a.UserInputError({code:"UNSUPPORTED_GRAPH_TYPE",message:`Unsupported graph type: ${e}`,context:{requested:e}})},qe={line:(e,t,r)=>Z(e,t,r),areaStacked:(e,t,r)=>Ye(e,t,r),bar:(e,t,r)=>S(e,"dodge",s.coord.flip(),t,r),barStacked:(e,t,r)=>S(e,"stack",s.coord.flip(),t,r),barStackedFill:(e,t,r)=>S(e,"fill",s.coord.flip(),t,r),column:(e,t,r)=>S(e,"dodge",s.coord.cartesian(),t,r),columnStacked:(e,t,r)=>S(e,"stack",s.coord.cartesian(),t,r),columnStackedFill:(e,t,r)=>S(e,"fill",s.coord.cartesian(),t,r),pie:e=>U(e,"pie"),donut:e=>U(e,"donut"),scatter:e=>Xe(e),bubble:e=>Ke(e),combo:(e,t,r)=>je(e,t,r),funnel:E("funnel"),heatmap:e=>$e(e),waterfall:E("waterfall"),mekko:E("mekko"),table:E("table")},Ze=new a.TransformRegistry,Je=["key",a.prefixInternalVariable("lineSeriesLabel"),a.prefixInternalVariable("barSeriesLabel")];function Qe(e){const t=e.annotations??[],r=tt(e.mapping),o=ot(e.dataset,e.transforms,e.layers),i=[];for(const n of t){if(n.type!=="highlight")continue;const l=rt({annotation:n,rowIdentityVariable:r,dataset:e.dataset,compiledVariableNames:o});l!==null&&i.push({type:"highlight",id:n.id,predicate:l,scope:et(n.highlight,e.mapping)})}return i}function et(e,t){const r=a.readVariableName(t.x);return!(r!==null&&r!=="")&&e==="x-value"?"series":e}function tt(e){const t=a.readVariableName(e.x);return t!==null&&t!==""?t:a.readVariableName(e.color)}function rt({annotation:e,rowIdentityVariable:t,dataset:r,compiledVariableNames:o}){switch(e.highlight){case"x-value":return W(e,t,r);case"series":return M(e,o);case"data-point":{const i=W(e,t,r),n=M(e,o);return i===null&&n===null?null:i===null?n:n===null?i:{and:[i,n]}}}}function W(e,t,r){if(t===null)return null;const o=it(e,t,r);return o===null?null:{variable:t,eq:o}}function M(e,t){const r=e.columnKey;if(!a.isDefined(r))return null;const o=Je.filter(i=>t.includes(i));return o.length===0?null:{or:o.map(i=>({variable:i,eq:r}))}}function ot(e,t,r){const o=[...e.getVariableNames()],i=n=>{for(const l of n){const{getIntroducedVariables:c}=Ze.get(l.transformType),u=c?.(l);u&&o.push(...u)}};i(t);for(const n of r)i(n.transforms??[]);return o}function it(e,t,r){return e.rowValue!==void 0?e.rowValue:!a.isDefined(e.rowIndex)||!r.getVariableNames().includes(t)?null:r.getValues(t)[e.rowIndex]??null}function nt(e,t,r){const{colorScheme:o,customPalettes:i}=r;if(i&&e&&i[e])return{type:"custom",id:e};if(e?.startsWith("preset:pastel"))return{type:"pastel",variant:_(t)};if(e?.startsWith("preset:graphy"))return{type:"graphy",variant:_(t)};if(e?.startsWith("preset:mono:")){const n=e.slice(12);if(st(n))return{type:"mono",base:n,variant:o}}if(e?.startsWith("preset:neon:")){const n=e.slice(12);if(at(n))return{type:"neon",base:n,variant:_(t)}}return{type:"default"}}function _(e){if(e==="waterfall")return"waterfall"}function st(e){return a.MONO_BASES.includes(e)}function at(e){return a.NEON_BASES.includes(e)}function lt({axes:e,palette:t,overrides:r,isFlipped:o}){const i=[];return i.push(O("x",o?e?.y:e?.x)),i.push(O("y",o?e?.x:e?.y)),i.push(s.scale.color.palette({palette:t,overrides:r})),i}function O(e,t){return t?.scaleType==="logarithmic"||t?.min!==void 0||t?.max!==void 0?t.scaleType==="logarithmic"?s.scale[e].log({domainMin:t.min??void 0,domainMax:t.max??void 0}):s.scale[e]({domainMin:t.min??void 0,domainMax:t.max??void 0}):s.scale[e]()}function ct(e){if(!e)return;const t={};for(const[r,o]of Object.entries(e)){if(!r.startsWith("series"))continue;const i=Number.parseInt(r.slice(6));if(Number.isNaN(i))continue;const n={hex:o.customColor,id:o.paletteColorId};(n.hex!==void 0||n.id!==void 0)&&(t[i]=n)}return Object.keys(t).length>0?t:void 0}function ut(e){const t=[],r=g(e?.fontAxisLabel);r!==void 0&&t.push(s.style.axisLabel(r));const o=St(e);o!==void 0&&t.push(s.style.tickLabel(o));const i=g(e?.fontGoalLineLabel);return i!==void 0&&t.push(s.style.geom.rule.label(i)),t.push(...ht(e)),t.push(...dt(e)),t.push(...vt(e)),t.push(...bt(e)),t}function dt(e){const t=[],r=pt(e);r!==void 0&&t.push(s.style.tooltip(r));const o=A(g(e?.fontTooltipHeading),y(e?.tooltipHeadingTextColor));o!==void 0&&t.push(s.style.tooltip.heading(o));const i=g(e?.fontTooltipLabel),n=A(i,y(e?.tooltipLabelTextColor));n!==void 0&&t.push(s.style.tooltip.label(n));const l=A(i,y(e?.tooltipValueTextColor));l!==void 0&&t.push(s.style.tooltip.value(l));const c=y(e?.tooltipPrimaryRowColor);c!==void 0&&t.push(s.style.tooltip.primaryRow({fill:c}));const u=ft(e);return u!==void 0&&t.push(s.style.annotation.pinnedNumber.label(u),s.style.annotation.comment.label(u)),t}var ft=e=>{const t=y(e?.tooltipBackground),r=y(e?.tooltipBorderColor),o={...A(g(e?.fontMiniTooltipLabel),y(e?.tooltipValueTextColor)),...t===void 0?{}:{fill:t},...r===void 0?{}:{stroke:r}};return Object.keys(o).length===0?void 0:o},pt=e=>{const t=y(e?.tooltipBackground),r=y(e?.tooltipBorderColor),o=b(e?.tooltipBorderWidth),i=b(e?.tooltipBorderRadius),n=b(e?.tooltipPaddingBlock),l=b(e?.tooltipPaddingInline),c=typeof e?.tooltipShadow=="string"?gt(e.tooltipShadow)??void 0:void 0,u={...t===void 0?{}:{fill:t},...r===void 0?{}:{stroke:r},...o===void 0?{}:{strokeWidth:o},...i===void 0?{}:{cornerRadius:i},...n===void 0?{}:{paddingBlock:n},...l===void 0?{}:{paddingInline:l},...c===void 0?{}:{shadow:c}};return Object.keys(u).length===0?void 0:u};function vt(e){const t=[],r=b(e?.legendItemGap);r!==void 0&&t.push(s.style.legend({gap:r}));const o=g(e?.fontLegendLabel),i=y(e?.legendTextColor),n=A(o,i),l=yt(e,n);l!==void 0&&t.push(s.style.legendItem(l));const c=mt(e);return c!==void 0&&t.push(s.style.legendItem.swatch({size:c})),n!==void 0&&t.push(s.style.directLabel(n)),t}var yt=(e,t)=>{const r=y(e?.legendBackground),o=y(e?.legendBorderColor),i=b(e?.legendPillBorderWidth),n=b(e?.legendPillPaddingInline),l=b(e?.legendPillPaddingBlock),c={...t,...r===void 0?{}:{fill:r},...o===void 0?{}:{stroke:o},...i===void 0?{}:{strokeWidth:i},...n===void 0?{}:{paddingInline:n},...l===void 0?{}:{paddingBlock:l}};return Object.keys(c).length===0?void 0:c},mt=e=>{const t=b(e?.legendSwatchWidth);return b(e?.legendSwatchHeight)??t},A=(e,t)=>{if(!(e===void 0&&t===void 0))return{...e,...t===void 0?{}:{textColor:t}}};function ht(e){const t=y(e?.dataLabelTextColor),r=y(e?.stackTotalTextColor),o=[["observation",g(e?.fontDataLabel),t],["category",g(e?.fontCategoryLabel),t],["aggregate",g(e?.fontStackTotal),r]],i=[];for(const[d,v,p]of o)v===void 0&&p===void 0||i.push(s.style.dataLabel[d]({...v,...p===void 0?{}:{textColor:p}}));const n=y(e?.dataLabelInsideTextColor);n!==void 0&&(i.push(s.style.dataLabel.observation.inside({textColor:n})),i.push(s.style.dataLabel.category.inside({textColor:n})));const l=y(e?.dataLabelOutsideBackground);l!==void 0&&(i.push(s.style.dataLabel.observation.outside({fill:l})),i.push(s.style.dataLabel.category.outside({fill:l})));const c=y(e?.stackTotalBackground),u=y(e?.stackTotalStroke);return(c!==void 0||u!==void 0)&&i.push(s.style.dataLabel.aggregate({...c===void 0?{}:{fill:c},...u===void 0?{}:{stroke:u}})),i}function bt(e){const t=[],r=y(e?.trendPositiveColor),o=y(e?.trendNegativeColor),i=y(e?.trendNeutralColor);return r!==void 0&&t.push(s.style.headlineItem.trend.up({textColor:r})),o!==void 0&&t.push(s.style.headlineItem.trend.down({textColor:o})),i!==void 0&&t.push(s.style.headlineItem.trend.flat({textColor:i})),t}function y(e){if(!(typeof e!="string"||e.trim().length===0))return e}function gt(e){const t=e.trim();if(t==="none")return"none";const r=t.split(/\s+/),o=N(r[0]),i=N(r[1]),n=N(r[2]),l=r.slice(3).join(" ");return o===null||i===null||n===null||l.length===0?null:{offsetX:o,offsetY:i,blur:n,color:l}}var N=e=>{if(e===void 0)return null;const t=/^(-?\d*\.?\d+)(px)?$/.exec(e);if(t?.[1]===void 0)return null;const r=Number.parseFloat(t[1]);return Number.isFinite(r)?r:null};function g(e){if(typeof e!="string")return;const t=K(e);if(t!==null)return{fontFamily:t.family,fontSize:x(t.size),fontWeight:t.weight,...t.lineHeight===void 0?{}:{lineHeight:t.lineHeight}}}function St(e){const t=g(e?.fontTickLabel),r=b(e?.tickLabelOffset);if(!(t===void 0&&r===void 0))return{...t,...r===void 0?{}:{offset:r}}}function b(e){if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(typeof e!="string")return;const t=V(e);return t===null?void 0:x(t)}var kt=new Set(["column","columnStacked","columnStackedFill","bar","barStacked","barStackedFill","line","areaStacked","scatter","bubble","funnel","combo"]),At=new Set(["column","columnStacked","columnStackedFill","bar","barStacked","barStackedFill","line","areaStacked","combo"]);function Et(e,t,r={}){return Tt(a.parseDataset(t),e,r)}function Tt(e,t,r={}){const o=t.type??"column",i=Oe({dataset:e,axes:t.axes},o,t.options??void 0,t.appearance??void 0),n=i.coords.coordType==="flip",l=i.transforms??[],c=nt(t.appearance?.paletteId,o,r),u=ct(t.appearance?.seriesStyles);return{mapping:i.mapping,layers:Lt(o,t,i.layers,i.coords,i.mapping,i.seriesVariables),scales:[...lt({axes:t.axes,palette:c,overrides:u,isFlipped:n}),...i.scales],styles:Se(ge(be({palette:c,overrides:u,ctx:r}),[...i.styleDefaults??[],...ke(t.appearance??void 0),...Le({appearance:t.appearance??void 0,themeOverrides:t.themeOverrides,palette:c,overrides:u,ctx:r}),...ut(t.themeOverrides),...ne(t.themeOverrides)],ie(t.annotations)),se(t.themeOverrides)),transforms:l,highlights:Qe({annotations:t.annotations,dataset:e,mapping:i.mapping,transforms:l,layers:i.layers}),annotations:le({annotations:t.annotations,dataset:e,mapping:i.mapping,seriesVariables:i.seriesVariables}),coords:i.coords,config:Pe(t,n,i.config)}}function Lt(e,t,r,o,i,n){const l=Dt(t.dataLabels),c=l===void 0?r:r.map(d=>d.interactive===!1?d:{...d,dataLabels:{...l,...d.dataLabels}}),u=t.axes?.hasDualYAxis??!1;return[...c,..._t({type:e,trendline:t.referenceLines?.trendline,coords:o,mapping:i}),...Nt({type:e,hasDualYAxis:u,goalLine:t.referenceLines?.goalLine,coords:o}),...xt({type:e,hasDualYAxis:u,averageLine:t.referenceLines?.averageLine,coords:o,mapping:i,seriesVariables:n})]}function _t({type:e,trendline:t,coords:r,mapping:o}){return t===void 0?[]:kt.has(e)?r.coordType==="polar"?[]:o.y===void 0?[]:[a.geom.line({aes:{lineType:{value:"dashed"}},stat:s.stat.smooth({method:t}),interactive:!1})]:[]}function Nt({type:e,hasDualYAxis:t,goalLine:r,coords:o}){if(!Vt(r))return[];if(o.coordType==="polar")return[];const i=o.coordType==="flip"?"end":"start";return[a.geom.rule({aes:{y:{value:r.target}},params:{labelPosition:i,label:r.label??"Goal"},yScaleType:e==="combo"&&t?"secondary":"primary",interactive:!1})]}function Vt(e){return e!==void 0&&Number.isFinite(e.target)}function xt({type:e,hasDualYAxis:t,averageLine:r,coords:o,mapping:i,seriesVariables:n}){if(r===void 0)return[];if(!At.has(e))return[];if(o.coordType==="polar")return[];const l=$(r.columnKey);if(!n.includes(l))return[];const c=i.color==="key",u=c?a.DEFAULT_RESHAPE_VALUE_NAME:l,d=c?[s.transform.filter({variableName:"key",operator:"eq",value:l})]:[];return[a.geom.rule({aes:{y:u,color:void 0,group:void 0,lineType:void 0},stat:s.stat.mean(),transforms:d,params:{label:"Average",labelPosition:o.coordType==="flip"?"end":"start"},yScaleType:e==="combo"&&t?"secondary":"primary",interactive:!1})]}function Dt(e){if(!e)return;const t={};return e.showDataLabels!==void 0&&(t.showDataLabels=e.showDataLabels),e.dataLabelFormat!==void 0&&(t.format=e.dataLabelFormat),e.showStackTotals!==void 0&&(t.showStackTotals=e.showStackTotals),e.showCategoryLabels!==void 0&&(t.showCategoryLabels=e.showCategoryLabels),Object.keys(t).length===0?void 0:t}var wt=[.8,1,1.2,1.4,1.6,1.8,2,2.5,3,4];exports.CHART_TEXT_SCALES=wt;exports.ROOT_FONT_SIZE_PX=J;exports.convertGraphConfig=Et;exports.isFontStyle=z;exports.parseFontLength=V;exports.parseFontShorthand=K;exports.parseFontWeight=Y;exports.parseUnitlessLineHeight=X;exports.toPixels=x;
|
package/dist/graph-config.mjs
CHANGED
|
@@ -1192,13 +1192,13 @@ function jt(e, t, r = {}) {
|
|
|
1192
1192
|
};
|
|
1193
1193
|
}
|
|
1194
1194
|
function qt(e, t, r, o, i, n) {
|
|
1195
|
-
const s = tr(t.dataLabels), l = s === void 0 ? r : r.
|
|
1195
|
+
const s = tr(t.dataLabels), l = s === void 0 ? r : r.map((u) => u.interactive === !1 ? u : {
|
|
1196
1196
|
...u,
|
|
1197
1197
|
dataLabels: {
|
|
1198
1198
|
...s,
|
|
1199
1199
|
...u.dataLabels
|
|
1200
1200
|
}
|
|
1201
|
-
})
|
|
1201
|
+
}), c = t.axes?.hasDualYAxis ?? !1;
|
|
1202
1202
|
return [
|
|
1203
1203
|
...l,
|
|
1204
1204
|
...Zt({
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./annotations-Dy-Gx6J6.cjs"),m=require("./compiler-jGyzPM0J.cjs"),b=require("./spec-builder-CQ5p2Jzs.cjs");let $=require("color2k"),Dn=require("date-fns"),Us=require("lodash-es"),ae=require("lodash-es/clamp");ae=l.__toESM(ae,1);let lt=require("humanize-duration");lt=l.__toESM(lt,1);let R=require("d3-shape"),Ws=require("d3-delaunay"),Pe=require("lodash-es/isEqual");Pe=l.__toESM(Pe,1);typeof window<"u"&&(window.__GRAPHY_SDK__??={},window.__GRAPHY_SDK__.vizEngine="1.9.0-beta.1790336418293");var Ys=1e6;function _(e){return String(Math.round(e*Ys))}var yr="#FFFFFF",Ze="#1A1A1A",Xs=4.5,On=e=>{try{return(0,$.getContrast)(e,yr)>(0,$.getContrast)(e,Ze)?yr:Ze}catch{return Ze}},qs=(e,t)=>{try{const r=_n(void 0,t);return r===void 0||(0,$.getContrast)(r,e)>=Xs?e:On(r)}catch{return e}},_n=(e,t)=>{try{if(e===void 0){const[,,,n]=(0,$.parseToRgba)(t);return n>=1?t:void 0}const[,,,r]=(0,$.parseToRgba)(e);return r>=1?e:(0,$.parseToRgba)(t)[3]<1?void 0:(0,$.mix)(t,(0,$.opacify)(e,1),r)}catch{return}};function W(e,t){return e.geom===t}var Qe="…",kn=(e,t,r)=>{if(t<=0||e.length===0)return"";if(r(e)<=t)return e;if(r(Qe)>t)return"";let n=0,a=e.length-1,i=0;for(;n<=a;){const o=n+a>>>1;r(e.slice(0,o)+Qe)<=t?(i=o,n=o+1):a=o-1}return e.slice(0,i)+Qe};var C={timeZone:"UTC"},L=e=>t=>{if(!l.isStrictTemporalDataValue(t))return"–";try{return e(t)}catch{return"n/a"}},z=e=>t=>l.isStrictNumericDataValue(t)?e(t):"–",bt=e=>t=>l.isStrictCategoricalDataValue(t)?t:"–",be=new Map,xe=new Map,Vn=256,le=(e,t)=>{const r=Nn(e,t),n=be.get(r);if(n!==void 0)return n;be.size>=Vn&&be.clear();const a=new Intl.NumberFormat(e,t);return be.set(r,a),a},w=(e,t)=>{const r=Nn(e,t),n=xe.get(r);if(n!==void 0)return n;xe.size>=Vn&&xe.clear();const a=new Intl.DateTimeFormat(e,t);return xe.set(r,a),a},Nn=(e,t)=>`${e}\0${JSON.stringify(t)}`,js=lt.default.humanizer({language:"en",spacer:"",delimiter:" ",languages:{en:{y:()=>"y",mo:()=>"mo",w:()=>"w",d:()=>"d",h:()=>"h",m:()=>"m",s:()=>"s",ms:()=>"ms"}}}),Fn=({valueFormat:e,locale:t,numberFormat:r,intlOptions:n})=>z(a=>{const i=typeof r.decimals=="number"?r.decimals:2,o=It(a,i),{base:s,suffix:c}=At(a,r.abbreviation);return`${le(t,{...o,...l.isCurrencyValueFormat(e)?{style:"currency",currencyDisplay:"narrowSymbol",currency:e.iso}:{},...n}).format(s)}${c}`}),Bn=({locale:e,numberFormat:t,intlOptions:r})=>z(n=>{const{base:a,suffix:i}=At(n,t.abbreviation);return`${le(e,{...It(a,t.decimals),...r}).format(a)}${i}`}),xt=e=>z(t=>js(t)),Gn=({locale:e,intlOptions:t})=>{const r=le(e,{maximumFractionDigits:0,...t});return z(n=>r.format(n))},Hn=({locale:e,numberFormat:t,intlOptions:r})=>z(n=>le(e,{...It(n,t.decimals),...r,style:"percent"}).format(n)),At=(e,t="none")=>{switch(t){case"none":return{base:e,suffix:""};case"auto":{const r=Zs(e);return At(e,r)}default:return{base:e/l.SUFFIX_MULTIPLIERS[t],suffix:t}}},It=(e,t)=>{if(typeof t=="number")return{minimumFractionDigits:t,maximumFractionDigits:t};const r=Math.ceil(Math.log10(Math.abs(e))),n=r>=3?0:r===2?1:2;return{minimumFractionDigits:t==="auto"?0:n,maximumFractionDigits:n}},Zs=e=>{const t=Math.abs(e);return t>=l.SUFFIX_MULTIPLIERS.b?"b":t>=l.SUFFIX_MULTIPLIERS.m?"m":t>=l.SUFFIX_MULTIPLIERS.k?"k":"none"},Qs=({locale:e,intlOptions:t})=>{const r=w(e,{dateStyle:"medium",...C,...t});return L(n=>r.format(n))},Js=({locale:e,intlOptions:t})=>{const r=w(e,{dateStyle:"medium",timeStyle:"medium",...C,...t});return L(n=>el(r.formatToParts(n).map(tl)))},$n=({locale:e,intlOptions:t})=>{const r=w(e,{day:"numeric",month:"long",...C,...t});return L(n=>r.format(n))},zn=({locale:e,intlOptions:t})=>{const r=w(e,{month:"long",...C,...t});return L(n=>r.format(n))},Tt=({locale:e,intlOptions:t})=>{const r=w(e,{month:"short",year:"numeric",...C,...t});return L(n=>r.format(n))},Lt=e=>L(t=>`Q${Math.floor(t.getUTCMonth()/3)+1} ${t.getUTCFullYear()}`),Kn=({locale:e,intlOptions:t})=>{const r=w(e,{day:"numeric",month:"long",...C,...t,year:void 0});return L(n=>r.formatRange(n,(0,Dn.addDays)(n,6)))},Un=({locale:e,intlOptions:t})=>{const r=w(e,{dateStyle:"medium",...C,...t});return L(n=>r.formatRange(n,(0,Dn.addDays)(n,6)))},Et=({locale:e,intlOptions:t})=>{const r=w(e,{year:"numeric",...C,...t});return L(n=>r.format(n))},Wn=({locale:e,intlOptions:t})=>{const r=w(e,{timeStyle:"short",...C,...t});return L(n=>r.format(n))},el=e=>e.map(t=>t.value).join(""),tl=e=>e.type!=="literal"||e.value!==", "?e:{type:"literal",value:" • "},Sr=1e3,rl=({valueFormat:e,locale:t,tickValues:r,intlOptions:n})=>z(a=>{const i={...Ct(a,r),notation:"compact",...l.isCurrencyValueFormat(e)?{style:"currency",currencyDisplay:"narrowSymbol",currency:e.iso}:{},...n};return Rt(a,t,i)}),nl=({locale:e,tickValues:t,intlOptions:r})=>z(n=>{const a={...Ct(n,t),notation:"compact",...r};return Rt(n,e,a)}),al=({locale:e,tickValues:t,intlOptions:r})=>z(n=>{const a={...Ct(n,t),notation:"compact",...r,style:"percent"};return Rt(n,e,a)}),Rt=(e,t,r)=>le(t,r).formatToParts(e).map(n=>n.type==="compact"?n.value.toLowerCase():n.value).join(""),Yn=e=>Math.abs(e)>Sr?Yn(e/Sr):Number.isInteger(e),il=e=>{if(e.length<2)return!1;const[t,r]=e;return typeof t!="number"||typeof r!="number"?!1:Math.abs(r-t)<1},Ct=(e,t)=>Yn(e)?{minimumFractionDigits:0,maximumFractionDigits:0}:il(t)?{minimumFractionDigits:0,maximumFractionDigits:4}:{minimumFractionDigits:0,maximumFractionDigits:1},ol=({locale:e,intlOptions:t})=>{const r=w(e,{day:"numeric",month:"short",...C,...t});return L(n=>r.format(n))},sl=({locale:e,intlOptions:t})=>{const r=w(e,{month:"short",...C,...t});return L(n=>r.format(n))},ll=({locale:e,intlOptions:t})=>{const r=w(e,{day:"numeric",month:"short",...C,...t});return L(n=>r.format(n))},cl=({locale:e,intlOptions:t})=>{const r=w(e,{timeStyle:"short",...C,...t});return L(n=>r.format(n))},wt=e=>{const{valueFormat:t}=e;switch(t.type){case"currency":return rl(e);case"date":case"datetime":return ol(e);case"day_month":case"weekly_date_range":case"weekly_date_range_with_year":return ll(e);case"decimal":case"integer":return nl(e);case"duration":return xt(e);case"month":return sl(e);case"month_year":return Tt(e);case"percentage":return al(e);case"quarter":return Lt(e);case"text":return bt(e);case"time":return cl(e);case"year":return Et(e);case"lookup":return wt({...e,valueFormat:t.fallback});default:throw new l.InternalError({message:`Unhandled value format: ${t.type}`})}},ul=.9,dl=1/3,ml=1/4,hl=e=>e.formattedAxis.position==="top"||e.formattedAxis.position==="bottom"?pl(e):fl(e),pl=({formattedAxis:e,bandwidthPx:t,panelRect:r,measureLabel:n})=>{const{widths:a,maxWidth:i,maxHeight:o}=Xn(e.ticks,n),s=gl(e.ticks,r.width),c=s*ul;if(i<=c)return{...e,labelRotation:0,labelMaxWidthPx:null};if(s>=50){const d=ut(c);return{...e,ticks:ct(e.ticks,a,d,n),labelRotation:0,labelMaxWidthPx:d}}if(o+8>t)return{...e,ticks:[],labelRotation:0,labelMaxWidthPx:null};const u=ut(r.height*dl);return{...e,ticks:ct(e.ticks,a,u,n),labelRotation:-90,labelMaxWidthPx:u}},fl=({formattedAxis:e,bandwidthPx:t,panelRect:r,measureLabel:n})=>{const{widths:a,maxWidth:i,maxHeight:o}=Xn(e.ticks,n);if(o>t)return{...e,ticks:[],labelRotation:0,labelMaxWidthPx:null};const s=ut(r.width*ml);return i<=s?{...e,labelRotation:0,labelMaxWidthPx:null}:{...e,ticks:ct(e.ticks,a,s,n),labelRotation:0,labelMaxWidthPx:s}},gl=(e,t)=>{const r=e[0],n=e[1];return r===void 0||n===void 0?t:Math.abs(n.position-r.position)*t},Xn=(e,t)=>{const r=[];let n=0,a=0;for(const i of e){const{width:o,height:s}=t(i.formattedLabel);r.push(o),o>n&&(n=o),s>a&&(a=s)}return{widths:r,maxWidth:n,maxHeight:a}},ct=(e,t,r,n)=>{const a=i=>n(i).width;return e.map((i,o)=>(t[o]??0)<=r?i:{...i,formattedLabel:kn(i.formattedLabel,r,a)})},ut=e=>Math.max(0,Math.floor(e)),vl=(e,t,r,n,a)=>{if(e===0)return!0;const i=r==="top"||r==="bottom",o=i?60:40;let s=n-(e-1)*o;for(let c=0;c<e;c+=1){const{width:u,height:d}=a(t(c));if(s-=i?u:d,s<0)return!1}return!0},yl={ticks:[],labelAt:()=>""},Sl=({axis:e,availableSpacePx:t,measureLabel:r,resolveFormatter:n})=>{const{tickCandidates:a,position:i}=e;if(a.length===0)return[];const o=new Map,s=h=>{const p=o.get(h);if(p)return p;const f=a[h],g=f?bl(f.ticks,n(f)):yl;return o.set(h,g),g};let c=0,u=a.length-1,d=-1;for(;c<=u;){const h=c+u>>>1,{ticks:p,labelAt:f}=s(h);vl(p.length,f,i,t,r)?(d=h,c=h+1):u=h-1}return xl(s(d>=0?d:0))},bl=(e,t)=>{const r=new Array(e.length);return{ticks:e,labelAt:n=>{const a=r[n];if(a!==void 0)return a;const i=t(e[n]?.value??null);return r[n]=i,i}}},xl=({ticks:e,labelAt:t})=>e.map((r,n)=>({...r,formattedLabel:t(n)})),Al=e=>{const t=I({...e,valueFormat:e.valueFormat.fallback}),r={};for(const[a,i]of Object.entries(e.valueFormat.cases))r[a]=I({...e,valueFormat:i});const n=e.valueFormat.byVariable;return(a,i)=>{if(i===void 0||i[n]===void 0)return t(a);const o=l.getStableKey(i[n]),s=r[o];return s!==void 0?s(a,i):t(a)}},I=e=>{switch(e.valueFormat.type){case"currency":return Fn(e);case"date":return Qs(e);case"datetime":return Js(e);case"day_month":return $n(e);case"decimal":return Bn(e);case"duration":return xt(e);case"integer":return Gn(e);case"month":return zn(e);case"month_year":return Tt(e);case"percentage":return Hn(e);case"quarter":return Lt(e);case"text":return bt(e);case"weekly_date_range":return Kn(e);case"weekly_date_range_with_year":return Un(e);case"year":return Et(e);case"time":return Wn(e);case"lookup":return Al({...e,valueFormat:e.valueFormat});default:{const t=e.valueFormat;throw new l.InternalError({message:`Unhandled value format: ${t.type}`})}}};function Pt({layer:e,numberFormat:t,locale:r}){return I({valueFormat:m.getLayerYValueFormat(e),locale:r,numberFormat:t})}var Il=(e,t)=>{const r=l.readVariableName(t.x);return r!==null&&r!==l.CONSTANT_VARIABLES.x?{read:m.createXValueReader(e,t),variable:r}:{read:m.getGroup,variable:l.GROUP_VARIABLES.group}},qn=({layer:e,coordSystem:t,axes:r,numberFormat:n,panelRect:a,measureDataLabel:i,readers:o,formattingLocale:s,percentageValueStrategy:c})=>{const u=Pt({layer:e,numberFormat:n,locale:s}),d=t.type==="cartesian"&&t.mainAxis==="y";return{layer:e,coordSystem:t,panelRect:a,measureDataLabel:i,styleReaders:o.geom(e),formatLabel:Cl({layer:e,numberFormat:n,axes:r,locale:s,absoluteFormatter:u,percentageValueStrategy:c,isFlipped:d}),formatAbsolute:u,formatCategory:Tl({layer:e,numberFormat:n,locale:s})}},Tl=({layer:e,numberFormat:t,locale:r})=>{const{read:n,variable:a}=Il(e.data,e.mapping),i=I({valueFormat:e.data.hasVariable(a)?e.data.getValueFormat(a):{type:"text"},locale:r,numberFormat:t});return o=>{const s=n(o);return s===null?null:i(s,o)}},Ll=(e,t,r)=>{switch(t){case"stack":return El(e);case"fill":return Rl(e,r);case"absoluteGrandTotal":return()=>e.summary.absoluteGrandTotal??null;case"none":return()=>null}},El=e=>{const t=l.readVariableName(e.mapping.x);let r=null,n=!1;return a=>{const i=e.summary.stackTotals;if(i===void 0||i.length===0||t===null)return null;if(!n){r=new Map;for(const c of i)r.set(c.xKey,c);n=!0}const o=a[t];if(o==null)return null;const s=r?.get(m.getObservationXKey(a,t));return s===void 0?null:s.total}},Rl=(e,t)=>{const r=t?l.getXMin:l.getYMin,n=t?l.getXMax:l.getYMax,a=m.createSegmentYReader(e);return i=>{const o=r(i),s=n(i);if(!l.isStrictNumericDataValue(o)||!l.isStrictNumericDataValue(s))return null;const c=Math.abs(s-o);if(c===0)return null;const u=a(i);return l.isStrictNumericDataValue(u)?u/c:null}},Cl=({layer:e,numberFormat:t,axes:r,locale:n,absoluteFormatter:a,percentageValueStrategy:i,isFlipped:o})=>{const s=m.createRawValueReader(e.data,e.dataLabels.labelSource),c=Ll(e,i,o),u=wl({layer:e,numberFormat:t,axes:r,locale:n,absoluteFormatter:a}),d=I({valueFormat:{type:"percentage"},locale:n,numberFormat:t}),h=e.dataLabels.format==="percentage"&&jn(e);return p=>{const f=s(p);if(f===null)return"";if(!h||!l.isStrictNumericDataValue(f))return u(f,p);const g=c(p);return g===null||g===0?u(f,p):d(f/g)}},wl=({layer:e,numberFormat:t,axes:r,locale:n,absoluteFormatter:a})=>{const i=e.dataLabels.labelSource,o=l.readVariableName(i);if(o!==null){if(jn(e))return a;const s=Pl(e,r,t,n,o);if(s!==null)return s}return I({valueFormat:Ml(e.data,i),locale:n,numberFormat:t})},jn=e=>{const t=l.readVariableName(e.dataLabels.labelSource);return t===null?!1:t===l.readVariableName(m.resolveSegmentYSource(e.position,e.mapping))},Pl=(e,t,r,n,a)=>{const i=l.readVariableName(e.mapping.x);if(i===null||i!==a)return null;const o=t.find(s=>s.scaleAestheticKey==="x");return o===void 0?null:I({valueFormat:o.valueFormat,locale:n,numberFormat:r})},Ml=(e,t)=>{const r=l.readConstantValue(t);if(r!==void 0)return l.isNumericDataValue(r)?{type:"decimal"}:l.isTemporalDataValue(r)?{type:"date"}:{type:"text"};const n=l.readVariableName(t);return n===null||!e.hasVariable(n)?{type:"text"}:e.getValueFormat(n)},Dl={cartesian:["cartesian","flip"],polar:["polar"]},Ol=null;function Zn(e=[]){const t=_l(e),r=(n,a)=>{if(!t.has(n))return null;const i=t.get(n);return i.getDataLabelPlacements===void 0||!Dl[a].some(o=>i.dataLabelCoordTypes.includes(o))?null:{place:i.getDataLabelPlacements.bind(i),getPercentageValueStrategy:o=>i.resolvePercentageValueStrategy?.(o,a)??"none"}};return{resolve:r,hasCapability:(n,a)=>r(n,a)!==null,hasPercentageFormat:(n,a)=>(r(n.geom,a)?.getPercentageValueStrategy(n)??"none")!=="none"}}function Mt(){return Ol??=Zn()}function _l(e){const t=new l.GeomRegistry;for(const r of e){const n=l.resolveDefinition(r);n instanceof l.Geom&&t.register(n.type,n)}return t}function*kl({layers:e,coordSystem:t,axes:r,numberFormat:n,panelRect:a,measureDataLabel:i,readers:o,locale:s,resolvePlacement:c=Mt()}){if(!(t.type!=="cartesian"||a.width<=0||a.height<=0))for(const u of e){if(!u.dataLabels.showDataLabels&&!u.dataLabels.showStackTotals)continue;const d=c.resolve(u.geom,"cartesian");if(d===null)continue;const h=qn({layer:u,coordSystem:t,axes:r,numberFormat:n,panelRect:a,measureDataLabel:i,readers:o,formattingLocale:s,percentageValueStrategy:d.getPercentageValueStrategy(u)});for(const p of d.place(h).labels)yield{x:a.x+p.x-p.width/2,y:a.y+p.y-p.height/2,width:p.width,height:p.height}}}var Je={abbreviation:"none",decimals:"auto"},Qn=({locale:e,kind:t,startValue:r,endValue:n,valueFormat:a})=>{if(r===null||n===null)return"n/a";switch(t){case"absolute-difference":return I({valueFormat:a,locale:e,numberFormat:Je,intlOptions:{signDisplay:"always"}})(n-r);case"relative-difference":{const i=n-r;if(i===0)return"0%";const o=i/r;return o===Number.POSITIVE_INFINITY?"∞":o===Number.NEGATIVE_INFINITY?"-∞":I({valueFormat:{type:"percentage"},locale:e,numberFormat:Je,intlOptions:{signDisplay:"always"}})(o)}case"proportion":{if(n-r===0)return"=";const i=n/r;return i===Number.POSITIVE_INFINITY?"∞":i===Number.NEGATIVE_INFINITY?"-∞":`${I({valueFormat:{type:"decimal"},locale:e,numberFormat:Je,intlOptions:{maximumFractionDigits:1}})(i)}x`}}},Vl=2,Nl=6,Fl=6,Bl=15,Gl=15,Hl=2.5,$l=.5,zl=.25,Jn=e=>{const t=e-Vl,r=1+$l*t,n=1+zl*t;return{arrowStartGap:Nl*r,arrowEndGap:Fl*r,offsetFromHigherObservation:Bl*n,arrowheadSize:Hl*e,curveRadius:Gl*n,strokeWidth:e}},Kl=(e,t,r,n)=>{const a=n.offsetFromHigherObservation+n.arrowheadSize+n.arrowEndGap;return e?Math.max(t.x,r.x)+a:Math.min(t.y,r.y)-a},Ul=(e,t,r,{arrowStartGap:n,arrowEndGap:a,curveRadius:i})=>{const o={x:e.x,y:e.y-n},s={x:e.x,y:r},c={x:t.x,y:r},u={x:t.x,y:t.y-a},d=t.x>e.x?1:-1;return`
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./annotations-Dy-Gx6J6.cjs"),m=require("./compiler-jGyzPM0J.cjs"),b=require("./spec-builder-CQ5p2Jzs.cjs");let $=require("color2k"),Dn=require("date-fns"),Us=require("lodash-es"),ae=require("lodash-es/clamp");ae=l.__toESM(ae,1);let lt=require("humanize-duration");lt=l.__toESM(lt,1);let R=require("d3-shape"),Ws=require("d3-delaunay"),Pe=require("lodash-es/isEqual");Pe=l.__toESM(Pe,1);typeof window<"u"&&(window.__GRAPHY_SDK__??={},window.__GRAPHY_SDK__.vizEngine="1.9.0-beta.1790336628799");var Ys=1e6;function _(e){return String(Math.round(e*Ys))}var yr="#FFFFFF",Ze="#1A1A1A",Xs=4.5,On=e=>{try{return(0,$.getContrast)(e,yr)>(0,$.getContrast)(e,Ze)?yr:Ze}catch{return Ze}},qs=(e,t)=>{try{const r=_n(void 0,t);return r===void 0||(0,$.getContrast)(r,e)>=Xs?e:On(r)}catch{return e}},_n=(e,t)=>{try{if(e===void 0){const[,,,n]=(0,$.parseToRgba)(t);return n>=1?t:void 0}const[,,,r]=(0,$.parseToRgba)(e);return r>=1?e:(0,$.parseToRgba)(t)[3]<1?void 0:(0,$.mix)(t,(0,$.opacify)(e,1),r)}catch{return}};function W(e,t){return e.geom===t}var Qe="…",kn=(e,t,r)=>{if(t<=0||e.length===0)return"";if(r(e)<=t)return e;if(r(Qe)>t)return"";let n=0,a=e.length-1,i=0;for(;n<=a;){const o=n+a>>>1;r(e.slice(0,o)+Qe)<=t?(i=o,n=o+1):a=o-1}return e.slice(0,i)+Qe};var C={timeZone:"UTC"},L=e=>t=>{if(!l.isStrictTemporalDataValue(t))return"–";try{return e(t)}catch{return"n/a"}},z=e=>t=>l.isStrictNumericDataValue(t)?e(t):"–",bt=e=>t=>l.isStrictCategoricalDataValue(t)?t:"–",be=new Map,xe=new Map,Vn=256,le=(e,t)=>{const r=Nn(e,t),n=be.get(r);if(n!==void 0)return n;be.size>=Vn&&be.clear();const a=new Intl.NumberFormat(e,t);return be.set(r,a),a},w=(e,t)=>{const r=Nn(e,t),n=xe.get(r);if(n!==void 0)return n;xe.size>=Vn&&xe.clear();const a=new Intl.DateTimeFormat(e,t);return xe.set(r,a),a},Nn=(e,t)=>`${e}\0${JSON.stringify(t)}`,js=lt.default.humanizer({language:"en",spacer:"",delimiter:" ",languages:{en:{y:()=>"y",mo:()=>"mo",w:()=>"w",d:()=>"d",h:()=>"h",m:()=>"m",s:()=>"s",ms:()=>"ms"}}}),Fn=({valueFormat:e,locale:t,numberFormat:r,intlOptions:n})=>z(a=>{const i=typeof r.decimals=="number"?r.decimals:2,o=It(a,i),{base:s,suffix:c}=At(a,r.abbreviation);return`${le(t,{...o,...l.isCurrencyValueFormat(e)?{style:"currency",currencyDisplay:"narrowSymbol",currency:e.iso}:{},...n}).format(s)}${c}`}),Bn=({locale:e,numberFormat:t,intlOptions:r})=>z(n=>{const{base:a,suffix:i}=At(n,t.abbreviation);return`${le(e,{...It(a,t.decimals),...r}).format(a)}${i}`}),xt=e=>z(t=>js(t)),Gn=({locale:e,intlOptions:t})=>{const r=le(e,{maximumFractionDigits:0,...t});return z(n=>r.format(n))},Hn=({locale:e,numberFormat:t,intlOptions:r})=>z(n=>le(e,{...It(n,t.decimals),...r,style:"percent"}).format(n)),At=(e,t="none")=>{switch(t){case"none":return{base:e,suffix:""};case"auto":{const r=Zs(e);return At(e,r)}default:return{base:e/l.SUFFIX_MULTIPLIERS[t],suffix:t}}},It=(e,t)=>{if(typeof t=="number")return{minimumFractionDigits:t,maximumFractionDigits:t};const r=Math.ceil(Math.log10(Math.abs(e))),n=r>=3?0:r===2?1:2;return{minimumFractionDigits:t==="auto"?0:n,maximumFractionDigits:n}},Zs=e=>{const t=Math.abs(e);return t>=l.SUFFIX_MULTIPLIERS.b?"b":t>=l.SUFFIX_MULTIPLIERS.m?"m":t>=l.SUFFIX_MULTIPLIERS.k?"k":"none"},Qs=({locale:e,intlOptions:t})=>{const r=w(e,{dateStyle:"medium",...C,...t});return L(n=>r.format(n))},Js=({locale:e,intlOptions:t})=>{const r=w(e,{dateStyle:"medium",timeStyle:"medium",...C,...t});return L(n=>el(r.formatToParts(n).map(tl)))},$n=({locale:e,intlOptions:t})=>{const r=w(e,{day:"numeric",month:"long",...C,...t});return L(n=>r.format(n))},zn=({locale:e,intlOptions:t})=>{const r=w(e,{month:"long",...C,...t});return L(n=>r.format(n))},Tt=({locale:e,intlOptions:t})=>{const r=w(e,{month:"short",year:"numeric",...C,...t});return L(n=>r.format(n))},Lt=e=>L(t=>`Q${Math.floor(t.getUTCMonth()/3)+1} ${t.getUTCFullYear()}`),Kn=({locale:e,intlOptions:t})=>{const r=w(e,{day:"numeric",month:"long",...C,...t,year:void 0});return L(n=>r.formatRange(n,(0,Dn.addDays)(n,6)))},Un=({locale:e,intlOptions:t})=>{const r=w(e,{dateStyle:"medium",...C,...t});return L(n=>r.formatRange(n,(0,Dn.addDays)(n,6)))},Et=({locale:e,intlOptions:t})=>{const r=w(e,{year:"numeric",...C,...t});return L(n=>r.format(n))},Wn=({locale:e,intlOptions:t})=>{const r=w(e,{timeStyle:"short",...C,...t});return L(n=>r.format(n))},el=e=>e.map(t=>t.value).join(""),tl=e=>e.type!=="literal"||e.value!==", "?e:{type:"literal",value:" • "},Sr=1e3,rl=({valueFormat:e,locale:t,tickValues:r,intlOptions:n})=>z(a=>{const i={...Ct(a,r),notation:"compact",...l.isCurrencyValueFormat(e)?{style:"currency",currencyDisplay:"narrowSymbol",currency:e.iso}:{},...n};return Rt(a,t,i)}),nl=({locale:e,tickValues:t,intlOptions:r})=>z(n=>{const a={...Ct(n,t),notation:"compact",...r};return Rt(n,e,a)}),al=({locale:e,tickValues:t,intlOptions:r})=>z(n=>{const a={...Ct(n,t),notation:"compact",...r,style:"percent"};return Rt(n,e,a)}),Rt=(e,t,r)=>le(t,r).formatToParts(e).map(n=>n.type==="compact"?n.value.toLowerCase():n.value).join(""),Yn=e=>Math.abs(e)>Sr?Yn(e/Sr):Number.isInteger(e),il=e=>{if(e.length<2)return!1;const[t,r]=e;return typeof t!="number"||typeof r!="number"?!1:Math.abs(r-t)<1},Ct=(e,t)=>Yn(e)?{minimumFractionDigits:0,maximumFractionDigits:0}:il(t)?{minimumFractionDigits:0,maximumFractionDigits:4}:{minimumFractionDigits:0,maximumFractionDigits:1},ol=({locale:e,intlOptions:t})=>{const r=w(e,{day:"numeric",month:"short",...C,...t});return L(n=>r.format(n))},sl=({locale:e,intlOptions:t})=>{const r=w(e,{month:"short",...C,...t});return L(n=>r.format(n))},ll=({locale:e,intlOptions:t})=>{const r=w(e,{day:"numeric",month:"short",...C,...t});return L(n=>r.format(n))},cl=({locale:e,intlOptions:t})=>{const r=w(e,{timeStyle:"short",...C,...t});return L(n=>r.format(n))},wt=e=>{const{valueFormat:t}=e;switch(t.type){case"currency":return rl(e);case"date":case"datetime":return ol(e);case"day_month":case"weekly_date_range":case"weekly_date_range_with_year":return ll(e);case"decimal":case"integer":return nl(e);case"duration":return xt(e);case"month":return sl(e);case"month_year":return Tt(e);case"percentage":return al(e);case"quarter":return Lt(e);case"text":return bt(e);case"time":return cl(e);case"year":return Et(e);case"lookup":return wt({...e,valueFormat:t.fallback});default:throw new l.InternalError({message:`Unhandled value format: ${t.type}`})}},ul=.9,dl=1/3,ml=1/4,hl=e=>e.formattedAxis.position==="top"||e.formattedAxis.position==="bottom"?pl(e):fl(e),pl=({formattedAxis:e,bandwidthPx:t,panelRect:r,measureLabel:n})=>{const{widths:a,maxWidth:i,maxHeight:o}=Xn(e.ticks,n),s=gl(e.ticks,r.width),c=s*ul;if(i<=c)return{...e,labelRotation:0,labelMaxWidthPx:null};if(s>=50){const d=ut(c);return{...e,ticks:ct(e.ticks,a,d,n),labelRotation:0,labelMaxWidthPx:d}}if(o+8>t)return{...e,ticks:[],labelRotation:0,labelMaxWidthPx:null};const u=ut(r.height*dl);return{...e,ticks:ct(e.ticks,a,u,n),labelRotation:-90,labelMaxWidthPx:u}},fl=({formattedAxis:e,bandwidthPx:t,panelRect:r,measureLabel:n})=>{const{widths:a,maxWidth:i,maxHeight:o}=Xn(e.ticks,n);if(o>t)return{...e,ticks:[],labelRotation:0,labelMaxWidthPx:null};const s=ut(r.width*ml);return i<=s?{...e,labelRotation:0,labelMaxWidthPx:null}:{...e,ticks:ct(e.ticks,a,s,n),labelRotation:0,labelMaxWidthPx:s}},gl=(e,t)=>{const r=e[0],n=e[1];return r===void 0||n===void 0?t:Math.abs(n.position-r.position)*t},Xn=(e,t)=>{const r=[];let n=0,a=0;for(const i of e){const{width:o,height:s}=t(i.formattedLabel);r.push(o),o>n&&(n=o),s>a&&(a=s)}return{widths:r,maxWidth:n,maxHeight:a}},ct=(e,t,r,n)=>{const a=i=>n(i).width;return e.map((i,o)=>(t[o]??0)<=r?i:{...i,formattedLabel:kn(i.formattedLabel,r,a)})},ut=e=>Math.max(0,Math.floor(e)),vl=(e,t,r,n,a)=>{if(e===0)return!0;const i=r==="top"||r==="bottom",o=i?60:40;let s=n-(e-1)*o;for(let c=0;c<e;c+=1){const{width:u,height:d}=a(t(c));if(s-=i?u:d,s<0)return!1}return!0},yl={ticks:[],labelAt:()=>""},Sl=({axis:e,availableSpacePx:t,measureLabel:r,resolveFormatter:n})=>{const{tickCandidates:a,position:i}=e;if(a.length===0)return[];const o=new Map,s=h=>{const p=o.get(h);if(p)return p;const f=a[h],g=f?bl(f.ticks,n(f)):yl;return o.set(h,g),g};let c=0,u=a.length-1,d=-1;for(;c<=u;){const h=c+u>>>1,{ticks:p,labelAt:f}=s(h);vl(p.length,f,i,t,r)?(d=h,c=h+1):u=h-1}return xl(s(d>=0?d:0))},bl=(e,t)=>{const r=new Array(e.length);return{ticks:e,labelAt:n=>{const a=r[n];if(a!==void 0)return a;const i=t(e[n]?.value??null);return r[n]=i,i}}},xl=({ticks:e,labelAt:t})=>e.map((r,n)=>({...r,formattedLabel:t(n)})),Al=e=>{const t=I({...e,valueFormat:e.valueFormat.fallback}),r={};for(const[a,i]of Object.entries(e.valueFormat.cases))r[a]=I({...e,valueFormat:i});const n=e.valueFormat.byVariable;return(a,i)=>{if(i===void 0||i[n]===void 0)return t(a);const o=l.getStableKey(i[n]),s=r[o];return s!==void 0?s(a,i):t(a)}},I=e=>{switch(e.valueFormat.type){case"currency":return Fn(e);case"date":return Qs(e);case"datetime":return Js(e);case"day_month":return $n(e);case"decimal":return Bn(e);case"duration":return xt(e);case"integer":return Gn(e);case"month":return zn(e);case"month_year":return Tt(e);case"percentage":return Hn(e);case"quarter":return Lt(e);case"text":return bt(e);case"weekly_date_range":return Kn(e);case"weekly_date_range_with_year":return Un(e);case"year":return Et(e);case"time":return Wn(e);case"lookup":return Al({...e,valueFormat:e.valueFormat});default:{const t=e.valueFormat;throw new l.InternalError({message:`Unhandled value format: ${t.type}`})}}};function Pt({layer:e,numberFormat:t,locale:r}){return I({valueFormat:m.getLayerYValueFormat(e),locale:r,numberFormat:t})}var Il=(e,t)=>{const r=l.readVariableName(t.x);return r!==null&&r!==l.CONSTANT_VARIABLES.x?{read:m.createXValueReader(e,t),variable:r}:{read:m.getGroup,variable:l.GROUP_VARIABLES.group}},qn=({layer:e,coordSystem:t,axes:r,numberFormat:n,panelRect:a,measureDataLabel:i,readers:o,formattingLocale:s,percentageValueStrategy:c})=>{const u=Pt({layer:e,numberFormat:n,locale:s}),d=t.type==="cartesian"&&t.mainAxis==="y";return{layer:e,coordSystem:t,panelRect:a,measureDataLabel:i,styleReaders:o.geom(e),formatLabel:Cl({layer:e,numberFormat:n,axes:r,locale:s,absoluteFormatter:u,percentageValueStrategy:c,isFlipped:d}),formatAbsolute:u,formatCategory:Tl({layer:e,numberFormat:n,locale:s})}},Tl=({layer:e,numberFormat:t,locale:r})=>{const{read:n,variable:a}=Il(e.data,e.mapping),i=I({valueFormat:e.data.hasVariable(a)?e.data.getValueFormat(a):{type:"text"},locale:r,numberFormat:t});return o=>{const s=n(o);return s===null?null:i(s,o)}},Ll=(e,t,r)=>{switch(t){case"stack":return El(e);case"fill":return Rl(e,r);case"absoluteGrandTotal":return()=>e.summary.absoluteGrandTotal??null;case"none":return()=>null}},El=e=>{const t=l.readVariableName(e.mapping.x);let r=null,n=!1;return a=>{const i=e.summary.stackTotals;if(i===void 0||i.length===0||t===null)return null;if(!n){r=new Map;for(const c of i)r.set(c.xKey,c);n=!0}const o=a[t];if(o==null)return null;const s=r?.get(m.getObservationXKey(a,t));return s===void 0?null:s.total}},Rl=(e,t)=>{const r=t?l.getXMin:l.getYMin,n=t?l.getXMax:l.getYMax,a=m.createSegmentYReader(e);return i=>{const o=r(i),s=n(i);if(!l.isStrictNumericDataValue(o)||!l.isStrictNumericDataValue(s))return null;const c=Math.abs(s-o);if(c===0)return null;const u=a(i);return l.isStrictNumericDataValue(u)?u/c:null}},Cl=({layer:e,numberFormat:t,axes:r,locale:n,absoluteFormatter:a,percentageValueStrategy:i,isFlipped:o})=>{const s=m.createRawValueReader(e.data,e.dataLabels.labelSource),c=Ll(e,i,o),u=wl({layer:e,numberFormat:t,axes:r,locale:n,absoluteFormatter:a}),d=I({valueFormat:{type:"percentage"},locale:n,numberFormat:t}),h=e.dataLabels.format==="percentage"&&jn(e);return p=>{const f=s(p);if(f===null)return"";if(!h||!l.isStrictNumericDataValue(f))return u(f,p);const g=c(p);return g===null||g===0?u(f,p):d(f/g)}},wl=({layer:e,numberFormat:t,axes:r,locale:n,absoluteFormatter:a})=>{const i=e.dataLabels.labelSource,o=l.readVariableName(i);if(o!==null){if(jn(e))return a;const s=Pl(e,r,t,n,o);if(s!==null)return s}return I({valueFormat:Ml(e.data,i),locale:n,numberFormat:t})},jn=e=>{const t=l.readVariableName(e.dataLabels.labelSource);return t===null?!1:t===l.readVariableName(m.resolveSegmentYSource(e.position,e.mapping))},Pl=(e,t,r,n,a)=>{const i=l.readVariableName(e.mapping.x);if(i===null||i!==a)return null;const o=t.find(s=>s.scaleAestheticKey==="x");return o===void 0?null:I({valueFormat:o.valueFormat,locale:n,numberFormat:r})},Ml=(e,t)=>{const r=l.readConstantValue(t);if(r!==void 0)return l.isNumericDataValue(r)?{type:"decimal"}:l.isTemporalDataValue(r)?{type:"date"}:{type:"text"};const n=l.readVariableName(t);return n===null||!e.hasVariable(n)?{type:"text"}:e.getValueFormat(n)},Dl={cartesian:["cartesian","flip"],polar:["polar"]},Ol=null;function Zn(e=[]){const t=_l(e),r=(n,a)=>{if(!t.has(n))return null;const i=t.get(n);return i.getDataLabelPlacements===void 0||!Dl[a].some(o=>i.dataLabelCoordTypes.includes(o))?null:{place:i.getDataLabelPlacements.bind(i),getPercentageValueStrategy:o=>i.resolvePercentageValueStrategy?.(o,a)??"none"}};return{resolve:r,hasCapability:(n,a)=>r(n,a)!==null,hasPercentageFormat:(n,a)=>(r(n.geom,a)?.getPercentageValueStrategy(n)??"none")!=="none"}}function Mt(){return Ol??=Zn()}function _l(e){const t=new l.GeomRegistry;for(const r of e){const n=l.resolveDefinition(r);n instanceof l.Geom&&t.register(n.type,n)}return t}function*kl({layers:e,coordSystem:t,axes:r,numberFormat:n,panelRect:a,measureDataLabel:i,readers:o,locale:s,resolvePlacement:c=Mt()}){if(!(t.type!=="cartesian"||a.width<=0||a.height<=0))for(const u of e){if(!u.dataLabels.showDataLabels&&!u.dataLabels.showStackTotals)continue;const d=c.resolve(u.geom,"cartesian");if(d===null)continue;const h=qn({layer:u,coordSystem:t,axes:r,numberFormat:n,panelRect:a,measureDataLabel:i,readers:o,formattingLocale:s,percentageValueStrategy:d.getPercentageValueStrategy(u)});for(const p of d.place(h).labels)yield{x:a.x+p.x-p.width/2,y:a.y+p.y-p.height/2,width:p.width,height:p.height}}}var Je={abbreviation:"none",decimals:"auto"},Qn=({locale:e,kind:t,startValue:r,endValue:n,valueFormat:a})=>{if(r===null||n===null)return"n/a";switch(t){case"absolute-difference":return I({valueFormat:a,locale:e,numberFormat:Je,intlOptions:{signDisplay:"always"}})(n-r);case"relative-difference":{const i=n-r;if(i===0)return"0%";const o=i/r;return o===Number.POSITIVE_INFINITY?"∞":o===Number.NEGATIVE_INFINITY?"-∞":I({valueFormat:{type:"percentage"},locale:e,numberFormat:Je,intlOptions:{signDisplay:"always"}})(o)}case"proportion":{if(n-r===0)return"=";const i=n/r;return i===Number.POSITIVE_INFINITY?"∞":i===Number.NEGATIVE_INFINITY?"-∞":`${I({valueFormat:{type:"decimal"},locale:e,numberFormat:Je,intlOptions:{maximumFractionDigits:1}})(i)}x`}}},Vl=2,Nl=6,Fl=6,Bl=15,Gl=15,Hl=2.5,$l=.5,zl=.25,Jn=e=>{const t=e-Vl,r=1+$l*t,n=1+zl*t;return{arrowStartGap:Nl*r,arrowEndGap:Fl*r,offsetFromHigherObservation:Bl*n,arrowheadSize:Hl*e,curveRadius:Gl*n,strokeWidth:e}},Kl=(e,t,r,n)=>{const a=n.offsetFromHigherObservation+n.arrowheadSize+n.arrowEndGap;return e?Math.max(t.x,r.x)+a:Math.min(t.y,r.y)-a},Ul=(e,t,r,{arrowStartGap:n,arrowEndGap:a,curveRadius:i})=>{const o={x:e.x,y:e.y-n},s={x:e.x,y:r},c={x:t.x,y:r},u={x:t.x,y:t.y-a},d=t.x>e.x?1:-1;return`
|
|
2
2
|
M ${o.x} ${o.y}
|
|
3
3
|
L ${s.x} ${s.y+i}
|
|
4
4
|
Q ${s.x} ${s.y} ${s.x+d*i} ${s.y}
|
package/dist/index.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import Xl from "humanize-duration";
|
|
|
9
9
|
import { area as Ua, curveCatmullRom as Zl, curveLinear as Ql, line as ja, symbol as qa, symbolCircle as Jl, symbolCross as ec, symbolDiamond as tc, symbolSquare as rc, symbolStar as nc, symbolTriangle as ac, symbolWye as ic } from "d3-shape";
|
|
10
10
|
import { Delaunay as sc } from "d3-delaunay";
|
|
11
11
|
import Xa from "lodash-es/isEqual";
|
|
12
|
-
typeof window < "u" && (window.__GRAPHY_SDK__ ??= {}, window.__GRAPHY_SDK__.vizEngine = "1.9.0-beta.
|
|
12
|
+
typeof window < "u" && (window.__GRAPHY_SDK__ ??= {}, window.__GRAPHY_SDK__.vizEngine = "1.9.0-beta.1790336628799");
|
|
13
13
|
var oc = 1e6;
|
|
14
14
|
function H(e) {
|
|
15
15
|
return String(Math.round(e * oc));
|