dsp-semactic 0.6.3 → 0.6.4

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/index.cjs.js CHANGED
@@ -18,7 +18,7 @@
18
18
  <path d="M67.37 43.9C74.0582 43.9 79.48 38.4782 79.48 31.79C79.48 25.1018 74.0582 19.68 67.37 19.68C60.6818 19.68 55.26 25.1018 55.26 31.79C55.26 38.4782 60.6818 43.9 67.37 43.9Z" fill="#fafafa"/>
19
19
  <path d="M47.5201 77.18H66.2501C73.5601 77.18 79.4801 71.26 79.4801 63.95C79.4801 56.64 73.5601 50.72 66.2501 50.72H47.3601C46.3801 50.72 45.5901 51.52 45.6001 52.5L45.7601 75.44C45.7601 76.41 46.5501 77.19 47.5201 77.19V77.18Z" fill="#07ACDD"/>
20
20
  <path d="M28.4201 76.12C35.1082 76.12 40.5301 70.6982 40.5301 64.01C40.5301 57.3218 35.1082 51.9 28.4201 51.9C21.7319 51.9 16.3101 57.3218 16.3101 64.01C16.3101 70.6982 21.7319 76.12 28.4201 76.12Z" fill="#fafafa"/>
21
- </svg>`)}`),Ve=e.computed(()=>{const t=O.value;return t&&t.radialLabels&&t.radialLabels.show===!0}),Se=e.computed(()=>{const t=O.value;return t&&t.radialLabels&&typeof t.radialLabels.fontSize=="number"?t.radialLabels.fontSize:12});e.computed(()=>{const t=O.value;return t&&t.radialLabels&&t.radialLabels.color?t.radialLabels.color:"#000"});const $t=e.computed(()=>{const t=O.value;return t&&t.radialLabels&&typeof t.radialLabels.pointerLength=="number"?t.radialLabels.pointerLength:25}),Zt=e.computed(()=>{const t=O.value;return t&&t.radialLabels&&typeof t.radialLabels.horizontalLength=="number"?t.radialLabels.horizontalLength:40}),rn=e.computed(()=>{const t=O.value;return t&&t.radialLabels&&typeof t.radialLabels.textOffset=="number"?t.radialLabels.textOffset:8}),Un=e.computed(()=>{const s=O.value?.radialBar?.dataLabels;return s&&(s.show===!0||s.enabled===!0)}),ko=e.computed(()=>{const s=O.value?.radialBar?.dataLabels?.minAngleDegrees;return typeof s=="number"&&s>=0?s:20}),co=e.computed(()=>{const s=O.value?.radialBar?.dataCenter;return no.value&&s&&(s.show===!0||s.enabled===!0)}),Rn=e.computed(()=>{if(!co.value||!yo.value.length)return"";const t=yo.value.reduce((s,o)=>s+(o.value??0),0);return sn(t)}),Wt=e.computed(()=>({x:Je.value,y:et.value-en.value+70})),Oo=e.computed(()=>{const s=O.value?.radialBar?.dataCenter?.fontSize;return typeof s=="number"&&s>0?s:24}),To=e.computed(()=>{const s=O.value?.radialBar?.dataCenter?.color;return typeof s=="string"&&s?s:"#333"}),En=e.computed(()=>{if(!Un.value||!gn.value||!yo.value.length)return[];const t=ko.value*Math.PI/180,s=(en.value+Pe.value)/2;return yo.value.map(o=>{const g=o.endAngle-o.startAngle>=t&&!o.isHidden,h=Je.value+Math.cos(o.midAngle)*s,w=et.value+Math.sin(o.midAngle)*s;return{value:sn(o.value),x:h,y:w,show:g,color:o.color}})}),Ho=e.computed(()=>{if(!I.flags||!I.flags.length)return[];const t=new Map;return I.flags.forEach(s=>{const o=s.categoryIndex;t.has(o)||t.set(o,[]),t.get(o).push(s)}),Array.from(t.entries()).map(([s,o])=>{const c=Mt(s),g=o.filter(w=>w.manual),h=o.filter(w=>!w.manual);return{categoryIndex:parseInt(s),x:c,flags:o,manualCount:g.length,autoCount:h.length,totalCount:o.length,hasManual:g.length>0,hasAuto:h.length>0,texts:o.map(w=>w.text).join(`
21
+ </svg>`)}`),Ve=e.computed(()=>{const t=O.value;return t&&t.radialLabels&&t.radialLabels.show===!0}),Se=e.computed(()=>{const t=O.value;return t&&t.radialLabels&&typeof t.radialLabels.fontSize=="number"?t.radialLabels.fontSize:12});e.computed(()=>{const t=O.value;return t&&t.radialLabels&&t.radialLabels.color?t.radialLabels.color:"#000"});const $t=e.computed(()=>{const t=O.value;return t&&t.radialLabels&&typeof t.radialLabels.pointerLength=="number"?t.radialLabels.pointerLength:25}),Zt=e.computed(()=>{const t=O.value;return t&&t.radialLabels&&typeof t.radialLabels.horizontalLength=="number"?t.radialLabels.horizontalLength:40}),rn=e.computed(()=>{const t=O.value;return t&&t.radialLabels&&typeof t.radialLabels.textOffset=="number"?t.radialLabels.textOffset:8}),Un=e.computed(()=>{const s=O.value?.radialBar?.dataLabels;return s&&(s.show===!0||s.enabled===!0)}),ko=e.computed(()=>{const s=O.value?.radialBar?.dataLabels?.minAngleDegrees;return typeof s=="number"&&s>=0?s:20}),co=e.computed(()=>{const s=O.value?.radialBar?.dataCenter;return no.value&&s&&(s.show===!0||s.enabled===!0)}),Rn=e.computed(()=>{if(!co.value||!yo.value.length)return"";const t=yo.value.reduce((s,o)=>s+(o.value??0),0);return sn(t)}),Wt=e.computed(()=>({x:Je.value,y:et.value-en.value+25})),Oo=e.computed(()=>{const s=O.value?.radialBar?.dataCenter?.fontSize;return typeof s=="number"&&s>0?s:24}),To=e.computed(()=>{const s=O.value?.radialBar?.dataCenter?.color;return typeof s=="string"&&s?s:"#333"}),En=e.computed(()=>{if(!Un.value||!gn.value||!yo.value.length)return[];const t=ko.value*Math.PI/180,s=(en.value+Pe.value)/2;return yo.value.map(o=>{const g=o.endAngle-o.startAngle>=t&&!o.isHidden,h=Je.value+Math.cos(o.midAngle)*s,w=et.value+Math.sin(o.midAngle)*s;return{value:sn(o.value),x:h,y:w,show:g,color:o.color}})}),Ho=e.computed(()=>{if(!I.flags||!I.flags.length)return[];const t=new Map;return I.flags.forEach(s=>{const o=s.categoryIndex;t.has(o)||t.set(o,[]),t.get(o).push(s)}),Array.from(t.entries()).map(([s,o])=>{const c=Mt(s),g=o.filter(w=>w.manual),h=o.filter(w=>!w.manual);return{categoryIndex:parseInt(s),x:c,flags:o,manualCount:g.length,autoCount:h.length,totalCount:o.length,hasManual:g.length>0,hasAuto:h.length>0,texts:o.map(w=>w.text).join(`
22
22
  `)}})}),cn=e.ref({show:!1,x:0,y:0,content:"",count:0}),Co=e.computed(()=>O.value?.bubbles?.tooltip?.fields||["x","y","size","label"]),uo=e.computed(()=>{const t=O.value;return{...{x:"X",y:"Y",size:"Size",label:"Label",seriesName:"Series"},...t?.bubbles?.tooltip?.labels||{}}}),bo=e.computed(()=>O.value?.bubbles?.tooltip?.formatters||{}),st=e.ref(new Set),K=e.ref(null),In=e.ref(!1),Me=e.ref({show:!1,x:0,y:0,title:"",value:"",bubbleData:[],spiderSeries:[]}),fn=e.ref({show:!1,x:0,y:0,categoryValue:"",description:""}),pe=e.ref({show:!1,x:0,categoryIndex:-1,data:[]}),ae=e.ref({show:!1,x:0,y:0,mouseDataX:0,mouseDataY:0,categoryIndex:-1,chartX:0,chartY:0}),F=e.ref({scale:1,offsetX:0,minScale:1,maxScale:2.5,isDragging:!1,lastMouseX:0,lastMouseY:0,isZooming:!1,zoomTimeout:null}),rt=e.ref([]),f=e.ref({show:!1,title:"",description:"",color:"#FF6B6B",type:"default",editingMarkerId:null,readonly:!1,categoryIndex:null,fromButton:!1});e.computed(()=>{const t=["default"];return Rt.value&&t.push(...Object.keys(Rt.value)),t});const k=e.computed(()=>{if(!I.categories||I.categories.length===0){const{maxX:t}=tt.value;return Array.from({length:t+1},(s,o)=>P("chart.fallback.item",{number:o+1}))}return I.categories}),E=e.computed(()=>f.value.editingMarkerId!==null),$=e.computed(()=>f.value.readonly),U=t=>{st.value.has(t)||(Tt.value=!0,K.value=t)},ye=()=>{Tt.value=!1,K.value=null},Be=t=>{if(vt.value||xt.value){pe.value.show=!1;return}const o=t.currentTarget.getBoundingClientRect(),c=t.clientX-o.left,g=t.clientY-o.top,h=wt.value?c>=B.value.left-50&&c<=B.value.right+50&&g>=B.value.top-50&&g<=B.value.bottom+100:c>=B.value.left&&c<=B.value.right&&g>=B.value.top&&g<=B.value.bottom;if(In.value=h,wt.value){if(!He.value||!h||F.value.isDragging||F.value.isZooming){pe.value.show=!1;return}if(Mo.value.find(q=>!q||q.isHidden?!1:Math.sqrt(Math.pow(q.x-c,2)+Math.pow(q.y-g,2))<=q.radius+3))pe.value.show=!1;else{const q=Mo.value.filter(ne=>!ne||ne.isHidden?!1:Math.sqrt(Math.pow(ne.x-c,2)+Math.pow(ne.y-g,2))<=250);if(q.length>0){let ne=q[0],G=Math.sqrt(Math.pow(ne.x-c,2)+Math.pow(ne.y-g,2));q.forEach(ee=>{const oe=Math.sqrt(Math.pow(ee.x-c,2)+Math.pow(ee.y-g,2));oe<G&&(G=oe,ne=ee)});const X=30,ke=Mo.value.filter(ee=>!ee||ee.isHidden?!1:Math.abs(ee.x-ne.x)<=X).sort((ee,oe)=>ee.y-oe.y);pe.value={show:!0,x:ne.x,categoryIndex:Math.round(ne.originalX),data:(()=>{const ee=Co.value,oe=uo.value,ce=[];return ke.forEach(ue=>{ee.forEach(Re=>{const Oe=oe[Re]||Re,yn=ol(Re,ue);yn&&ce.push({seriesName:ue.seriesName,label:ue.label,value:`${Oe}: ${yn}`,color:ue.color,y:ue.y})})}),ce})()}}else pe.value.show=!1}return}if(F.value.isDragging&&F.value.scale>1&&Yt.value&&Bt.value){pe.value.show=!1;const se=t.clientX-F.value.lastMouseX,{minX:q,maxX:ne}=tt.value,G=ne-q||1,ke=se*.8;F.value.offsetX+=ke;const ee=G/F.value.scale,oe=G-ee,ce=0,ue=-oe/G*B.value.width,Re=ce;F.value.offsetX=Math.max(ue,Math.min(Re,F.value.offsetX)),F.value.lastMouseX=t.clientX,F.value.lastMouseY=t.clientY;return}if(!He.value||!Yt.value||F.value.isDragging||F.value.isZooming||!h){pe.value.show=!1;return}const{minX:w,maxX:C}=tt.value,S=C-w||1,H=S/F.value.scale,L=w-F.value.offsetX/B.value.width*S,_=(c-B.value.left)/B.value.width,Y=L+_*H,le=Math.round(Y);if(le>=0&&le<=C){const se=Mt(le),q=Sn.value.map((ne,G)=>{const X=I.series.findIndex(ee=>ee===ne),ke=ne.data[le];return{seriesName:ne.name,value:ke!==void 0?ke:null,color:pt(X),y:ke!==void 0?Ft(ke):null}}).filter(ne=>ne.value!==null);pe.value={show:!0,x:se,categoryIndex:le,data:q}}},qt=()=>{pe.value.show=!1,In.value=!1,xt.value=!1,vt.value||(cn.value.show=!1),F.value.isDragging&&(F.value.isDragging=!1),F.value.zoomTimeout&&(clearTimeout(F.value.zoomTimeout),F.value.zoomTimeout=null),F.value.isZooming=!1,setTimeout(()=>{K.value=null,Me.value.show=!1},150)},Tn=t=>{if(t.preventDefault(),t.stopPropagation(),!lt.value)return;const s=t.currentTarget.getBoundingClientRect(),o=t.clientX-s.left,c=t.clientY-s.top;if(gn.value){ae.value.show=!1,e.nextTick(()=>{ae.value.show=!0,ae.value.x=t.clientX,ae.value.y=t.clientY,ae.value.categoryIndex=null});return}const g=Math.max(0,B.value.left-20),h=B.value.right,w=B.value.top,C=B.value.bottom+80;o>=g&&o<=h&&c>=w&&c<=C&&(ae.value.show=!1,e.nextTick(()=>{ae.value.show=!0,ae.value.x=t.clientX,ae.value.y=t.clientY,ae.value.categoryIndex=null;const S=Math.max(B.value.left,Math.min(o,B.value.right))-B.value.left,L=B.value.width/No.value.length,_=Math.floor(S/L);_>=0&&_<No.value.length&&(ae.value.categoryIndex=_)}))},mt=t=>{if(!(t&&t.button===2)){if(ae.value.show&&t&&t.type==="click"){const s=document.querySelector(".dss-context-menu");if(s&&s.contains(t.target))return}ae.value.show=!1}},Zo=t=>{if(typeof t.template=="function"){const s={series:I.series,categories:I.categories,markers:rt.value},o={chartX:ae.value.chartX,chartY:ae.value.chartY,dataX:ae.value.mouseDataX,dataY:ae.value.mouseDataY,categoryIndex:ae.value.categoryIndex};return t.template(s,o)}return t.template||t.label||""},Wo=t=>{const s=["dss-context-menu-item"];return t.cssClass&&s.push(t.cssClass),s},Xn=t=>t.style||{},Qt=t=>t.type&&Rt.value[t.type]?Rt.value[t.type]:t.customIcon?t.customIcon:Nt.value,qo=t=>t==null?"":I.categories&&I.categories[t]?I.categories[t]:"",Ut=t=>rt.value.length?rt.value.filter(s=>s.categoryIndex===t):[],Yn=t=>{if(!Yt.value&&!wt.value)return{x:0,y:0};const s=Mt(t),o=Ne.value+B.value.bottom-vn.value/2;return{x:s,y:o}},cl=()=>{rt.value.forEach(t=>{if(t.categoryIndex!==void 0&&(Yt.value||wt.value)){const s=Yn(t.categoryIndex);t.x=s.x,t.y=s.y}})},dl=()=>{if(f.value.description&&f.value.description.length){if(E.value){const t=rt.value.findIndex(s=>s.id===f.value.editingMarkerId);t!==-1?(rt.value[t].description=f.value.description||"",rt.value[t].color=f.value.color||"",rt.value[t].type=f.value.type||"default",Ie("update-marker",rt.value[t])):Ie("update-marker",{id:f.value.editingMarkerId,description:f.value.description||"",color:f.value.color||"",type:f.value.type||"default"})}else{const t="dss-marker-"+Date.now()+"-"+Math.random().toString(36).substring(2,9);let s=Math.max(0,f.value.categoryIndex);if(wt.value){const{maxX:w}=tt.value;s=Math.max(0,Math.min(s,Math.floor(w)))}else Yt.value&&(s=Math.max(0,Math.min(s,tt.value.maxX)));const o=Mt(s),c=Ne.value+B.value.bottom-vn.value/2,g=Array.isArray(I.categories)?I.categories[s]:null,h={id:t,title:"",description:f.value.description||"",color:f.value.color||"",type:f.value.type||"default",categoryIndex:s,x:o,y:c,marker_date:g||null};f.value.categoryIndex=s,rt.value.push(h),Ie("add-marker",h)}jn(),Uo()}},jn=()=>{f.value.show=!1,f.value.title="",f.value.description="",f.value.color="#FF6B6B",f.value.type="default",f.value.editingMarkerId=null,f.value.readonly=!1,f.value.categoryIndex=null,f.value.fromButton=!1},dn=()=>{E.value&&(ul(f.value.editingMarkerId),jn())},ul=t=>{const s=rt.value.findIndex(o=>o.id===t);s!==-1&&(rt.value.splice(s,1),Uo()),Ie("delete-marker",t)},ml=t=>{f.value.show=!0,f.value.title=t?.title??t?.comment??"",f.value.description=t?.description??t?.comment??"",f.value.color=t?.color??"",f.value.type=t?.type??"default",f.value.editingMarkerId=t?.id??t?.marker_id??null,f.value.readonly=t?.readonly??!1,f.value.categoryIndex=t?.categoryIndex??null},Uo=()=>{try{const t=`dss-chart-markers-${I.chartId}`;localStorage.setItem(t,JSON.stringify(rt.value))}catch(t){console.warn("Could not save markers to localStorage:",t)}},pl=()=>{try{const t=`dss-chart-markers-${I.chartId}`,s=localStorage.getItem(t);if(s){const o=JSON.parse(s);Array.isArray(o)&&(rt.value=o.map(c=>({...c,originalYOffset:c.originalYOffset!==void 0?c.originalYOffset:15})))}}catch(t){console.warn("Could not load markers from localStorage:",t),rt.value=[]}},wo=t=>{const s=Q.value||"Chart",o=new Date().toLocaleDateString("en-GB",{day:"2-digit",month:"2-digit",year:"2-digit"}).replace(/\//g,"-");return`${s.replace(/[^a-zA-Z0-9\s]/g,"").replace(/\s+/g,"-").substring(0,50).replace(/^-|-$/g,"")||"Chart"}-${o}.${t}`},un=()=>{const t=pe.value.show,s=Me.value.show;return pe.value.show=!1,Me.value.show=!1,{originalCrosshair:t,originalTooltip:s}},Kn=t=>{pe.value.show=t.originalCrosshair,Me.value.show=t.originalTooltip},Vl=async(t,s=32,o=32)=>new Promise((c,g)=>{if(t.startsWith("data:")){c(t);return}const h=new Image;h.crossOrigin="anonymous";const w=setTimeout(()=>{console.warn("Image conversion timeout for:",t),c(t)},5e3);h.onload=()=>{clearTimeout(w);try{const C=document.createElement("canvas"),S=C.getContext("2d");C.width=s,C.height=o,S.fillStyle="#fafafa",S.fillRect(0,0,s,o),S.drawImage(h,0,0,s,o);const H=C.toDataURL("image/png");c(H)}catch(C){console.warn("Canvas conversion failed:",C),c(t)}},h.onerror=C=>{clearTimeout(w),console.warn("Failed to load image:",t,C),c(t)},h.src=t}),Xt=async()=>{try{const t=un();setTimeout(async()=>{try{const s=document.querySelector(".dss-chart-svg");if(!s){console.error("Chart SVG element not found"),Kn(t);return}const o=qe(),c=Ue.value,g=Qe.value+o.height,h=s.cloneNode(!0);h.querySelectorAll(".dss-flag-markers, .dss-flag-line, .dss-flag-extension-line, .dss-flag-count-indicator, .dss-flag-count-text").forEach(X=>X.remove());const C=h.querySelectorAll("image"),S=Array.from(C).map(async X=>{const ke=X.getAttribute("xlink:href")||X.getAttribute("href");if(ke&&!ke.startsWith("data:"))try{const ee=await Vl(ke,32,32);X.setAttribute("xlink:href",ee),X.setAttribute("href",ee)}catch(ee){console.warn("Failed to convert logo to base64:",ee)}});await Promise.all(S);const L=new XMLSerializer().serializeToString(h).replace(/<svg[^>]*>/,"").replace("</svg>","");let _="",Y=30;if(Q.value&&(_+=`
23
23
  <text x="24" y="${Y}"
24
24
  font-family="Arial, sans-serif"
package/dist/index.es.js CHANGED
@@ -696,7 +696,7 @@ const ws = ["data-chart-type"], xs = { class: "dss-chart-header-titles" }, ks =
696
696
  return wa(e);
697
697
  }), sa = x(() => ({
698
698
  x: vt.value,
699
- y: ft.value - pa.value + 70
699
+ y: ft.value - pa.value + 25
700
700
  })), dl = x(() => {
701
701
  const o = j.value?.radialBar?.dataCenter?.fontSize;
702
702
  return typeof o == "number" && o > 0 ? o : 24;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsp-semactic",
3
3
  "private": false,
4
- "version": "0.6.3",
4
+ "version": "0.6.4",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs.js",
7
7
  "module": "dist/index.es.js",