@oliasoft-open-source/charts-library 5.1.0 → 5.1.1-beta-2

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.
Files changed (32) hide show
  1. package/dist/assets/{Color-YHDXOIA2-Cf20dAz7.js → Color-YHDXOIA2-DK-zvEp4.js} +1 -1
  2. package/dist/assets/{DocsRenderer-CFRXHY34-BLg8W1W2.js → DocsRenderer-CFRXHY34-Bg8MQWAR.js} +3 -3
  3. package/dist/assets/{bar-chart.stories-BYQyquXm.js → bar-chart.stories-C41de-ei.js} +1 -1
  4. package/dist/assets/{entry-preview-BZo_8q_9.js → entry-preview-BFBa1CWR.js} +1 -1
  5. package/dist/assets/{get-draggableData-dkvBi0Bl.js → get-draggableData-DPTQjrFS.js} +1 -1
  6. package/dist/assets/{iframe-DQBiGpMD.js → iframe-CpYKaSFw.js} +2 -2
  7. package/dist/assets/{legend-Dsh-gS4D.js → legend-D-2OZtHn.js} +1 -1
  8. package/dist/assets/{legend-context-9xqNf4cB.js → legend-context-BDAlvkJS.js} +12 -12
  9. package/dist/assets/line-chart-BMOGGJ6G.js +1 -0
  10. package/dist/assets/{line-chart.stories-B40-dAYL.js → line-chart.stories-CXTeCdqs.js} +76 -69
  11. package/dist/assets/{line-chart.test-case.stories-DtULjl6w.js → line-chart.test-case.stories-D2DsX-6x.js} +1 -1
  12. package/dist/assets/{pie-chart.stories-Birt17VG.js → pie-chart.stories-CUYoikIz.js} +1 -1
  13. package/dist/assets/{preview-C_VJ39RO.js → preview-CrH-Kwuw.js} +1 -1
  14. package/dist/assets/{preview-BxIF5cTA.js → preview-HxUexXep.js} +2 -2
  15. package/dist/assets/{scatter-chart.stories-BoOuwmMg.js → scatter-chart.stories--WaN2oN8.js} +1 -1
  16. package/dist/common/common.interface.d.ts +3 -0
  17. package/dist/common/helpers/get-chart-annotation.d.ts +1 -0
  18. package/dist/common/plugins/ellipsis-annotation-plugin/compute-ellipse-geometry.d.ts +9 -0
  19. package/dist/common/plugins/ellipsis-annotation-plugin/ellipsis-annotation-plugin.d.ts +18 -0
  20. package/dist/iframe.html +1 -1
  21. package/dist/index.js.js +27 -100
  22. package/dist/index.js.js.map +1 -1
  23. package/dist/index.json +1 -1
  24. package/dist/line-chart/hooks/use-chart-state.d.ts +1 -5
  25. package/dist/line-chart/utils/axis-scales/axis-scales.d.ts +1 -3
  26. package/dist/line-chart/utils/line-chart-utils.d.ts +5 -0
  27. package/dist/project.json +1 -1
  28. package/dist/src/components/line-chart/hooks/use-chart-state.d.ts +1 -5
  29. package/dist/src/components/line-chart/utils/axis-scales/axis-scales.d.ts +1 -3
  30. package/dist/src/components/line-chart/utils/line-chart-utils.d.ts +5 -0
  31. package/package.json +1 -1
  32. package/dist/assets/line-chart-r9Mg5Qcy.js +0 -1
@@ -1,4 +1,4 @@
1
- import{j as a}from"./jsx-runtime-Y5Ju2SGo.js";import{r as s}from"./index-eCxJ45ll.js";import{D as ea,B as l}from"./legend-Dsh-gS4D.js";import{L as c}from"./line-chart-r9Mg5Qcy.js";import{D as la}from"./legend-context-9xqNf4cB.js";import"./index-BGqSdrBK.js";import"./index-D3-0uUTW.js";import"./index-B-BONL6g.js";import"./get-draggableData-dkvBi0Bl.js";const ta="chartOne-plan-view-chart-controls",na={datasets:[{label:"CH-4ST",lineTension:0,borderColor:"#a30125",pointBackgroundColor:"#a30125",pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:2,fill:!1,data:[{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:.3927,label:[]},{x:0,y:2.4838,label:[]},{x:0,y:7.1727,label:[]},{x:0,y:14.4238,label:[]},{x:0,y:24.1818,label:[]},{x:0,y:36.3728,label:[]},{x:0,y:50.9039,label:[]},{x:0,y:67.6648,label:[]},{x:0,y:86.528,label:[]},{x:0,y:107.3503,label:[]},{x:0,y:129.9733,label:[]},{x:0,y:154.2251,label:[]},{x:0,y:179.9215,label:[]},{x:0,y:206.867,label:[]},{x:0,y:234.8569,label:[]},{x:0,y:263.6785,label:[]},{x:0,y:293.1127,label:[]},{x:0,y:322.9358,label:[]},{x:0,y:344.2833,label:[]},{x:0,y:352.9221,label:[]},{x:0,y:382.9221,label:[]},{x:0,y:412.9221,label:[]},{x:0,y:442.9221,label:[]},{x:0,y:472.9221,label:[]},{x:0,y:502.9221,label:[]},{x:0,y:532.9221,label:[]},{x:0,y:562.9221,label:[]},{x:0,y:592.9221,label:[]},{x:0,y:622.9221,label:[]},{x:0,y:644.2821,label:[]}]},{label:"CH-4",lineTension:0,borderColor:"#0154a3",pointBackgroundColor:"#0154a3",pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:2,fill:!1,data:[{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]}]}]},oa={direction:"vertical",axes:{x:[{label:"E/W [m]",position:"top"}],y:[{label:"N/S [m]",position:"left"}]},additionalAxesOptions:{chartScaleType:"linear"},graph:{showDataLabels:!0,showMinorGridlines:!0,lineTension:0},chartStyling:{height:"100%"},annotations:{showAnnotations:!0,enableDragAnnotation:!0,annotationsData:[]}},sa={controlsPortalId:ta,data:na,options:oa},m=[{label:"Dataset 1",data:[{x:0,y:0},{x:5,y:25}]}],ra={data:{datasets:m},options:{title:"Chart title",chartStyling:{height:"100%"}}},ma={title:"LineChart / Test Cases",component:c,args:{chart:ra}},y=()=>a.jsx(c,{chart:{data:{datasets:[{label:"Duration %",lineTension:"0",pointHitRadius:10,borderColor:"#dc3912",pointBackgroundColor:"#dc3912",borderWidth:2,pointRadius:4,data:[{x:3,y:0},{x:3,y:100}],yAxisID:"y2"}]},options:{direction:"vertical",axes:{x:[{label:"Duration (TempSim long) [d]",position:"bottom"}],y:[{label:"Probability"},{label:"Percentage [%]"}]},annotations:{annotationsData:[{annotationAxis:"y2",color:"darkgrey",value:16},{displayDragCoordinates:!1,color:"#ff9900",label:"P16",dragAxis:"y",enableDrag:!0,resizable:!1,type:"box",xMax:3,xMin:3,yMax:17,yMin:15,yScaleID:"y2"},{annotationAxis:"y2",color:"darkgrey",value:66},{displayDragCoordinates:!1,color:"#109618",label:"P66",dragAxis:"y",enableDrag:!0,resizable:!1,type:"box",xMax:3,xMin:3,yMax:67,yMin:65,yScaleID:"y2"},{annotationAxis:"y2",color:"darkgrey",value:78},{displayDragCoordinates:!1,color:"#990099",label:"P78",dragAxis:"y",enableDrag:!0,resizable:!1,type:"box",xMax:3,xMin:3,yMax:79,yMin:77,yScaleID:"y2"},{annotationAxis:"y2",color:"darkgrey",value:90},{displayDragCoordinates:!1,color:"#0099c6",label:"P90",dragAxis:"y",enableDrag:!0,resizable:!1,type:"box",xMax:3,xMin:3,yMax:91,yMin:89,yScaleID:"y2"}],enableDragAnnotation:!0,showAnnotations:!0},additionalAxesOptions:{range:{x:{min:3}},chartScaleType:"linear",reverse:!1},graph:{showMinorGridlines:!0},chartStyling:{height:"100%"},chartOptions:{showPoints:!1,enableDragAnnotation:!0}}}}),b=()=>a.jsx(c,{chart:sa}),x=()=>{const[u,n]=s.useState(m),[L,d]=s.useState(0),[g,_]=s.useState(!1),[D,i]=s.useState(!0),[O,C]=s.useState(!1),[f,W]=s.useState(!0),[A,E]=s.useState("linear"),[S,p]=s.useState(!1),M=s.useMemo(()=>({title:"Stress Tester",axes:{x:[{label:"X Axis"}],y:[{label:"Y Axis"}]},chartOptions:{enableDragAnnotation:!0},annotations:{showAnnotations:!0,enableDragAnnotation:!0,annotationsData:[{enableDrag:!0,type:"box",xMin:3.5,xMax:4,yMin:5,yMax:10,color:"rgba(255, 0, 0, 0.3)",label:"DRAG ME!"},{type:"point",enableDrag:!0,xValue:1,yValue:10,radius:ea,color:"red",label:"Draggable Point",labelConfig:{font:`bold 8px ${la}`,color:"rgba(0,0,0,0.7)"}}]},chartStyling:{height:"100%",squareAspectRatio:f},additionalAxesOptions:{chartScaleType:A},legend:{display:!1}}),[u,f,A]),U=s.useMemo(()=>({data:{datasets:u},options:M}),[u,M]),V=()=>{p(!0),i(!0),setTimeout(()=>{i(!1),p(!1)},5e3)},F=()=>{n(m),d(e=>e+1),i(!0),p(!1)},$=()=>{C(!0);const e=[],o=50,r=40;for(let t=0;t<o;t++)setTimeout(()=>{e.push({label:`DS ${t+1}`,data:[{x:t,y:Math.random()*100},{x:t+1,y:Math.random()*100}],borderColor:`hsl(${t*(360/o)}, 100%, 50%)`}),n([...e]),t===15&&(console.warn("Forcing unmount mid-update"),i(!1)),t===25&&(console.warn("Remounting chart"),i(!0),d(h=>h+1)),t===o-1&&(console.log("Async injection complete"),C(!1))},t*r)},z=()=>{n([{label:"Broken Dataset",borderColor:"red"}])},X=()=>{n([])},Y=()=>{n([{label:"X/Y Points",data:[{x:0,y:0},{x:1,y:1}],borderColor:"green"},{label:"Y Only Array",data:[2,4,6],borderColor:"blue"}])},K=()=>{n([{label:"Bad Y Axis Ref",yAxisID:"y-missing",data:[{x:1,y:1},{x:2,y:2}],borderColor:"purple"}])},H=()=>{const e=Array.from({length:5e3},(o,r)=>({x:r,y:Math.sin(r/100)*100}));n([{label:"Big 5k Points",data:e,borderColor:"orange"}])},N=()=>{n([{label:"Corrupt Point Dataset",data:[{x:0,y:10},{x:1},{y:20},null,void 0,"bad-value",{x:5,y:50}],borderColor:"red"}])},G=()=>{n([{label:"Valid A",data:[{x:0,y:1},{x:1,y:2}],borderColor:"blue"},{label:"Corrupt",data:"not-an-array",borderColor:"red"},{label:"Valid B",data:[{x:0,y:3},{x:1,y:4}],borderColor:"green"}])},q=()=>{const e=[];for(let t=0;t<4;t++){const h=Array.from({length:3e3},(ia,aa)=>({x:aa,y:Math.random()*100}));e.push({label:`Stream DS ${t+1}`,data:h,borderColor:`hsl(${t*90}, 100%, 50%)`})}let o=0;const r=setInterval(()=>{n(e.slice(0,o+1)),o++,o===e.length&&clearInterval(r)},500)},J=()=>{E(e=>e==="linear"?"logarithmic":"linear")},Q=()=>{W(e=>!e)},Z=()=>{let e=0;const o=setInterval(()=>{d(r=>r+1),e++,e===100&&clearInterval(o)},30)};return a.jsxs(a.Fragment,{children:[a.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",marginBottom:16},children:[a.jsx(l,{label:"Reset to Initial State",colored:!0,onClick:F}),a.jsx(l,{label:"Async Dataset + Unmount",onClick:$,disabled:O}),a.jsx(l,{label:"Set Invalid Dataset",onClick:z}),a.jsx(l,{label:"Set Empty Dataset",onClick:X}),a.jsx(l,{label:"Mixed Data Formats",onClick:Y}),a.jsx(l,{label:"Bad Axis Ref",onClick:K}),a.jsx(l,{label:"Toggle size",onClick:()=>_(!g)}),a.jsx(l,{label:"Toggle Axis Type",onClick:J}),a.jsx(l,{label:"Toggle Aspect Ratio",onClick:Q}),a.jsx(l,{label:"Spam Re-renders",onClick:Z}),a.jsx(l,{label:D?"Unmount Chart":"Remount Chart",onClick:()=>i(e=>!e)}),a.jsx(l,{label:"Manual Re-render",onClick:()=>d(e=>e+1)}),a.jsx(l,{label:"Empty Dataset",onClick:()=>n([])}),a.jsx(l,{label:"Add 5k Points Slowly",onClick:H}),a.jsx(l,{label:"Dataset With Invalid Point",onClick:N}),a.jsx(l,{label:"Malformed Dataset Combo",onClick:G}),a.jsx(l,{label:"Cycle Big Load (Async)",onClick:q}),a.jsx(l,{label:"Timed Unmount During Drag",onClick:V,disabled:S})]}),S&&a.jsx("span",{style:{color:"crimson",fontWeight:"bold"},children:"⏱ Unmounting in 5s – start dragging!"}),a.jsx("div",{style:{height:g?300:null,width:g?300:null,padding:"var(--padding)",overflow:"auto"},children:D?a.jsx(c,{chart:U},L):a.jsx("div",{style:{padding:40,textAlign:"center"},children:"Chart unmounted"})})]})};y.__docgenInfo={description:"",methods:[],displayName:"PartialRangeWithSimilarValues"};b.__docgenInfo={description:"",methods:[],displayName:"closeToValueInDifferentAxes"};x.__docgenInfo={description:"",methods:[],displayName:"StressTest"};var T,v,R;y.parameters={...y.parameters,docs:{...(T=y.parameters)==null?void 0:T.docs,source:{originalSource:`() => {
1
+ import{j as a}from"./jsx-runtime-Y5Ju2SGo.js";import{r as s}from"./index-eCxJ45ll.js";import{D as ea,B as l}from"./legend-D-2OZtHn.js";import{L as c}from"./line-chart-BMOGGJ6G.js";import{D as la}from"./legend-context-BDAlvkJS.js";import"./index-BGqSdrBK.js";import"./index-D3-0uUTW.js";import"./index-B-BONL6g.js";import"./get-draggableData-DPTQjrFS.js";const ta="chartOne-plan-view-chart-controls",na={datasets:[{label:"CH-4ST",lineTension:0,borderColor:"#a30125",pointBackgroundColor:"#a30125",pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:2,fill:!1,data:[{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:.3927,label:[]},{x:0,y:2.4838,label:[]},{x:0,y:7.1727,label:[]},{x:0,y:14.4238,label:[]},{x:0,y:24.1818,label:[]},{x:0,y:36.3728,label:[]},{x:0,y:50.9039,label:[]},{x:0,y:67.6648,label:[]},{x:0,y:86.528,label:[]},{x:0,y:107.3503,label:[]},{x:0,y:129.9733,label:[]},{x:0,y:154.2251,label:[]},{x:0,y:179.9215,label:[]},{x:0,y:206.867,label:[]},{x:0,y:234.8569,label:[]},{x:0,y:263.6785,label:[]},{x:0,y:293.1127,label:[]},{x:0,y:322.9358,label:[]},{x:0,y:344.2833,label:[]},{x:0,y:352.9221,label:[]},{x:0,y:382.9221,label:[]},{x:0,y:412.9221,label:[]},{x:0,y:442.9221,label:[]},{x:0,y:472.9221,label:[]},{x:0,y:502.9221,label:[]},{x:0,y:532.9221,label:[]},{x:0,y:562.9221,label:[]},{x:0,y:592.9221,label:[]},{x:0,y:622.9221,label:[]},{x:0,y:644.2821,label:[]}]},{label:"CH-4",lineTension:0,borderColor:"#0154a3",pointBackgroundColor:"#0154a3",pointRadius:0,pointHoverRadius:0,pointHitRadius:0,borderWidth:2,fill:!1,data:[{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]},{x:0,y:0,label:[]}]}]},oa={direction:"vertical",axes:{x:[{label:"E/W [m]",position:"top"}],y:[{label:"N/S [m]",position:"left"}]},additionalAxesOptions:{chartScaleType:"linear"},graph:{showDataLabels:!0,showMinorGridlines:!0,lineTension:0},chartStyling:{height:"100%"},annotations:{showAnnotations:!0,enableDragAnnotation:!0,annotationsData:[]}},sa={controlsPortalId:ta,data:na,options:oa},m=[{label:"Dataset 1",data:[{x:0,y:0},{x:5,y:25}]}],ra={data:{datasets:m},options:{title:"Chart title",chartStyling:{height:"100%"}}},ma={title:"LineChart / Test Cases",component:c,args:{chart:ra}},y=()=>a.jsx(c,{chart:{data:{datasets:[{label:"Duration %",lineTension:"0",pointHitRadius:10,borderColor:"#dc3912",pointBackgroundColor:"#dc3912",borderWidth:2,pointRadius:4,data:[{x:3,y:0},{x:3,y:100}],yAxisID:"y2"}]},options:{direction:"vertical",axes:{x:[{label:"Duration (TempSim long) [d]",position:"bottom"}],y:[{label:"Probability"},{label:"Percentage [%]"}]},annotations:{annotationsData:[{annotationAxis:"y2",color:"darkgrey",value:16},{displayDragCoordinates:!1,color:"#ff9900",label:"P16",dragAxis:"y",enableDrag:!0,resizable:!1,type:"box",xMax:3,xMin:3,yMax:17,yMin:15,yScaleID:"y2"},{annotationAxis:"y2",color:"darkgrey",value:66},{displayDragCoordinates:!1,color:"#109618",label:"P66",dragAxis:"y",enableDrag:!0,resizable:!1,type:"box",xMax:3,xMin:3,yMax:67,yMin:65,yScaleID:"y2"},{annotationAxis:"y2",color:"darkgrey",value:78},{displayDragCoordinates:!1,color:"#990099",label:"P78",dragAxis:"y",enableDrag:!0,resizable:!1,type:"box",xMax:3,xMin:3,yMax:79,yMin:77,yScaleID:"y2"},{annotationAxis:"y2",color:"darkgrey",value:90},{displayDragCoordinates:!1,color:"#0099c6",label:"P90",dragAxis:"y",enableDrag:!0,resizable:!1,type:"box",xMax:3,xMin:3,yMax:91,yMin:89,yScaleID:"y2"}],enableDragAnnotation:!0,showAnnotations:!0},additionalAxesOptions:{range:{x:{min:3}},chartScaleType:"linear",reverse:!1},graph:{showMinorGridlines:!0},chartStyling:{height:"100%"},chartOptions:{showPoints:!1,enableDragAnnotation:!0}}}}),b=()=>a.jsx(c,{chart:sa}),x=()=>{const[u,n]=s.useState(m),[L,d]=s.useState(0),[g,_]=s.useState(!1),[D,i]=s.useState(!0),[O,C]=s.useState(!1),[f,W]=s.useState(!0),[A,E]=s.useState("linear"),[S,p]=s.useState(!1),M=s.useMemo(()=>({title:"Stress Tester",axes:{x:[{label:"X Axis"}],y:[{label:"Y Axis"}]},chartOptions:{enableDragAnnotation:!0},annotations:{showAnnotations:!0,enableDragAnnotation:!0,annotationsData:[{enableDrag:!0,type:"box",xMin:3.5,xMax:4,yMin:5,yMax:10,color:"rgba(255, 0, 0, 0.3)",label:"DRAG ME!"},{type:"point",enableDrag:!0,xValue:1,yValue:10,radius:ea,color:"red",label:"Draggable Point",labelConfig:{font:`bold 8px ${la}`,color:"rgba(0,0,0,0.7)"}}]},chartStyling:{height:"100%",squareAspectRatio:f},additionalAxesOptions:{chartScaleType:A},legend:{display:!1}}),[u,f,A]),U=s.useMemo(()=>({data:{datasets:u},options:M}),[u,M]),V=()=>{p(!0),i(!0),setTimeout(()=>{i(!1),p(!1)},5e3)},F=()=>{n(m),d(e=>e+1),i(!0),p(!1)},$=()=>{C(!0);const e=[],o=50,r=40;for(let t=0;t<o;t++)setTimeout(()=>{e.push({label:`DS ${t+1}`,data:[{x:t,y:Math.random()*100},{x:t+1,y:Math.random()*100}],borderColor:`hsl(${t*(360/o)}, 100%, 50%)`}),n([...e]),t===15&&(console.warn("Forcing unmount mid-update"),i(!1)),t===25&&(console.warn("Remounting chart"),i(!0),d(h=>h+1)),t===o-1&&(console.log("Async injection complete"),C(!1))},t*r)},z=()=>{n([{label:"Broken Dataset",borderColor:"red"}])},X=()=>{n([])},Y=()=>{n([{label:"X/Y Points",data:[{x:0,y:0},{x:1,y:1}],borderColor:"green"},{label:"Y Only Array",data:[2,4,6],borderColor:"blue"}])},K=()=>{n([{label:"Bad Y Axis Ref",yAxisID:"y-missing",data:[{x:1,y:1},{x:2,y:2}],borderColor:"purple"}])},H=()=>{const e=Array.from({length:5e3},(o,r)=>({x:r,y:Math.sin(r/100)*100}));n([{label:"Big 5k Points",data:e,borderColor:"orange"}])},N=()=>{n([{label:"Corrupt Point Dataset",data:[{x:0,y:10},{x:1},{y:20},null,void 0,"bad-value",{x:5,y:50}],borderColor:"red"}])},G=()=>{n([{label:"Valid A",data:[{x:0,y:1},{x:1,y:2}],borderColor:"blue"},{label:"Corrupt",data:"not-an-array",borderColor:"red"},{label:"Valid B",data:[{x:0,y:3},{x:1,y:4}],borderColor:"green"}])},q=()=>{const e=[];for(let t=0;t<4;t++){const h=Array.from({length:3e3},(ia,aa)=>({x:aa,y:Math.random()*100}));e.push({label:`Stream DS ${t+1}`,data:h,borderColor:`hsl(${t*90}, 100%, 50%)`})}let o=0;const r=setInterval(()=>{n(e.slice(0,o+1)),o++,o===e.length&&clearInterval(r)},500)},J=()=>{E(e=>e==="linear"?"logarithmic":"linear")},Q=()=>{W(e=>!e)},Z=()=>{let e=0;const o=setInterval(()=>{d(r=>r+1),e++,e===100&&clearInterval(o)},30)};return a.jsxs(a.Fragment,{children:[a.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",marginBottom:16},children:[a.jsx(l,{label:"Reset to Initial State",colored:!0,onClick:F}),a.jsx(l,{label:"Async Dataset + Unmount",onClick:$,disabled:O}),a.jsx(l,{label:"Set Invalid Dataset",onClick:z}),a.jsx(l,{label:"Set Empty Dataset",onClick:X}),a.jsx(l,{label:"Mixed Data Formats",onClick:Y}),a.jsx(l,{label:"Bad Axis Ref",onClick:K}),a.jsx(l,{label:"Toggle size",onClick:()=>_(!g)}),a.jsx(l,{label:"Toggle Axis Type",onClick:J}),a.jsx(l,{label:"Toggle Aspect Ratio",onClick:Q}),a.jsx(l,{label:"Spam Re-renders",onClick:Z}),a.jsx(l,{label:D?"Unmount Chart":"Remount Chart",onClick:()=>i(e=>!e)}),a.jsx(l,{label:"Manual Re-render",onClick:()=>d(e=>e+1)}),a.jsx(l,{label:"Empty Dataset",onClick:()=>n([])}),a.jsx(l,{label:"Add 5k Points Slowly",onClick:H}),a.jsx(l,{label:"Dataset With Invalid Point",onClick:N}),a.jsx(l,{label:"Malformed Dataset Combo",onClick:G}),a.jsx(l,{label:"Cycle Big Load (Async)",onClick:q}),a.jsx(l,{label:"Timed Unmount During Drag",onClick:V,disabled:S})]}),S&&a.jsx("span",{style:{color:"crimson",fontWeight:"bold"},children:"⏱ Unmounting in 5s – start dragging!"}),a.jsx("div",{style:{height:g?300:null,width:g?300:null,padding:"var(--padding)",overflow:"auto"},children:D?a.jsx(c,{chart:U},L):a.jsx("div",{style:{padding:40,textAlign:"center"},children:"Chart unmounted"})})]})};y.__docgenInfo={description:"",methods:[],displayName:"PartialRangeWithSimilarValues"};b.__docgenInfo={description:"",methods:[],displayName:"closeToValueInDifferentAxes"};x.__docgenInfo={description:"",methods:[],displayName:"StressTest"};var T,v,R;y.parameters={...y.parameters,docs:{...(T=y.parameters)==null?void 0:T.docs,source:{originalSource:`() => {
2
2
  return <LineChart chart={{
3
3
  data: {
4
4
  datasets: [{
@@ -1,4 +1,4 @@
1
- import{j as H}from"./jsx-runtime-Y5Ju2SGo.js";import{r as Le}from"./index-eCxJ45ll.js";import{A as Oe,P as He,C as w,g as je,T as Ie,L as B,a as Ae,d as ve,r as Ne,b as we,s as Me,c as $e,e as ye,f as We,h as Re,i as Ee,j as Ue,k as Be,l as Fe,p as Ve,m as Ge,n as Ze,o as qe,q as Xe,t as Ye}from"./legend-context-9xqNf4cB.js";import{D as ze,a as Je}from"./bar-chart-const-Cgj9sgUU.js";import"./index-B-BONL6g.js";const Ke="_chart_1jdnu_1",Qe="_fixedHeight_1jdnu_13",ea="_stretchHeight_1jdnu_19",M={chart:Ke,fixedHeight:Qe,stretchHeight:ea},aa=e=>({width:e==null?void 0:e.width,height:e==null?void 0:e.height,maintainAspectRatio:(e==null?void 0:e.maintainAspectRatio)||!1,staticChartHeight:(e==null?void 0:e.staticChartHeight)||!1,performanceMode:(e==null?void 0:e.performanceMode)??!0}),ta=e=>({tooltips:(e==null?void 0:e.tooltips)??!0,showLabelsInTooltips:(e==null?void 0:e.showLabelsInTooltips)||!1,scientificNotation:(e==null?void 0:e.scientificNotation)??!0}),sa=e=>({showDataLabels:(e==null?void 0:e.showDataLabels)||!1,stacked:(e==null?void 0:e.stacked)||!1,cutout:(e==null?void 0:e.cutout)||0}),ra=e=>({display:(e==null?void 0:e.display)??!0,useDataset:(e==null?void 0:e.useDataset)||!1,position:(e==null?void 0:e.position)||He.Bottom,align:(e==null?void 0:e.align)||Oe.Center}),na=e=>({enableZoom:(e==null?void 0:e.enableZoom)||!1,enablePan:(e==null?void 0:e.enablePan)||!1}),oa=e=>({onLegendClick:e==null?void 0:e.onLegendClick,onHover:e==null?void 0:e.onHover,onUnhover:e==null?void 0:e.onUnhover}),la=e=>({labels:(e==null?void 0:e.labels)||[],datasets:(e==null?void 0:e.datasets)||[]}),Pe=e=>{const l=(e==null?void 0:e.chart)||{},s=(l==null?void 0:l.options)||{};return{testId:(l==null?void 0:l.testId)??null,data:la(l==null?void 0:l.data),options:{title:(s==null?void 0:s.title)||"",chartStyling:aa(s==null?void 0:s.chartStyling),tooltip:ta(s==null?void 0:s.tooltip),graph:sa(s==null?void 0:s.graph),legend:ra(s==null?void 0:s.legend),chartOptions:na(s==null?void 0:s.chartOptions),interactions:oa(s==null?void 0:s.interactions)}}},ia=e=>{const[l,s]=Le.useState(!1),{data:i,options:t}=e,j=(u=>{var n;const a=[...u];if(t.graph.stacked){const o={label:((n=a==null?void 0:a[0])==null?void 0:n.label)??"",backgroundColor:[],borderColor:"",borderWidth:Number(a[0].borderWidth)||1,data:[],borderDash:[]};return i.labels.map((c,d)=>{a.map((g,b)=>{o.data.push(g.data[d]);const{backgroundColor:x}=g,{borderColor:f}=g;o.backgroundColor.push((Array.isArray(x)?x[d%((f==null?void 0:f.length)||1)]:x)||w[d]+`${99-10*b}`),o.borderColor=f??""})}),[o]}return a.map((o,c)=>{const{borderWidth:d="1"}=o??{},g=parseFloat(String(d))||1,b=w[c],x=o.borderColor||b,f=o.backgroundColor||je(w);return{...o,borderWidth:g,borderColor:x,backgroundColor:f}})})(i.datasets),N=()=>t.title!==""?{display:!0,text:e.options.title}:{},I=(u,a,r)=>{var o;const{chart:n}=r??{};if(a&&n){const{index:c=0}=a;if(n.toggleDataVisibility(c),n.update(),(o=t.interactions)!=null&&o.onLegendClick){const d=n.isDatasetVisible(c);t.interactions.onLegendClick(a.text,!d)}}};return{generatedDatasets:j,getTitle:N,legendClick:I,onClick:(u,a,r)=>{r.resetZoom()},onHover:(u,a)=>{if(l&&!(a!=null&&a.length)&&(s(!1),t.interactions.onUnhover&&t.interactions.onUnhover(u)),!l&&(a!=null&&a.length)&&(s(!0),t.interactions.onHover)){const{index:r,datasetIndex:n}=a[0],o=j;t.interactions.onHover(u,n,r,o)}},getDatalabels:()=>t.graph.showDataLabels?{display:"auto",align:"center",anchor:"center",formatter:(u,a)=>{if(a.chart.getDatasetMeta(t.graph.stacked?0:a.datasetIndex).data[a.dataIndex].hidden)return"";const r=a.dataset.data[a.dataIndex],n=(r==null?void 0:r.label)||(typeof r=="number"?r:Array.isArray(r)?r.reduce((c,d,g)=>g===0?`${c} ${d}`:`${c}, ${d}`,""):"");return typeof r=="number"?Number.isInteger(n)?n:n.toFixed(2):n}}:{display:!1},getLegend:()=>({position:t.legend.position,display:t.legend.display,align:t.legend.align,labels:{boxHeight:6,boxWidth:6,usePointStyle:!0,filter:u=>{var a;return t.legend.useDataset?!((a=i.datasets[u.index])!=null&&a.hideLegend):!0}},onClick:I}),getToolTips:()=>{const u=a=>{var n;let r={};return(n=t==null?void 0:t.tooltip)!=null&&n.scientificNotation?(Math.abs(a)<ze||Math.abs(a)>Je)&&(r={roundScientificCoefficient:3}):r={scientific:!1},ve(Ne(a),r)};return{callbacks:{title:a=>{const{dataIndex:r}=a[0],n=t.graph.stacked?parseInt(String(r/i.labels.length)):r;return`${i.labels[n]}`},label:a=>{var b;const{dataIndex:r}=a,n=t.graph.stacked?r%i.datasets.length:a.datasetIndex,o=i.datasets.length>1?`${(b=i.datasets[n])==null?void 0:b.label}: `:"",c=a.dataset.data[r],d=typeof c=="object"?`${c.value||""} ${t.tooltip.showLabelsInTooltips&&c.label?"("+c.label+")":""}`:c,g=i!=null&&i.yUnit?`[${i==null?void 0:i.yUnit}]`:"";return`${o} ${u(d)} ${g}`}},padding:Ae,boxWidth:B,boxHeight:B,boxPadding:Ie,usePointStyle:!0}}}};Re.register(Ee,Ue,Be,Fe,Ve,Ge,Ze,qe,Xe,Ye);const ca=e=>{Me();const l=Pe(e),s=Le.useRef(null),{data:i,options:t,testId:y}=l,{generatedDatasets:j,getTitle:N,onClick:I,onHover:W,getDatalabels:R,getLegend:E,getToolTips:U}=ia(l);return H.jsx("div",{className:$e(M.chart,!t.chartStyling.width||!t.chartStyling.height?t.chartStyling.staticChartHeight?M.fixedHeight:M.stretchHeight:""),style:{width:t.chartStyling.width||"auto",height:t.chartStyling.height||"auto"},"data-testid":y,children:H.jsx(ye,{ref:s,data:{datasets:j,labels:t.graph.stacked?void 0:i.labels},options:{cutout:t.graph.cutout,onClick:I,responsive:!0,maintainAspectRatio:t.chartStyling.maintainAspectRatio,animation:t.chartStyling.performanceMode?!1:{duration:We.FAST},hover:{mode:"nearest",intersect:!0},onHover:W,plugins:{annotation:!1,title:N(),datalabels:R(),tooltip:U(),legend:E()}}})})},$=e=>{const{options:l}=Pe(e);return H.jsx(we,{options:l,children:H.jsx(ca,{...e})})};$.__docgenInfo={description:"",methods:[],displayName:"PieChartWithLegend",props:{chart:{required:!0,tsType:{name:"IPieChartData"},description:""},testId:{required:!1,tsType:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}]},description:""}}};const h=["label 1","label 2","label 3"],C={label:"data1",data:[3,8,7]},_e={label:"data2",data:[1,2,3]},Te={label:"data3",data:[5,0,4]},da={label:"spacing data",offset:40,data:[3,8,7]},ua={label:"hover data",data:[3,8,7],hoverOffset:40},ke={label:"data",data:[{value:210,label:"label"},{value:333,label:"labal"},{value:248,label:"lebel"}]},ha={label:"data",data:[210,333,248]},pa={data:{labels:h,datasets:[C]}},ga={data:{labels:h,datasets:[C,_e,Te]}},ba={data:{labels:h,datasets:[C,_e,Te]},options:{title:"Stacked",graph:{stacked:!0}}},fa={data:{labels:h,datasets:[ke]},options:{title:"With custom datalabels",graph:{showDataLabels:!0}}},ma={data:{labels:h,datasets:[ha]},options:{title:"With value as datalabels",graph:{showDataLabels:!0}}},Ca={data:{labels:h,datasets:[ke]},options:{title:"With datalabels in tooltips",tooltip:{showLabelsInTooltips:!0}}},xa={data:{labels:h,datasets:[ua]},options:{title:"Hover offset"}},Da={data:{labels:h,datasets:[da]},options:{title:"Segment offset"}},Sa={data:{labels:h,datasets:[C]},options:{chartStyling:{performanceMode:!1}}},La={data:{labels:h,datasets:[C]},options:{title:"Cutout 50%",graph:{cutout:"50%"}}},Pa={data:{labels:h,datasets:[C]},options:{title:"Cutout 20 pixels",graph:{cutout:20}}},Ia={title:"PieChart",component:$,args:{chart:pa}},p=e=>H.jsx($,{...e}),A=p.bind({}),D=p.bind({});D.args={chart:ga};const S=p.bind({});S.args={chart:ba};const L=p.bind({});L.args={chart:fa};const P=p.bind({});P.args={chart:ma};const _=p.bind({});_.args={chart:Ca};const T=p.bind({});T.args={chart:Sa};const k=p.bind({});k.args={chart:La};const O=p.bind({});O.args={chart:Pa};const m=p.bind({});m.args={chart:xa};const v=p.bind({});m.args={chart:Da};var F,V,G;A.parameters={...A.parameters,docs:{...(F=A.parameters)==null?void 0:F.docs,source:{originalSource:`args => {
1
+ import{j as H}from"./jsx-runtime-Y5Ju2SGo.js";import{r as Le}from"./index-eCxJ45ll.js";import{A as Oe,P as He,C as w,g as je,T as Ie,L as B,a as Ae,d as ve,r as Ne,b as we,s as Me,c as $e,e as ye,f as We,h as Re,i as Ee,j as Ue,k as Be,l as Fe,p as Ve,m as Ge,n as Ze,o as qe,q as Xe,t as Ye}from"./legend-context-BDAlvkJS.js";import{D as ze,a as Je}from"./bar-chart-const-Cgj9sgUU.js";import"./index-B-BONL6g.js";const Ke="_chart_1jdnu_1",Qe="_fixedHeight_1jdnu_13",ea="_stretchHeight_1jdnu_19",M={chart:Ke,fixedHeight:Qe,stretchHeight:ea},aa=e=>({width:e==null?void 0:e.width,height:e==null?void 0:e.height,maintainAspectRatio:(e==null?void 0:e.maintainAspectRatio)||!1,staticChartHeight:(e==null?void 0:e.staticChartHeight)||!1,performanceMode:(e==null?void 0:e.performanceMode)??!0}),ta=e=>({tooltips:(e==null?void 0:e.tooltips)??!0,showLabelsInTooltips:(e==null?void 0:e.showLabelsInTooltips)||!1,scientificNotation:(e==null?void 0:e.scientificNotation)??!0}),sa=e=>({showDataLabels:(e==null?void 0:e.showDataLabels)||!1,stacked:(e==null?void 0:e.stacked)||!1,cutout:(e==null?void 0:e.cutout)||0}),ra=e=>({display:(e==null?void 0:e.display)??!0,useDataset:(e==null?void 0:e.useDataset)||!1,position:(e==null?void 0:e.position)||He.Bottom,align:(e==null?void 0:e.align)||Oe.Center}),na=e=>({enableZoom:(e==null?void 0:e.enableZoom)||!1,enablePan:(e==null?void 0:e.enablePan)||!1}),oa=e=>({onLegendClick:e==null?void 0:e.onLegendClick,onHover:e==null?void 0:e.onHover,onUnhover:e==null?void 0:e.onUnhover}),la=e=>({labels:(e==null?void 0:e.labels)||[],datasets:(e==null?void 0:e.datasets)||[]}),Pe=e=>{const l=(e==null?void 0:e.chart)||{},s=(l==null?void 0:l.options)||{};return{testId:(l==null?void 0:l.testId)??null,data:la(l==null?void 0:l.data),options:{title:(s==null?void 0:s.title)||"",chartStyling:aa(s==null?void 0:s.chartStyling),tooltip:ta(s==null?void 0:s.tooltip),graph:sa(s==null?void 0:s.graph),legend:ra(s==null?void 0:s.legend),chartOptions:na(s==null?void 0:s.chartOptions),interactions:oa(s==null?void 0:s.interactions)}}},ia=e=>{const[l,s]=Le.useState(!1),{data:i,options:t}=e,j=(u=>{var n;const a=[...u];if(t.graph.stacked){const o={label:((n=a==null?void 0:a[0])==null?void 0:n.label)??"",backgroundColor:[],borderColor:"",borderWidth:Number(a[0].borderWidth)||1,data:[],borderDash:[]};return i.labels.map((c,d)=>{a.map((g,b)=>{o.data.push(g.data[d]);const{backgroundColor:x}=g,{borderColor:f}=g;o.backgroundColor.push((Array.isArray(x)?x[d%((f==null?void 0:f.length)||1)]:x)||w[d]+`${99-10*b}`),o.borderColor=f??""})}),[o]}return a.map((o,c)=>{const{borderWidth:d="1"}=o??{},g=parseFloat(String(d))||1,b=w[c],x=o.borderColor||b,f=o.backgroundColor||je(w);return{...o,borderWidth:g,borderColor:x,backgroundColor:f}})})(i.datasets),N=()=>t.title!==""?{display:!0,text:e.options.title}:{},I=(u,a,r)=>{var o;const{chart:n}=r??{};if(a&&n){const{index:c=0}=a;if(n.toggleDataVisibility(c),n.update(),(o=t.interactions)!=null&&o.onLegendClick){const d=n.isDatasetVisible(c);t.interactions.onLegendClick(a.text,!d)}}};return{generatedDatasets:j,getTitle:N,legendClick:I,onClick:(u,a,r)=>{r.resetZoom()},onHover:(u,a)=>{if(l&&!(a!=null&&a.length)&&(s(!1),t.interactions.onUnhover&&t.interactions.onUnhover(u)),!l&&(a!=null&&a.length)&&(s(!0),t.interactions.onHover)){const{index:r,datasetIndex:n}=a[0],o=j;t.interactions.onHover(u,n,r,o)}},getDatalabels:()=>t.graph.showDataLabels?{display:"auto",align:"center",anchor:"center",formatter:(u,a)=>{if(a.chart.getDatasetMeta(t.graph.stacked?0:a.datasetIndex).data[a.dataIndex].hidden)return"";const r=a.dataset.data[a.dataIndex],n=(r==null?void 0:r.label)||(typeof r=="number"?r:Array.isArray(r)?r.reduce((c,d,g)=>g===0?`${c} ${d}`:`${c}, ${d}`,""):"");return typeof r=="number"?Number.isInteger(n)?n:n.toFixed(2):n}}:{display:!1},getLegend:()=>({position:t.legend.position,display:t.legend.display,align:t.legend.align,labels:{boxHeight:6,boxWidth:6,usePointStyle:!0,filter:u=>{var a;return t.legend.useDataset?!((a=i.datasets[u.index])!=null&&a.hideLegend):!0}},onClick:I}),getToolTips:()=>{const u=a=>{var n;let r={};return(n=t==null?void 0:t.tooltip)!=null&&n.scientificNotation?(Math.abs(a)<ze||Math.abs(a)>Je)&&(r={roundScientificCoefficient:3}):r={scientific:!1},ve(Ne(a),r)};return{callbacks:{title:a=>{const{dataIndex:r}=a[0],n=t.graph.stacked?parseInt(String(r/i.labels.length)):r;return`${i.labels[n]}`},label:a=>{var b;const{dataIndex:r}=a,n=t.graph.stacked?r%i.datasets.length:a.datasetIndex,o=i.datasets.length>1?`${(b=i.datasets[n])==null?void 0:b.label}: `:"",c=a.dataset.data[r],d=typeof c=="object"?`${c.value||""} ${t.tooltip.showLabelsInTooltips&&c.label?"("+c.label+")":""}`:c,g=i!=null&&i.yUnit?`[${i==null?void 0:i.yUnit}]`:"";return`${o} ${u(d)} ${g}`}},padding:Ae,boxWidth:B,boxHeight:B,boxPadding:Ie,usePointStyle:!0}}}};Re.register(Ee,Ue,Be,Fe,Ve,Ge,Ze,qe,Xe,Ye);const ca=e=>{Me();const l=Pe(e),s=Le.useRef(null),{data:i,options:t,testId:y}=l,{generatedDatasets:j,getTitle:N,onClick:I,onHover:W,getDatalabels:R,getLegend:E,getToolTips:U}=ia(l);return H.jsx("div",{className:$e(M.chart,!t.chartStyling.width||!t.chartStyling.height?t.chartStyling.staticChartHeight?M.fixedHeight:M.stretchHeight:""),style:{width:t.chartStyling.width||"auto",height:t.chartStyling.height||"auto"},"data-testid":y,children:H.jsx(ye,{ref:s,data:{datasets:j,labels:t.graph.stacked?void 0:i.labels},options:{cutout:t.graph.cutout,onClick:I,responsive:!0,maintainAspectRatio:t.chartStyling.maintainAspectRatio,animation:t.chartStyling.performanceMode?!1:{duration:We.FAST},hover:{mode:"nearest",intersect:!0},onHover:W,plugins:{annotation:!1,title:N(),datalabels:R(),tooltip:U(),legend:E()}}})})},$=e=>{const{options:l}=Pe(e);return H.jsx(we,{options:l,children:H.jsx(ca,{...e})})};$.__docgenInfo={description:"",methods:[],displayName:"PieChartWithLegend",props:{chart:{required:!0,tsType:{name:"IPieChartData"},description:""},testId:{required:!1,tsType:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}]},description:""}}};const h=["label 1","label 2","label 3"],C={label:"data1",data:[3,8,7]},_e={label:"data2",data:[1,2,3]},Te={label:"data3",data:[5,0,4]},da={label:"spacing data",offset:40,data:[3,8,7]},ua={label:"hover data",data:[3,8,7],hoverOffset:40},ke={label:"data",data:[{value:210,label:"label"},{value:333,label:"labal"},{value:248,label:"lebel"}]},ha={label:"data",data:[210,333,248]},pa={data:{labels:h,datasets:[C]}},ga={data:{labels:h,datasets:[C,_e,Te]}},ba={data:{labels:h,datasets:[C,_e,Te]},options:{title:"Stacked",graph:{stacked:!0}}},fa={data:{labels:h,datasets:[ke]},options:{title:"With custom datalabels",graph:{showDataLabels:!0}}},ma={data:{labels:h,datasets:[ha]},options:{title:"With value as datalabels",graph:{showDataLabels:!0}}},Ca={data:{labels:h,datasets:[ke]},options:{title:"With datalabels in tooltips",tooltip:{showLabelsInTooltips:!0}}},xa={data:{labels:h,datasets:[ua]},options:{title:"Hover offset"}},Da={data:{labels:h,datasets:[da]},options:{title:"Segment offset"}},Sa={data:{labels:h,datasets:[C]},options:{chartStyling:{performanceMode:!1}}},La={data:{labels:h,datasets:[C]},options:{title:"Cutout 50%",graph:{cutout:"50%"}}},Pa={data:{labels:h,datasets:[C]},options:{title:"Cutout 20 pixels",graph:{cutout:20}}},Ia={title:"PieChart",component:$,args:{chart:pa}},p=e=>H.jsx($,{...e}),A=p.bind({}),D=p.bind({});D.args={chart:ga};const S=p.bind({});S.args={chart:ba};const L=p.bind({});L.args={chart:fa};const P=p.bind({});P.args={chart:ma};const _=p.bind({});_.args={chart:Ca};const T=p.bind({});T.args={chart:Sa};const k=p.bind({});k.args={chart:La};const O=p.bind({});O.args={chart:Pa};const m=p.bind({});m.args={chart:xa};const v=p.bind({});m.args={chart:Da};var F,V,G;A.parameters={...A.parameters,docs:{...(F=A.parameters)==null?void 0:F.docs,source:{originalSource:`args => {
2
2
  return <PieChart
3
3
  // eslint-disable-next-line react/jsx-props-no-spreading
4
4
  {...args} />;
@@ -1,3 +1,3 @@
1
- import{j as c}from"./jsx-runtime-Y5Ju2SGo.js";import{r as v}from"./index-eCxJ45ll.js";import{c as p,D as j}from"./DocsRenderer-CFRXHY34-BLg8W1W2.js";import{e as E}from"./index-B-BONL6g.js";import"./preview-BxIF5cTA.js";import"./iframe-DQBiGpMD.js";import"./index-BGqSdrBK.js";import"./index-D3-0uUTW.js";import"./index-Dytf1aFS.js";import"./client-9BU5HM4U.js";var g="DARK_MODE";function f(t){"@babel/helpers - typeof";return f=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},f(t)}var b;function A(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),e.push.apply(e,n)}return e}function D(t){for(var r=1;r<arguments.length;r++){var e=arguments[r]!=null?arguments[r]:{};r%2?A(Object(e),!0).forEach(function(n){I(t,n,e[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):A(Object(e)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))})}return t}function I(t,r,e){return r=M(r),r in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function M(t){var r=R(t,"string");return f(r)==="symbol"?r:String(r)}function R(t,r){if(f(t)!=="object"||t===null)return t;var e=t[Symbol.toPrimitive];if(e!==void 0){var n=e.call(t,r);if(f(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}function y(t){return L(t)||N(t)||K(t)||x()}function x(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
1
+ import{j as c}from"./jsx-runtime-Y5Ju2SGo.js";import{r as v}from"./index-eCxJ45ll.js";import{c as p,D as j}from"./DocsRenderer-CFRXHY34-Bg8MQWAR.js";import{e as E}from"./index-B-BONL6g.js";import"./preview-HxUexXep.js";import"./iframe-CpYKaSFw.js";import"./index-BGqSdrBK.js";import"./index-D3-0uUTW.js";import"./index-Dytf1aFS.js";import"./client-9BU5HM4U.js";var g="DARK_MODE";function f(t){"@babel/helpers - typeof";return f=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},f(t)}var b;function A(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),e.push.apply(e,n)}return e}function D(t){for(var r=1;r<arguments.length;r++){var e=arguments[r]!=null?arguments[r]:{};r%2?A(Object(e),!0).forEach(function(n){I(t,n,e[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):A(Object(e)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))})}return t}function I(t,r,e){return r=M(r),r in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function M(t){var r=R(t,"string");return f(r)==="symbol"?r:String(r)}function R(t,r){if(f(t)!=="object"||t===null)return t;var e=t[Symbol.toPrimitive];if(e!==void 0){var n=e.call(t,r);if(f(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}function y(t){return L(t)||N(t)||K(t)||x()}function x(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function K(t,r){if(t){if(typeof t=="string")return O(t,r);var e=Object.prototype.toString.call(t).slice(8,-1);if(e==="Object"&&t.constructor&&(e=t.constructor.name),e==="Map"||e==="Set")return Array.from(t);if(e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return O(t,r)}}function N(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function L(t){if(Array.isArray(t))return O(t)}function O(t,r){(r==null||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}const{global:U}=__STORYBOOK_MODULE_GLOBAL__,{STORY_CHANGED:st,SET_STORIES:ct,DOCS_RENDERED:ft}=__STORYBOOK_MODULE_CORE_EVENTS__;var T=U,Y=T.document,h=T.window,C="sb-addon-themes-3";(b=h.matchMedia)===null||b===void 0||b.call(h,"(prefers-color-scheme: dark)");var S={classTarget:"body",dark:p.dark,darkClass:["dark"],light:p.light,lightClass:["light"],stylePreview:!1,userHasExplicitlySetTheTheme:!1},k=function(r){h.localStorage.setItem(C,JSON.stringify(r))},B=function(r,e){var n=e.current,a=e.darkClass,l=a===void 0?S.darkClass:a,o=e.lightClass,i=o===void 0?S.lightClass:o;if(n==="dark"){var u,s;(u=r.classList).remove.apply(u,y(d(i))),(s=r.classList).add.apply(s,y(d(l)))}else{var m,_;(m=r.classList).remove.apply(m,y(d(l))),(_=r.classList).add.apply(_,y(d(i)))}},d=function(r){var e=[];return e.concat(r).map(function(n){return n})},W=function(r){var e=Y.querySelector(r.classTarget);e&&B(e,r)},P=function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=h.localStorage.getItem(C);if(typeof e=="string"){var n=JSON.parse(e);return r&&(r.dark&&!E(n.dark,r.dark)&&(n.dark=r.dark,k(n)),r.light&&!E(n.light,r.light)&&(n.light=r.light,k(n))),n}return D(D({},S),r)};W(P());function H(t,r){return q(t)||G(t,r)||$(t,r)||V()}function V(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
3
3
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function $(t,r){if(t){if(typeof t=="string")return w(t,r);var e=Object.prototype.toString.call(t).slice(8,-1);if(e==="Object"&&t.constructor&&(e=t.constructor.name),e==="Map"||e==="Set")return Array.from(t);if(e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return w(t,r)}}function w(t,r){(r==null||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}function G(t,r){var e=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(e!=null){var n,a,l,o,i=[],u=!0,s=!1;try{if(l=(e=e.call(t)).next,r!==0)for(;!(u=(n=l.call(e)).done)&&(i.push(n.value),i.length!==r);u=!0);}catch(m){s=!0,a=m}finally{try{if(!u&&e.return!=null&&(o=e.return(),Object(o)!==o))return}finally{if(s)throw a}}return i}}function q(t){if(Array.isArray(t))return t}const{addons:J,useState:F,useEffect:z}=__STORYBOOK_MODULE_PREVIEW_API__;function Q(){var t=F(P().current==="dark"),r=H(t,2),e=r[0],n=r[1];return z(function(){var a=J.getChannel();return a.on(g,n),function(){return a.off(g,n)}},[]),e}const{definePreview:mt}=__STORYBOOK_MODULE_PREVIEW_API__,yt=[t=>c.jsx(c.Fragment,{children:c.jsx(t,{})}),t=>{const r=Q();return v.useEffect(()=>(document.documentElement.dataset.theme=r?"dark":"default",()=>{delete document.documentElement.dataset.theme}),[r]),c.jsx(t,{})}],X=t=>{const[r,e]=v.useState(!1);return v.useEffect(()=>{const n=a=>e(a);return t.context.channel.on(g,n),()=>{t.context.channel.off(g,n)}},[t.context.channel]),c.jsx(j,{...t,theme:r?p.dark:p.light})},dt={docs:{container:X},darkMode:{current:"light",stylePreview:!0}},pt=["autodocs"];export{yt as decorators,dt as parameters,pt as tags};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./DocsRenderer-CFRXHY34-BLg8W1W2.js","./iframe-DQBiGpMD.js","./index-eCxJ45ll.js","./jsx-runtime-Y5Ju2SGo.js","./index-BGqSdrBK.js","./index-D3-0uUTW.js","./index-Dytf1aFS.js","./client-9BU5HM4U.js"])))=>i.map(i=>d[i]);
2
- import{_ as o}from"./iframe-DQBiGpMD.js";var s=Object.defineProperty,i=(e,r)=>{for(var t in r)s(e,t,{get:r[t],enumerable:!0})},n={};i(n,{parameters:()=>d});var _=Object.entries(globalThis.TAGS_OPTIONS??{}).reduce((e,r)=>{let[t,a]=r;return a.excludeFromDocsStories&&(e[t]=!0),e},{}),d={docs:{renderer:async()=>{let{DocsRenderer:e}=await o(async()=>{const{DocsRenderer:r}=await import("./DocsRenderer-CFRXHY34-BLg8W1W2.js").then(t=>t.e);return{DocsRenderer:r}},__vite__mapDeps([0,1,2,3,4,5,6,7]),import.meta.url);return new e},stories:{filter:e=>{var r;return(e.tags||[]).filter(t=>_[t]).length===0&&!((r=e.parameters.docs)!=null&&r.disable)}}}};export{d as parameters};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./DocsRenderer-CFRXHY34-Bg8MQWAR.js","./iframe-CpYKaSFw.js","./index-eCxJ45ll.js","./jsx-runtime-Y5Ju2SGo.js","./index-BGqSdrBK.js","./index-D3-0uUTW.js","./index-Dytf1aFS.js","./client-9BU5HM4U.js"])))=>i.map(i=>d[i]);
2
+ import{_ as o}from"./iframe-CpYKaSFw.js";var s=Object.defineProperty,i=(e,r)=>{for(var t in r)s(e,t,{get:r[t],enumerable:!0})},n={};i(n,{parameters:()=>d});var _=Object.entries(globalThis.TAGS_OPTIONS??{}).reduce((e,r)=>{let[t,a]=r;return a.excludeFromDocsStories&&(e[t]=!0),e},{}),d={docs:{renderer:async()=>{let{DocsRenderer:e}=await o(async()=>{const{DocsRenderer:r}=await import("./DocsRenderer-CFRXHY34-Bg8MQWAR.js").then(t=>t.e);return{DocsRenderer:r}},__vite__mapDeps([0,1,2,3,4,5,6,7]),import.meta.url);return new e},stories:{filter:e=>{var r;return(e.tags||[]).filter(t=>_[t]).length===0&&!((r=e.parameters.docs)!=null&&r.disable)}}}};export{d as parameters};
@@ -1,4 +1,4 @@
1
- import{j as g}from"./jsx-runtime-Y5Ju2SGo.js";import{r as ye}from"./index-eCxJ45ll.js";import{d as ve,r as Ae,w as ke,x as u,S as De,y as He,z as je,B as we,f as U,C as Me,A as Ee,P as Ie,G as Pe,E as z,b as Ne,s as qe,F as Ue,H as ze,I as Fe,h as Ze,i as Ye,J as Xe,j as $e,p as Ve,m as Je,n as Ke,q as Qe,t as Ge}from"./legend-context-9xqNf4cB.js";import{u as et,j as tt,t as at,k as st,l as rt,m as lt,H as ot,L as nt,n as ct,o as dt}from"./legend-Dsh-gS4D.js";import{D as it,a as ut}from"./bar-chart-const-Cgj9sgUU.js";import"./index-B-BONL6g.js";import"./index-BGqSdrBK.js";import"./index-D3-0uUTW.js";const F=(e,t)=>{let a={};return t?(Math.abs(e)<it||Math.abs(e)>ut)&&(a={roundScientificCoefficient:3}):a={scientific:!1},ve(Ae(e),a)},gt=(e,t)=>{var a;if((a=t==null?void 0:t.tooltip)!=null&&a.showLabelsInTooltips){const r=e[0],{label:s}=(r==null?void 0:r.dataset)??{};return s}},ht=(e,t)=>{var o;const{raw:a,dataset:r}=e??{},s=a==null?void 0:a.label,n=(o=t==null?void 0:t.tooltip)==null?void 0:o.scientificNotation;return`${s??(r==null?void 0:r.label)} ( x: ${F(a==null?void 0:a.x,n)} , y: ${F(a==null?void 0:a.y,n)} )`},mt=e=>{var t,a,r;return{enabled:(t=e==null?void 0:e.tooltip)==null?void 0:t.enabled,callbacks:{title:s=>gt(s,e),label:s=>ht(s,e)},backgroundColor:(a=e==null?void 0:e.tooltip)==null?void 0:a.backgroundColor,displayColors:(r=e==null?void 0:e.tooltip)==null?void 0:r.displayColors,padding:7}},Z=({options:e,axisType:t=u.X,currentScale:a})=>{var C,T,p,b,L,f,w,y,M;const r=ke(e.direction),s=a||((T=(C=e==null?void 0:e.axes)==null?void 0:C[t])==null?void 0:T[0]),n=r&&t===u.Y||!r&&t===u.X,o=(s==null?void 0:s.gridLines)||{},x=()=>{var l;const c=r?u.Y:u.X;return t===c?(l=e==null?void 0:e.additionalAxesOptions)==null?void 0:l.reverse:!1},S=()=>{const c=e==null?void 0:e.additionalAxesOptions;return{...{stepSize:(s==null?void 0:s.stepSize)??(t===u.Y?c==null?void 0:c.stepSize:void 0)},includeBounds:!1,font:{size:He}}};return{type:De.Linear,position:s==null?void 0:s.position,beginAtZero:(p=e==null?void 0:e.additionalAxesOptions)==null?void 0:p.beginAtZero,reverse:x(),suggestedMax:(b=e==null?void 0:e.additionalAxesOptions)==null?void 0:b.suggestedMax,suggestedMin:(L=e==null?void 0:e.additionalAxesOptions)==null?void 0:L.suggestedMin,min:n?(f=e==null?void 0:e.additionalAxesOptions)==null?void 0:f.min:void 0,max:n?(w=e==null?void 0:e.additionalAxesOptions)==null?void 0:w.max:void 0,title:{display:!!((y=s==null?void 0:s.label)!=null&&y.length)||!!((M=s==null?void 0:s.unit)!=null&&M.length),text:(s==null?void 0:s.label)||(s==null?void 0:s.unit),padding:0},ticks:S(),grid:{...o}}},bt=e=>{const t=Z({options:e,axisType:u.X}),a=Z({options:e,axisType:u.Y});return{x:t,y:a}},ft=(e,t)=>{const{data:a,options:r}=e,{interactions:s,chartStyling:n}=r,[o,x]=ye.useState(!1),{legend:S,customLegendPlugin:C,legendClick:T}=et({chartRef:t,options:r}),{state:p}=tt(),{annotation:b}=p,f=(c=>c.map((l,R)=>{const{borderWidth:E=st}=l??{},_e=parseFloat(String(E))||1,q=Me[R],We=l.borderColor??q,Be=l.backgroundColor??q;return{...l,borderWidth:_e,borderColor:We,backgroundColor:Be}}))(a.datasets),w=(c,l,R)=>{R.resetZoom()},y=(c,l)=>{if(o&&!(l!=null&&l.length)&&(x(!1),s.onUnhover&&s.onUnhover(c)),!o&&(l!=null&&l.length)&&(x(!0),s.onHover)){const{index:R,datasetIndex:E}=l[0];s.onHover(c,E,R,f)}},M={onClick:w,onHover:y,...n,interactions:{onLegendClick:T,onHover:y},scales:bt(e==null?void 0:e.options),animation:n.performanceMode?{duration:U.NO}:{duration:U.FAST,onComplete:s==null?void 0:s.onAnimationComplete},plugins:{legend:{...S,display:!1,events:[]},customLegendPlugin:C,title:je(r),annotation:at(b),chartAreaBorder:{borderColor:we},datalabels:{display:r.graph.showDataLabels},tooltip:mt(r)}};return{generatedDatasets:f,scatterOptions:M}};var d=(e=>(e[e.TopToBottom=0]="TopToBottom",e[e.BottomToTop=1]="BottomToTop",e[e.LeftToRight=2]="LeftToRight",e[e.RightToLeft=3]="RightToLeft",e[e.TopLeftToBottomRight=4]="TopLeftToBottomRight",e[e.BottomRightToTopLeft=5]="BottomRightToTopLeft",e[e.BottomLeftToTopRight=6]="BottomLeftToTopRight",e[e.TopRightToBottomLeft=7]="TopRightToBottomLeft",e))(d||{});const xt=e=>({display:(e==null?void 0:e.display)??!1,gradientColors:(e==null?void 0:e.gradientColors)??Pe,direction:(e==null?void 0:e.direction)??d.BottomLeftToTopRight}),Ct=e=>({width:(e==null?void 0:e.width)??z,height:(e==null?void 0:e.height)??z,maintainAspectRatio:(e==null?void 0:e.maintainAspectRatio)||!1,staticChartHeight:(e==null?void 0:e.staticChartHeight)||!1,performanceMode:(e==null?void 0:e.performanceMode)??!0,gradient:xt(e==null?void 0:e.gradient)}),Tt=e=>({enabled:(e==null?void 0:e.enabled)??!0,tooltips:(e==null?void 0:e.tooltips)??!0,showLabelsInTooltips:(e==null?void 0:e.showLabelsInTooltips)||!1,backgroundColor:(e==null?void 0:e.backgroundColor)||"#333",displayColors:(e==null?void 0:e.displayColors)||!1,scientificNotation:(e==null?void 0:e.scientificNotation)??!0}),pt=e=>({showMinorGridlines:(e==null?void 0:e.showMinorGridlines)??!1,showDataLabels:(e==null?void 0:e.showDataLabels)??!1}),St=e=>({display:(e==null?void 0:e.display)??!0,useDataset:(e==null?void 0:e.useDataset)||!1,position:(e==null?void 0:e.position)||Ie.BottomLeft,align:(e==null?void 0:e.align)||Ee.Center}),Lt=e=>({enableZoom:(e==null?void 0:e.enableZoom)||!1,enablePan:(e==null?void 0:e.enablePan)||!1}),yt=e=>({onLegendClick:e==null?void 0:e.onLegendClick,onHover:e==null?void 0:e.onHover,onUnhover:e==null?void 0:e.onUnhover,onAnimationComplete:e==null?void 0:e.onAnimationComplete}),Rt=e=>({labels:(e==null?void 0:e.labels)||[],datasets:(e==null?void 0:e.datasets)||[]}),Ot=e=>e?e.map(t=>({...t,display:(t==null?void 0:t.display)??!0})):[],_t=e=>({showAnnotations:(e==null?void 0:e.showAnnotations)??!0,controlAnnotation:(e==null?void 0:e.controlAnnotation)||!1,annotationsData:Ot(e==null?void 0:e.annotationsData)}),Wt=e=>({x:(e==null?void 0:e.x)||[{}],y:(e==null?void 0:e.y)||[{}]}),Bt=e=>({reverse:(e==null?void 0:e.reverse)||!1,stacked:(e==null?void 0:e.stacked)||!1,beginAtZero:(e==null?void 0:e.beginAtZero)??!0,stepSize:e==null?void 0:e.stepSize,suggestedMin:e==null?void 0:e.suggestedMin,suggestedMax:e==null?void 0:e.suggestedMax,min:e==null?void 0:e.min,max:e==null?void 0:e.max}),Re=e=>{const t=(e==null?void 0:e.chart)||{},a=(t==null?void 0:t.options)||{};return{testId:(t==null?void 0:t.testId)??null,data:Rt(t==null?void 0:t.data),options:{title:(a==null?void 0:a.title)||"",axes:Wt(a==null?void 0:a.axes),additionalAxesOptions:Bt(a==null?void 0:a.additionalAxesOptions),direction:(a==null?void 0:a.direction)||rt.VERTICAL,chartStyling:Ct(a==null?void 0:a.chartStyling),tooltip:Tt(a==null?void 0:a.tooltip),graph:pt(a==null?void 0:a.graph),legend:St(a==null?void 0:a.legend),annotations:_t(a==null?void 0:a.annotations),chartOptions:Lt(a==null?void 0:a.chartOptions),interactions:yt(a==null?void 0:a.interactions)}}},vt=(e,t)=>{switch(e){case d.TopToBottom:return[t.left,t.top,t.left,t.bottom];case d.BottomToTop:return[t.left,t.bottom,t.left,t.top];case d.LeftToRight:return[t.left,t.top,t.right,t.top];case d.RightToLeft:return[t.right,t.top,t.left,t.top];case d.TopLeftToBottomRight:return[t.left,t.top,t.right,t.bottom];case d.BottomRightToTopLeft:return[t.right,t.bottom,t.left,t.top];case d.BottomLeftToTopRight:return[t.left,t.bottom,t.right,t.top];case d.TopRightToBottomLeft:return[t.right,t.top,t.left,t.bottom];default:return[t.left,t.bottom,t.right,t.top]}},At={id:"gradientBackgroundPlugin",beforeDraw:e=>{const{ctx:t,chartArea:a,options:r}=e;if(!t||!a)return;const s=r==null?void 0:r.gradient,{display:n=!1,gradientColors:o,direction:x=d.BottomLeftToTopRight}=s??{};if(!n||!o||o.length===0)return;const[S,C,T,p]=vt(x,a),b=t.createLinearGradient(S,C,T,p);o.forEach(({offset:L,color:f})=>{b.addColorStop(L,f)}),t.save(),t.globalCompositeOperation="destination-over",t.fillStyle=b,t.fillRect(a.left,a.top,a.right-a.left,a.bottom-a.top),t.restore()}},kt="_chart_1qlu1_1",Dt="_canvas_1qlu1_11",Ht="_fixedHeight_1qlu1_20",jt="_stretchHeight_1qlu1_26",wt="_squareAspectRatio_1qlu1_32",Y={chart:kt,canvas:Dt,fixedHeight:Ht,stretchHeight:jt,squareAspectRatio:wt};Ze.register(Ye,Xe,$e,Ve,Je,Ke,Qe,Ge,dt,At);const Mt=e=>{qe();const t=ye.useRef(null),a=Re(e),{options:r,testId:s}=a,{scatterOptions:n,generatedDatasets:o}=ft(a,t);return g.jsx("div",{className:Ue(r.chartStyling,Y),style:{width:r.chartStyling.width,height:r.chartStyling.height},"data-testid":s,children:g.jsx(lt,{backend:ot,context:window,children:g.jsxs("div",{className:Y.canvas,id:"canvas",children:[g.jsx(ze,{ref:t,data:{datasets:o},options:n,plugins:Fe(r.graph,r.legend)}),!!o.length&&g.jsx(nt,{chartRef:t,legendConfig:{options:r,generatedDatasets:o,chartType:ct.SCATTER}})]})})})},I=e=>{const{options:t}=Re(e);return g.jsx(Ne,{options:t,children:g.jsx(Mt,{...e})})};I.__docgenInfo={description:"",methods:[],displayName:"ScatterChartWithLegend",props:{chart:{required:!0,tsType:{name:"IScatterChartData"},description:""},testId:{required:!1,tsType:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}]},description:""}}};const h=["label 1","label 2","label 3"],m={label:"Dataset 1",data:[{x:1,y:5},{x:3,y:7},{x:6,y:2},{x:8,y:6},{x:9,y:4}]},P={label:"Dataset 2",data:[{x:1,y:3},{x:4,y:5},{x:7,y:9},{x:10,y:2},{x:12,y:7}]},Et={label:"Dataset 3",data:[{x:2,y:8},{x:5,y:6},{x:8,y:10},{x:11,y:5},{x:14,y:9}]},Oe={label:"Dataset 4",data:[{x:2,y:8},{x:14,y:9}]},It={label:"Dataset 5",data:[{x:14,y:7,label:"Echo"},{x:3,y:18,label:"Lima"},{x:19,y:2,label:"Romeo"},{x:8,y:11,label:"Charlie"},{x:12,y:9,label:"Oscar"}]},Pt={label:"Dataset 6",data:[{x:15,y:3,label:"Hotel"},{x:9,y:14,label:"Tango"},{x:4,y:17,label:"Whiskey"},{x:11,y:7,label:"Juliet"},{x:13,y:1,label:"Zulu"}]},Nt={label:"Dataset Decimals",data:[{x:4.30021321123002,y:2.30021321123005},{x:5.12321321000003,y:3.23213210000037}]},N={data:{labels:h,datasets:[m]}},qt={data:{labels:h,datasets:[m]},options:{chartStyling:{height:300,width:700}}},Ut={data:{labels:h,datasets:[m,P,Et]}},zt={data:{labels:h,datasets:[m]},options:{title:"With Data Labels",graph:{showDataLabels:!0}}},Ft={data:{labels:h,datasets:[m,P,Nt]},options:{title:"With Tooltips",tooltip:{title:"Tooltip",showLabelsInTooltips:!0}}},Zt={data:{labels:h,datasets:[{...m,backgroundColor:"red",borderColor:"red"}]}},Yt={data:{labels:h,datasets:[m]},options:{title:"With Annotation",annotations:{showAnnotations:!0,annotationsData:[{annotationAxis:"y",label:"Horizontal Annotation",value:2.5,color:"rgba(96, 32, 196, 0.5)"}]}}},Xt={data:{labels:h,datasets:[m,P,Oe]},options:{title:"With Axes Labels",axes:{x:[{label:"x axis"}],y:[{label:"y axis"}]}}},$t={...N,options:{title:"With Gradient",chartStyling:{gradient:{display:!0}}}},Vt={data:{datasets:[It,Pt,Oe]},options:{title:"With datapoint label showing when hovered",tooltip:{showLabelsInTooltips:!0}}},ra={title:"ScatterChart",component:I,args:{chart:N}},i=e=>g.jsx(I,{...e}),O=i.bind({});O.args={chart:N};const _=i.bind({});_.args={chart:qt};const W=i.bind({});W.args={chart:Ut};const B=i.bind({});B.args={chart:zt};const v=i.bind({});v.args={chart:Ft};const A=i.bind({});A.args={chart:Yt};const k=i.bind({});k.args={chart:Xt};const D=i.bind({});D.args={chart:$t};const H=i.bind({});H.args={chart:Vt};const j=i.bind({});j.args={chart:Zt};var X,$,V;O.parameters={...O.parameters,docs:{...(X=O.parameters)==null?void 0:X.docs,source:{originalSource:`args => {
1
+ import{j as g}from"./jsx-runtime-Y5Ju2SGo.js";import{r as ye}from"./index-eCxJ45ll.js";import{d as ve,r as Ae,w as ke,x as u,S as De,y as He,z as je,B as we,f as U,C as Me,A as Ee,P as Ie,G as Pe,E as z,b as Ne,s as qe,F as Ue,H as ze,I as Fe,h as Ze,i as Ye,J as Xe,j as $e,p as Ve,m as Je,n as Ke,q as Qe,t as Ge}from"./legend-context-BDAlvkJS.js";import{u as et,j as tt,t as at,k as st,l as rt,m as lt,H as ot,L as nt,n as ct,o as dt}from"./legend-D-2OZtHn.js";import{D as it,a as ut}from"./bar-chart-const-Cgj9sgUU.js";import"./index-B-BONL6g.js";import"./index-BGqSdrBK.js";import"./index-D3-0uUTW.js";const F=(e,t)=>{let a={};return t?(Math.abs(e)<it||Math.abs(e)>ut)&&(a={roundScientificCoefficient:3}):a={scientific:!1},ve(Ae(e),a)},gt=(e,t)=>{var a;if((a=t==null?void 0:t.tooltip)!=null&&a.showLabelsInTooltips){const r=e[0],{label:s}=(r==null?void 0:r.dataset)??{};return s}},ht=(e,t)=>{var o;const{raw:a,dataset:r}=e??{},s=a==null?void 0:a.label,n=(o=t==null?void 0:t.tooltip)==null?void 0:o.scientificNotation;return`${s??(r==null?void 0:r.label)} ( x: ${F(a==null?void 0:a.x,n)} , y: ${F(a==null?void 0:a.y,n)} )`},mt=e=>{var t,a,r;return{enabled:(t=e==null?void 0:e.tooltip)==null?void 0:t.enabled,callbacks:{title:s=>gt(s,e),label:s=>ht(s,e)},backgroundColor:(a=e==null?void 0:e.tooltip)==null?void 0:a.backgroundColor,displayColors:(r=e==null?void 0:e.tooltip)==null?void 0:r.displayColors,padding:7}},Z=({options:e,axisType:t=u.X,currentScale:a})=>{var C,T,p,b,L,f,w,y,M;const r=ke(e.direction),s=a||((T=(C=e==null?void 0:e.axes)==null?void 0:C[t])==null?void 0:T[0]),n=r&&t===u.Y||!r&&t===u.X,o=(s==null?void 0:s.gridLines)||{},x=()=>{var l;const c=r?u.Y:u.X;return t===c?(l=e==null?void 0:e.additionalAxesOptions)==null?void 0:l.reverse:!1},S=()=>{const c=e==null?void 0:e.additionalAxesOptions;return{...{stepSize:(s==null?void 0:s.stepSize)??(t===u.Y?c==null?void 0:c.stepSize:void 0)},includeBounds:!1,font:{size:He}}};return{type:De.Linear,position:s==null?void 0:s.position,beginAtZero:(p=e==null?void 0:e.additionalAxesOptions)==null?void 0:p.beginAtZero,reverse:x(),suggestedMax:(b=e==null?void 0:e.additionalAxesOptions)==null?void 0:b.suggestedMax,suggestedMin:(L=e==null?void 0:e.additionalAxesOptions)==null?void 0:L.suggestedMin,min:n?(f=e==null?void 0:e.additionalAxesOptions)==null?void 0:f.min:void 0,max:n?(w=e==null?void 0:e.additionalAxesOptions)==null?void 0:w.max:void 0,title:{display:!!((y=s==null?void 0:s.label)!=null&&y.length)||!!((M=s==null?void 0:s.unit)!=null&&M.length),text:(s==null?void 0:s.label)||(s==null?void 0:s.unit),padding:0},ticks:S(),grid:{...o}}},bt=e=>{const t=Z({options:e,axisType:u.X}),a=Z({options:e,axisType:u.Y});return{x:t,y:a}},ft=(e,t)=>{const{data:a,options:r}=e,{interactions:s,chartStyling:n}=r,[o,x]=ye.useState(!1),{legend:S,customLegendPlugin:C,legendClick:T}=et({chartRef:t,options:r}),{state:p}=tt(),{annotation:b}=p,f=(c=>c.map((l,R)=>{const{borderWidth:E=st}=l??{},_e=parseFloat(String(E))||1,q=Me[R],We=l.borderColor??q,Be=l.backgroundColor??q;return{...l,borderWidth:_e,borderColor:We,backgroundColor:Be}}))(a.datasets),w=(c,l,R)=>{R.resetZoom()},y=(c,l)=>{if(o&&!(l!=null&&l.length)&&(x(!1),s.onUnhover&&s.onUnhover(c)),!o&&(l!=null&&l.length)&&(x(!0),s.onHover)){const{index:R,datasetIndex:E}=l[0];s.onHover(c,E,R,f)}},M={onClick:w,onHover:y,...n,interactions:{onLegendClick:T,onHover:y},scales:bt(e==null?void 0:e.options),animation:n.performanceMode?{duration:U.NO}:{duration:U.FAST,onComplete:s==null?void 0:s.onAnimationComplete},plugins:{legend:{...S,display:!1,events:[]},customLegendPlugin:C,title:je(r),annotation:at(b),chartAreaBorder:{borderColor:we},datalabels:{display:r.graph.showDataLabels},tooltip:mt(r)}};return{generatedDatasets:f,scatterOptions:M}};var d=(e=>(e[e.TopToBottom=0]="TopToBottom",e[e.BottomToTop=1]="BottomToTop",e[e.LeftToRight=2]="LeftToRight",e[e.RightToLeft=3]="RightToLeft",e[e.TopLeftToBottomRight=4]="TopLeftToBottomRight",e[e.BottomRightToTopLeft=5]="BottomRightToTopLeft",e[e.BottomLeftToTopRight=6]="BottomLeftToTopRight",e[e.TopRightToBottomLeft=7]="TopRightToBottomLeft",e))(d||{});const xt=e=>({display:(e==null?void 0:e.display)??!1,gradientColors:(e==null?void 0:e.gradientColors)??Pe,direction:(e==null?void 0:e.direction)??d.BottomLeftToTopRight}),Ct=e=>({width:(e==null?void 0:e.width)??z,height:(e==null?void 0:e.height)??z,maintainAspectRatio:(e==null?void 0:e.maintainAspectRatio)||!1,staticChartHeight:(e==null?void 0:e.staticChartHeight)||!1,performanceMode:(e==null?void 0:e.performanceMode)??!0,gradient:xt(e==null?void 0:e.gradient)}),Tt=e=>({enabled:(e==null?void 0:e.enabled)??!0,tooltips:(e==null?void 0:e.tooltips)??!0,showLabelsInTooltips:(e==null?void 0:e.showLabelsInTooltips)||!1,backgroundColor:(e==null?void 0:e.backgroundColor)||"#333",displayColors:(e==null?void 0:e.displayColors)||!1,scientificNotation:(e==null?void 0:e.scientificNotation)??!0}),pt=e=>({showMinorGridlines:(e==null?void 0:e.showMinorGridlines)??!1,showDataLabels:(e==null?void 0:e.showDataLabels)??!1}),St=e=>({display:(e==null?void 0:e.display)??!0,useDataset:(e==null?void 0:e.useDataset)||!1,position:(e==null?void 0:e.position)||Ie.BottomLeft,align:(e==null?void 0:e.align)||Ee.Center}),Lt=e=>({enableZoom:(e==null?void 0:e.enableZoom)||!1,enablePan:(e==null?void 0:e.enablePan)||!1}),yt=e=>({onLegendClick:e==null?void 0:e.onLegendClick,onHover:e==null?void 0:e.onHover,onUnhover:e==null?void 0:e.onUnhover,onAnimationComplete:e==null?void 0:e.onAnimationComplete}),Rt=e=>({labels:(e==null?void 0:e.labels)||[],datasets:(e==null?void 0:e.datasets)||[]}),Ot=e=>e?e.map(t=>({...t,display:(t==null?void 0:t.display)??!0})):[],_t=e=>({showAnnotations:(e==null?void 0:e.showAnnotations)??!0,controlAnnotation:(e==null?void 0:e.controlAnnotation)||!1,annotationsData:Ot(e==null?void 0:e.annotationsData)}),Wt=e=>({x:(e==null?void 0:e.x)||[{}],y:(e==null?void 0:e.y)||[{}]}),Bt=e=>({reverse:(e==null?void 0:e.reverse)||!1,stacked:(e==null?void 0:e.stacked)||!1,beginAtZero:(e==null?void 0:e.beginAtZero)??!0,stepSize:e==null?void 0:e.stepSize,suggestedMin:e==null?void 0:e.suggestedMin,suggestedMax:e==null?void 0:e.suggestedMax,min:e==null?void 0:e.min,max:e==null?void 0:e.max}),Re=e=>{const t=(e==null?void 0:e.chart)||{},a=(t==null?void 0:t.options)||{};return{testId:(t==null?void 0:t.testId)??null,data:Rt(t==null?void 0:t.data),options:{title:(a==null?void 0:a.title)||"",axes:Wt(a==null?void 0:a.axes),additionalAxesOptions:Bt(a==null?void 0:a.additionalAxesOptions),direction:(a==null?void 0:a.direction)||rt.VERTICAL,chartStyling:Ct(a==null?void 0:a.chartStyling),tooltip:Tt(a==null?void 0:a.tooltip),graph:pt(a==null?void 0:a.graph),legend:St(a==null?void 0:a.legend),annotations:_t(a==null?void 0:a.annotations),chartOptions:Lt(a==null?void 0:a.chartOptions),interactions:yt(a==null?void 0:a.interactions)}}},vt=(e,t)=>{switch(e){case d.TopToBottom:return[t.left,t.top,t.left,t.bottom];case d.BottomToTop:return[t.left,t.bottom,t.left,t.top];case d.LeftToRight:return[t.left,t.top,t.right,t.top];case d.RightToLeft:return[t.right,t.top,t.left,t.top];case d.TopLeftToBottomRight:return[t.left,t.top,t.right,t.bottom];case d.BottomRightToTopLeft:return[t.right,t.bottom,t.left,t.top];case d.BottomLeftToTopRight:return[t.left,t.bottom,t.right,t.top];case d.TopRightToBottomLeft:return[t.right,t.top,t.left,t.bottom];default:return[t.left,t.bottom,t.right,t.top]}},At={id:"gradientBackgroundPlugin",beforeDraw:e=>{const{ctx:t,chartArea:a,options:r}=e;if(!t||!a)return;const s=r==null?void 0:r.gradient,{display:n=!1,gradientColors:o,direction:x=d.BottomLeftToTopRight}=s??{};if(!n||!o||o.length===0)return;const[S,C,T,p]=vt(x,a),b=t.createLinearGradient(S,C,T,p);o.forEach(({offset:L,color:f})=>{b.addColorStop(L,f)}),t.save(),t.globalCompositeOperation="destination-over",t.fillStyle=b,t.fillRect(a.left,a.top,a.right-a.left,a.bottom-a.top),t.restore()}},kt="_chart_1qlu1_1",Dt="_canvas_1qlu1_11",Ht="_fixedHeight_1qlu1_20",jt="_stretchHeight_1qlu1_26",wt="_squareAspectRatio_1qlu1_32",Y={chart:kt,canvas:Dt,fixedHeight:Ht,stretchHeight:jt,squareAspectRatio:wt};Ze.register(Ye,Xe,$e,Ve,Je,Ke,Qe,Ge,dt,At);const Mt=e=>{qe();const t=ye.useRef(null),a=Re(e),{options:r,testId:s}=a,{scatterOptions:n,generatedDatasets:o}=ft(a,t);return g.jsx("div",{className:Ue(r.chartStyling,Y),style:{width:r.chartStyling.width,height:r.chartStyling.height},"data-testid":s,children:g.jsx(lt,{backend:ot,context:window,children:g.jsxs("div",{className:Y.canvas,id:"canvas",children:[g.jsx(ze,{ref:t,data:{datasets:o},options:n,plugins:Fe(r.graph,r.legend)}),!!o.length&&g.jsx(nt,{chartRef:t,legendConfig:{options:r,generatedDatasets:o,chartType:ct.SCATTER}})]})})})},I=e=>{const{options:t}=Re(e);return g.jsx(Ne,{options:t,children:g.jsx(Mt,{...e})})};I.__docgenInfo={description:"",methods:[],displayName:"ScatterChartWithLegend",props:{chart:{required:!0,tsType:{name:"IScatterChartData"},description:""},testId:{required:!1,tsType:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}]},description:""}}};const h=["label 1","label 2","label 3"],m={label:"Dataset 1",data:[{x:1,y:5},{x:3,y:7},{x:6,y:2},{x:8,y:6},{x:9,y:4}]},P={label:"Dataset 2",data:[{x:1,y:3},{x:4,y:5},{x:7,y:9},{x:10,y:2},{x:12,y:7}]},Et={label:"Dataset 3",data:[{x:2,y:8},{x:5,y:6},{x:8,y:10},{x:11,y:5},{x:14,y:9}]},Oe={label:"Dataset 4",data:[{x:2,y:8},{x:14,y:9}]},It={label:"Dataset 5",data:[{x:14,y:7,label:"Echo"},{x:3,y:18,label:"Lima"},{x:19,y:2,label:"Romeo"},{x:8,y:11,label:"Charlie"},{x:12,y:9,label:"Oscar"}]},Pt={label:"Dataset 6",data:[{x:15,y:3,label:"Hotel"},{x:9,y:14,label:"Tango"},{x:4,y:17,label:"Whiskey"},{x:11,y:7,label:"Juliet"},{x:13,y:1,label:"Zulu"}]},Nt={label:"Dataset Decimals",data:[{x:4.30021321123002,y:2.30021321123005},{x:5.12321321000003,y:3.23213210000037}]},N={data:{labels:h,datasets:[m]}},qt={data:{labels:h,datasets:[m]},options:{chartStyling:{height:300,width:700}}},Ut={data:{labels:h,datasets:[m,P,Et]}},zt={data:{labels:h,datasets:[m]},options:{title:"With Data Labels",graph:{showDataLabels:!0}}},Ft={data:{labels:h,datasets:[m,P,Nt]},options:{title:"With Tooltips",tooltip:{title:"Tooltip",showLabelsInTooltips:!0}}},Zt={data:{labels:h,datasets:[{...m,backgroundColor:"red",borderColor:"red"}]}},Yt={data:{labels:h,datasets:[m]},options:{title:"With Annotation",annotations:{showAnnotations:!0,annotationsData:[{annotationAxis:"y",label:"Horizontal Annotation",value:2.5,color:"rgba(96, 32, 196, 0.5)"}]}}},Xt={data:{labels:h,datasets:[m,P,Oe]},options:{title:"With Axes Labels",axes:{x:[{label:"x axis"}],y:[{label:"y axis"}]}}},$t={...N,options:{title:"With Gradient",chartStyling:{gradient:{display:!0}}}},Vt={data:{datasets:[It,Pt,Oe]},options:{title:"With datapoint label showing when hovered",tooltip:{showLabelsInTooltips:!0}}},ra={title:"ScatterChart",component:I,args:{chart:N}},i=e=>g.jsx(I,{...e}),O=i.bind({});O.args={chart:N};const _=i.bind({});_.args={chart:qt};const W=i.bind({});W.args={chart:Ut};const B=i.bind({});B.args={chart:zt};const v=i.bind({});v.args={chart:Ft};const A=i.bind({});A.args={chart:Yt};const k=i.bind({});k.args={chart:Xt};const D=i.bind({});D.args={chart:$t};const H=i.bind({});H.args={chart:Vt};const j=i.bind({});j.args={chart:Zt};var X,$,V;O.parameters={...O.parameters,docs:{...(X=O.parameters)==null?void 0:X.docs,source:{originalSource:`args => {
2
2
  return <ScatterChart
3
3
  // eslint-disable-next-line react/jsx-props-no-spreading
4
4
  {...args} />;
@@ -51,8 +51,11 @@ export interface ICommonAnnotationsData {
51
51
  id?: string;
52
52
  adjustScaleRange: boolean;
53
53
  annotationAxis: 'x' | 'y';
54
+ rotation: number;
54
55
  color: string;
55
56
  endValue: number;
57
+ borderWidth?: number;
58
+ backgroundColor?: string;
56
59
  label: string;
57
60
  labelConfig?: Record<string, any>;
58
61
  type: AnnotationType;
@@ -67,6 +67,7 @@ declare const getAnnotation: ({ showAnnotations, annotationsData, }: IGetAnnotat
67
67
  displayDragCoordinates: boolean;
68
68
  hideLegend?: boolean;
69
69
  annotationAxis: "x" | "y";
70
+ rotation: number;
70
71
  color: string;
71
72
  endValue: number;
72
73
  labelConfig?: Record<string, any>;
@@ -0,0 +1,9 @@
1
+ import { Scale } from 'chart.js';
2
+ import { IEllipsePoints } from './ellipsis-annotation-plugin.ts';
3
+ export declare const computeEllipseGeometry: (ellipsePoints: IEllipsePoints, xScale: Scale, yScale: Scale) => {
4
+ cx: number;
5
+ cy: number;
6
+ radiusX: number;
7
+ radiusY: number;
8
+ angle: number;
9
+ };
@@ -0,0 +1,18 @@
1
+ import { Chart, ChartDataset, ScatterDataPoint } from 'chart.js';
2
+ export interface IPoint {
3
+ x: number;
4
+ y: number;
5
+ }
6
+ export interface IEllipsePoints {
7
+ major: [IPoint, IPoint];
8
+ minor: [IPoint, IPoint];
9
+ }
10
+ export interface ICustomDataPoint extends ScatterDataPoint {
11
+ ellipsePoints?: IEllipsePoints;
12
+ }
13
+ export interface ICustomDataset extends ChartDataset<any, ICustomDataPoint[]> {
14
+ }
15
+ export declare const ellipsisAnnotationPlugin: {
16
+ id: string;
17
+ afterDatasetsDraw(chart: Chart<"scatter">): void;
18
+ };
package/dist/iframe.html CHANGED
@@ -509,7 +509,7 @@
509
509
  }
510
510
  </script>
511
511
 
512
- <script type="module" crossorigin src="./assets/iframe-DQBiGpMD.js"></script>
512
+ <script type="module" crossorigin src="./assets/iframe-CpYKaSFw.js"></script>
513
513
  </head>
514
514
 
515
515
  <body>
package/dist/index.js.js CHANGED
@@ -22766,18 +22766,6 @@ const setDefaultTheme = () => {
22766
22766
  defaults$2.color = DEFAULT_COLOR;
22767
22767
  defaults$2.borderColor = BORDER_COLOR;
22768
22768
  };
22769
- const isNilOrEmpty = (value) => {
22770
- if (value === null || value === void 0 || value === "") {
22771
- return true;
22772
- }
22773
- if (Array.isArray(value) && value.length === 0) {
22774
- return true;
22775
- }
22776
- if (typeof value === "object" && Object.keys(value).length === 0) {
22777
- return true;
22778
- }
22779
- return false;
22780
- };
22781
22769
  const isEmptyString = (value) => value === "";
22782
22770
  const computeEllipseGeometry = (ellipsePoints, xScale, yScale) => {
22783
22771
  const [p1, p2] = ellipsePoints.major;
@@ -24398,9 +24386,17 @@ const generateKey = (values) => {
24398
24386
  return key;
24399
24387
  };
24400
24388
  const isPrimitiveValue = (value) => typeof value === "string" || typeof value === "number" || typeof value === "boolean" || value === null;
24401
- const isRangeValid = (r2) => {
24402
- if (!r2) return false;
24403
- return Object.values(r2).some((value) => !isNilOrEmpty(value));
24389
+ const getChartKey = (state, languageKey) => {
24390
+ const axesKey = ((state == null ? void 0 : state.axes) || []).map(({ id, min, max }) => `${id}:${min}-${max}`).join("|");
24391
+ return generateKey([
24392
+ axesKey,
24393
+ state == null ? void 0 : state.enableDragPoints,
24394
+ state == null ? void 0 : state.enableDragAnnotation,
24395
+ state == null ? void 0 : state.zoomEnabled,
24396
+ state == null ? void 0 : state.panEnabled,
24397
+ state == null ? void 0 : state.edited,
24398
+ languageKey
24399
+ ]);
24404
24400
  };
24405
24401
  const useChartFunctions = ({
24406
24402
  chartRef,
@@ -24574,7 +24570,7 @@ const validateAxes = (axes) => {
24574
24570
  );
24575
24571
  return { errors, valid };
24576
24572
  };
24577
- const RANGE_GAP$1 = 1;
24573
+ const RANGE_GAP = 1;
24578
24574
  const getInitAxes = ({ chartRef, state }) => {
24579
24575
  const chart2 = chartRef == null ? void 0 : chartRef.current;
24580
24576
  if (!chart2) return [];
@@ -24584,9 +24580,9 @@ const getInitAxes = ({ chartRef, state }) => {
24584
24580
  let adjustedMin = Number(min);
24585
24581
  let adjustedMax = Number(max);
24586
24582
  if (isNaN(adjustedMin)) adjustedMin = 0;
24587
- if (isNaN(adjustedMax)) adjustedMax = adjustedMin + RANGE_GAP$1;
24583
+ if (isNaN(adjustedMax)) adjustedMax = adjustedMin + RANGE_GAP;
24588
24584
  if (adjustedMin === adjustedMax) {
24589
- adjustedMax += RANGE_GAP$1;
24585
+ adjustedMax += RANGE_GAP;
24590
24586
  }
24591
24587
  const { unit } = ((_a2 = state == null ? void 0 : state.axes) == null ? void 0 : _a2.find((axis) => axis.id === id)) ?? {};
24592
24588
  return {
@@ -25245,29 +25241,6 @@ const generateLineChartDatasets = (datasets, state, options, { label }) => {
25245
25241
  };
25246
25242
  });
25247
25243
  };
25248
- const getAnnotationsData = (data) => {
25249
- return data == null ? void 0 : data.reduce((acc, obj) => {
25250
- return {
25251
- ...acc,
25252
- [obj.annotationAxis]: [...acc[obj.annotationAxis] || [], +obj.value]
25253
- };
25254
- }, {});
25255
- };
25256
- const getAxisRangeByType = (chartRef, axesType, annotationsData) => {
25257
- if (!chartRef || !chartRef.current) return null;
25258
- const metasets = chartRef.current.getSortedVisibleDatasetMetas();
25259
- const annotDataByType = getAnnotationsData(annotationsData)[axesType] ?? [];
25260
- let allData = [];
25261
- metasets.forEach((metaset) => {
25262
- const data = metaset._parsed.map((parsedData) => parsedData[axesType]).filter((value) => value != null && !isNaN(value));
25263
- allData = allData.concat(data);
25264
- });
25265
- allData = allData.concat(annotDataByType);
25266
- if (allData.length === 0) return null;
25267
- const min = Math.min(...allData);
25268
- const max = Math.max(...allData);
25269
- return { min, max };
25270
- };
25271
25244
  const calculateDelta$1 = (tickValue, ticks) => {
25272
25245
  let delta = ticks.length > 3 ? ticks[2].value - ticks[1].value : ticks[1].value - ticks[0].value;
25273
25246
  if (Math.abs(delta) >= 1 && tickValue !== Math.floor(Number(tickValue))) {
@@ -25461,6 +25434,14 @@ const getSuggestedAxisRange = ({
25461
25434
  max: round$2(maxAxisValue, DECIMAL_POINT_TOLERANCE)
25462
25435
  };
25463
25436
  };
25437
+ const getAnnotationsData = (data) => {
25438
+ return data == null ? void 0 : data.reduce((acc, obj) => {
25439
+ return {
25440
+ ...acc,
25441
+ [obj.annotationAxis]: [...acc[obj.annotationAxis] || [], +obj.value]
25442
+ };
25443
+ }, {});
25444
+ };
25464
25445
  const getAxesDataFromMetasets = (generatedDatasets, scalesKeys, annotationsData) => {
25465
25446
  if (!Array.isArray(generatedDatasets) || !Array.isArray(scalesKeys)) {
25466
25447
  return {};
@@ -25481,7 +25462,7 @@ const getAxesDataFromMetasets = (generatedDatasets, scalesKeys, annotationsData)
25481
25462
  }, {});
25482
25463
  };
25483
25464
  const shouldCalculate = (min, max) => !isNil(min) || !isNil(max);
25484
- const autoScale = (options, state, generatedDatasets, chartRef) => {
25465
+ const autoScale = (options, state, generatedDatasets) => {
25485
25466
  const {
25486
25467
  additionalAxesOptions,
25487
25468
  annotations: { annotationsData = [], controlAnnotation = false } = {}
@@ -25500,7 +25481,6 @@ const autoScale = (options, state, generatedDatasets, chartRef) => {
25500
25481
  const adjustedScales = data && (scalesKeys == null ? void 0 : scalesKeys.reduce((acc, key) => {
25501
25482
  const scale = scales[key];
25502
25483
  const { min: propMin = void 0, max: propMax = void 0 } = scale;
25503
- const { min: calcMin, max: calcMax } = getAxisRangeByType(chartRef, key, annotationsData) ?? {};
25504
25484
  const { min: suggestedMin, max: suggestedMax } = getSuggestedAxisRange({
25505
25485
  data: data[key],
25506
25486
  beginAtZero: additionalAxesOptions == null ? void 0 : additionalAxesOptions.beginAtZero,
@@ -25509,8 +25489,8 @@ const autoScale = (options, state, generatedDatasets, chartRef) => {
25509
25489
  const res = {
25510
25490
  [key]: {
25511
25491
  ...scale,
25512
- min: propMin ?? (shouldCalculate(propMin, propMax) ? calcMin : suggestedMin),
25513
- max: propMax ?? (shouldCalculate(propMin, propMax) ? calcMax : suggestedMax)
25492
+ min: propMin ?? (shouldCalculate(propMin, propMax) ? void 0 : suggestedMin),
25493
+ max: propMax ?? (shouldCalculate(propMin, propMax) ? void 0 : suggestedMax)
25514
25494
  }
25515
25495
  };
25516
25496
  return { ...acc, ...res };
@@ -26098,7 +26078,7 @@ const useChartOptions = ({
26098
26078
  const datalabels = getLineChartDataLabels(options) ?? {};
26099
26079
  const tooltip = getLineChartToolTips(options) ?? {};
26100
26080
  const scales = useMemo(
26101
- () => autoScale(options, state, generatedDatasets, chartRef),
26081
+ () => autoScale(options, state, generatedDatasets),
26102
26082
  [options, state, generatedDatasets, chartRef]
26103
26083
  );
26104
26084
  const dragData = useMemo(
@@ -26215,7 +26195,6 @@ const useChartPlugins = ({ options, resetZoom: resetZoom2 }) => {
26215
26195
  ];
26216
26196
  }, [handleDoubleClick]);
26217
26197
  };
26218
- const RANGE_GAP = 1;
26219
26198
  const useToggleCustomLegendVisibility = (memoState, memoOptions) => {
26220
26199
  var _a2, _b2;
26221
26200
  useEffect(() => {
@@ -26245,65 +26224,15 @@ const useStoreChartStateInStorage = (memoState, persistenceId) => {
26245
26224
  memoState.zoomEnabled
26246
26225
  ]);
26247
26226
  };
26248
- const useUpdateAxesRanges = ({
26249
- chartRef,
26250
- range,
26251
- state,
26252
- dispatch,
26253
- annotationsData
26254
- }) => {
26255
- const prevAxes = useRef(state.axes);
26256
- useEffect(() => {
26257
- if (range && isRangeValid(range)) {
26258
- const newAxes = Object.entries(range).map(([key, { min, max }]) => {
26259
- const { min: minFromData = void 0, max: maxFromData = void 0 } = getAxisRangeByType(chartRef, key, annotationsData) ?? {};
26260
- let finalMin = min ?? minFromData;
26261
- let finalMax = max ?? maxFromData;
26262
- if (finalMin === finalMax) {
26263
- finalMax += RANGE_GAP;
26264
- }
26265
- return {
26266
- id: key,
26267
- min: finalMin,
26268
- max: finalMax
26269
- };
26270
- });
26271
- const mergedAxes = [...prevAxes.current ?? []].map((axis) => {
26272
- const newAxis = newAxes.find((a2) => a2.id === axis.id);
26273
- return newAxis ? { ...axis, ...newAxis } : axis;
26274
- });
26275
- if (!isEqual(mergedAxes, prevAxes.current)) {
26276
- dispatch({
26277
- type: UPDATE_AXES_RANGES,
26278
- payload: { axes: mergedAxes }
26279
- });
26280
- prevAxes.current = mergedAxes;
26281
- }
26282
- }
26283
- }, [range]);
26284
- };
26285
26227
  const useChartState = ({
26286
- chartRef,
26287
26228
  options,
26288
26229
  state,
26289
- dispatch,
26290
26230
  persistenceId
26291
26231
  }) => {
26292
26232
  const memoState = useMemo(() => state, [state]);
26293
26233
  const memoOptions = useMemo(() => options, [options]);
26294
- const {
26295
- additionalAxesOptions: { range = void 0 },
26296
- annotations: { annotationsData = [] } = {}
26297
- } = memoOptions;
26298
26234
  useStoreChartStateInStorage(memoState, persistenceId);
26299
26235
  useToggleCustomLegendVisibility(memoState, memoOptions);
26300
- useUpdateAxesRanges({
26301
- range,
26302
- state: memoState,
26303
- dispatch,
26304
- chartRef,
26305
- annotationsData
26306
- });
26307
26236
  };
26308
26237
  const WORD_SEPARATOR = " ";
26309
26238
  const SEMI_TRANSPARENT = "rgba(0, 0, 0, 0.5)";
@@ -27408,10 +27337,8 @@ const LineChart = (props) => {
27408
27337
  graph
27409
27338
  ]);
27410
27339
  useChartState({
27411
- chartRef,
27412
27340
  options,
27413
27341
  state,
27414
- dispatch,
27415
27342
  persistenceId
27416
27343
  });
27417
27344
  const { resetZoom: resetZoom2, handleKeyDown, handleKeyUp } = useChartFunctions({
@@ -27483,7 +27410,7 @@ const LineChart = (props) => {
27483
27410
  ] }) })
27484
27411
  ]
27485
27412
  },
27486
- generateKey([...Object.values(state), languageKey])
27413
+ getChartKey(state, languageKey)
27487
27414
  );
27488
27415
  };
27489
27416
  const LineChartWithLegend = (props) => {