@oliasoft-open-source/charts-library 5.5.0 → 5.6.1
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-DslOJdIH.js → Color-AVL7NMMY-BhIWok9f.js} +1 -1
- package/dist/assets/{DocsRenderer-PQXLIZUC-BiQzcNLO.js → DocsRenderer-PQXLIZUC-l5sNhr4I.js} +2 -2
- package/dist/assets/bar-chart.stories-DFidSeui.js +145 -0
- package/dist/assets/client-wRWi0_mZ.js +1 -0
- package/dist/assets/{components-prYN4JAE.js → components-Chhe1HuF.js} +1 -1
- package/dist/assets/{get-draggableData-1oZD82KQ.js → get-draggableData-CgSzQCju.js} +2 -2
- package/dist/assets/{iframe-DomYTowy.js → iframe-cITPFXiZ.js} +5 -5
- package/dist/assets/{legend-C854veju.js → legend-DREhMczt.js} +142 -123
- package/dist/assets/legend-context-BNa2-E_P.js +28 -0
- package/dist/assets/line-chart-iy0xMQat.js +1 -0
- package/dist/assets/line-chart.stories-ZXuIC102.js +1207 -0
- package/dist/assets/line-chart.test-case.stories-BKahQPMm.js +1545 -0
- package/dist/assets/pie-chart.stories-DzIuCVdV.js +45 -0
- package/dist/assets/{react-18-BE1hRK-o.js → react-18-Dekepht0.js} +1 -1
- package/dist/assets/{react-Di-Jgalc.js → react-Cwqzj5I1.js} +1 -1
- package/dist/assets/scatter-chart.stories-BMyGRe3F.js +41 -0
- package/dist/common/common.interface.d.ts +3 -0
- package/dist/common/helpers/callout-helpers/callout-helpers.d.ts +6 -0
- package/dist/common/helpers/enums.d.ts +2 -1
- package/dist/common/helpers/get-chart-annotation.d.ts +5 -3
- package/dist/common/helpers/get-chart-from-ctx.d.ts +1 -0
- package/dist/common/helpers/get-grouped-color-scheme/get-grouped-color-scheme.d.ts +1 -0
- package/dist/common/plugins/annotation-dragger-plugin/annotation-position-storage.d.ts +7 -0
- package/dist/common/plugins/annotation-dragger-plugin/enums.d.ts +2 -1
- package/dist/common/plugins/annotation-dragger-plugin/event-helpers.d.ts +1 -1
- package/dist/iframe.html +1 -1
- package/dist/index.js +18 -14
- package/dist/index.json +1 -1
- package/dist/line-chart/hooks/use-chart-options.d.ts +4 -1
- package/dist/line-chart/plugins/callout-plugin/callout-plugin.d.ts +11 -0
- package/dist/line-chart/plugins/callout-plugin/helpers.d.ts +26 -0
- package/dist/project.json +1 -1
- package/dist/src/components/common/hooks/use-update-annotations.d.ts +0 -3
- package/package.json +3 -4
- package/dist/assets/bar-chart.stories-BSrCvMWq.js +0 -145
- package/dist/assets/client-pKq9BHla.js +0 -1
- package/dist/assets/legend-context-1H9KQ-2n.js +0 -47
- package/dist/assets/line-chart-CraAaKF1.js +0 -1
- package/dist/assets/line-chart.stories-DyM3ZVYD.js +0 -1174
- package/dist/assets/line-chart.test-case.stories-BHdzgxeT.js +0 -430
- package/dist/assets/pie-chart.stories-B395IqJr.js +0 -45
- package/dist/assets/scatter-chart.stories-upN9mASr.js +0 -41
- /package/dist/assets/{bar-chart-const-D_44J3Hs.js → bar-chart-const-KaipikFs.js} +0 -0
|
@@ -1,430 +0,0 @@
|
|
|
1
|
-
import{_t as e,at as t,dt as n}from"./iframe-DomYTowy.js";import{W as r}from"./legend-context-1H9KQ-2n.js";import{v as i,w as a}from"./legend-C854veju.js";import"./get-draggableData-1oZD82KQ.js";import{t as o}from"./line-chart-CraAaKF1.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
|
-
return <LineChart chart={{
|
|
3
|
-
data: {
|
|
4
|
-
datasets: [{
|
|
5
|
-
label: 'Duration %',
|
|
6
|
-
lineTension: '0',
|
|
7
|
-
pointHitRadius: 10,
|
|
8
|
-
borderColor: '#dc3912',
|
|
9
|
-
pointBackgroundColor: '#dc3912',
|
|
10
|
-
borderWidth: 2,
|
|
11
|
-
pointRadius: 4,
|
|
12
|
-
data: [{
|
|
13
|
-
x: 3,
|
|
14
|
-
y: 0
|
|
15
|
-
}, {
|
|
16
|
-
x: 3,
|
|
17
|
-
y: 100
|
|
18
|
-
}],
|
|
19
|
-
yAxisID: 'y2'
|
|
20
|
-
}]
|
|
21
|
-
},
|
|
22
|
-
options: {
|
|
23
|
-
direction: 'vertical',
|
|
24
|
-
axes: {
|
|
25
|
-
x: [{
|
|
26
|
-
label: 'Duration (TempSim long) [d]',
|
|
27
|
-
position: 'bottom'
|
|
28
|
-
}],
|
|
29
|
-
y: [{
|
|
30
|
-
label: 'Probability'
|
|
31
|
-
}, {
|
|
32
|
-
label: 'Percentage [%]'
|
|
33
|
-
}]
|
|
34
|
-
},
|
|
35
|
-
annotations: {
|
|
36
|
-
annotationsData: [{
|
|
37
|
-
annotationAxis: 'y2',
|
|
38
|
-
color: 'darkgrey',
|
|
39
|
-
value: 16
|
|
40
|
-
}, {
|
|
41
|
-
displayDragCoordinates: false,
|
|
42
|
-
color: '#ff9900',
|
|
43
|
-
label: 'P16',
|
|
44
|
-
dragAxis: 'y',
|
|
45
|
-
enableDrag: true,
|
|
46
|
-
resizable: false,
|
|
47
|
-
type: 'box',
|
|
48
|
-
xMax: 3,
|
|
49
|
-
xMin: 3,
|
|
50
|
-
yMax: 17,
|
|
51
|
-
yMin: 15,
|
|
52
|
-
yScaleID: 'y2'
|
|
53
|
-
}, {
|
|
54
|
-
annotationAxis: 'y2',
|
|
55
|
-
color: 'darkgrey',
|
|
56
|
-
value: 66
|
|
57
|
-
}, {
|
|
58
|
-
displayDragCoordinates: false,
|
|
59
|
-
color: '#109618',
|
|
60
|
-
label: 'P66',
|
|
61
|
-
dragAxis: 'y',
|
|
62
|
-
enableDrag: true,
|
|
63
|
-
resizable: false,
|
|
64
|
-
type: 'box',
|
|
65
|
-
xMax: 3,
|
|
66
|
-
xMin: 3,
|
|
67
|
-
yMax: 67,
|
|
68
|
-
yMin: 65,
|
|
69
|
-
yScaleID: 'y2'
|
|
70
|
-
}, {
|
|
71
|
-
annotationAxis: 'y2',
|
|
72
|
-
color: 'darkgrey',
|
|
73
|
-
value: 78
|
|
74
|
-
}, {
|
|
75
|
-
displayDragCoordinates: false,
|
|
76
|
-
color: '#990099',
|
|
77
|
-
label: 'P78',
|
|
78
|
-
dragAxis: 'y',
|
|
79
|
-
enableDrag: true,
|
|
80
|
-
resizable: false,
|
|
81
|
-
type: 'box',
|
|
82
|
-
xMax: 3,
|
|
83
|
-
xMin: 3,
|
|
84
|
-
yMax: 79,
|
|
85
|
-
yMin: 77,
|
|
86
|
-
yScaleID: 'y2'
|
|
87
|
-
}, {
|
|
88
|
-
annotationAxis: 'y2',
|
|
89
|
-
color: 'darkgrey',
|
|
90
|
-
value: 90
|
|
91
|
-
}, {
|
|
92
|
-
displayDragCoordinates: false,
|
|
93
|
-
color: '#0099c6',
|
|
94
|
-
label: 'P90',
|
|
95
|
-
dragAxis: 'y',
|
|
96
|
-
enableDrag: true,
|
|
97
|
-
resizable: false,
|
|
98
|
-
type: 'box',
|
|
99
|
-
xMax: 3,
|
|
100
|
-
xMin: 3,
|
|
101
|
-
yMax: 91,
|
|
102
|
-
yMin: 89,
|
|
103
|
-
yScaleID: 'y2'
|
|
104
|
-
}],
|
|
105
|
-
enableDragAnnotation: true,
|
|
106
|
-
showAnnotations: true
|
|
107
|
-
},
|
|
108
|
-
additionalAxesOptions: {
|
|
109
|
-
range: {
|
|
110
|
-
x: {
|
|
111
|
-
min: 3
|
|
112
|
-
}
|
|
113
|
-
},
|
|
114
|
-
chartScaleType: 'linear',
|
|
115
|
-
reverse: false
|
|
116
|
-
},
|
|
117
|
-
graph: {
|
|
118
|
-
showMinorGridlines: true
|
|
119
|
-
},
|
|
120
|
-
chartStyling: {
|
|
121
|
-
height: '100%'
|
|
122
|
-
},
|
|
123
|
-
chartOptions: {
|
|
124
|
-
showPoints: false,
|
|
125
|
-
enableDragAnnotation: true
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}} />;
|
|
129
|
-
}`,...f.parameters?.docs?.source}}},p.parameters={...p.parameters,docs:{...p.parameters?.docs,source:{originalSource:`() => {
|
|
130
|
-
return <LineChart chart={planView} />;
|
|
131
|
-
}`,...p.parameters?.docs?.source}}},m.parameters={...m.parameters,docs:{...m.parameters?.docs,source:{originalSource:`() => {
|
|
132
|
-
const [datasets, setDatasets] = useState(basicDS);
|
|
133
|
-
const [chartKey, setChartKey] = useState(0);
|
|
134
|
-
const [isSmall, setIsSmall] = useState(false);
|
|
135
|
-
const [showChart, setShowChart] = useState(true);
|
|
136
|
-
const [loading, setLoading] = useState(false);
|
|
137
|
-
const [aspectRatio, setAspectRatio] = useState(true);
|
|
138
|
-
const [xAxisType, setXAxisType] = useState('linear');
|
|
139
|
-
const [timerRunning, setTimerRunning] = useState(false);
|
|
140
|
-
const baseOptions = useMemo(() => ({
|
|
141
|
-
title: 'Stress Tester',
|
|
142
|
-
axes: {
|
|
143
|
-
x: [{
|
|
144
|
-
label: 'X Axis'
|
|
145
|
-
}],
|
|
146
|
-
y: [{
|
|
147
|
-
label: 'Y Axis'
|
|
148
|
-
}]
|
|
149
|
-
},
|
|
150
|
-
chartOptions: {
|
|
151
|
-
enableDragAnnotation: true
|
|
152
|
-
},
|
|
153
|
-
annotations: {
|
|
154
|
-
showAnnotations: true,
|
|
155
|
-
enableDragAnnotation: true,
|
|
156
|
-
annotationsData: [{
|
|
157
|
-
enableDrag: true,
|
|
158
|
-
type: 'box',
|
|
159
|
-
xMin: 3.5,
|
|
160
|
-
xMax: 4,
|
|
161
|
-
yMin: 5,
|
|
162
|
-
yMax: 10,
|
|
163
|
-
color: 'rgba(255, 0, 0, 0.3)',
|
|
164
|
-
label: 'DRAG ME!'
|
|
165
|
-
}, {
|
|
166
|
-
type: 'point',
|
|
167
|
-
enableDrag: true,
|
|
168
|
-
xValue: 1,
|
|
169
|
-
yValue: 10,
|
|
170
|
-
radius: DEFAULT_POINT_RADIUS,
|
|
171
|
-
color: 'red',
|
|
172
|
-
label: 'Draggable Point',
|
|
173
|
-
labelConfig: {
|
|
174
|
-
font: \`bold 8px \${DEFAULT_FONT_FAMILY}\`,
|
|
175
|
-
color: 'rgba(0,0,0,0.7)'
|
|
176
|
-
}
|
|
177
|
-
}]
|
|
178
|
-
},
|
|
179
|
-
chartStyling: {
|
|
180
|
-
height: '100%',
|
|
181
|
-
squareAspectRatio: aspectRatio
|
|
182
|
-
},
|
|
183
|
-
additionalAxesOptions: {
|
|
184
|
-
chartScaleType: xAxisType
|
|
185
|
-
},
|
|
186
|
-
legend: {
|
|
187
|
-
display: false
|
|
188
|
-
}
|
|
189
|
-
}), [datasets, aspectRatio, xAxisType]);
|
|
190
|
-
const chartConfig = useMemo(() => ({
|
|
191
|
-
data: {
|
|
192
|
-
datasets
|
|
193
|
-
},
|
|
194
|
-
options: baseOptions
|
|
195
|
-
}), [datasets, baseOptions]);
|
|
196
|
-
const startTimedUnmount = () => {
|
|
197
|
-
setTimerRunning(true);
|
|
198
|
-
setShowChart(true);
|
|
199
|
-
setTimeout(() => {
|
|
200
|
-
setShowChart(false);
|
|
201
|
-
setTimerRunning(false);
|
|
202
|
-
}, 5000);
|
|
203
|
-
};
|
|
204
|
-
const resetChart = () => {
|
|
205
|
-
setDatasets(basicDS);
|
|
206
|
-
setChartKey(k => k + 1);
|
|
207
|
-
setShowChart(true);
|
|
208
|
-
setTimerRunning(false);
|
|
209
|
-
};
|
|
210
|
-
const injectDatasetsAsync = () => {
|
|
211
|
-
setLoading(true);
|
|
212
|
-
const buffer = [];
|
|
213
|
-
const total = 50;
|
|
214
|
-
const delay = 40;
|
|
215
|
-
for (let i = 0; i < total; i++) {
|
|
216
|
-
setTimeout(() => {
|
|
217
|
-
buffer.push({
|
|
218
|
-
label: \`DS \${i + 1}\`,
|
|
219
|
-
data: [{
|
|
220
|
-
x: i,
|
|
221
|
-
y: Math.random() * 100
|
|
222
|
-
}, {
|
|
223
|
-
x: i + 1,
|
|
224
|
-
y: Math.random() * 100
|
|
225
|
-
}],
|
|
226
|
-
borderColor: \`hsl(\${i * (360 / total)}, 100%, 50%)\`
|
|
227
|
-
});
|
|
228
|
-
setDatasets([...buffer]);
|
|
229
|
-
if (i === 15) {
|
|
230
|
-
console.warn('Forcing unmount mid-update');
|
|
231
|
-
setShowChart(false);
|
|
232
|
-
}
|
|
233
|
-
if (i === 25) {
|
|
234
|
-
console.warn('Remounting chart');
|
|
235
|
-
setShowChart(true);
|
|
236
|
-
setChartKey(prev => prev + 1);
|
|
237
|
-
}
|
|
238
|
-
if (i === total - 1) {
|
|
239
|
-
console.log('Async injection complete');
|
|
240
|
-
setLoading(false);
|
|
241
|
-
}
|
|
242
|
-
}, i * delay);
|
|
243
|
-
}
|
|
244
|
-
};
|
|
245
|
-
const setInvalidDataset = () => {
|
|
246
|
-
setDatasets([{
|
|
247
|
-
label: 'Broken Dataset',
|
|
248
|
-
borderColor: 'red'
|
|
249
|
-
}]);
|
|
250
|
-
};
|
|
251
|
-
const setEmptyDataset = () => {
|
|
252
|
-
setDatasets([]);
|
|
253
|
-
};
|
|
254
|
-
const setMixedDataTypes = () => {
|
|
255
|
-
setDatasets([{
|
|
256
|
-
label: 'X/Y Points',
|
|
257
|
-
data: [{
|
|
258
|
-
x: 0,
|
|
259
|
-
y: 0
|
|
260
|
-
}, {
|
|
261
|
-
x: 1,
|
|
262
|
-
y: 1
|
|
263
|
-
}],
|
|
264
|
-
borderColor: 'green'
|
|
265
|
-
}, {
|
|
266
|
-
label: 'Y Only Array',
|
|
267
|
-
data: [2, 4, 6],
|
|
268
|
-
borderColor: 'blue'
|
|
269
|
-
}]);
|
|
270
|
-
};
|
|
271
|
-
const setMissingAxisRef = () => {
|
|
272
|
-
setDatasets([{
|
|
273
|
-
label: 'Bad Y Axis Ref',
|
|
274
|
-
yAxisID: 'y-missing',
|
|
275
|
-
data: [{
|
|
276
|
-
x: 1,
|
|
277
|
-
y: 1
|
|
278
|
-
}, {
|
|
279
|
-
x: 2,
|
|
280
|
-
y: 2
|
|
281
|
-
}],
|
|
282
|
-
borderColor: 'purple'
|
|
283
|
-
}]);
|
|
284
|
-
};
|
|
285
|
-
const addBigDataset = () => {
|
|
286
|
-
const data = Array.from({
|
|
287
|
-
length: 5000
|
|
288
|
-
}, (_, i) => ({
|
|
289
|
-
x: i,
|
|
290
|
-
y: Math.sin(i / 100) * 100
|
|
291
|
-
}));
|
|
292
|
-
setDatasets([{
|
|
293
|
-
label: 'Big 5k Points',
|
|
294
|
-
data,
|
|
295
|
-
borderColor: 'orange'
|
|
296
|
-
}]);
|
|
297
|
-
};
|
|
298
|
-
const addDatasetWithInvalidPoint = () => {
|
|
299
|
-
setDatasets([{
|
|
300
|
-
label: 'Corrupt Point Dataset',
|
|
301
|
-
data: [{
|
|
302
|
-
x: 0,
|
|
303
|
-
y: 10
|
|
304
|
-
}, {
|
|
305
|
-
x: 1
|
|
306
|
-
},
|
|
307
|
-
// missing y
|
|
308
|
-
{
|
|
309
|
-
y: 20
|
|
310
|
-
},
|
|
311
|
-
// missing x
|
|
312
|
-
null, undefined, 'bad-value', {
|
|
313
|
-
x: 5,
|
|
314
|
-
y: 50
|
|
315
|
-
}],
|
|
316
|
-
borderColor: 'red'
|
|
317
|
-
}]);
|
|
318
|
-
};
|
|
319
|
-
const addMalformedDatasetCombo = () => {
|
|
320
|
-
setDatasets([{
|
|
321
|
-
label: 'Valid A',
|
|
322
|
-
data: [{
|
|
323
|
-
x: 0,
|
|
324
|
-
y: 1
|
|
325
|
-
}, {
|
|
326
|
-
x: 1,
|
|
327
|
-
y: 2
|
|
328
|
-
}],
|
|
329
|
-
borderColor: 'blue'
|
|
330
|
-
}, {
|
|
331
|
-
label: 'Corrupt',
|
|
332
|
-
data: 'not-an-array',
|
|
333
|
-
borderColor: 'red'
|
|
334
|
-
}, {
|
|
335
|
-
label: 'Valid B',
|
|
336
|
-
data: [{
|
|
337
|
-
x: 0,
|
|
338
|
-
y: 3
|
|
339
|
-
}, {
|
|
340
|
-
x: 1,
|
|
341
|
-
y: 4
|
|
342
|
-
}],
|
|
343
|
-
borderColor: 'green'
|
|
344
|
-
}]);
|
|
345
|
-
};
|
|
346
|
-
const streamLargeData = () => {
|
|
347
|
-
const allDS = [];
|
|
348
|
-
for (let j = 0; j < 4; j++) {
|
|
349
|
-
const data = Array.from({
|
|
350
|
-
length: 3000
|
|
351
|
-
}, (_, i) => ({
|
|
352
|
-
x: i,
|
|
353
|
-
y: Math.random() * 100
|
|
354
|
-
}));
|
|
355
|
-
allDS.push({
|
|
356
|
-
label: \`Stream DS \${j + 1}\`,
|
|
357
|
-
data,
|
|
358
|
-
borderColor: \`hsl(\${j * 90}, 100%, 50%)\`
|
|
359
|
-
});
|
|
360
|
-
}
|
|
361
|
-
let step = 0;
|
|
362
|
-
const interval = setInterval(() => {
|
|
363
|
-
setDatasets(allDS.slice(0, step + 1));
|
|
364
|
-
step++;
|
|
365
|
-
if (step === allDS.length) clearInterval(interval);
|
|
366
|
-
}, 500);
|
|
367
|
-
};
|
|
368
|
-
const cycleXAxisType = () => {
|
|
369
|
-
setXAxisType(prev => prev === 'linear' ? 'logarithmic' : 'linear');
|
|
370
|
-
};
|
|
371
|
-
const toggleAspectRatio = () => {
|
|
372
|
-
setAspectRatio(prev => !prev);
|
|
373
|
-
};
|
|
374
|
-
const spamReRenders = () => {
|
|
375
|
-
let count = 0;
|
|
376
|
-
const interval = setInterval(() => {
|
|
377
|
-
setChartKey(prev => prev + 1);
|
|
378
|
-
count++;
|
|
379
|
-
if (count === 100) clearInterval(interval);
|
|
380
|
-
}, 30);
|
|
381
|
-
};
|
|
382
|
-
return <>
|
|
383
|
-
<div style={{
|
|
384
|
-
display: 'flex',
|
|
385
|
-
gap: 8,
|
|
386
|
-
flexWrap: 'wrap',
|
|
387
|
-
marginBottom: 16
|
|
388
|
-
}}>
|
|
389
|
-
<Button label="Reset to Initial State" colored onClick={resetChart} />
|
|
390
|
-
<Button label="Async Dataset + Unmount" onClick={injectDatasetsAsync} disabled={loading} />
|
|
391
|
-
<Button label="Set Invalid Dataset" onClick={setInvalidDataset} />
|
|
392
|
-
<Button label="Set Empty Dataset" onClick={setEmptyDataset} />
|
|
393
|
-
<Button label="Mixed Data Formats" onClick={setMixedDataTypes} />
|
|
394
|
-
<Button label="Bad Axis Ref" onClick={setMissingAxisRef} />
|
|
395
|
-
<Button label="Toggle size" onClick={() => setIsSmall(!isSmall)} />
|
|
396
|
-
<Button label="Toggle Axis Type" onClick={cycleXAxisType} />
|
|
397
|
-
<Button label="Toggle Aspect Ratio" onClick={toggleAspectRatio} />
|
|
398
|
-
<Button label="Spam Re-renders" onClick={spamReRenders} />
|
|
399
|
-
<Button label={showChart ? 'Unmount Chart' : 'Remount Chart'} onClick={() => setShowChart(s => !s)} />
|
|
400
|
-
<Button label="Manual Re-render" onClick={() => setChartKey(k => k + 1)} />
|
|
401
|
-
<Button label="Empty Dataset" onClick={() => setDatasets([])} />
|
|
402
|
-
<Button label="Add 5k Points Slowly" onClick={addBigDataset} />
|
|
403
|
-
<Button label="Dataset With Invalid Point" onClick={addDatasetWithInvalidPoint} />
|
|
404
|
-
<Button label="Malformed Dataset Combo" onClick={addMalformedDatasetCombo} />
|
|
405
|
-
<Button label="Cycle Big Load (Async)" onClick={streamLargeData} />
|
|
406
|
-
<Button label="Timed Unmount During Drag" onClick={startTimedUnmount} disabled={timerRunning} />
|
|
407
|
-
</div>
|
|
408
|
-
|
|
409
|
-
{timerRunning && <span style={{
|
|
410
|
-
color: 'crimson',
|
|
411
|
-
fontWeight: 'bold'
|
|
412
|
-
}}>
|
|
413
|
-
⏱ Unmounting in 5s – start dragging!
|
|
414
|
-
</span>}
|
|
415
|
-
|
|
416
|
-
<div style={{
|
|
417
|
-
height: isSmall ? 300 : null,
|
|
418
|
-
width: isSmall ? 300 : null,
|
|
419
|
-
padding: 'var(--padding)',
|
|
420
|
-
overflow: 'auto'
|
|
421
|
-
}}>
|
|
422
|
-
{showChart ? <LineChart key={chartKey} chart={chartConfig} /> : <div style={{
|
|
423
|
-
padding: 40,
|
|
424
|
-
textAlign: 'center'
|
|
425
|
-
}}>
|
|
426
|
-
Chart unmounted
|
|
427
|
-
</div>}
|
|
428
|
-
</div>
|
|
429
|
-
</>;
|
|
430
|
-
}`,...m.parameters?.docs?.source}}};const h=[`PartialRangeWithSimilarValues`,`closeToValueInDifferentAxes`,`StressTest`];export{f as PartialRangeWithSimilarValues,m as StressTest,h as __namedExportsOrder,p as closeToValueInDifferentAxes,d as default};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import{_t as e,at as t,dt as n}from"./iframe-DomYTowy.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-1H9KQ-2n.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
|
-
return <PieChart
|
|
3
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
4
|
-
{...args} />;
|
|
5
|
-
}`,...U.parameters?.docs?.source}}},W.parameters={...W.parameters,docs:{...W.parameters?.docs,source:{originalSource:`args => {
|
|
6
|
-
return <PieChart
|
|
7
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
8
|
-
{...args} />;
|
|
9
|
-
}`,...W.parameters?.docs?.source}}},G.parameters={...G.parameters,docs:{...G.parameters?.docs,source:{originalSource:`args => {
|
|
10
|
-
return <PieChart
|
|
11
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
12
|
-
{...args} />;
|
|
13
|
-
}`,...G.parameters?.docs?.source}}},K.parameters={...K.parameters,docs:{...K.parameters?.docs,source:{originalSource:`args => {
|
|
14
|
-
return <PieChart
|
|
15
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
16
|
-
{...args} />;
|
|
17
|
-
}`,...K.parameters?.docs?.source}}},q.parameters={...q.parameters,docs:{...q.parameters?.docs,source:{originalSource:`args => {
|
|
18
|
-
return <PieChart
|
|
19
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
20
|
-
{...args} />;
|
|
21
|
-
}`,...q.parameters?.docs?.source}}},J.parameters={...J.parameters,docs:{...J.parameters?.docs,source:{originalSource:`args => {
|
|
22
|
-
return <PieChart
|
|
23
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
24
|
-
{...args} />;
|
|
25
|
-
}`,...J.parameters?.docs?.source}}},Y.parameters={...Y.parameters,docs:{...Y.parameters?.docs,source:{originalSource:`args => {
|
|
26
|
-
return <PieChart
|
|
27
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
28
|
-
{...args} />;
|
|
29
|
-
}`,...Y.parameters?.docs?.source}}},X.parameters={...X.parameters,docs:{...X.parameters?.docs,source:{originalSource:`args => {
|
|
30
|
-
return <PieChart
|
|
31
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
32
|
-
{...args} />;
|
|
33
|
-
}`,...X.parameters?.docs?.source}}},Z.parameters={...Z.parameters,docs:{...Z.parameters?.docs,source:{originalSource:`args => {
|
|
34
|
-
return <PieChart
|
|
35
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
36
|
-
{...args} />;
|
|
37
|
-
}`,...Z.parameters?.docs?.source}}},Q.parameters={...Q.parameters,docs:{...Q.parameters?.docs,source:{originalSource:`args => {
|
|
38
|
-
return <PieChart
|
|
39
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
40
|
-
{...args} />;
|
|
41
|
-
}`,...Q.parameters?.docs?.source}}},$.parameters={...$.parameters,docs:{...$.parameters?.docs,source:{originalSource:`args => {
|
|
42
|
-
return <PieChart
|
|
43
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
44
|
-
{...args} />;
|
|
45
|
-
}`,...$.parameters?.docs?.source}}};const Ce=[`Default`,`MultipleSets`,`MultipleSetsStacked`,`Datalabels`,`DatalabelsValues`,`DatalabelsInTooltips`,`Animated`,`Doughnut`,`DoughnutFixedCutout`,`HoverOffset`,`SegmentOffset`];export{Y as Animated,K as Datalabels,J as DatalabelsInTooltips,q as DatalabelsValues,U as Default,X as Doughnut,Z as DoughnutFixedCutout,Q as HoverOffset,W as MultipleSets,G as MultipleSetsStacked,$ as SegmentOffset,Ce as __namedExportsOrder,Se as default};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import{_t as e,at as t,dt as n}from"./iframe-DomYTowy.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-1H9KQ-2n.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-C854veju.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
|
-
return <ScatterChart
|
|
3
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
4
|
-
{...args} />;
|
|
5
|
-
}`,...W.parameters?.docs?.source}}},G.parameters={...G.parameters,docs:{...G.parameters?.docs,source:{originalSource:`args => {
|
|
6
|
-
return <ScatterChart
|
|
7
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
8
|
-
{...args} />;
|
|
9
|
-
}`,...G.parameters?.docs?.source}}},K.parameters={...K.parameters,docs:{...K.parameters?.docs,source:{originalSource:`args => {
|
|
10
|
-
return <ScatterChart
|
|
11
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
12
|
-
{...args} />;
|
|
13
|
-
}`,...K.parameters?.docs?.source}}},q.parameters={...q.parameters,docs:{...q.parameters?.docs,source:{originalSource:`args => {
|
|
14
|
-
return <ScatterChart
|
|
15
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
16
|
-
{...args} />;
|
|
17
|
-
}`,...q.parameters?.docs?.source}}},J.parameters={...J.parameters,docs:{...J.parameters?.docs,source:{originalSource:`args => {
|
|
18
|
-
return <ScatterChart
|
|
19
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
20
|
-
{...args} />;
|
|
21
|
-
}`,...J.parameters?.docs?.source}}},Y.parameters={...Y.parameters,docs:{...Y.parameters?.docs,source:{originalSource:`args => {
|
|
22
|
-
return <ScatterChart
|
|
23
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
24
|
-
{...args} />;
|
|
25
|
-
}`,...Y.parameters?.docs?.source}}},X.parameters={...X.parameters,docs:{...X.parameters?.docs,source:{originalSource:`args => {
|
|
26
|
-
return <ScatterChart
|
|
27
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
28
|
-
{...args} />;
|
|
29
|
-
}`,...X.parameters?.docs?.source}}},Z.parameters={...Z.parameters,docs:{...Z.parameters?.docs,source:{originalSource:`args => {
|
|
30
|
-
return <ScatterChart
|
|
31
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
32
|
-
{...args} />;
|
|
33
|
-
}`,...Z.parameters?.docs?.source}}},Q.parameters={...Q.parameters,docs:{...Q.parameters?.docs,source:{originalSource:`args => {
|
|
34
|
-
return <ScatterChart
|
|
35
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
36
|
-
{...args} />;
|
|
37
|
-
}`,...Q.parameters?.docs?.source}}},$.parameters={...$.parameters,docs:{...$.parameters?.docs,source:{originalSource:`args => {
|
|
38
|
-
return <ScatterChart
|
|
39
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
40
|
-
{...args} />;
|
|
41
|
-
}`,...$.parameters?.docs?.source}}};const qe=[`Default`,`StyledChart`,`MultipleDatasets`,`WithDataLabels`,`WithTooltips`,`WithAnnotation`,`WithAxesLabels`,`WithGradient`,`WithDatapointsHavingLabel`,`CustomPointColor`];export{$ as CustomPointColor,W as Default,K as MultipleDatasets,G as StyledChart,Y as WithAnnotation,X as WithAxesLabels,q as WithDataLabels,Q as WithDatapointsHavingLabel,Z as WithGradient,J as WithTooltips,qe as __namedExportsOrder,Ke as default};
|
|
File without changes
|