@oliasoft-open-source/charts-library 5.0.2 → 5.0.3-beta-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-YHDXOIA2-DvkV04os.js → Color-YHDXOIA2-BvfhVAjI.js} +1 -1
- package/dist/assets/{DocsRenderer-CFRXHY34-cMkmi-tX.js → DocsRenderer-CFRXHY34-CliORq5_.js} +3 -3
- package/dist/assets/{bar-chart.stories-Eq_jQ19D.js → bar-chart.stories-BMExUqt4.js} +1 -1
- package/dist/assets/{entry-preview-Cgd6khWs.js → entry-preview-Bqd2U7mX.js} +1 -1
- package/dist/assets/{get-draggableData-CQpLHCdg.js → get-draggableData-DS0HhINp.js} +1 -1
- package/dist/assets/{iframe-Bj1sRZW3.js → iframe-CB3H5nUS.js} +2 -2
- package/dist/assets/{legend-krJw8Ykb.js → legend-CD8XU7nW.js} +1 -1
- package/dist/assets/line-chart-D3YG7EEV.js +1 -0
- package/dist/assets/line-chart.stories-DY8ALwMk.js +1155 -0
- package/dist/assets/line-chart.test-case.stories-BXMQ2TyL.js +428 -0
- package/dist/assets/{preview-BNebtty_.js → preview-CiEdDnYv.js} +2 -2
- package/dist/assets/{preview-CASZ8WNA.js → preview-y81lG200.js} +1 -1
- package/dist/assets/{scatter-chart.stories-BCbRBdJY.js → scatter-chart.stories-sl5FPoGH.js} +1 -1
- package/dist/iframe.html +1 -1
- package/dist/index.js.js +64 -34
- package/dist/index.js.js.map +1 -1
- package/dist/index.json +1 -1
- package/dist/line-chart/controls/axes-options/axes-options-interfaces.d.ts +1 -0
- package/dist/line-chart/hooks/use-chart-functions.d.ts +2 -1
- package/dist/line-chart/state/action-types.d.ts +1 -0
- package/dist/line-chart/state/state.interfaces.d.ts +1 -0
- package/dist/project.json +1 -1
- package/dist/src/components/line-chart/controls/axes-options/axes-options-interfaces.d.ts +1 -0
- package/dist/src/components/line-chart/hooks/use-chart-functions.d.ts +1 -0
- package/dist/src/components/line-chart/state/action-types.d.ts +1 -0
- package/dist/src/components/line-chart/state/state.interfaces.d.ts +1 -0
- package/package.json +1 -1
- package/dist/assets/line-chart-TEIxShHM.js +0 -1
- package/dist/assets/line-chart.stories-CRpxf_tv.js +0 -1130
- package/dist/assets/line-chart.test-case.stories-Cb2jns7e.js +0 -142
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
import{j as t}from"./jsx-runtime-Y5Ju2SGo.js";import{r as l}from"./index-eCxJ45ll.js";import{D as J,B as e}from"./legend-CD8XU7nW.js";import{L as m}from"./line-chart-D3YG7EEV.js";import{D as Q}from"./legend-context-vqtlaWwg.js";import"./index-BGqSdrBK.js";import"./index-D3-0uUTW.js";import"./index-B-BONL6g.js";import"./get-draggableData-DS0HhINp.js";const p=[{label:"Dataset 1",data:[{x:0,y:0},{x:5,y:25}]}],Z={data:{datasets:p},options:{title:"Chart title",chartStyling:{height:"100%"}}},ct={title:"LineChart / Test Cases",component:m,args:{chart:Z}},d=()=>t.jsx(m,{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}}}}),c=()=>{const[u,o]=l.useState(p),[B,y]=l.useState(0),[x,j]=l.useState(!1),[h,i]=l.useState(!0),[P,D]=l.useState(!1),[C,w]=l.useState(!0),[f,L]=l.useState("linear"),[A,b]=l.useState(!1),S=l.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:J,color:"red",label:"Draggable Point",labelConfig:{font:`bold 8px ${Q}`,color:"rgba(0,0,0,0.7)"}}]},chartStyling:{height:"100%",squareAspectRatio:C},additionalAxesOptions:{chartScaleType:f},legend:{display:!1}}),[u,C,f]),_=l.useMemo(()=>({data:{datasets:u},options:S}),[u,S]),O=()=>{b(!0),i(!0),setTimeout(()=>{i(!1),b(!1)},5e3)},U=()=>{o(p),y(a=>a+1),i(!0),b(!1)},E=()=>{D(!0);const a=[],s=50,r=40;for(let n=0;n<s;n++)setTimeout(()=>{a.push({label:`DS ${n+1}`,data:[{x:n,y:Math.random()*100},{x:n+1,y:Math.random()*100}],borderColor:`hsl(${n*(360/s)}, 100%, 50%)`}),o([...a]),n===15&&(console.warn("Forcing unmount mid-update"),i(!1)),n===25&&(console.warn("Remounting chart"),i(!0),y(g=>g+1)),n===s-1&&(console.log("Async injection complete"),D(!1))},n*r)},W=()=>{o([{label:"Broken Dataset",borderColor:"red"}])},F=()=>{o([])},V=()=>{o([{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"}])},$=()=>{o([{label:"Bad Y Axis Ref",yAxisID:"y-missing",data:[{x:1,y:1},{x:2,y:2}],borderColor:"purple"}])},z=()=>{const a=Array.from({length:5e3},(s,r)=>({x:r,y:Math.sin(r/100)*100}));o([{label:"Big 5k Points",data:a,borderColor:"orange"}])},X=()=>{o([{label:"Corrupt Point Dataset",data:[{x:0,y:10},{x:1},{y:20},null,void 0,"bad-value",{x:5,y:50}],borderColor:"red"}])},Y=()=>{o([{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"}])},K=()=>{const a=[];for(let n=0;n<4;n++){const g=Array.from({length:3e3},(tt,H)=>({x:H,y:Math.random()*100}));a.push({label:`Stream DS ${n+1}`,data:g,borderColor:`hsl(${n*90}, 100%, 50%)`})}let s=0;const r=setInterval(()=>{o(a.slice(0,s+1)),s++,s===a.length&&clearInterval(r)},500)},N=()=>{L(a=>a==="linear"?"logarithmic":"linear")},G=()=>{w(a=>!a)},q=()=>{let a=0;const s=setInterval(()=>{y(r=>r+1),a++,a===100&&clearInterval(s)},30)};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",marginBottom:16},children:[t.jsx(e,{label:"Reset to Initial State",colored:!0,onClick:U}),t.jsx(e,{label:"Async Dataset + Unmount",onClick:E,disabled:P}),t.jsx(e,{label:"Set Invalid Dataset",onClick:W}),t.jsx(e,{label:"Set Empty Dataset",onClick:F}),t.jsx(e,{label:"Mixed Data Formats",onClick:V}),t.jsx(e,{label:"Bad Axis Ref",onClick:$}),t.jsx(e,{label:"Toggle size",onClick:()=>j(!x)}),t.jsx(e,{label:"Toggle Axis Type",onClick:N}),t.jsx(e,{label:"Toggle Aspect Ratio",onClick:G}),t.jsx(e,{label:"Spam Re-renders",onClick:q}),t.jsx(e,{label:h?"Unmount Chart":"Remount Chart",onClick:()=>i(a=>!a)}),t.jsx(e,{label:"Manual Re-render",onClick:()=>y(a=>a+1)}),t.jsx(e,{label:"Empty Dataset",onClick:()=>o([])}),t.jsx(e,{label:"Add 5k Points Slowly",onClick:z}),t.jsx(e,{label:"Dataset With Invalid Point",onClick:X}),t.jsx(e,{label:"Malformed Dataset Combo",onClick:Y}),t.jsx(e,{label:"Cycle Big Load (Async)",onClick:K}),t.jsx(e,{label:"Timed Unmount During Drag",onClick:O,disabled:A})]}),A&&t.jsx("span",{style:{color:"crimson",fontWeight:"bold"},children:"⏱ Unmounting in 5s – start dragging!"}),t.jsx("div",{style:{height:x?300:null,width:x?300:null,padding:"var(--padding)",overflow:"auto"},children:h?t.jsx(m,{chart:_},B):t.jsx("div",{style:{padding:40,textAlign:"center"},children:"Chart unmounted"})})]})};d.__docgenInfo={description:"",methods:[],displayName:"PartialRangeWithSimilarValues"};c.__docgenInfo={description:"",methods:[],displayName:"StressTest"};var M,v,R;d.parameters={...d.parameters,docs:{...(M=d.parameters)==null?void 0:M.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
|
+
}`,...(R=(v=d.parameters)==null?void 0:v.docs)==null?void 0:R.source}}};var k,T,I;c.parameters={...c.parameters,docs:{...(k=c.parameters)==null?void 0:k.docs,source:{originalSource:`() => {
|
|
130
|
+
const [datasets, setDatasets] = useState(basicDS);
|
|
131
|
+
const [chartKey, setChartKey] = useState(0);
|
|
132
|
+
const [isSmall, setIsSmall] = useState(false);
|
|
133
|
+
const [showChart, setShowChart] = useState(true);
|
|
134
|
+
const [loading, setLoading] = useState(false);
|
|
135
|
+
const [aspectRatio, setAspectRatio] = useState(true);
|
|
136
|
+
const [xAxisType, setXAxisType] = useState('linear');
|
|
137
|
+
const [timerRunning, setTimerRunning] = useState(false);
|
|
138
|
+
const baseOptions = useMemo(() => ({
|
|
139
|
+
title: 'Stress Tester',
|
|
140
|
+
axes: {
|
|
141
|
+
x: [{
|
|
142
|
+
label: 'X Axis'
|
|
143
|
+
}],
|
|
144
|
+
y: [{
|
|
145
|
+
label: 'Y Axis'
|
|
146
|
+
}]
|
|
147
|
+
},
|
|
148
|
+
chartOptions: {
|
|
149
|
+
enableDragAnnotation: true
|
|
150
|
+
},
|
|
151
|
+
annotations: {
|
|
152
|
+
showAnnotations: true,
|
|
153
|
+
enableDragAnnotation: true,
|
|
154
|
+
annotationsData: [{
|
|
155
|
+
enableDrag: true,
|
|
156
|
+
type: 'box',
|
|
157
|
+
xMin: 3.5,
|
|
158
|
+
xMax: 4,
|
|
159
|
+
yMin: 5,
|
|
160
|
+
yMax: 10,
|
|
161
|
+
color: 'rgba(255, 0, 0, 0.3)',
|
|
162
|
+
label: 'DRAG ME!'
|
|
163
|
+
}, {
|
|
164
|
+
type: 'point',
|
|
165
|
+
enableDrag: true,
|
|
166
|
+
xValue: 1,
|
|
167
|
+
yValue: 10,
|
|
168
|
+
radius: DEFAULT_POINT_RADIUS,
|
|
169
|
+
color: 'red',
|
|
170
|
+
label: 'Draggable Point',
|
|
171
|
+
labelConfig: {
|
|
172
|
+
font: \`bold 8px \${DEFAULT_FONT_FAMILY}\`,
|
|
173
|
+
color: 'rgba(0,0,0,0.7)'
|
|
174
|
+
}
|
|
175
|
+
}]
|
|
176
|
+
},
|
|
177
|
+
chartStyling: {
|
|
178
|
+
height: '100%',
|
|
179
|
+
squareAspectRatio: aspectRatio
|
|
180
|
+
},
|
|
181
|
+
additionalAxesOptions: {
|
|
182
|
+
chartScaleType: xAxisType
|
|
183
|
+
},
|
|
184
|
+
legend: {
|
|
185
|
+
display: false
|
|
186
|
+
}
|
|
187
|
+
}), [datasets, aspectRatio, xAxisType]);
|
|
188
|
+
const chartConfig = useMemo(() => ({
|
|
189
|
+
data: {
|
|
190
|
+
datasets
|
|
191
|
+
},
|
|
192
|
+
options: baseOptions
|
|
193
|
+
}), [datasets, baseOptions]);
|
|
194
|
+
const startTimedUnmount = () => {
|
|
195
|
+
setTimerRunning(true);
|
|
196
|
+
setShowChart(true);
|
|
197
|
+
setTimeout(() => {
|
|
198
|
+
setShowChart(false);
|
|
199
|
+
setTimerRunning(false);
|
|
200
|
+
}, 5000);
|
|
201
|
+
};
|
|
202
|
+
const resetChart = () => {
|
|
203
|
+
setDatasets(basicDS);
|
|
204
|
+
setChartKey(k => k + 1);
|
|
205
|
+
setShowChart(true);
|
|
206
|
+
setTimerRunning(false);
|
|
207
|
+
};
|
|
208
|
+
const injectDatasetsAsync = () => {
|
|
209
|
+
setLoading(true);
|
|
210
|
+
const buffer = [];
|
|
211
|
+
const total = 50;
|
|
212
|
+
const delay = 40;
|
|
213
|
+
for (let i = 0; i < total; i++) {
|
|
214
|
+
setTimeout(() => {
|
|
215
|
+
buffer.push({
|
|
216
|
+
label: \`DS \${i + 1}\`,
|
|
217
|
+
data: [{
|
|
218
|
+
x: i,
|
|
219
|
+
y: Math.random() * 100
|
|
220
|
+
}, {
|
|
221
|
+
x: i + 1,
|
|
222
|
+
y: Math.random() * 100
|
|
223
|
+
}],
|
|
224
|
+
borderColor: \`hsl(\${i * (360 / total)}, 100%, 50%)\`
|
|
225
|
+
});
|
|
226
|
+
setDatasets([...buffer]);
|
|
227
|
+
if (i === 15) {
|
|
228
|
+
console.warn('Forcing unmount mid-update');
|
|
229
|
+
setShowChart(false);
|
|
230
|
+
}
|
|
231
|
+
if (i === 25) {
|
|
232
|
+
console.warn('Remounting chart');
|
|
233
|
+
setShowChart(true);
|
|
234
|
+
setChartKey(prev => prev + 1);
|
|
235
|
+
}
|
|
236
|
+
if (i === total - 1) {
|
|
237
|
+
console.log('Async injection complete');
|
|
238
|
+
setLoading(false);
|
|
239
|
+
}
|
|
240
|
+
}, i * delay);
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
const setInvalidDataset = () => {
|
|
244
|
+
setDatasets([{
|
|
245
|
+
label: 'Broken Dataset',
|
|
246
|
+
borderColor: 'red'
|
|
247
|
+
}]);
|
|
248
|
+
};
|
|
249
|
+
const setEmptyDataset = () => {
|
|
250
|
+
setDatasets([]);
|
|
251
|
+
};
|
|
252
|
+
const setMixedDataTypes = () => {
|
|
253
|
+
setDatasets([{
|
|
254
|
+
label: 'X/Y Points',
|
|
255
|
+
data: [{
|
|
256
|
+
x: 0,
|
|
257
|
+
y: 0
|
|
258
|
+
}, {
|
|
259
|
+
x: 1,
|
|
260
|
+
y: 1
|
|
261
|
+
}],
|
|
262
|
+
borderColor: 'green'
|
|
263
|
+
}, {
|
|
264
|
+
label: 'Y Only Array',
|
|
265
|
+
data: [2, 4, 6],
|
|
266
|
+
borderColor: 'blue'
|
|
267
|
+
}]);
|
|
268
|
+
};
|
|
269
|
+
const setMissingAxisRef = () => {
|
|
270
|
+
setDatasets([{
|
|
271
|
+
label: 'Bad Y Axis Ref',
|
|
272
|
+
yAxisID: 'y-missing',
|
|
273
|
+
data: [{
|
|
274
|
+
x: 1,
|
|
275
|
+
y: 1
|
|
276
|
+
}, {
|
|
277
|
+
x: 2,
|
|
278
|
+
y: 2
|
|
279
|
+
}],
|
|
280
|
+
borderColor: 'purple'
|
|
281
|
+
}]);
|
|
282
|
+
};
|
|
283
|
+
const addBigDataset = () => {
|
|
284
|
+
const data = Array.from({
|
|
285
|
+
length: 5000
|
|
286
|
+
}, (_, i) => ({
|
|
287
|
+
x: i,
|
|
288
|
+
y: Math.sin(i / 100) * 100
|
|
289
|
+
}));
|
|
290
|
+
setDatasets([{
|
|
291
|
+
label: 'Big 5k Points',
|
|
292
|
+
data,
|
|
293
|
+
borderColor: 'orange'
|
|
294
|
+
}]);
|
|
295
|
+
};
|
|
296
|
+
const addDatasetWithInvalidPoint = () => {
|
|
297
|
+
setDatasets([{
|
|
298
|
+
label: 'Corrupt Point Dataset',
|
|
299
|
+
data: [{
|
|
300
|
+
x: 0,
|
|
301
|
+
y: 10
|
|
302
|
+
}, {
|
|
303
|
+
x: 1
|
|
304
|
+
},
|
|
305
|
+
// missing y
|
|
306
|
+
{
|
|
307
|
+
y: 20
|
|
308
|
+
},
|
|
309
|
+
// missing x
|
|
310
|
+
null, undefined, 'bad-value', {
|
|
311
|
+
x: 5,
|
|
312
|
+
y: 50
|
|
313
|
+
}],
|
|
314
|
+
borderColor: 'red'
|
|
315
|
+
}]);
|
|
316
|
+
};
|
|
317
|
+
const addMalformedDatasetCombo = () => {
|
|
318
|
+
setDatasets([{
|
|
319
|
+
label: 'Valid A',
|
|
320
|
+
data: [{
|
|
321
|
+
x: 0,
|
|
322
|
+
y: 1
|
|
323
|
+
}, {
|
|
324
|
+
x: 1,
|
|
325
|
+
y: 2
|
|
326
|
+
}],
|
|
327
|
+
borderColor: 'blue'
|
|
328
|
+
}, {
|
|
329
|
+
label: 'Corrupt',
|
|
330
|
+
data: 'not-an-array',
|
|
331
|
+
borderColor: 'red'
|
|
332
|
+
}, {
|
|
333
|
+
label: 'Valid B',
|
|
334
|
+
data: [{
|
|
335
|
+
x: 0,
|
|
336
|
+
y: 3
|
|
337
|
+
}, {
|
|
338
|
+
x: 1,
|
|
339
|
+
y: 4
|
|
340
|
+
}],
|
|
341
|
+
borderColor: 'green'
|
|
342
|
+
}]);
|
|
343
|
+
};
|
|
344
|
+
const streamLargeData = () => {
|
|
345
|
+
const allDS = [];
|
|
346
|
+
for (let j = 0; j < 4; j++) {
|
|
347
|
+
const data = Array.from({
|
|
348
|
+
length: 3000
|
|
349
|
+
}, (_, i) => ({
|
|
350
|
+
x: i,
|
|
351
|
+
y: Math.random() * 100
|
|
352
|
+
}));
|
|
353
|
+
allDS.push({
|
|
354
|
+
label: \`Stream DS \${j + 1}\`,
|
|
355
|
+
data,
|
|
356
|
+
borderColor: \`hsl(\${j * 90}, 100%, 50%)\`
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
let step = 0;
|
|
360
|
+
const interval = setInterval(() => {
|
|
361
|
+
setDatasets(allDS.slice(0, step + 1));
|
|
362
|
+
step++;
|
|
363
|
+
if (step === allDS.length) clearInterval(interval);
|
|
364
|
+
}, 500);
|
|
365
|
+
};
|
|
366
|
+
const cycleXAxisType = () => {
|
|
367
|
+
setXAxisType(prev => prev === 'linear' ? 'logarithmic' : 'linear');
|
|
368
|
+
};
|
|
369
|
+
const toggleAspectRatio = () => {
|
|
370
|
+
setAspectRatio(prev => !prev);
|
|
371
|
+
};
|
|
372
|
+
const spamReRenders = () => {
|
|
373
|
+
let count = 0;
|
|
374
|
+
const interval = setInterval(() => {
|
|
375
|
+
setChartKey(prev => prev + 1);
|
|
376
|
+
count++;
|
|
377
|
+
if (count === 100) clearInterval(interval);
|
|
378
|
+
}, 30);
|
|
379
|
+
};
|
|
380
|
+
return <>
|
|
381
|
+
<div style={{
|
|
382
|
+
display: 'flex',
|
|
383
|
+
gap: 8,
|
|
384
|
+
flexWrap: 'wrap',
|
|
385
|
+
marginBottom: 16
|
|
386
|
+
}}>
|
|
387
|
+
<Button label="Reset to Initial State" colored onClick={resetChart} />
|
|
388
|
+
<Button label="Async Dataset + Unmount" onClick={injectDatasetsAsync} disabled={loading} />
|
|
389
|
+
<Button label="Set Invalid Dataset" onClick={setInvalidDataset} />
|
|
390
|
+
<Button label="Set Empty Dataset" onClick={setEmptyDataset} />
|
|
391
|
+
<Button label="Mixed Data Formats" onClick={setMixedDataTypes} />
|
|
392
|
+
<Button label="Bad Axis Ref" onClick={setMissingAxisRef} />
|
|
393
|
+
<Button label="Toggle size" onClick={() => setIsSmall(!isSmall)} />
|
|
394
|
+
<Button label="Toggle Axis Type" onClick={cycleXAxisType} />
|
|
395
|
+
<Button label="Toggle Aspect Ratio" onClick={toggleAspectRatio} />
|
|
396
|
+
<Button label="Spam Re-renders" onClick={spamReRenders} />
|
|
397
|
+
<Button label={showChart ? 'Unmount Chart' : 'Remount Chart'} onClick={() => setShowChart(s => !s)} />
|
|
398
|
+
<Button label="Manual Re-render" onClick={() => setChartKey(k => k + 1)} />
|
|
399
|
+
<Button label="Empty Dataset" onClick={() => setDatasets([])} />
|
|
400
|
+
<Button label="Add 5k Points Slowly" onClick={addBigDataset} />
|
|
401
|
+
<Button label="Dataset With Invalid Point" onClick={addDatasetWithInvalidPoint} />
|
|
402
|
+
<Button label="Malformed Dataset Combo" onClick={addMalformedDatasetCombo} />
|
|
403
|
+
<Button label="Cycle Big Load (Async)" onClick={streamLargeData} />
|
|
404
|
+
<Button label="Timed Unmount During Drag" onClick={startTimedUnmount} disabled={timerRunning} />
|
|
405
|
+
</div>
|
|
406
|
+
|
|
407
|
+
{timerRunning && <span style={{
|
|
408
|
+
color: 'crimson',
|
|
409
|
+
fontWeight: 'bold'
|
|
410
|
+
}}>
|
|
411
|
+
⏱ Unmounting in 5s – start dragging!
|
|
412
|
+
</span>}
|
|
413
|
+
|
|
414
|
+
<div style={{
|
|
415
|
+
height: isSmall ? 300 : null,
|
|
416
|
+
width: isSmall ? 300 : null,
|
|
417
|
+
padding: 'var(--padding)',
|
|
418
|
+
overflow: 'auto'
|
|
419
|
+
}}>
|
|
420
|
+
{showChart ? <LineChart key={chartKey} chart={chartConfig} /> : <div style={{
|
|
421
|
+
padding: 40,
|
|
422
|
+
textAlign: 'center'
|
|
423
|
+
}}>
|
|
424
|
+
Chart unmounted
|
|
425
|
+
</div>}
|
|
426
|
+
</div>
|
|
427
|
+
</>;
|
|
428
|
+
}`,...(I=(T=c.parameters)==null?void 0:T.docs)==null?void 0:I.source}}};const yt=["PartialRangeWithSimilarValues","StressTest"];export{d as PartialRangeWithSimilarValues,c as StressTest,yt as __namedExportsOrder,ct as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./DocsRenderer-CFRXHY34-
|
|
2
|
-
import{_ as o}from"./iframe-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./DocsRenderer-CFRXHY34-CliORq5_.js","./iframe-CB3H5nUS.js","./index-eCxJ45ll.js","./jsx-runtime-Y5Ju2SGo.js","./index-BGqSdrBK.js","./index-D3-0uUTW.js","./index-Dytf1aFS.js","./client-9BU5HM4U.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{_ as o}from"./iframe-CB3H5nUS.js";var s=Object.defineProperty,i=(e,r)=>{for(var t in r)s(e,t,{get:r[t],enumerable:!0})},n={};i(n,{parameters:()=>d});var _=Object.entries(globalThis.TAGS_OPTIONS??{}).reduce((e,r)=>{let[t,a]=r;return a.excludeFromDocsStories&&(e[t]=!0),e},{}),d={docs:{renderer:async()=>{let{DocsRenderer:e}=await o(async()=>{const{DocsRenderer:r}=await import("./DocsRenderer-CFRXHY34-CliORq5_.js").then(t=>t.e);return{DocsRenderer:r}},__vite__mapDeps([0,1,2,3,4,5,6,7]),import.meta.url);return new e},stories:{filter:e=>{var r;return(e.tags||[]).filter(t=>_[t]).length===0&&!((r=e.parameters.docs)!=null&&r.disable)}}}};export{d as parameters};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{j as c}from"./jsx-runtime-Y5Ju2SGo.js";import{r as v}from"./index-eCxJ45ll.js";import{c as p,D as j}from"./DocsRenderer-CFRXHY34-
|
|
1
|
+
import{j as c}from"./jsx-runtime-Y5Ju2SGo.js";import{r as v}from"./index-eCxJ45ll.js";import{c as p,D as j}from"./DocsRenderer-CFRXHY34-CliORq5_.js";import{e as E}from"./index-B-BONL6g.js";import"./preview-CiEdDnYv.js";import"./iframe-CB3H5nUS.js";import"./index-BGqSdrBK.js";import"./index-D3-0uUTW.js";import"./index-Dytf1aFS.js";import"./client-9BU5HM4U.js";var g="DARK_MODE";function f(t){"@babel/helpers - typeof";return f=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},f(t)}var b;function A(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),e.push.apply(e,n)}return e}function D(t){for(var r=1;r<arguments.length;r++){var e=arguments[r]!=null?arguments[r]:{};r%2?A(Object(e),!0).forEach(function(n){I(t,n,e[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):A(Object(e)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))})}return t}function I(t,r,e){return r=M(r),r in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function M(t){var r=R(t,"string");return f(r)==="symbol"?r:String(r)}function R(t,r){if(f(t)!=="object"||t===null)return t;var e=t[Symbol.toPrimitive];if(e!==void 0){var n=e.call(t,r);if(f(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}function y(t){return L(t)||N(t)||K(t)||x()}function x(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
2
2
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function K(t,r){if(t){if(typeof t=="string")return O(t,r);var e=Object.prototype.toString.call(t).slice(8,-1);if(e==="Object"&&t.constructor&&(e=t.constructor.name),e==="Map"||e==="Set")return Array.from(t);if(e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return O(t,r)}}function N(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function L(t){if(Array.isArray(t))return O(t)}function O(t,r){(r==null||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}const{global:U}=__STORYBOOK_MODULE_GLOBAL__,{STORY_CHANGED:st,SET_STORIES:ct,DOCS_RENDERED:ft}=__STORYBOOK_MODULE_CORE_EVENTS__;var T=U,Y=T.document,h=T.window,C="sb-addon-themes-3";(b=h.matchMedia)===null||b===void 0||b.call(h,"(prefers-color-scheme: dark)");var S={classTarget:"body",dark:p.dark,darkClass:["dark"],light:p.light,lightClass:["light"],stylePreview:!1,userHasExplicitlySetTheTheme:!1},k=function(r){h.localStorage.setItem(C,JSON.stringify(r))},B=function(r,e){var n=e.current,a=e.darkClass,l=a===void 0?S.darkClass:a,o=e.lightClass,i=o===void 0?S.lightClass:o;if(n==="dark"){var u,s;(u=r.classList).remove.apply(u,y(d(i))),(s=r.classList).add.apply(s,y(d(l)))}else{var m,_;(m=r.classList).remove.apply(m,y(d(l))),(_=r.classList).add.apply(_,y(d(i)))}},d=function(r){var e=[];return e.concat(r).map(function(n){return n})},W=function(r){var e=Y.querySelector(r.classTarget);e&&B(e,r)},P=function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=h.localStorage.getItem(C);if(typeof e=="string"){var n=JSON.parse(e);return r&&(r.dark&&!E(n.dark,r.dark)&&(n.dark=r.dark,k(n)),r.light&&!E(n.light,r.light)&&(n.light=r.light,k(n))),n}return D(D({},S),r)};W(P());function H(t,r){return q(t)||G(t,r)||$(t,r)||V()}function V(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
3
3
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function $(t,r){if(t){if(typeof t=="string")return w(t,r);var e=Object.prototype.toString.call(t).slice(8,-1);if(e==="Object"&&t.constructor&&(e=t.constructor.name),e==="Map"||e==="Set")return Array.from(t);if(e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return w(t,r)}}function w(t,r){(r==null||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}function G(t,r){var e=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(e!=null){var n,a,l,o,i=[],u=!0,s=!1;try{if(l=(e=e.call(t)).next,r!==0)for(;!(u=(n=l.call(e)).done)&&(i.push(n.value),i.length!==r);u=!0);}catch(m){s=!0,a=m}finally{try{if(!u&&e.return!=null&&(o=e.return(),Object(o)!==o))return}finally{if(s)throw a}}return i}}function q(t){if(Array.isArray(t))return t}const{addons:J,useState:F,useEffect:z}=__STORYBOOK_MODULE_PREVIEW_API__;function Q(){var t=F(P().current==="dark"),r=H(t,2),e=r[0],n=r[1];return z(function(){var a=J.getChannel();return a.on(g,n),function(){return a.off(g,n)}},[]),e}const{definePreview:mt}=__STORYBOOK_MODULE_PREVIEW_API__,yt=[t=>c.jsx(c.Fragment,{children:c.jsx(t,{})}),t=>{const r=Q();return v.useEffect(()=>(document.documentElement.dataset.theme=r?"dark":"default",()=>{delete document.documentElement.dataset.theme}),[r]),c.jsx(t,{})}],X=t=>{const[r,e]=v.useState(!1);return v.useEffect(()=>{const n=a=>e(a);return t.context.channel.on(g,n),()=>{t.context.channel.off(g,n)}},[t.context.channel]),c.jsx(j,{...t,theme:r?p.dark:p.light})},dt={docs:{container:X},darkMode:{current:"light",stylePreview:!0}},pt=["autodocs"];export{yt as decorators,dt as parameters,pt as tags};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as g}from"./jsx-runtime-Y5Ju2SGo.js";import{r as ye}from"./index-eCxJ45ll.js";import{d as ve,r as Ae,w as ke,x as u,S as De,y as He,z as je,B as we,f as U,C as Me,A as Ee,P as Ie,G as Pe,E as z,b as Ne,s as qe,F as Ue,H as ze,I as Fe,h as Ze,i as Ye,J as Xe,j as $e,p as Ve,m as Je,n as Ke,q as Qe,t as Ge}from"./legend-context-vqtlaWwg.js";import{u as et,j as tt,t as at,k as st,l as rt,m as lt,H as ot,L as nt,n as ct,o as dt}from"./legend-krJw8Ykb.js";import{D as it,a as ut}from"./bar-chart-const-Cgj9sgUU.js";import"./index-B-BONL6g.js";import"./index-BGqSdrBK.js";import"./index-D3-0uUTW.js";const F=(e,t)=>{let a={};return t?(Math.abs(e)<it||Math.abs(e)>ut)&&(a={roundScientificCoefficient:3}):a={scientific:!1},ve(Ae(e),a)},gt=(e,t)=>{var a;if((a=t==null?void 0:t.tooltip)!=null&&a.showLabelsInTooltips){const r=e[0],{label:s}=(r==null?void 0:r.dataset)??{};return s}},ht=(e,t)=>{var o;const{raw:a,dataset:r}=e??{},s=a==null?void 0:a.label,n=(o=t==null?void 0:t.tooltip)==null?void 0:o.scientificNotation;return`${s??(r==null?void 0:r.label)} ( x: ${F(a==null?void 0:a.x,n)} , y: ${F(a==null?void 0:a.y,n)} )`},mt=e=>{var t,a,r;return{enabled:(t=e==null?void 0:e.tooltip)==null?void 0:t.enabled,callbacks:{title:s=>gt(s,e),label:s=>ht(s,e)},backgroundColor:(a=e==null?void 0:e.tooltip)==null?void 0:a.backgroundColor,displayColors:(r=e==null?void 0:e.tooltip)==null?void 0:r.displayColors,padding:7}},Z=({options:e,axisType:t=u.X,currentScale:a})=>{var C,T,p,b,L,f,w,y,M;const r=ke(e.direction),s=a||((T=(C=e==null?void 0:e.axes)==null?void 0:C[t])==null?void 0:T[0]),n=r&&t===u.Y||!r&&t===u.X,o=(s==null?void 0:s.gridLines)||{},x=()=>{var l;const c=r?u.Y:u.X;return t===c?(l=e==null?void 0:e.additionalAxesOptions)==null?void 0:l.reverse:!1},S=()=>{const c=e==null?void 0:e.additionalAxesOptions;return{...{stepSize:(s==null?void 0:s.stepSize)??(t===u.Y?c==null?void 0:c.stepSize:void 0)},includeBounds:!1,font:{size:He}}};return{type:De.Linear,position:s==null?void 0:s.position,beginAtZero:(p=e==null?void 0:e.additionalAxesOptions)==null?void 0:p.beginAtZero,reverse:x(),suggestedMax:(b=e==null?void 0:e.additionalAxesOptions)==null?void 0:b.suggestedMax,suggestedMin:(L=e==null?void 0:e.additionalAxesOptions)==null?void 0:L.suggestedMin,min:n?(f=e==null?void 0:e.additionalAxesOptions)==null?void 0:f.min:void 0,max:n?(w=e==null?void 0:e.additionalAxesOptions)==null?void 0:w.max:void 0,title:{display:!!((y=s==null?void 0:s.label)!=null&&y.length)||!!((M=s==null?void 0:s.unit)!=null&&M.length),text:(s==null?void 0:s.label)||(s==null?void 0:s.unit),padding:0},ticks:S(),grid:{...o}}},bt=e=>{const t=Z({options:e,axisType:u.X}),a=Z({options:e,axisType:u.Y});return{x:t,y:a}},ft=(e,t)=>{const{data:a,options:r}=e,{interactions:s,chartStyling:n}=r,[o,x]=ye.useState(!1),{legend:S,customLegendPlugin:C,legendClick:T}=et({chartRef:t,options:r}),{state:p}=tt(),{annotation:b}=p,f=(c=>c.map((l,R)=>{const{borderWidth:E=st}=l??{},_e=parseFloat(String(E))||1,q=Me[R],We=l.borderColor??q,Be=l.backgroundColor??q;return{...l,borderWidth:_e,borderColor:We,backgroundColor:Be}}))(a.datasets),w=(c,l,R)=>{R.resetZoom()},y=(c,l)=>{if(o&&!(l!=null&&l.length)&&(x(!1),s.onUnhover&&s.onUnhover(c)),!o&&(l!=null&&l.length)&&(x(!0),s.onHover)){const{index:R,datasetIndex:E}=l[0];s.onHover(c,E,R,f)}},M={onClick:w,onHover:y,...n,interactions:{onLegendClick:T,onHover:y},scales:bt(e==null?void 0:e.options),animation:n.performanceMode?{duration:U.NO}:{duration:U.FAST,onComplete:s==null?void 0:s.onAnimationComplete},plugins:{legend:{...S,display:!1,events:[]},customLegendPlugin:C,title:je(r),annotation:at(b),chartAreaBorder:{borderColor:we},datalabels:{display:r.graph.showDataLabels},tooltip:mt(r)}};return{generatedDatasets:f,scatterOptions:M}};var d=(e=>(e[e.TopToBottom=0]="TopToBottom",e[e.BottomToTop=1]="BottomToTop",e[e.LeftToRight=2]="LeftToRight",e[e.RightToLeft=3]="RightToLeft",e[e.TopLeftToBottomRight=4]="TopLeftToBottomRight",e[e.BottomRightToTopLeft=5]="BottomRightToTopLeft",e[e.BottomLeftToTopRight=6]="BottomLeftToTopRight",e[e.TopRightToBottomLeft=7]="TopRightToBottomLeft",e))(d||{});const xt=e=>({display:(e==null?void 0:e.display)??!1,gradientColors:(e==null?void 0:e.gradientColors)??Pe,direction:(e==null?void 0:e.direction)??d.BottomLeftToTopRight}),Ct=e=>({width:(e==null?void 0:e.width)??z,height:(e==null?void 0:e.height)??z,maintainAspectRatio:(e==null?void 0:e.maintainAspectRatio)||!1,staticChartHeight:(e==null?void 0:e.staticChartHeight)||!1,performanceMode:(e==null?void 0:e.performanceMode)??!0,gradient:xt(e==null?void 0:e.gradient)}),Tt=e=>({enabled:(e==null?void 0:e.enabled)??!0,tooltips:(e==null?void 0:e.tooltips)??!0,showLabelsInTooltips:(e==null?void 0:e.showLabelsInTooltips)||!1,backgroundColor:(e==null?void 0:e.backgroundColor)||"#333",displayColors:(e==null?void 0:e.displayColors)||!1,scientificNotation:(e==null?void 0:e.scientificNotation)??!0}),pt=e=>({showMinorGridlines:(e==null?void 0:e.showMinorGridlines)??!1,showDataLabels:(e==null?void 0:e.showDataLabels)??!1}),St=e=>({display:(e==null?void 0:e.display)??!0,useDataset:(e==null?void 0:e.useDataset)||!1,position:(e==null?void 0:e.position)||Ie.BottomLeft,align:(e==null?void 0:e.align)||Ee.Center}),Lt=e=>({enableZoom:(e==null?void 0:e.enableZoom)||!1,enablePan:(e==null?void 0:e.enablePan)||!1}),yt=e=>({onLegendClick:e==null?void 0:e.onLegendClick,onHover:e==null?void 0:e.onHover,onUnhover:e==null?void 0:e.onUnhover,onAnimationComplete:e==null?void 0:e.onAnimationComplete}),Rt=e=>({labels:(e==null?void 0:e.labels)||[],datasets:(e==null?void 0:e.datasets)||[]}),Ot=e=>e?e.map(t=>({...t,display:(t==null?void 0:t.display)??!0})):[],_t=e=>({showAnnotations:(e==null?void 0:e.showAnnotations)??!0,controlAnnotation:(e==null?void 0:e.controlAnnotation)||!1,annotationsData:Ot(e==null?void 0:e.annotationsData)}),Wt=e=>({x:(e==null?void 0:e.x)||[{}],y:(e==null?void 0:e.y)||[{}]}),Bt=e=>({reverse:(e==null?void 0:e.reverse)||!1,stacked:(e==null?void 0:e.stacked)||!1,beginAtZero:(e==null?void 0:e.beginAtZero)??!0,stepSize:e==null?void 0:e.stepSize,suggestedMin:e==null?void 0:e.suggestedMin,suggestedMax:e==null?void 0:e.suggestedMax,min:e==null?void 0:e.min,max:e==null?void 0:e.max}),Re=e=>{const t=(e==null?void 0:e.chart)||{},a=(t==null?void 0:t.options)||{};return{testId:(t==null?void 0:t.testId)??null,data:Rt(t==null?void 0:t.data),options:{title:(a==null?void 0:a.title)||"",axes:Wt(a==null?void 0:a.axes),additionalAxesOptions:Bt(a==null?void 0:a.additionalAxesOptions),direction:(a==null?void 0:a.direction)||rt.VERTICAL,chartStyling:Ct(a==null?void 0:a.chartStyling),tooltip:Tt(a==null?void 0:a.tooltip),graph:pt(a==null?void 0:a.graph),legend:St(a==null?void 0:a.legend),annotations:_t(a==null?void 0:a.annotations),chartOptions:Lt(a==null?void 0:a.chartOptions),interactions:yt(a==null?void 0:a.interactions)}}},vt=(e,t)=>{switch(e){case d.TopToBottom:return[t.left,t.top,t.left,t.bottom];case d.BottomToTop:return[t.left,t.bottom,t.left,t.top];case d.LeftToRight:return[t.left,t.top,t.right,t.top];case d.RightToLeft:return[t.right,t.top,t.left,t.top];case d.TopLeftToBottomRight:return[t.left,t.top,t.right,t.bottom];case d.BottomRightToTopLeft:return[t.right,t.bottom,t.left,t.top];case d.BottomLeftToTopRight:return[t.left,t.bottom,t.right,t.top];case d.TopRightToBottomLeft:return[t.right,t.top,t.left,t.bottom];default:return[t.left,t.bottom,t.right,t.top]}},At={id:"gradientBackgroundPlugin",beforeDraw:e=>{const{ctx:t,chartArea:a,options:r}=e,s=r.gradient,{display:n=!1,gradientColors:o,direction:x=d.BottomLeftToTopRight}=s??{};if(!n||!o||o.length===0)return;const[S,C,T,p]=vt(x,a),b=t.createLinearGradient(S,C,T,p);o.forEach(({offset:L,color:f})=>{b.addColorStop(L,f)}),t.save(),t.globalCompositeOperation="destination-over",t.fillStyle=b,t.fillRect(a.left,a.top,a.right-a.left,a.bottom-a.top),t.restore()}},kt="_chart_1qlu1_1",Dt="_canvas_1qlu1_11",Ht="_fixedHeight_1qlu1_20",jt="_stretchHeight_1qlu1_26",wt="_squareAspectRatio_1qlu1_32",Y={chart:kt,canvas:Dt,fixedHeight:Ht,stretchHeight:jt,squareAspectRatio:wt};Ze.register(Ye,Xe,$e,Ve,Je,Ke,Qe,Ge,dt,At);const Mt=e=>{qe();const t=ye.useRef(null),a=Re(e),{options:r,testId:s}=a,{scatterOptions:n,generatedDatasets:o}=ft(a,t);return g.jsx("div",{className:Ue(r.chartStyling,Y),style:{width:r.chartStyling.width,height:r.chartStyling.height},"data-testid":s,children:g.jsx(lt,{backend:ot,context:window,children:g.jsxs("div",{className:Y.canvas,id:"canvas",children:[g.jsx(ze,{ref:t,data:{datasets:o},options:n,plugins:Fe(r.graph,r.legend)}),!!o.length&&g.jsx(nt,{chartRef:t,legendConfig:{options:r,generatedDatasets:o,chartType:ct.SCATTER}})]})})})},I=e=>{const{options:t}=Re(e);return g.jsx(Ne,{options:t,children:g.jsx(Mt,{...e})})};I.__docgenInfo={description:"",methods:[],displayName:"ScatterChartWithLegend",props:{chart:{required:!0,tsType:{name:"IScatterChartData"},description:""},testId:{required:!1,tsType:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}]},description:""}}};const h=["label 1","label 2","label 3"],m={label:"Dataset 1",data:[{x:1,y:5},{x:3,y:7},{x:6,y:2},{x:8,y:6},{x:9,y:4}]},P={label:"Dataset 2",data:[{x:1,y:3},{x:4,y:5},{x:7,y:9},{x:10,y:2},{x:12,y:7}]},Et={label:"Dataset 3",data:[{x:2,y:8},{x:5,y:6},{x:8,y:10},{x:11,y:5},{x:14,y:9}]},Oe={label:"Dataset 4",data:[{x:2,y:8},{x:14,y:9}]},It={label:"Dataset 5",data:[{x:14,y:7,label:"Echo"},{x:3,y:18,label:"Lima"},{x:19,y:2,label:"Romeo"},{x:8,y:11,label:"Charlie"},{x:12,y:9,label:"Oscar"}]},Pt={label:"Dataset 6",data:[{x:15,y:3,label:"Hotel"},{x:9,y:14,label:"Tango"},{x:4,y:17,label:"Whiskey"},{x:11,y:7,label:"Juliet"},{x:13,y:1,label:"Zulu"}]},Nt={label:"Dataset Decimals",data:[{x:4.30021321123002,y:2.30021321123005},{x:5.12321321000003,y:3.23213210000037}]},N={data:{labels:h,datasets:[m]}},qt={data:{labels:h,datasets:[m]},options:{chartStyling:{height:300,width:700}}},Ut={data:{labels:h,datasets:[m,P,Et]}},zt={data:{labels:h,datasets:[m]},options:{title:"With Data Labels",graph:{showDataLabels:!0}}},Ft={data:{labels:h,datasets:[m,P,Nt]},options:{title:"With Tooltips",tooltip:{title:"Tooltip",showLabelsInTooltips:!0}}},Zt={data:{labels:h,datasets:[{...m,backgroundColor:"red",borderColor:"red"}]}},Yt={data:{labels:h,datasets:[m]},options:{title:"With Annotation",annotations:{showAnnotations:!0,annotationsData:[{annotationAxis:"y",label:"Horizontal Annotation",value:2.5,color:"rgba(96, 32, 196, 0.5)"}]}}},Xt={data:{labels:h,datasets:[m,P,Oe]},options:{title:"With Axes Labels",axes:{x:[{label:"x axis"}],y:[{label:"y axis"}]}}},$t={...N,options:{title:"With Gradient",chartStyling:{gradient:{display:!0}}}},Vt={data:{datasets:[It,Pt,Oe]},options:{title:"With datapoint label showing when hovered",tooltip:{showLabelsInTooltips:!0}}},ra={title:"ScatterChart",component:I,args:{chart:N}},i=e=>g.jsx(I,{...e}),O=i.bind({});O.args={chart:N};const _=i.bind({});_.args={chart:qt};const W=i.bind({});W.args={chart:Ut};const B=i.bind({});B.args={chart:zt};const v=i.bind({});v.args={chart:Ft};const A=i.bind({});A.args={chart:Yt};const k=i.bind({});k.args={chart:Xt};const D=i.bind({});D.args={chart:$t};const H=i.bind({});H.args={chart:Vt};const j=i.bind({});j.args={chart:Zt};var X,$,V;O.parameters={...O.parameters,docs:{...(X=O.parameters)==null?void 0:X.docs,source:{originalSource:`args => {
|
|
1
|
+
import{j as g}from"./jsx-runtime-Y5Ju2SGo.js";import{r as ye}from"./index-eCxJ45ll.js";import{d as ve,r as Ae,w as ke,x as u,S as De,y as He,z as je,B as we,f as U,C as Me,A as Ee,P as Ie,G as Pe,E as z,b as Ne,s as qe,F as Ue,H as ze,I as Fe,h as Ze,i as Ye,J as Xe,j as $e,p as Ve,m as Je,n as Ke,q as Qe,t as Ge}from"./legend-context-vqtlaWwg.js";import{u as et,j as tt,t as at,k as st,l as rt,m as lt,H as ot,L as nt,n as ct,o as dt}from"./legend-CD8XU7nW.js";import{D as it,a as ut}from"./bar-chart-const-Cgj9sgUU.js";import"./index-B-BONL6g.js";import"./index-BGqSdrBK.js";import"./index-D3-0uUTW.js";const F=(e,t)=>{let a={};return t?(Math.abs(e)<it||Math.abs(e)>ut)&&(a={roundScientificCoefficient:3}):a={scientific:!1},ve(Ae(e),a)},gt=(e,t)=>{var a;if((a=t==null?void 0:t.tooltip)!=null&&a.showLabelsInTooltips){const r=e[0],{label:s}=(r==null?void 0:r.dataset)??{};return s}},ht=(e,t)=>{var o;const{raw:a,dataset:r}=e??{},s=a==null?void 0:a.label,n=(o=t==null?void 0:t.tooltip)==null?void 0:o.scientificNotation;return`${s??(r==null?void 0:r.label)} ( x: ${F(a==null?void 0:a.x,n)} , y: ${F(a==null?void 0:a.y,n)} )`},mt=e=>{var t,a,r;return{enabled:(t=e==null?void 0:e.tooltip)==null?void 0:t.enabled,callbacks:{title:s=>gt(s,e),label:s=>ht(s,e)},backgroundColor:(a=e==null?void 0:e.tooltip)==null?void 0:a.backgroundColor,displayColors:(r=e==null?void 0:e.tooltip)==null?void 0:r.displayColors,padding:7}},Z=({options:e,axisType:t=u.X,currentScale:a})=>{var C,T,p,b,L,f,w,y,M;const r=ke(e.direction),s=a||((T=(C=e==null?void 0:e.axes)==null?void 0:C[t])==null?void 0:T[0]),n=r&&t===u.Y||!r&&t===u.X,o=(s==null?void 0:s.gridLines)||{},x=()=>{var l;const c=r?u.Y:u.X;return t===c?(l=e==null?void 0:e.additionalAxesOptions)==null?void 0:l.reverse:!1},S=()=>{const c=e==null?void 0:e.additionalAxesOptions;return{...{stepSize:(s==null?void 0:s.stepSize)??(t===u.Y?c==null?void 0:c.stepSize:void 0)},includeBounds:!1,font:{size:He}}};return{type:De.Linear,position:s==null?void 0:s.position,beginAtZero:(p=e==null?void 0:e.additionalAxesOptions)==null?void 0:p.beginAtZero,reverse:x(),suggestedMax:(b=e==null?void 0:e.additionalAxesOptions)==null?void 0:b.suggestedMax,suggestedMin:(L=e==null?void 0:e.additionalAxesOptions)==null?void 0:L.suggestedMin,min:n?(f=e==null?void 0:e.additionalAxesOptions)==null?void 0:f.min:void 0,max:n?(w=e==null?void 0:e.additionalAxesOptions)==null?void 0:w.max:void 0,title:{display:!!((y=s==null?void 0:s.label)!=null&&y.length)||!!((M=s==null?void 0:s.unit)!=null&&M.length),text:(s==null?void 0:s.label)||(s==null?void 0:s.unit),padding:0},ticks:S(),grid:{...o}}},bt=e=>{const t=Z({options:e,axisType:u.X}),a=Z({options:e,axisType:u.Y});return{x:t,y:a}},ft=(e,t)=>{const{data:a,options:r}=e,{interactions:s,chartStyling:n}=r,[o,x]=ye.useState(!1),{legend:S,customLegendPlugin:C,legendClick:T}=et({chartRef:t,options:r}),{state:p}=tt(),{annotation:b}=p,f=(c=>c.map((l,R)=>{const{borderWidth:E=st}=l??{},_e=parseFloat(String(E))||1,q=Me[R],We=l.borderColor??q,Be=l.backgroundColor??q;return{...l,borderWidth:_e,borderColor:We,backgroundColor:Be}}))(a.datasets),w=(c,l,R)=>{R.resetZoom()},y=(c,l)=>{if(o&&!(l!=null&&l.length)&&(x(!1),s.onUnhover&&s.onUnhover(c)),!o&&(l!=null&&l.length)&&(x(!0),s.onHover)){const{index:R,datasetIndex:E}=l[0];s.onHover(c,E,R,f)}},M={onClick:w,onHover:y,...n,interactions:{onLegendClick:T,onHover:y},scales:bt(e==null?void 0:e.options),animation:n.performanceMode?{duration:U.NO}:{duration:U.FAST,onComplete:s==null?void 0:s.onAnimationComplete},plugins:{legend:{...S,display:!1,events:[]},customLegendPlugin:C,title:je(r),annotation:at(b),chartAreaBorder:{borderColor:we},datalabels:{display:r.graph.showDataLabels},tooltip:mt(r)}};return{generatedDatasets:f,scatterOptions:M}};var d=(e=>(e[e.TopToBottom=0]="TopToBottom",e[e.BottomToTop=1]="BottomToTop",e[e.LeftToRight=2]="LeftToRight",e[e.RightToLeft=3]="RightToLeft",e[e.TopLeftToBottomRight=4]="TopLeftToBottomRight",e[e.BottomRightToTopLeft=5]="BottomRightToTopLeft",e[e.BottomLeftToTopRight=6]="BottomLeftToTopRight",e[e.TopRightToBottomLeft=7]="TopRightToBottomLeft",e))(d||{});const xt=e=>({display:(e==null?void 0:e.display)??!1,gradientColors:(e==null?void 0:e.gradientColors)??Pe,direction:(e==null?void 0:e.direction)??d.BottomLeftToTopRight}),Ct=e=>({width:(e==null?void 0:e.width)??z,height:(e==null?void 0:e.height)??z,maintainAspectRatio:(e==null?void 0:e.maintainAspectRatio)||!1,staticChartHeight:(e==null?void 0:e.staticChartHeight)||!1,performanceMode:(e==null?void 0:e.performanceMode)??!0,gradient:xt(e==null?void 0:e.gradient)}),Tt=e=>({enabled:(e==null?void 0:e.enabled)??!0,tooltips:(e==null?void 0:e.tooltips)??!0,showLabelsInTooltips:(e==null?void 0:e.showLabelsInTooltips)||!1,backgroundColor:(e==null?void 0:e.backgroundColor)||"#333",displayColors:(e==null?void 0:e.displayColors)||!1,scientificNotation:(e==null?void 0:e.scientificNotation)??!0}),pt=e=>({showMinorGridlines:(e==null?void 0:e.showMinorGridlines)??!1,showDataLabels:(e==null?void 0:e.showDataLabels)??!1}),St=e=>({display:(e==null?void 0:e.display)??!0,useDataset:(e==null?void 0:e.useDataset)||!1,position:(e==null?void 0:e.position)||Ie.BottomLeft,align:(e==null?void 0:e.align)||Ee.Center}),Lt=e=>({enableZoom:(e==null?void 0:e.enableZoom)||!1,enablePan:(e==null?void 0:e.enablePan)||!1}),yt=e=>({onLegendClick:e==null?void 0:e.onLegendClick,onHover:e==null?void 0:e.onHover,onUnhover:e==null?void 0:e.onUnhover,onAnimationComplete:e==null?void 0:e.onAnimationComplete}),Rt=e=>({labels:(e==null?void 0:e.labels)||[],datasets:(e==null?void 0:e.datasets)||[]}),Ot=e=>e?e.map(t=>({...t,display:(t==null?void 0:t.display)??!0})):[],_t=e=>({showAnnotations:(e==null?void 0:e.showAnnotations)??!0,controlAnnotation:(e==null?void 0:e.controlAnnotation)||!1,annotationsData:Ot(e==null?void 0:e.annotationsData)}),Wt=e=>({x:(e==null?void 0:e.x)||[{}],y:(e==null?void 0:e.y)||[{}]}),Bt=e=>({reverse:(e==null?void 0:e.reverse)||!1,stacked:(e==null?void 0:e.stacked)||!1,beginAtZero:(e==null?void 0:e.beginAtZero)??!0,stepSize:e==null?void 0:e.stepSize,suggestedMin:e==null?void 0:e.suggestedMin,suggestedMax:e==null?void 0:e.suggestedMax,min:e==null?void 0:e.min,max:e==null?void 0:e.max}),Re=e=>{const t=(e==null?void 0:e.chart)||{},a=(t==null?void 0:t.options)||{};return{testId:(t==null?void 0:t.testId)??null,data:Rt(t==null?void 0:t.data),options:{title:(a==null?void 0:a.title)||"",axes:Wt(a==null?void 0:a.axes),additionalAxesOptions:Bt(a==null?void 0:a.additionalAxesOptions),direction:(a==null?void 0:a.direction)||rt.VERTICAL,chartStyling:Ct(a==null?void 0:a.chartStyling),tooltip:Tt(a==null?void 0:a.tooltip),graph:pt(a==null?void 0:a.graph),legend:St(a==null?void 0:a.legend),annotations:_t(a==null?void 0:a.annotations),chartOptions:Lt(a==null?void 0:a.chartOptions),interactions:yt(a==null?void 0:a.interactions)}}},vt=(e,t)=>{switch(e){case d.TopToBottom:return[t.left,t.top,t.left,t.bottom];case d.BottomToTop:return[t.left,t.bottom,t.left,t.top];case d.LeftToRight:return[t.left,t.top,t.right,t.top];case d.RightToLeft:return[t.right,t.top,t.left,t.top];case d.TopLeftToBottomRight:return[t.left,t.top,t.right,t.bottom];case d.BottomRightToTopLeft:return[t.right,t.bottom,t.left,t.top];case d.BottomLeftToTopRight:return[t.left,t.bottom,t.right,t.top];case d.TopRightToBottomLeft:return[t.right,t.top,t.left,t.bottom];default:return[t.left,t.bottom,t.right,t.top]}},At={id:"gradientBackgroundPlugin",beforeDraw:e=>{const{ctx:t,chartArea:a,options:r}=e,s=r.gradient,{display:n=!1,gradientColors:o,direction:x=d.BottomLeftToTopRight}=s??{};if(!n||!o||o.length===0)return;const[S,C,T,p]=vt(x,a),b=t.createLinearGradient(S,C,T,p);o.forEach(({offset:L,color:f})=>{b.addColorStop(L,f)}),t.save(),t.globalCompositeOperation="destination-over",t.fillStyle=b,t.fillRect(a.left,a.top,a.right-a.left,a.bottom-a.top),t.restore()}},kt="_chart_1qlu1_1",Dt="_canvas_1qlu1_11",Ht="_fixedHeight_1qlu1_20",jt="_stretchHeight_1qlu1_26",wt="_squareAspectRatio_1qlu1_32",Y={chart:kt,canvas:Dt,fixedHeight:Ht,stretchHeight:jt,squareAspectRatio:wt};Ze.register(Ye,Xe,$e,Ve,Je,Ke,Qe,Ge,dt,At);const Mt=e=>{qe();const t=ye.useRef(null),a=Re(e),{options:r,testId:s}=a,{scatterOptions:n,generatedDatasets:o}=ft(a,t);return g.jsx("div",{className:Ue(r.chartStyling,Y),style:{width:r.chartStyling.width,height:r.chartStyling.height},"data-testid":s,children:g.jsx(lt,{backend:ot,context:window,children:g.jsxs("div",{className:Y.canvas,id:"canvas",children:[g.jsx(ze,{ref:t,data:{datasets:o},options:n,plugins:Fe(r.graph,r.legend)}),!!o.length&&g.jsx(nt,{chartRef:t,legendConfig:{options:r,generatedDatasets:o,chartType:ct.SCATTER}})]})})})},I=e=>{const{options:t}=Re(e);return g.jsx(Ne,{options:t,children:g.jsx(Mt,{...e})})};I.__docgenInfo={description:"",methods:[],displayName:"ScatterChartWithLegend",props:{chart:{required:!0,tsType:{name:"IScatterChartData"},description:""},testId:{required:!1,tsType:{name:"union",raw:"string | null",elements:[{name:"string"},{name:"null"}]},description:""}}};const h=["label 1","label 2","label 3"],m={label:"Dataset 1",data:[{x:1,y:5},{x:3,y:7},{x:6,y:2},{x:8,y:6},{x:9,y:4}]},P={label:"Dataset 2",data:[{x:1,y:3},{x:4,y:5},{x:7,y:9},{x:10,y:2},{x:12,y:7}]},Et={label:"Dataset 3",data:[{x:2,y:8},{x:5,y:6},{x:8,y:10},{x:11,y:5},{x:14,y:9}]},Oe={label:"Dataset 4",data:[{x:2,y:8},{x:14,y:9}]},It={label:"Dataset 5",data:[{x:14,y:7,label:"Echo"},{x:3,y:18,label:"Lima"},{x:19,y:2,label:"Romeo"},{x:8,y:11,label:"Charlie"},{x:12,y:9,label:"Oscar"}]},Pt={label:"Dataset 6",data:[{x:15,y:3,label:"Hotel"},{x:9,y:14,label:"Tango"},{x:4,y:17,label:"Whiskey"},{x:11,y:7,label:"Juliet"},{x:13,y:1,label:"Zulu"}]},Nt={label:"Dataset Decimals",data:[{x:4.30021321123002,y:2.30021321123005},{x:5.12321321000003,y:3.23213210000037}]},N={data:{labels:h,datasets:[m]}},qt={data:{labels:h,datasets:[m]},options:{chartStyling:{height:300,width:700}}},Ut={data:{labels:h,datasets:[m,P,Et]}},zt={data:{labels:h,datasets:[m]},options:{title:"With Data Labels",graph:{showDataLabels:!0}}},Ft={data:{labels:h,datasets:[m,P,Nt]},options:{title:"With Tooltips",tooltip:{title:"Tooltip",showLabelsInTooltips:!0}}},Zt={data:{labels:h,datasets:[{...m,backgroundColor:"red",borderColor:"red"}]}},Yt={data:{labels:h,datasets:[m]},options:{title:"With Annotation",annotations:{showAnnotations:!0,annotationsData:[{annotationAxis:"y",label:"Horizontal Annotation",value:2.5,color:"rgba(96, 32, 196, 0.5)"}]}}},Xt={data:{labels:h,datasets:[m,P,Oe]},options:{title:"With Axes Labels",axes:{x:[{label:"x axis"}],y:[{label:"y axis"}]}}},$t={...N,options:{title:"With Gradient",chartStyling:{gradient:{display:!0}}}},Vt={data:{datasets:[It,Pt,Oe]},options:{title:"With datapoint label showing when hovered",tooltip:{showLabelsInTooltips:!0}}},ra={title:"ScatterChart",component:I,args:{chart:N}},i=e=>g.jsx(I,{...e}),O=i.bind({});O.args={chart:N};const _=i.bind({});_.args={chart:qt};const W=i.bind({});W.args={chart:Ut};const B=i.bind({});B.args={chart:zt};const v=i.bind({});v.args={chart:Ft};const A=i.bind({});A.args={chart:Yt};const k=i.bind({});k.args={chart:Xt};const D=i.bind({});D.args={chart:$t};const H=i.bind({});H.args={chart:Vt};const j=i.bind({});j.args={chart:Zt};var X,$,V;O.parameters={...O.parameters,docs:{...(X=O.parameters)==null?void 0:X.docs,source:{originalSource:`args => {
|
|
2
2
|
return <ScatterChart
|
|
3
3
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
4
4
|
{...args} />;
|