@graphysdk/viz-engine 1.9.0-beta.1791444651663 → 1.9.0-beta.1791458483540
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.d.ts +4 -9
- package/dist/graph-config.mjs +212 -205
- package/dist/index.cjs +4 -4
- package/dist/index.d.ts +19 -1
- package/dist/index.mjs +1569 -1544
- package/package.json +4 -4
package/dist/graph-config.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./annotations-BEb-h7gP.cjs"),s=require("./spec-builder-n8kRICtS.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},w=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="",u]=n.split("/"),c=V(l);if(c===null)return null;const d=u===void 0?null:X(u),v=t.slice(i+1).join(" ").trim();return v===""?null:{style:r,weight:o,size:c,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=[],u=[],c=[],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":u.push(pe(h));break;case"image":c.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:u,images:c,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=[],u=Ne(e?.border,n),c=_e(e,t,n),d=B(e?.textStyle?.body?.fontId,i.fontList),v=e?.textStyle?.body?.color,p={...c===void 0?{}:{fill:c},...u,...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:we(o,F),dark:xe(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}%)`,we=(e,t)=>`hsl(from ${e} h s calc(l * ${1+t}))`,xe=(e,t)=>`hsl(from ${e} h s calc(l * ${1-t}))`,De={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),tooltip:Ue(e.appearance),content:We(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:De[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){return e?.showTooltips===!1?{mode:"none"}:void 0}function We(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=Me(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 Me(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 x=a.prefixInternalVariable("constantY"),Oe=.15,Ge=(e,t,r,o)=>Ze[t](e,r,o),D=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})]}},ze=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:x,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:x,type:"categorical",value:""})],scales:[s.scale.y.discrete()]}),Ye=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}=D(e.dataset),l=R({appearance:r,seriesVariables:n}),u=n.length<=1,c=[a.geom.line({params:{curve:t?.isSmoothLine?"smooth":"linear",missingValues:t?.missingValues}})],d=[];return u&&(t?.showFill??!0)&&d.push(s.style.geom.line({fillAlpha:Oe})),typeof t?.lineThickness=="number"&&d.push(s.style.geom.line({strokeWidth:t.lineThickness})),t?.showPoints&&(c.push(a.geom.point({interactive:!1})),typeof t.pointSize=="number"&&d.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:d}},Xe=(e,t,r)=>{const{transforms:o,mapping:i,seriesVariables:n}=D(e.dataset),l=R({appearance:r,seriesVariables:n}),u=[a.geom.area({position:"stack",params:{curve:t?.isSmoothLine?"smooth":"linear",missingValues:t?.missingValues}})],c=[];return typeof t?.lineThickness=="number"&&c.push(s.style.geom.area({strokeWidth:t.lineThickness})),t?.showPoints&&(u.push(a.geom.point({position:"stack",interactive:!1})),typeof t.pointSize=="number"&&c.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:c}},S=(e,t,r,o,i)=>{const{transforms:n,mapping:l,seriesVariables:u}=D(e.dataset),c=[...n];if(o?.sortBars){const d=a.readVariableName(l.y);d!==null&&d!==""&&c.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:c,seriesVariables:u}},U=(e,t)=>({layers:[a.geom.bar({position:"fill"})],coords:s.coord.polar({theta:"y",innerRadius:t==="donut"?.55:0}),mapping:Ye(e.dataset),scales:[],seriesVariables:[]}),Ke=e=>{const{transforms:t,scales:r,mapping:o}=ze(e.dataset);return{layers:[a.geom.point()],coords:s.coord.cartesian(),mapping:o,scales:r,transforms:t,seriesVariables:[]}},$e=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]??x,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:[]}},je=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})},qe=(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),u=s.COMBO_BAR_POSITIONS[t?.comboType??"grouped-bars"],c=u===null;if(l.length===1)return c?Z(e,t,r):S(e,"dodge",s.coord.cartesian(),t,r);const d=e.axes?.hasDualYAxis===!0,v=c?[]:l.slice(0,-1),p=c?l:l.slice(-1),m=[],h=[];if(u!==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:u})):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:u}))}if(c&&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}})},Ze={line:(e,t,r)=>Z(e,t,r),areaStacked:(e,t,r)=>Xe(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=>Ke(e),bubble:e=>$e(e),combo:(e,t,r)=>qe(e,t,r),funnel:E("funnel"),heatmap:e=>je(e),waterfall:E("waterfall"),mekko:E("mekko"),table:E("table")},Je=new a.TransformRegistry,Qe=["key",a.prefixInternalVariable("lineSeriesLabel"),a.prefixInternalVariable("barSeriesLabel")];function et(e){const t=e.annotations??[],r=rt(e.mapping),o=it(e.dataset,e.transforms,e.layers),i=[];for(const n of t){if(n.type!=="highlight")continue;const l=ot({annotation:n,rowIdentityVariable:r,dataset:e.dataset,compiledVariableNames:o});l!==null&&i.push({type:"highlight",id:n.id,predicate:l,scope:tt(n.highlight,e.mapping)})}return i}function tt(e,t){const r=a.readVariableName(t.x);return!(r!==null&&r!=="")&&e==="x-value"?"series":e}function rt(e){const t=a.readVariableName(e.x);return t!==null&&t!==""?t:a.readVariableName(e.color)}function ot({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=nt(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=Qe.filter(i=>t.includes(i));return o.length===0?null:{or:o.map(i=>({variable:i,eq:r}))}}function it(e,t,r){const o=[...e.getVariableNames()],i=n=>{for(const l of n){const{getIntroducedVariables:u}=Je.get(l.transformType),c=u?.(l);c&&o.push(...c)}};i(t);for(const n of r)i(n.transforms??[]);return o}function nt(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 st(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(at(n))return{type:"mono",base:n,variant:o}}if(e?.startsWith("preset:neon:")){const n=e.slice(12);if(lt(n))return{type:"neon",base:n,variant:_(t)}}return{type:"default"}}function _(e){if(e==="waterfall")return"waterfall"}function at(e){return a.MONO_BASES.includes(e)}function lt(e){return a.NEON_BASES.includes(e)}function ct({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 ut(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 dt(e){const t=[],r=g(e?.fontAxisLabel);r!==void 0&&t.push(s.style.axisLabel(r));const o=kt(e);o!==void 0&&t.push(s.style.tickLabel(o));const i=g(e?.fontGoalLineLabel);i!==void 0&&t.push(s.style.geom.rule.label(i)),t.push(...bt(e)),t.push(...ft(e)),t.push(...yt(e)),t.push(...gt(e));const n=b(e?.headlineRowGap);return n!==void 0&&t.push(s.style.headlineItem({gap:n})),t}function ft(e){const t=[],r=vt(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 u=y(e?.tooltipPrimaryRowColor);u!==void 0&&t.push(s.style.tooltip.primaryRow({fill:u}));const c=pt(e);return c!==void 0&&t.push(s.style.annotation.pinnedNumber.label(c),s.style.annotation.comment.label(c)),t}var pt=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},vt=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),u=b(e?.tooltipRowGap),c=typeof e?.tooltipShadow=="string"?St(e.tooltipShadow)??void 0:void 0,d={...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},...u===void 0?{}:{gap:u},...c===void 0?{}:{shadow:c}};return Object.keys(d).length===0?void 0:d};function yt(e){const t=[],r=b(e?.legendItemGap);r!==void 0&&t.push(s.style.legend({gap:r}));const o=y(e?.legendFocusOutlineColor);o!==void 0&&t.push(s.style.legend({focusStroke:o}));const i=g(e?.fontLegendLabel),n=y(e?.legendTextColor),l=A(i,n),u=mt(e,l);u!==void 0&&t.push(s.style.legendItem(u));const c=ht(e);return c!==void 0&&t.push(s.style.legendItem.swatch({size:c})),l!==void 0&&t.push(s.style.directLabel(l)),t}var mt=(e,t)=>{const r=y(e?.legendBackground),o=y(e?.legendBorderColor),i=b(e?.legendPillBorderWidth),n=b(e?.legendPillPaddingInline),l=b(e?.legendPillPaddingBlock),u=b(e?.legendSwatchGap),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},...u===void 0?{}:{gap:u}};return Object.keys(c).length===0?void 0:c},ht=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 bt(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 u=y(e?.stackTotalBackground),c=y(e?.stackTotalStroke);return(u!==void 0||c!==void 0)&&i.push(s.style.dataLabel.aggregate({...u===void 0?{}:{fill:u},...c===void 0?{}:{stroke:c}})),i}function gt(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 St(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:w(t.size),fontWeight:t.weight,...t.lineHeight===void 0?{}:{lineHeight:t.lineHeight}}}function kt(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:w(t)}var At=new Set(["column","columnStacked","columnStackedFill","bar","barStacked","barStackedFill","line","areaStacked","scatter","bubble","funnel","combo"]),Et=new Set(["column","columnStacked","columnStackedFill","bar","barStacked","barStackedFill","line","areaStacked","combo"]);function Tt(e,t,r={}){return Lt(a.parseDataset(t),e,r)}function Lt(e,t,r={}){const o=t.type??"column",i=Ge({dataset:e,axes:t.axes},o,t.options??void 0,t.appearance??void 0),n=i.coords.coordType==="flip",l=i.transforms??[],u=st(t.appearance?.paletteId,o,r),c=ut(t.appearance?.seriesStyles);return{mapping:i.mapping,layers:_t(o,t,i.layers,i.coords,i.mapping,i.seriesVariables),scales:[...ct({axes:t.axes,palette:u,overrides:c,isFlipped:n}),...i.scales],styles:Se(ge(be({palette:u,overrides:c,ctx:r}),[...i.styleDefaults??[],...ke(t.appearance??void 0),...Le({appearance:t.appearance??void 0,themeOverrides:t.themeOverrides,palette:u,overrides:c,ctx:r}),...dt(t.themeOverrides),...ne(t.themeOverrides)],ie(t.annotations)),se(t.themeOverrides)),transforms:l,highlights:et({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 _t(e,t,r,o,i,n){const l=Dt(t.dataLabels),u=l===void 0?r:r.map(d=>d.interactive===!1?d:{...d,dataLabels:{...l,...d.dataLabels}}),c=t.axes?.hasDualYAxis??!1;return[...u,...Nt({type:e,trendline:t.referenceLines?.trendline,coords:o,mapping:i}),...Vt({type:e,hasDualYAxis:c,goalLine:t.referenceLines?.goalLine,coords:o}),...xt({type:e,hasDualYAxis:c,averageLine:t.referenceLines?.averageLine,coords:o,mapping:i,seriesVariables:n})]}function Nt({type:e,trendline:t,coords:r,mapping:o}){return t===void 0?[]:At.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 Vt({type:e,hasDualYAxis:t,goalLine:r,coords:o}){if(!wt(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 wt(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(!Et.has(e))return[];if(o.coordType==="polar")return[];const l=$(r.columnKey);if(!n.includes(l))return[];const u=i.color==="key",c=u?a.DEFAULT_RESHAPE_VALUE_NAME:l,d=u?[s.transform.filter({variableName:"key",operator:"eq",value:l})]:[];return[a.geom.rule({aes:{y:c,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 Rt=[.8,1,1.2,1.4,1.6,1.8,2,2.5,3,4];exports.CHART_TEXT_SCALES=Rt;exports.ROOT_FONT_SIZE_PX=J;exports.convertGraphConfig=Tt;exports.isFontStyle=z;exports.parseFontLength=V;exports.parseFontShorthand=K;exports.parseFontWeight=Y;exports.parseUnitlessLineHeight=X;exports.toPixels=w;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./annotations-BEb-h7gP.cjs"),s=require("./spec-builder-n8kRICtS.cjs");var Q=10,ee=["normal","italic","oblique"],te=/^(\d*\.?\d+)(px|em)$/,z=/^\d*\.?\d+$/,re=1,oe=1e3,ie={normal:400,bold:700},Y=e=>ee.includes(e),V=e=>{const t=te.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"}},X=e=>{const t=e.trim(),r=ie[t];if(r!==void 0)return r;if(!z.test(t))return null;const o=Number.parseFloat(t);return o>=re&&o<=oe?o:null},K=e=>{const t=e.trim();return z.test(t)?Number.parseFloat(t):null},x=e=>e.unit==="em"?e.value*10:e.value,$=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(Y(p))r=p,i++;else{const m=X(p);if(m===null)break;o=m,i++}}const n=t[i];if(n===void 0)return null;const[l="",u]=n.split("/"),c=V(l);if(c===null)return null;const d=u===void 0?null:K(u),v=t.slice(i+1).join(" ").trim();return v===""?null:{style:r,weight:o,size:c,family:v,...d!==null?{lineHeight:d}:{}}};function ne(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 se(e){const t=[],r=e?.defaultAnnotationShapeFill;typeof r=="string"&&t.push(s.style.annotation.shape({fill:r}));const o=e?.annotationOutlineColor;return typeof o=="string"&&t.push(s.style.editOutline.selected({stroke:o})),t}function ae(e){const t=e?.defaultAnnotationArrowStroke;return typeof t=="string"?{annotationArrow:t}:void 0}var le="#%_ENCODED_%#",j=e=>{if(!e.startsWith(le))return e;try{const{value:t}=JSON.parse(e.slice(13));return typeof t=="string"?t:e}catch{return e}},ce=({annotations:e,dataset:t,mapping:r,seriesVariables:o})=>{const i=[],n=[],l=[],u=[],c=[],d=[],v=[],p=[],m={dataset:t,...ue(r,o)};for(const h of e??[])switch(h.type){case"difference-arrow":{const f=de(h,m);f!==null&&i.push(f);break}case"shape":n.push(fe(h));break;case"arrow":l.push(he(h));break;case"highlight":break;case"text":u.push(ve(h));break;case"image":c.push(pe(h));break;case"sticker":{const f=ye(h,m);f!==null&&d.push(f);break}case"tooltip":{const f=me(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:u,images:c,stickers:d,pinnedNumbers:v,comments:p}},ue=(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}},de=(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}},fe=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}}),pe=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}),ve=e=>({id:e.id,content:e.content,at:{anchorType:"panel",x:e.x,y:e.y},width:e.width,align:"top-left"}),ye=(e,t)=>{const r=T(t,e);return r===null?null:{id:e.id,at:{anchorType:"observation",...r},sticker:e.sticker}},me=(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}}},he=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=be(t,o,r);return n===null?null:i?a.isDefined(t.columnKey)?{anchorValue:n,groupValue:j(t.columnKey)}:null:{anchorValue:n,groupValue:void 0}},be=(e,t,r)=>!a.isDefined(e.rowIndex)||!r.hasVariable(t)?null:r.getValues(t)[e.rowIndex]??null;function ge({palette:e,overrides:t,ctx:r}){const o=q(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 Se(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 F(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 q(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",C=.1,B={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=q(r,o,i)??"#B84737",l=[],u=Ne(e?.border,n),c=_e(e,t,n),d=I(e?.textStyle?.body?.fontId,i.fontList),v=e?.textStyle?.body?.color,p={...c===void 0?{}:{fill:c},...u,...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=I(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:H(a.DEFAULT_GRAPH_BACKGROUND.light,r,B.light),dark:H(a.DEFAULT_GRAPH_BACKGROUND.dark,r,B.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,C),dark:we(o,C)},strokeWidth:r}:{stroke:o,strokeWidth:r}}function I(e,t){if(!(e===void 0||t===void 0))return t.find(r=>r.id===e)?.fontFamily}var Ve=e=>Ae.includes(e),H=(e,t,r)=>`color-mix(in srgb, ${e}, ${t} ${r*100}%)`,xe=(e,t)=>`hsl(from ${e} h s calc(l * ${1+t}))`,we=(e,t)=>`hsl(from ${e} h s calc(l * ${1-t}))`,De={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),tooltip:Ue(e.appearance),content:We(e.content)}).config}function Fe(e,t){if(!(!e&&!t))return{...e?{position:e.position}:void 0,...t}}function U(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:De[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=U("x",e?.x,e?.showGridLines),i=U("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){return e?.showTooltips===!1?{mode:"none"}:void 0}function We(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=Me(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 Me(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 w=a.prefixInternalVariable("constantY"),Oe=.15,Ge=(e,t,r,o)=>Ze[t](e,r,o),D=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})]}},ze=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?{...Z(),mapping:{x:i,y:w,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"}}},Z=()=>({transforms:[s.transform.constant({variableName:w,type:"categorical",value:""})],scales:[s.scale.y.discrete()]}),Ye=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}},J=(e,t,r)=>{const{transforms:o,mapping:i,seriesVariables:n}=D(e.dataset),l=R({appearance:r,seriesVariables:n}),u=n.length<=1,c=[a.geom.line({params:{curve:t?.isSmoothLine?"smooth":"linear",missingValues:t?.missingValues}})],d=[];return u&&(t?.showFill??!0)&&d.push(s.style.geom.line({fillAlpha:Oe})),typeof t?.lineThickness=="number"&&d.push(s.style.geom.line({strokeWidth:t.lineThickness})),t?.showPoints&&(c.push(a.geom.point({interactive:!1})),typeof t.pointSize=="number"&&d.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:d}},Xe=(e,t,r)=>{const{transforms:o,mapping:i,seriesVariables:n}=D(e.dataset),l=R({appearance:r,seriesVariables:n}),u=[a.geom.area({position:"stack",params:{curve:t?.isSmoothLine?"smooth":"linear",missingValues:t?.missingValues}})],c=[];return typeof t?.lineThickness=="number"&&c.push(s.style.geom.area({strokeWidth:t.lineThickness})),t?.showPoints&&(u.push(a.geom.point({position:"stack",interactive:!1})),typeof t.pointSize=="number"&&c.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:c}},S=(e,t,r,o,i)=>{const{transforms:n,mapping:l,seriesVariables:u}=D(e.dataset),c=[...n];if(o?.sortBars){const d=a.readVariableName(l.y);d!==null&&d!==""&&c.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:c,seriesVariables:u}},W=(e,t)=>({layers:[a.geom.bar({position:"fill"})],coords:s.coord.polar({theta:"y",innerRadius:t==="donut"?.55:0}),mapping:Ye(e.dataset),scales:[],seriesVariables:[]}),Ke=e=>{const{transforms:t,scales:r,mapping:o}=ze(e.dataset);return{layers:[a.geom.point()],coords:s.coord.cartesian(),mapping:o,scales:r,transforms:t,seriesVariables:[]}},$e=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:[]}:Z(),n={x:o,y:t[1]??w,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:[]}},je=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})},qe=(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),u=s.COMBO_BAR_POSITIONS[t?.comboType??"grouped-bars"],c=u===null;if(l.length===1)return c?J(e,t,r):S(e,"dodge",s.coord.cartesian(),t,r);const d=e.axes?.hasDualYAxis===!0,v=c?[]:l.slice(0,-1),p=c?l:l.slice(-1),m=[],h=[];if(u!==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:u})):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:u}))}if(c&&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}})},Ze={line:(e,t,r)=>J(e,t,r),areaStacked:(e,t,r)=>Xe(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=>W(e,"pie"),donut:e=>W(e,"donut"),scatter:e=>Ke(e),bubble:e=>$e(e),combo:(e,t,r)=>qe(e,t,r),funnel:E("funnel"),heatmap:e=>je(e),waterfall:E("waterfall"),mekko:E("mekko"),table:E("table")},Je=new a.TransformRegistry,Qe=["key",a.prefixInternalVariable("lineSeriesLabel"),a.prefixInternalVariable("barSeriesLabel")];function et(e){const t=e.annotations??[],r=rt(e.mapping),o=it(e.dataset,e.transforms,e.layers),i=[];for(const n of t){if(n.type!=="highlight")continue;const l=ot({annotation:n,rowIdentityVariable:r,dataset:e.dataset,compiledVariableNames:o});l!==null&&i.push({type:"highlight",id:n.id,predicate:l,scope:tt(n.highlight,e.mapping)})}return i}function tt(e,t){const r=a.readVariableName(t.x);return!(r!==null&&r!=="")&&e==="x-value"?"series":e}function rt(e){const t=a.readVariableName(e.x);return t!==null&&t!==""?t:a.readVariableName(e.color)}function ot({annotation:e,rowIdentityVariable:t,dataset:r,compiledVariableNames:o}){switch(e.highlight){case"x-value":return M(e,t,r);case"series":return O(e,o);case"data-point":{const i=M(e,t,r),n=O(e,o);return i===null&&n===null?null:i===null?n:n===null?i:{and:[i,n]}}}}function M(e,t,r){if(t===null)return null;const o=nt(e,t,r);return o===null?null:{variable:t,eq:o}}function O(e,t){const r=e.columnKey;if(!a.isDefined(r))return null;const o=Qe.filter(i=>t.includes(i));return o.length===0?null:{or:o.map(i=>({variable:i,eq:r}))}}function it(e,t,r){const o=[...e.getVariableNames()],i=n=>{for(const l of n){const{getIntroducedVariables:u}=Je.get(l.transformType),c=u?.(l);c&&o.push(...c)}};i(t);for(const n of r)i(n.transforms??[]);return o}function nt(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 st(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(at(n))return{type:"mono",base:n,variant:o}}if(e?.startsWith("preset:neon:")){const n=e.slice(12);if(lt(n))return{type:"neon",base:n,variant:_(t)}}return{type:"default"}}function _(e){if(e==="waterfall")return"waterfall"}function at(e){return a.MONO_BASES.includes(e)}function lt(e){return a.NEON_BASES.includes(e)}function ct({axes:e,palette:t,overrides:r,isFlipped:o}){const i=[];return i.push(G("x",o?e?.y:e?.x)),i.push(G("y",o?e?.x:e?.y)),i.push(s.scale.color.palette({palette:t,overrides:r})),i}function G(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 ut(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 dt(e){const t=[],r=g(e?.fontAxisLabel);r!==void 0&&t.push(s.style.axisLabel(r));const o=At(e);o!==void 0&&t.push(s.style.tickLabel(o));const i=g(e?.fontGoalLineLabel);i!==void 0&&t.push(s.style.geom.rule.label(i)),t.push(...gt(e)),t.push(...pt(e)),t.push(...mt(e)),t.push(...St(e));const n=b(e?.headlineRowGap);return n!==void 0&&t.push(s.style.headlineItem({gap:n})),t}function ft(e){const t={},r=e?.textPrimary,o=e?.textSecondary;return typeof r=="string"&&(t.textPrimary=r),typeof o=="string"&&(t.textSecondary=o),Object.keys(t).length===0?void 0:t}function pt(e){const t=[],r=yt(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 u=y(e?.tooltipPrimaryRowColor);u!==void 0&&t.push(s.style.tooltip.primaryRow({fill:u}));const c=vt(e);return c!==void 0&&t.push(s.style.annotation.pinnedNumber.label(c),s.style.annotation.comment.label(c)),t}var vt=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},yt=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),u=b(e?.tooltipRowGap),c=typeof e?.tooltipShadow=="string"?kt(e.tooltipShadow)??void 0:void 0,d={...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},...u===void 0?{}:{gap:u},...c===void 0?{}:{shadow:c}};return Object.keys(d).length===0?void 0:d};function mt(e){const t=[],r=b(e?.legendItemGap);r!==void 0&&t.push(s.style.legend({gap:r}));const o=y(e?.legendFocusOutlineColor);o!==void 0&&t.push(s.style.legend({focusStroke:o}));const i=g(e?.fontLegendLabel),n=y(e?.legendTextColor),l=A(i,n),u=ht(e,l);u!==void 0&&t.push(s.style.legendItem(u));const c=bt(e);return c!==void 0&&t.push(s.style.legendItem.swatch({size:c})),l!==void 0&&t.push(s.style.directLabel(l)),t}var ht=(e,t)=>{const r=y(e?.legendBackground),o=y(e?.legendBorderColor),i=b(e?.legendPillBorderWidth),n=b(e?.legendPillPaddingInline),l=b(e?.legendPillPaddingBlock),u=b(e?.legendSwatchGap),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},...u===void 0?{}:{gap:u}};return Object.keys(c).length===0?void 0:c},bt=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 gt(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 u=y(e?.stackTotalBackground),c=y(e?.stackTotalStroke);return(u!==void 0||c!==void 0)&&i.push(s.style.dataLabel.aggregate({...u===void 0?{}:{fill:u},...c===void 0?{}:{stroke:c}})),i}function St(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 kt(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=$(e);if(t!==null)return{fontFamily:t.family,fontSize:x(t.size),fontWeight:t.weight,...t.lineHeight===void 0?{}:{lineHeight:t.lineHeight}}}function At(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 Et=new Set(["column","columnStacked","columnStackedFill","bar","barStacked","barStackedFill","line","areaStacked","scatter","bubble","funnel","combo"]),Tt=new Set(["column","columnStacked","columnStackedFill","bar","barStacked","barStackedFill","line","areaStacked","combo"]);function Lt(e,t,r={}){return _t(a.parseDataset(t),e,r)}function _t(e,t,r={}){const o=t.type??"column",i=Ge({dataset:e,axes:t.axes},o,t.options??void 0,t.appearance??void 0),n=i.coords.coordType==="flip",l=i.transforms??[],u=st(t.appearance?.paletteId,o,r),c=ut(t.appearance?.seriesStyles),d=Nt(t);return{mapping:i.mapping,layers:Vt(o,t,i.layers,i.coords,i.mapping,i.seriesVariables),scales:[...ct({axes:t.axes,palette:u,overrides:c,isFlipped:n}),...i.scales],styles:F(F(Se(ge({palette:u,overrides:c,ctx:r}),[...i.styleDefaults??[],...ke(t.appearance??void 0),...Le({appearance:t.appearance??void 0,themeOverrides:d,palette:u,overrides:c,ctx:r}),...dt(d),...se(d)],ne(t.annotations)),ae(d)),ft(d)),transforms:l,highlights:et({annotations:t.annotations,dataset:e,mapping:i.mapping,transforms:l,layers:i.layers}),annotations:ce({annotations:t.annotations,dataset:e,mapping:i.mapping,seriesVariables:i.seriesVariables}),coords:i.coords,config:Pe(t,n,i.config)}}var Nt=e=>e.themeOverrides;function Vt(e,t,r,o,i,n){const l=Pt(t.dataLabels),u=l===void 0?r:r.map(d=>d.interactive===!1?d:{...d,dataLabels:{...l,...d.dataLabels}}),c=t.axes?.hasDualYAxis??!1;return[...u,...xt({type:e,trendline:t.referenceLines?.trendline,coords:o,mapping:i}),...wt({type:e,hasDualYAxis:c,goalLine:t.referenceLines?.goalLine,coords:o}),...Rt({type:e,hasDualYAxis:c,averageLine:t.referenceLines?.averageLine,coords:o,mapping:i,seriesVariables:n})]}function xt({type:e,trendline:t,coords:r,mapping:o}){return t===void 0?[]:Et.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 wt({type:e,hasDualYAxis:t,goalLine:r,coords:o}){if(!Dt(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 Dt(e){return e!==void 0&&Number.isFinite(e.target)}function Rt({type:e,hasDualYAxis:t,averageLine:r,coords:o,mapping:i,seriesVariables:n}){if(r===void 0)return[];if(!Tt.has(e))return[];if(o.coordType==="polar")return[];const l=j(r.columnKey);if(!n.includes(l))return[];const u=i.color==="key",c=u?a.DEFAULT_RESHAPE_VALUE_NAME:l,d=u?[s.transform.filter({variableName:"key",operator:"eq",value:l})]:[];return[a.geom.rule({aes:{y:c,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 Pt(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 Ft=[.8,1,1.2,1.4,1.6,1.8,2,2.5,3,4];exports.CHART_TEXT_SCALES=Ft;exports.ROOT_FONT_SIZE_PX=Q;exports.convertGraphConfig=Lt;exports.isFontStyle=Y;exports.parseFontLength=V;exports.parseFontShorthand=$;exports.parseFontWeight=X;exports.parseUnitlessLineHeight=K;exports.toPixels=x;
|
package/dist/graph-config.d.ts
CHANGED
|
@@ -1469,10 +1469,10 @@ declare type ContinuousScaleSpec = {
|
|
|
1469
1469
|
* reshape the graph type needs is emitted as a spec transform rather than applied here. The same
|
|
1470
1470
|
* `data` value the caller passed goes on to `compile`/`<GraphProvider>` untouched.
|
|
1471
1471
|
*
|
|
1472
|
-
* This is a one-way, lossy conversion. Features
|
|
1473
|
-
* line type,
|
|
1474
|
-
*
|
|
1475
|
-
*
|
|
1472
|
+
* This is a one-way, lossy conversion. Features the spec has no equivalent for (series styles beyond
|
|
1473
|
+
* line type, content) are silently dropped. A saved chart may still carry `themeOverrides`; those
|
|
1474
|
+
* keys are copied onto stylesheet settings here. `appearance.textStyle` resolves against
|
|
1475
|
+
* `ctx.fontList` into graph and heading style entries.
|
|
1476
1476
|
*/
|
|
1477
1477
|
export declare function convertGraphConfig(graphConfig: GraphConfig, data: Data, ctx?: GraphConfigContext): Spec;
|
|
1478
1478
|
|
|
@@ -3495,11 +3495,6 @@ export declare interface GraphConfig {
|
|
|
3495
3495
|
axes?: Axes;
|
|
3496
3496
|
legend?: Legend;
|
|
3497
3497
|
appearance?: Appearance;
|
|
3498
|
-
/** Ad-hoc overrides of individual theme tokens, plus a shortcut for the graph background. */
|
|
3499
|
-
themeOverrides?: {
|
|
3500
|
-
[key: string]: unknown;
|
|
3501
|
-
graphBackground?: string;
|
|
3502
|
-
};
|
|
3503
3498
|
content?: Content;
|
|
3504
3499
|
headlineNumbers?: HeadlineNumbers;
|
|
3505
3500
|
dataLabels?: DataLabels;
|