@oliasoft-open-source/charts-library 5.4.0 → 5.5.0-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.
- package/dist/assets/{Color-AVL7NMMY-994VbFdE.js → Color-AVL7NMMY-Q1jtZEj4.js} +1 -1
- package/dist/assets/{DocsRenderer-PQXLIZUC-bAUpr2nb.js → DocsRenderer-PQXLIZUC-DH8_P5-s.js} +2 -2
- package/dist/assets/{bar-chart.stories-BgSpvkVq.js → bar-chart.stories-Dxq2MpGf.js} +1 -1
- package/dist/assets/client-D6AIHE8P.js +1 -0
- package/dist/assets/{components-Dh2frV4l.js → components-iTRs0GNG.js} +1 -1
- package/dist/assets/{get-draggableData-DaqZhgHK.js → get-draggableData-BhNReYKn.js} +1 -1
- package/dist/assets/{iframe-D8t45Jkw.js → iframe-BXFCu_25.js} +5 -5
- package/dist/assets/{legend-CPlrxuvf.js → legend-axxK95g8.js} +2 -2
- package/dist/assets/{legend-context-SNdgAaoM.js → legend-context-DWzlUfd5.js} +3 -3
- package/dist/assets/line-chart-DCxYmFrH.js +1 -0
- package/dist/assets/{line-chart.stories-ChpI0UHM.js → line-chart.stories-xyxJIMgK.js} +57 -45
- package/dist/assets/{line-chart.test-case.stories-B-SWX8h6.js → line-chart.test-case.stories-DtWmVHPp.js} +1 -1
- package/dist/assets/{pie-chart.stories-CBcjkrFA.js → pie-chart.stories-BnXOfjZV.js} +1 -1
- package/dist/assets/{react-18-DMqmYXih.js → react-18-BZQFBYmq.js} +1 -1
- package/dist/assets/{react-BgjAoB93.js → react-BnokuHUr.js} +1 -1
- package/dist/assets/{scatter-chart.stories-BqsR5bsR.js → scatter-chart.stories-CKOOIigg.js} +1 -1
- package/dist/common/common.interface.d.ts +9 -0
- package/dist/common/helpers/callout-helpers/callout-helpers.d.ts +5 -0
- package/dist/common/helpers/enums.d.ts +2 -1
- package/dist/common/helpers/get-chart-annotation.d.ts +5 -3
- package/dist/common/plugins/annotation-dragger-plugin/enums.d.ts +2 -1
- package/dist/iframe.html +1 -1
- package/dist/index.js +343 -110
- package/dist/index.json +1 -1
- package/dist/line-chart/plugins/callout-plugin/callout-plugin.d.ts +11 -0
- package/dist/line-chart/plugins/callout-plugin/helpers.d.ts +25 -0
- package/dist/line-chart/utils/get-line-chart-tooltips.d.ts +4 -8
- package/dist/project.json +1 -1
- package/dist/src/components/common/common.interface.d.ts +3 -0
- package/dist/src/components/common/helpers/callout-helpers/callout-helpers.d.ts +5 -0
- package/dist/src/components/common/helpers/enums.d.ts +2 -1
- package/dist/src/components/common/helpers/get-chart-annotation.d.ts +5 -3
- package/dist/src/components/common/plugins/annotation-dragger-plugin/enums.d.ts +2 -1
- package/dist/src/components/line-chart/plugins/callout-plugin/callout-plugin.d.ts +11 -0
- package/dist/src/components/line-chart/plugins/callout-plugin/helpers.d.ts +25 -0
- package/package.json +1 -1
- package/dist/assets/client-BDy5C6da.js +0 -1
- package/dist/assets/line-chart-WOEGLOk2.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{_t as e,at as t,dt as n}from"./iframe-D8t45Jkw.js";import{W as r}from"./legend-context-SNdgAaoM.js";import{v as i,w as a}from"./legend-CPlrxuvf.js";import"./get-draggableData-DaqZhgHK.js";import{t as o}from"./line-chart-WOEGLOk2.js";var s=e(n(),1),c={controlsPortalId:`chartOne-plan-view-chart-controls`,data:{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:[]}]}]},options:{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:[]}}},l=e(t(),1),u=[{label:`Dataset 1`,data:[{x:0,y:0},{x:5,y:25}]}],d={title:`LineChart / Test Cases`,component:o,args:{chart:{data:{datasets:u},options:{title:`Chart title`,chartStyling:{height:`100%`}}}}};const f=()=>(0,l.jsx)(o,{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}}}}),p=()=>(0,l.jsx)(o,{chart:c}),m=()=>{let[e,t]=(0,s.useState)(u),[n,i]=(0,s.useState)(0),[c,d]=(0,s.useState)(!1),[f,p]=(0,s.useState)(!0),[m,h]=(0,s.useState)(!1),[g,_]=(0,s.useState)(!0),[v,y]=(0,s.useState)(`linear`),[b,x]=(0,s.useState)(!1),S=(0,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:2,color:`red`,label:`Draggable Point`,labelConfig:{font:`bold 8px ${r}`,color:`rgba(0,0,0,0.7)`}}]},chartStyling:{height:`100%`,squareAspectRatio:g},additionalAxesOptions:{chartScaleType:v},legend:{display:!1}}),[e,g,v]),C=(0,s.useMemo)(()=>({data:{datasets:e},options:S}),[e,S]);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{style:{display:`flex`,gap:8,flexWrap:`wrap`,marginBottom:16},children:[(0,l.jsx)(a,{label:`Reset to Initial State`,colored:!0,onClick:()=>{t(u),i(e=>e+1),p(!0),x(!1)}}),(0,l.jsx)(a,{label:`Async Dataset + Unmount`,onClick:()=>{h(!0);let e=[];for(let n=0;n<50;n++)setTimeout(()=>{e.push({label:`DS ${n+1}`,data:[{x:n,y:Math.random()*100},{x:n+1,y:Math.random()*100}],borderColor:`hsl(${n*(360/50)}, 100%, 50%)`}),t([...e]),n===15&&(console.warn(`Forcing unmount mid-update`),p(!1)),n===25&&(console.warn(`Remounting chart`),p(!0),i(e=>e+1)),n===49&&(console.log(`Async injection complete`),h(!1))},n*40)},disabled:m}),(0,l.jsx)(a,{label:`Set Invalid Dataset`,onClick:()=>{t([{label:`Broken Dataset`,borderColor:`red`}])}}),(0,l.jsx)(a,{label:`Set Empty Dataset`,onClick:()=>{t([])}}),(0,l.jsx)(a,{label:`Mixed Data Formats`,onClick:()=>{t([{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`}])}}),(0,l.jsx)(a,{label:`Bad Axis Ref`,onClick:()=>{t([{label:`Bad Y Axis Ref`,yAxisID:`y-missing`,data:[{x:1,y:1},{x:2,y:2}],borderColor:`purple`}])}}),(0,l.jsx)(a,{label:`Toggle size`,onClick:()=>d(!c)}),(0,l.jsx)(a,{label:`Toggle Axis Type`,onClick:()=>{y(e=>e===`linear`?`logarithmic`:`linear`)}}),(0,l.jsx)(a,{label:`Toggle Aspect Ratio`,onClick:()=>{_(e=>!e)}}),(0,l.jsx)(a,{label:`Spam Re-renders`,onClick:()=>{let e=0,t=setInterval(()=>{i(e=>e+1),e++,e===100&&clearInterval(t)},30)}}),(0,l.jsx)(a,{label:f?`Unmount Chart`:`Remount Chart`,onClick:()=>p(e=>!e)}),(0,l.jsx)(a,{label:`Manual Re-render`,onClick:()=>i(e=>e+1)}),(0,l.jsx)(a,{label:`Empty Dataset`,onClick:()=>t([])}),(0,l.jsx)(a,{label:`Add 5k Points Slowly`,onClick:()=>{t([{label:`Big 5k Points`,data:Array.from({length:5e3},(e,t)=>({x:t,y:Math.sin(t/100)*100})),borderColor:`orange`}])}}),(0,l.jsx)(a,{label:`Dataset With Invalid Point`,onClick:()=>{t([{label:`Corrupt Point Dataset`,data:[{x:0,y:10},{x:1},{y:20},null,void 0,`bad-value`,{x:5,y:50}],borderColor:`red`}])}}),(0,l.jsx)(a,{label:`Malformed Dataset Combo`,onClick:()=>{t([{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`}])}}),(0,l.jsx)(a,{label:`Cycle Big Load (Async)`,onClick:()=>{let e=[];for(let t=0;t<4;t++){let n=Array.from({length:3e3},(e,t)=>({x:t,y:Math.random()*100}));e.push({label:`Stream DS ${t+1}`,data:n,borderColor:`hsl(${t*90}, 100%, 50%)`})}let n=0,r=setInterval(()=>{t(e.slice(0,n+1)),n++,n===e.length&&clearInterval(r)},500)}}),(0,l.jsx)(a,{label:`Timed Unmount During Drag`,onClick:()=>{x(!0),p(!0),setTimeout(()=>{p(!1),x(!1)},5e3)},disabled:b})]}),b&&(0,l.jsx)(`span`,{style:{color:`crimson`,fontWeight:`bold`},children:`⏱ Unmounting in 5s – start dragging!`}),(0,l.jsx)(`div`,{style:{height:c?300:null,width:c?300:null,padding:`var(--padding)`,overflow:`auto`},children:f?(0,l.jsx)(o,{chart:C},n):(0,l.jsx)(`div`,{style:{padding:40,textAlign:`center`},children:`Chart unmounted`})})]})};f.__docgenInfo={description:``,methods:[],displayName:`PartialRangeWithSimilarValues`},p.__docgenInfo={description:``,methods:[],displayName:`closeToValueInDifferentAxes`},m.__docgenInfo={description:``,methods:[],displayName:`StressTest`},f.parameters={...f.parameters,docs:{...f.parameters?.docs,source:{originalSource:`() => {
|
|
1
|
+
import{_t as e,at as t,dt as n}from"./iframe-BXFCu_25.js";import{W as r}from"./legend-context-DWzlUfd5.js";import{v as i,w as a}from"./legend-axxK95g8.js";import"./get-draggableData-BhNReYKn.js";import{t as o}from"./line-chart-DCxYmFrH.js";var s=e(n(),1),c={controlsPortalId:`chartOne-plan-view-chart-controls`,data:{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:[]}]}]},options:{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:[]}}},l=e(t(),1),u=[{label:`Dataset 1`,data:[{x:0,y:0},{x:5,y:25}]}],d={title:`LineChart / Test Cases`,component:o,args:{chart:{data:{datasets:u},options:{title:`Chart title`,chartStyling:{height:`100%`}}}}};const f=()=>(0,l.jsx)(o,{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}}}}),p=()=>(0,l.jsx)(o,{chart:c}),m=()=>{let[e,t]=(0,s.useState)(u),[n,i]=(0,s.useState)(0),[c,d]=(0,s.useState)(!1),[f,p]=(0,s.useState)(!0),[m,h]=(0,s.useState)(!1),[g,_]=(0,s.useState)(!0),[v,y]=(0,s.useState)(`linear`),[b,x]=(0,s.useState)(!1),S=(0,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:2,color:`red`,label:`Draggable Point`,labelConfig:{font:`bold 8px ${r}`,color:`rgba(0,0,0,0.7)`}}]},chartStyling:{height:`100%`,squareAspectRatio:g},additionalAxesOptions:{chartScaleType:v},legend:{display:!1}}),[e,g,v]),C=(0,s.useMemo)(()=>({data:{datasets:e},options:S}),[e,S]);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`div`,{style:{display:`flex`,gap:8,flexWrap:`wrap`,marginBottom:16},children:[(0,l.jsx)(a,{label:`Reset to Initial State`,colored:!0,onClick:()=>{t(u),i(e=>e+1),p(!0),x(!1)}}),(0,l.jsx)(a,{label:`Async Dataset + Unmount`,onClick:()=>{h(!0);let e=[];for(let n=0;n<50;n++)setTimeout(()=>{e.push({label:`DS ${n+1}`,data:[{x:n,y:Math.random()*100},{x:n+1,y:Math.random()*100}],borderColor:`hsl(${n*(360/50)}, 100%, 50%)`}),t([...e]),n===15&&(console.warn(`Forcing unmount mid-update`),p(!1)),n===25&&(console.warn(`Remounting chart`),p(!0),i(e=>e+1)),n===49&&(console.log(`Async injection complete`),h(!1))},n*40)},disabled:m}),(0,l.jsx)(a,{label:`Set Invalid Dataset`,onClick:()=>{t([{label:`Broken Dataset`,borderColor:`red`}])}}),(0,l.jsx)(a,{label:`Set Empty Dataset`,onClick:()=>{t([])}}),(0,l.jsx)(a,{label:`Mixed Data Formats`,onClick:()=>{t([{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`}])}}),(0,l.jsx)(a,{label:`Bad Axis Ref`,onClick:()=>{t([{label:`Bad Y Axis Ref`,yAxisID:`y-missing`,data:[{x:1,y:1},{x:2,y:2}],borderColor:`purple`}])}}),(0,l.jsx)(a,{label:`Toggle size`,onClick:()=>d(!c)}),(0,l.jsx)(a,{label:`Toggle Axis Type`,onClick:()=>{y(e=>e===`linear`?`logarithmic`:`linear`)}}),(0,l.jsx)(a,{label:`Toggle Aspect Ratio`,onClick:()=>{_(e=>!e)}}),(0,l.jsx)(a,{label:`Spam Re-renders`,onClick:()=>{let e=0,t=setInterval(()=>{i(e=>e+1),e++,e===100&&clearInterval(t)},30)}}),(0,l.jsx)(a,{label:f?`Unmount Chart`:`Remount Chart`,onClick:()=>p(e=>!e)}),(0,l.jsx)(a,{label:`Manual Re-render`,onClick:()=>i(e=>e+1)}),(0,l.jsx)(a,{label:`Empty Dataset`,onClick:()=>t([])}),(0,l.jsx)(a,{label:`Add 5k Points Slowly`,onClick:()=>{t([{label:`Big 5k Points`,data:Array.from({length:5e3},(e,t)=>({x:t,y:Math.sin(t/100)*100})),borderColor:`orange`}])}}),(0,l.jsx)(a,{label:`Dataset With Invalid Point`,onClick:()=>{t([{label:`Corrupt Point Dataset`,data:[{x:0,y:10},{x:1},{y:20},null,void 0,`bad-value`,{x:5,y:50}],borderColor:`red`}])}}),(0,l.jsx)(a,{label:`Malformed Dataset Combo`,onClick:()=>{t([{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`}])}}),(0,l.jsx)(a,{label:`Cycle Big Load (Async)`,onClick:()=>{let e=[];for(let t=0;t<4;t++){let n=Array.from({length:3e3},(e,t)=>({x:t,y:Math.random()*100}));e.push({label:`Stream DS ${t+1}`,data:n,borderColor:`hsl(${t*90}, 100%, 50%)`})}let n=0,r=setInterval(()=>{t(e.slice(0,n+1)),n++,n===e.length&&clearInterval(r)},500)}}),(0,l.jsx)(a,{label:`Timed Unmount During Drag`,onClick:()=>{x(!0),p(!0),setTimeout(()=>{p(!1),x(!1)},5e3)},disabled:b})]}),b&&(0,l.jsx)(`span`,{style:{color:`crimson`,fontWeight:`bold`},children:`⏱ Unmounting in 5s – start dragging!`}),(0,l.jsx)(`div`,{style:{height:c?300:null,width:c?300:null,padding:`var(--padding)`,overflow:`auto`},children:f?(0,l.jsx)(o,{chart:C},n):(0,l.jsx)(`div`,{style:{padding:40,textAlign:`center`},children:`Chart unmounted`})})]})};f.__docgenInfo={description:``,methods:[],displayName:`PartialRangeWithSimilarValues`},p.__docgenInfo={description:``,methods:[],displayName:`closeToValueInDifferentAxes`},m.__docgenInfo={description:``,methods:[],displayName:`StressTest`},f.parameters={...f.parameters,docs:{...f.parameters?.docs,source:{originalSource:`() => {
|
|
2
2
|
return <LineChart chart={{
|
|
3
3
|
data: {
|
|
4
4
|
datasets: [{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{_t as e,at as t,dt as n}from"./iframe-
|
|
1
|
+
import{_t as e,at as t,dt as n}from"./iframe-BXFCu_25.js";import{B as r,Ct as i,F as a,Mt as o,Nt as s,Ot as c,Pt as l,Q as u,X as ee,Z as d,b as f,et as p,ht as m,it as h,j as g,jt as _,kt as te,mt as ne,n as re,q as ie,u as ae,vt as oe,wt as se,x as ce,xt as le}from"./legend-context-DWzlUfd5.js";import{n as ue,t as de}from"./bar-chart-const-D_44J3Hs.js";var v=e(u(),1),y=e(n(),1),b={chart:`_chart_1jdnu_1`,fixedHeight:`_fixedHeight_1jdnu_13`,stretchHeight:`_stretchHeight_1jdnu_19`,zoomForm:`_zoomForm_1jdnu_32`,zoomReset:`_zoomReset_1jdnu_40`,help:`_help_1jdnu_43`,autoWeight:`_autoWeight_1jdnu_47`},x=e=>({width:e?.width,height:e?.height,maintainAspectRatio:e?.maintainAspectRatio||!1,staticChartHeight:e?.staticChartHeight||!1,performanceMode:e?.performanceMode??!0}),S=e=>({tooltips:e?.tooltips??!0,showLabelsInTooltips:e?.showLabelsInTooltips||!1,scientificNotation:e?.scientificNotation??!0}),fe=e=>({showDataLabels:e?.showDataLabels||!1,stacked:e?.stacked||!1,cutout:e?.cutout||0}),C=e=>({display:e?.display??!0,useDataset:e?.useDataset||!1,position:e?.position||g.Bottom,align:e?.align||ce.Center}),w=e=>({enableZoom:e?.enableZoom||!1,enablePan:e?.enablePan||!1}),T=e=>({onLegendClick:e?.onLegendClick,onHover:e?.onHover,onUnhover:e?.onUnhover}),E=e=>({labels:e?.labels||[],datasets:e?.datasets||[]});const D=e=>{let t=e?.chart||{},n=t?.options||{};return{testId:t?.testId??null,data:E(t?.data),options:{title:n?.title||``,chartStyling:x(n?.chartStyling),tooltip:S(n?.tooltip),graph:fe(n?.graph),legend:C(n?.legend),chartOptions:w(n?.chartOptions),interactions:T(n?.interactions)}}},O=e=>{let[t,n]=(0,y.useState)(!1),{data:i,options:a}=e,o=(e=>{let t=[...e];if(a.graph.stacked){let e={label:t?.[0]?.label??``,backgroundColor:[],borderColor:``,borderWidth:Number(t[0].borderWidth)||1,data:[],borderDash:[]};return i.labels.map((n,i)=>{t.map((t,n)=>{e.data.push(t.data[i]);let{backgroundColor:a}=t,{borderColor:o}=t;e.backgroundColor.push((Array.isArray(a)?a[i%(o?.length||1)]:a)||r[i]+`${99-10*n}`),e.borderColor=o??``})}),[e]}return t.map((e,t)=>{let{borderWidth:n=`1`}=e??{},i=parseFloat(String(n))||1,a=r[t],o=e.borderColor||a,s=e.backgroundColor||ae(r);return{...e,borderWidth:i,borderColor:o,backgroundColor:s}})})(i.datasets),s=()=>a.title===``?{}:{display:!0,text:e.options.title},c=(e,t,n)=>{let{chart:r}=n??{};if(t&&r){let{index:e=0}=t;if(r.toggleDataVisibility(e),r.update(),a.interactions?.onLegendClick){let n=r.isDatasetVisible(e);a.interactions.onLegendClick(t.text,!n)}}};return{generatedDatasets:o,getTitle:s,legendClick:c,onClick:(e,t,n)=>{n.resetZoom()},onHover:(e,r)=>{if(t&&!r?.length&&(n(!1),a.interactions.onUnhover&&a.interactions.onUnhover(e)),!t&&r?.length&&(n(!0),a.interactions.onHover)){let{index:t,datasetIndex:n}=r[0],i=o;a.interactions.onHover(e,n,t,i)}},getDatalabels:()=>a.graph.showDataLabels?{display:`auto`,align:`center`,anchor:`center`,formatter:(e,t)=>{if(t.chart.getDatasetMeta(a.graph.stacked?0:t.datasetIndex).data[t.dataIndex].hidden)return``;let n=t.dataset.data[t.dataIndex],r=n?.label||(typeof n==`number`?n:Array.isArray(n)?n.reduce((e,t,n)=>n===0?`${e} ${t}`:`${e}, ${t}`,``):``);return typeof n==`number`?Number.isInteger(r)?r:r.toFixed(2):r}}:{display:!1},getLegend:()=>({position:a.legend.position,display:a.legend.display,align:a.legend.align,labels:{boxHeight:6,boxWidth:6,usePointStyle:!0,filter:e=>a.legend.useDataset?!i.datasets[e.index]?.hideLegend:!0},onClick:c}),getToolTips:()=>{let e=e=>{let t={};return a?.tooltip?.scientificNotation?(Math.abs(e)<1e-4||Math.abs(e)>1e7)&&(t={roundScientificCoefficient:3}):t={scientific:!1},p(h(e),t)};return{callbacks:{title:e=>{let{dataIndex:t}=e[0],n=a.graph.stacked?parseInt(String(t/i.labels.length)):t;return`${i.labels[n]}`},label:t=>{let{dataIndex:n}=t,r=a.graph.stacked?n%i.datasets.length:t.datasetIndex,o=i.datasets.length>1?`${i.datasets[r]?.label}: `:``,s=t.dataset.data[n],c=typeof s==`object`?`${s.value||``} ${a.tooltip.showLabelsInTooltips&&s.label?`(`+s.label+`)`:``}`:s,l=i?.yUnit?`[${i?.yUnit}]`:``;return`${o} ${e(c)} ${l}`}},padding:8,boxWidth:12,boxHeight:12,boxPadding:4,usePointStyle:!0}}}};var k=e(t(),1);se.register(c,i,te,le,o,l,s,_,m,ne);var A=e=>{f();let t=D(e),n=(0,y.useRef)(null),{data:r,options:i,testId:o}=t,{generatedDatasets:s,getTitle:c,onClick:l,onHover:u,getDatalabels:ee,getLegend:d,getToolTips:p}=O(t);return(0,k.jsx)(`div`,{className:(0,v.default)(b.chart,!i.chartStyling.width||!i.chartStyling.height?i.chartStyling.staticChartHeight?b.fixedHeight:b.stretchHeight:``),style:{width:i.chartStyling.width||`auto`,height:i.chartStyling.height||`auto`},"data-testid":o,children:(0,k.jsx)(oe,{ref:n,data:{datasets:s,labels:i.graph.stacked?void 0:r.labels},options:{cutout:i.graph.cutout,onClick:l,responsive:!0,maintainAspectRatio:i.chartStyling.maintainAspectRatio,animation:i.chartStyling.performanceMode?!1:{duration:a.FAST},hover:{mode:`nearest`,intersect:!0},onHover:u,plugins:{annotation:!1,title:c(),datalabels:ee(),tooltip:p(),legend:d()}}})})},j=e=>{let{options:t}=D(e);return(0,k.jsx)(re,{options:t,children:(0,k.jsx)(A,{...e})})};j.__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:``}}};var M=[`label 1`,`label 2`,`label 3`],N={label:`data1`,data:[3,8,7]},P={label:`data2`,data:[1,2,3]},F={label:`data3`,data:[5,0,4]},I={label:`spacing data`,offset:40,data:[3,8,7]},L={label:`hover data`,data:[3,8,7],hoverOffset:40},R={label:`data`,data:[{value:210,label:`label`},{value:333,label:`labal`},{value:248,label:`lebel`}]},z={label:`data`,data:[210,333,248]},B={data:{labels:M,datasets:[N]}},V={data:{labels:M,datasets:[N,P,F]}},pe={data:{labels:M,datasets:[N,P,F]},options:{title:`Stacked`,graph:{stacked:!0}}},me={data:{labels:M,datasets:[R]},options:{title:`With custom datalabels`,graph:{showDataLabels:!0}}},he={data:{labels:M,datasets:[z]},options:{title:`With value as datalabels`,graph:{showDataLabels:!0}}},ge={data:{labels:M,datasets:[R]},options:{title:`With datalabels in tooltips`,tooltip:{showLabelsInTooltips:!0}}},_e={data:{labels:M,datasets:[L]},options:{title:`Hover offset`}},ve={data:{labels:M,datasets:[I]},options:{title:`Segment offset`}},ye={data:{labels:M,datasets:[N]},options:{chartStyling:{performanceMode:!1}}},be={data:{labels:M,datasets:[N]},options:{title:`Cutout 50%`,graph:{cutout:`50%`}}},xe={data:{labels:M,datasets:[N]},options:{title:`Cutout 20 pixels`,graph:{cutout:20}}},Se={title:`PieChart`,component:j,args:{chart:B}},H=e=>(0,k.jsx)(j,{...e});const U=H.bind({}),W=H.bind({});W.args={chart:V};const G=H.bind({});G.args={chart:pe};const K=H.bind({});K.args={chart:me};const q=H.bind({});q.args={chart:he};const J=H.bind({});J.args={chart:ge};const Y=H.bind({});Y.args={chart:ye};const X=H.bind({});X.args={chart:be};const Z=H.bind({});Z.args={chart:xe};const Q=H.bind({});Q.args={chart:_e};const $=H.bind({});Q.args={chart:ve},U.parameters={...U.parameters,docs:{...U.parameters?.docs,source:{originalSource:`args => {
|
|
2
2
|
return <PieChart
|
|
3
3
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
4
4
|
{...args} />;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_t as e,dt as t}from"./iframe-
|
|
1
|
+
import{_t as e,dt as t}from"./iframe-BXFCu_25.js";import{t as n}from"./client-D6AIHE8P.js";var r=e(t(),1),i=e(n(),1),a=new Map;function o(){return globalThis.IS_REACT_ACT_ENVIRONMENT}var s=({callback:e,children:t})=>{let n=r.useRef();return r.useLayoutEffect(()=>{n.current!==e&&(n.current=e,e())},[e]),t};typeof Promise.withResolvers>`u`&&(Promise.withResolvers=()=>{let e=null,t=null;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}});var c=async(e,t,n)=>{let i=await u(t,n);if(o()){i.render(e);return}let{promise:a,resolve:c}=Promise.withResolvers();return i.render(r.createElement(s,{callback:c},e)),a},l=(e,t)=>{let n=a.get(e);n&&(n.unmount(),a.delete(e))},u=async(e,t)=>{let n=a.get(e);return n||(n=i.createRoot(e,t),a.set(e,n)),n};export{c as renderElement,l as unmountElement};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_t as e,dt as t}from"./iframe-
|
|
1
|
+
import{_t as e,dt as t}from"./iframe-BXFCu_25.js";var n=e(t(),1),r={},i=n.createContext(r);function a(e){let t=n.useContext(i);return n.useMemo(function(){return typeof e==`function`?e(t):{...t,...e}},[t,e])}function o(e){let t;return t=e.disableParentContext?typeof e.components==`function`?e.components(r):e.components||r:a(e.components),n.createElement(i.Provider,{value:t},e.children)}export{o as MDXProvider,a as useMDXComponents};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{_t as e,at as t,dt as n}from"./iframe-
|
|
1
|
+
import{_t as e,at as t,dt as n}from"./iframe-BXFCu_25.js";import{At as r,B as i,C as a,Ct as o,F as s,G as c,K as l,L as u,M as d,Mt as f,Nt as p,Ot as m,Pt as h,R as ee,b as g,et as _,g as v,h as y,ht as b,it as te,j as ne,mt as re,n as ie,p as ae,wt as oe,x as se,y as ce,yt as le}from"./legend-context-DWzlUfd5.js";import{J as ue,Y as de,d as fe,f as pe,g as me,i as he,p as ge,q as _e,r as ve,t as ye}from"./legend-axxK95g8.js";import{n as be,t as xe}from"./bar-chart-const-D_44J3Hs.js";var x=e(n(),1);const S=(e,t)=>{let n={};return t?(Math.abs(e)<1e-4||Math.abs(e)>1e7)&&(n={roundScientificCoefficient:3}):n={scientific:!1},_(te(e),n)};var C=(e,t)=>{if(t?.tooltip?.showLabelsInTooltips){let{label:t}=e[0]?.dataset??{};return t}},w=(e,t)=>{let{raw:n,dataset:r}=e??{},i=n?.label,a=t?.tooltip?.scientificNotation;return`${i??r?.label} ( x: ${S(n?.x,a)} , y: ${S(n?.y,a)} )`};const T=e=>({enabled:e?.tooltip?.enabled,callbacks:{title:t=>C(t,e),label:t=>w(t,e)},backgroundColor:e?.tooltip?.backgroundColor,displayColors:e?.tooltip?.displayColors,padding:7});var E=({options:e,axisType:t=a.X,currentScale:n})=>{let r=ce(e.direction),i=n||e?.axes?.[t]?.[0],o=r&&t===a.Y||!r&&t===a.X,s=i?.gridLines||{};return{type:d.Linear,position:i?.position,beginAtZero:e?.additionalAxesOptions?.beginAtZero,reverse:(()=>t===(r?a.Y:a.X)?e?.additionalAxesOptions?.reverse:!1)(),suggestedMax:e?.additionalAxesOptions?.suggestedMax,suggestedMin:e?.additionalAxesOptions?.suggestedMin,min:o?e?.additionalAxesOptions?.min:void 0,max:o?e?.additionalAxesOptions?.max:void 0,title:{display:!!i?.label?.length||!!i?.unit?.length,text:i?.label||i?.unit,padding:0},ticks:(()=>{let n=e?.additionalAxesOptions;return{stepSize:i?.stepSize??(t===a.Y?n?.stepSize:void 0),includeBounds:!1,font:{size:12}}})(),grid:{...s}}};const D=e=>({x:E({options:e,axisType:a.X}),y:E({options:e,axisType:a.Y})}),O=(e,t)=>{let{data:n,options:r}=e,{interactions:a,chartStyling:o}=r,[c,l]=(0,x.useState)(!1),{legend:u,customLegendPlugin:d,legendClick:f}=pe({chartRef:t,options:r}),{state:p}=ge(),{annotation:m}=p,h=(e=>e.map((e,t)=>{let{borderWidth:n=1}=e??{},r=parseFloat(String(n))||1,a=i[t],o=e.borderColor??a,s=e.backgroundColor??a;return{...e,borderWidth:r,borderColor:o,backgroundColor:s}}))(n.datasets),g=(e,t,n)=>{n.resetZoom()},_=(e,t)=>{if(c&&!t?.length&&(l(!1),a.onUnhover&&a.onUnhover(e)),!c&&t?.length&&(l(!0),a.onHover)){let{index:n,datasetIndex:r}=t[0];a.onHover(e,r,n,h)}};return{generatedDatasets:h,scatterOptions:{onClick:g,onHover:_,...o,interactions:{onLegendClick:f,onHover:_},scales:D(e?.options),animation:o.performanceMode?{duration:s.NO}:{duration:s.FAST,onComplete:a?.onAnimationComplete},plugins:{legend:{...u,display:!1,events:[]},customLegendPlugin:d,title:v(r),annotation:fe(m),chartAreaBorder:{borderColor:ee},datalabels:{display:r.graph.showDataLabels},tooltip:T(r)}}}};let k=function(e){return 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}({});var A=e=>({display:e?.display??!1,gradientColors:e?.gradientColors??l,direction:e?.direction??k.BottomLeftToTopRight}),j=e=>({width:e?.width??`auto`,height:e?.height??`auto`,maintainAspectRatio:e?.maintainAspectRatio||!1,staticChartHeight:e?.staticChartHeight||!1,performanceMode:e?.performanceMode??!0,gradient:A(e?.gradient)}),M=e=>({enabled:e?.enabled??!0,tooltips:e?.tooltips??!0,showLabelsInTooltips:e?.showLabelsInTooltips||!1,backgroundColor:e?.backgroundColor||`#333`,displayColors:e?.displayColors||!1,scientificNotation:e?.scientificNotation??!0}),Se=e=>({showMinorGridlines:e?.showMinorGridlines??!1,showDataLabels:e?.showDataLabels??!1}),Ce=e=>({display:e?.display??!0,useDataset:e?.useDataset||!1,position:e?.position||ne.BottomLeft,align:e?.align||se.Center}),we=e=>({enableZoom:e?.enableZoom||!1,enablePan:e?.enablePan||!1}),Te=e=>({onLegendClick:e?.onLegendClick,onHover:e?.onHover,onUnhover:e?.onUnhover,onAnimationComplete:e?.onAnimationComplete}),Ee=e=>({labels:e?.labels||[],datasets:e?.datasets||[]}),De=e=>e?e.map(e=>({...e,display:e?.display??!0})):[],Oe=e=>({showAnnotations:e?.showAnnotations??!0,controlAnnotation:e?.controlAnnotation||!1,annotationsData:De(e?.annotationsData)}),ke=e=>({x:e?.x||[{}],y:e?.y||[{}]}),Ae=e=>({reverse:e?.reverse||!1,stacked:e?.stacked||!1,beginAtZero:e?.beginAtZero??!0,stepSize:e?.stepSize,suggestedMin:e?.suggestedMin,suggestedMax:e?.suggestedMax,min:e?.min,max:e?.max});const N=e=>{let t=e?.chart||{},n=t?.options||{};return{testId:t?.testId??null,data:Ee(t?.data),options:{title:n?.title||``,axes:ke(n?.axes),additionalAxesOptions:Ae(n?.additionalAxesOptions),direction:n?.direction||ve.VERTICAL,chartStyling:j(n?.chartStyling),tooltip:M(n?.tooltip),graph:Se(n?.graph),legend:Ce(n?.legend),annotations:Oe(n?.annotations),chartOptions:we(n?.chartOptions),interactions:Te(n?.interactions)}}};var je=(e,t)=>{switch(e){case k.TopToBottom:return[t.left,t.top,t.left,t.bottom];case k.BottomToTop:return[t.left,t.bottom,t.left,t.top];case k.LeftToRight:return[t.left,t.top,t.right,t.top];case k.RightToLeft:return[t.right,t.top,t.left,t.top];case k.TopLeftToBottomRight:return[t.left,t.top,t.right,t.bottom];case k.BottomRightToTopLeft:return[t.right,t.bottom,t.left,t.top];case k.BottomLeftToTopRight:return[t.left,t.bottom,t.right,t.top];case k.TopRightToBottomLeft:return[t.right,t.top,t.left,t.bottom];default:return[t.left,t.bottom,t.right,t.top]}};const Me={id:`gradientBackgroundPlugin`,beforeDraw:e=>{let{ctx:t,chartArea:n,options:r}=e;if(!t||!n)return;let{display:i=!1,gradientColors:a,direction:o=k.BottomLeftToTopRight}=r?.gradient??{};if(!i||!a||a.length===0)return;let[s,c,l,u]=je(o,n),d=t.createLinearGradient(s,c,l,u);a.forEach(({offset:e,color:t})=>{d.addColorStop(e,t)}),t.save(),t.globalCompositeOperation=`destination-over`,t.fillStyle=d,t.fillRect(n.left,n.top,n.right-n.left,n.bottom-n.top),t.restore()}};var P={chart:`_chart_1qlu1_1`,canvas:`_canvas_1qlu1_11`,fixedHeight:`_fixedHeight_1qlu1_20`,stretchHeight:`_stretchHeight_1qlu1_26`,squareAspectRatio:`_squareAspectRatio_1qlu1_32`,zoomForm:`_zoomForm_1qlu1_43`,zoomReset:`_zoomReset_1qlu1_51`,help:`_help_1qlu1_54`,autoWeight:`_autoWeight_1qlu1_58`},F=e(t(),1);oe.register(m,r,o,f,h,p,b,re,de,Me);var Ne=e=>{g();let t=(0,x.useRef)(null),n=N(e),{options:r,testId:i}=n,{scatterOptions:a,generatedDatasets:o}=O(n,t);return(0,F.jsx)(`div`,{className:ae(r.chartStyling,P),style:{width:r.chartStyling.width,height:r.chartStyling.height},"data-testid":i,children:(0,F.jsx)(_e,{backend:ue,context:window,children:(0,F.jsxs)(`div`,{className:P.canvas,id:`canvas`,children:[(0,F.jsx)(le,{ref:t,data:{datasets:o},options:a,plugins:y(r.graph,r.legend)}),!!o.length&&(0,F.jsx)(ye,{chartRef:t,legendConfig:{options:r,generatedDatasets:o,chartType:he.SCATTER}})]})})})},I=e=>{let{options:t}=N(e);return(0,F.jsx)(ie,{options:t,children:(0,F.jsx)(Ne,{...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:``}}};var L=[`label 1`,`label 2`,`label 3`],R={label:`Dataset 1`,data:[{x:1,y:5},{x:3,y:7},{x:6,y:2},{x:8,y:6},{x:9,y:4}]},z={label:`Dataset 2`,data:[{x:1,y:3},{x:4,y:5},{x:7,y:9},{x:10,y:2},{x:12,y:7}]},Pe={label:`Dataset 3`,data:[{x:2,y:8},{x:5,y:6},{x:8,y:10},{x:11,y:5},{x:14,y:9}]},B={label:`Dataset 4`,data:[{x:2,y:8},{x:14,y:9}]},Fe={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`}]},Ie={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`}]},Le={label:`Dataset Decimals`,data:[{x:4.30021321123002,y:2.30021321123005},{x:5.12321321000003,y:3.23213210000037}]},V={data:{labels:L,datasets:[R]}},Re={data:{labels:L,datasets:[R]},options:{chartStyling:{height:300,width:700}}},ze={data:{labels:L,datasets:[R,z,Pe]}},Be={data:{labels:L,datasets:[R]},options:{title:`With Data Labels`,graph:{showDataLabels:!0}}},Ve={data:{labels:L,datasets:[R,z,Le]},options:{title:`With Tooltips`,tooltip:{title:`Tooltip`,showLabelsInTooltips:!0}}},He={data:{labels:L,datasets:[{...R,backgroundColor:`red`,borderColor:`red`}]}},Ue={data:{labels:L,datasets:[R]},options:{title:`With Annotation`,annotations:{showAnnotations:!0,annotationsData:[{annotationAxis:`y`,label:`Horizontal Annotation`,value:2.5,color:`rgba(96, 32, 196, 0.5)`}]}}},We={data:{labels:L,datasets:[R,z,B]},options:{title:`With Axes Labels`,axes:{x:[{label:`x axis`}],y:[{label:`y axis`}]}}},Ge={...V,options:{title:`With Gradient`,chartStyling:{gradient:{display:!0}}}},H={data:{datasets:[Fe,Ie,B]},options:{title:`With datapoint label showing when hovered`,tooltip:{showLabelsInTooltips:!0}}},Ke={title:`ScatterChart`,component:I,args:{chart:V}},U=e=>(0,F.jsx)(I,{...e});const W=U.bind({});W.args={chart:V};const G=U.bind({});G.args={chart:Re};const K=U.bind({});K.args={chart:ze};const q=U.bind({});q.args={chart:Be};const J=U.bind({});J.args={chart:Ve};const Y=U.bind({});Y.args={chart:Ue};const X=U.bind({});X.args={chart:We};const Z=U.bind({});Z.args={chart:Ge};const Q=U.bind({});Q.args={chart:H};const $=U.bind({});$.args={chart:He},W.parameters={...W.parameters,docs:{...W.parameters?.docs,source:{originalSource:`args => {
|
|
2
2
|
return <ScatterChart
|
|
3
3
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
4
4
|
{...args} />;
|
|
@@ -22,6 +22,7 @@ export interface ICommonScales extends Partial<Record<string, LinearScaleOptions
|
|
|
22
22
|
y: LinearScaleOptions;
|
|
23
23
|
}
|
|
24
24
|
export interface ICommonAnnotationElement {
|
|
25
|
+
id?: string;
|
|
25
26
|
display: boolean;
|
|
26
27
|
annotationIndex: number;
|
|
27
28
|
label: {
|
|
@@ -49,6 +50,7 @@ export interface ICoordinates {
|
|
|
49
50
|
export interface ICommonAnnotationsData {
|
|
50
51
|
display?: boolean;
|
|
51
52
|
hideLegend?: boolean;
|
|
53
|
+
labelOffsetPx?: number;
|
|
52
54
|
id?: string;
|
|
53
55
|
adjustScaleRange: boolean;
|
|
54
56
|
annotationAxis: 'x' | 'y';
|
|
@@ -106,10 +108,16 @@ export interface ICommonLegend {
|
|
|
106
108
|
position: Position;
|
|
107
109
|
align: AlignOptions;
|
|
108
110
|
}
|
|
111
|
+
export interface ICommonTooltipCallbacks {
|
|
112
|
+
title?: () => void;
|
|
113
|
+
label?: () => void;
|
|
114
|
+
afterLabel?: () => void;
|
|
115
|
+
}
|
|
109
116
|
export interface ICommonTooltip {
|
|
110
117
|
tooltips: boolean;
|
|
111
118
|
showLabelsInTooltips: boolean;
|
|
112
119
|
scientificNotation: boolean;
|
|
120
|
+
callbacks?: ICommonTooltipCallbacks;
|
|
113
121
|
}
|
|
114
122
|
export interface ICommonAdditionalAxesOptions {
|
|
115
123
|
chartScaleType?: 'linear' | 'logarithmic';
|
|
@@ -136,6 +144,7 @@ export interface ICommonAnnotations {
|
|
|
136
144
|
showAnnotations?: boolean;
|
|
137
145
|
controlAnnotation?: boolean;
|
|
138
146
|
enableDragAnnotation?: boolean;
|
|
147
|
+
enableCalloutAnnotation?: boolean;
|
|
139
148
|
annotationsData?: ICommonAnnotationsData[];
|
|
140
149
|
labelAnnotation?: ICommonAnnotation;
|
|
141
150
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ICommonAnnotationsData } from '../../common.interface';
|
|
2
|
+
type TCalloutCfg = NonNullable<NonNullable<ICommonAnnotationsData['labelConfig']>['callout']>;
|
|
3
|
+
export declare const resolveCalloutXAdjust: (ctx: any, refAnnotation: ICommonAnnotationsData, calloutCfg: TCalloutCfg, index: number) => any;
|
|
4
|
+
export declare const resolveCalloutYAdjust: (ctx: any, refAnnotation: ICommonAnnotationsData, calloutCfg: TCalloutCfg, index: number) => any;
|
|
5
|
+
export {};
|
|
@@ -9,7 +9,7 @@ export interface IGetAnnotationsProps {
|
|
|
9
9
|
interface TChart extends Chart {
|
|
10
10
|
hoveredAnnotationId?: string | null;
|
|
11
11
|
}
|
|
12
|
-
declare const
|
|
12
|
+
export declare const generateAnn: (ann: ICommonAnnotationsData, index: number) => {
|
|
13
13
|
display: boolean | undefined;
|
|
14
14
|
annotationIndex: number;
|
|
15
15
|
id: string;
|
|
@@ -66,6 +66,7 @@ declare const getAnnotation: ({ showAnnotations, annotationsData, }: IGetAnnotat
|
|
|
66
66
|
resizable: boolean;
|
|
67
67
|
displayDragCoordinates: boolean;
|
|
68
68
|
hideLegend?: boolean;
|
|
69
|
+
labelOffsetPx?: number;
|
|
69
70
|
annotationAxis: "x" | "y";
|
|
70
71
|
rotation: number;
|
|
71
72
|
color: string;
|
|
@@ -88,5 +89,6 @@ declare const getAnnotation: ({ showAnnotations, annotationsData, }: IGetAnnotat
|
|
|
88
89
|
xScaleID?: string;
|
|
89
90
|
yScaleID?: string;
|
|
90
91
|
opacity?: number;
|
|
91
|
-
}
|
|
92
|
-
export
|
|
92
|
+
};
|
|
93
|
+
export declare const getAnnotation: ({ showAnnotations, annotationsData, }: IGetAnnotationsProps) => any[];
|
|
94
|
+
export {};
|
package/dist/iframe.html
CHANGED
|
@@ -529,7 +529,7 @@
|
|
|
529
529
|
}
|
|
530
530
|
</script>
|
|
531
531
|
|
|
532
|
-
<script type="module" crossorigin src="./assets/iframe-
|
|
532
|
+
<script type="module" crossorigin src="./assets/iframe-BXFCu_25.js"></script>
|
|
533
533
|
<link rel="modulepreload" crossorigin href="./assets/preload-helper-Dr7BywEQ.js">
|
|
534
534
|
|
|
535
535
|
</head>
|