@oliasoft-open-source/charts-library 5.0.6 → 5.0.8-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-BZV55NoA.js → Color-YHDXOIA2-CdwL15G5.js} +1 -1
- package/dist/assets/{DocsRenderer-CFRXHY34-bjwBB41e.js → DocsRenderer-CFRXHY34-Dg2X56DC.js} +3 -3
- package/dist/assets/{bar-chart.stories-B3Mw3oSh.js → bar-chart.stories-CMHZnlP4.js} +1 -1
- package/dist/assets/{entry-preview-Fnu4Axk-.js → entry-preview-Dk_wWDkt.js} +1 -1
- package/dist/assets/get-draggableData-Dccb4oAz.js +2 -0
- package/dist/assets/{iframe-BCkdTAel.js → iframe-BAfMmzoz.js} +2 -2
- package/dist/assets/{legend-CD8XU7nW.js → legend-Dl2DUlTl.js} +1 -1
- package/dist/assets/{legend-context-vqtlaWwg.js → legend-context-CUxjGljk.js} +19 -19
- package/dist/assets/line-chart-BvC78NXq.js +1 -0
- package/dist/assets/{line-chart.stories-BVDmKaAF.js → line-chart.stories-DNpxHMyZ.js} +1 -1
- package/dist/assets/line-chart.test-case.stories-iWaQFA2t.js +430 -0
- package/dist/assets/{pie-chart.stories-BiFagB5b.js → pie-chart.stories-DQH7bOja.js} +1 -1
- package/dist/assets/{preview-BMg4pO3m.js → preview-CfXyMlir.js} +2 -2
- package/dist/assets/{preview-CoPVovTG.js → preview-CsgyCU-7.js} +1 -1
- package/dist/assets/{scatter-chart.stories-Cuu-Wd2A.js → scatter-chart.stories-CM6nYYvv.js} +1 -1
- package/dist/common/helpers/chart-utils.d.ts +1 -0
- package/dist/common/helpers/download-pgn.d.ts +1 -2
- package/dist/iframe.html +1 -1
- package/dist/index.js.js +105 -59
- package/dist/index.js.js.map +1 -1
- package/dist/index.json +1 -1
- package/dist/line-chart/plugins/tooltip-null-guard.d.ts +2 -0
- package/dist/line-chart/utils/get-axes-data-from-metasets.d.ts +1 -1
- package/dist/project.json +1 -1
- package/dist/src/components/line-chart/plugins/tooltip-null-guard.d.ts +2 -0
- package/dist/src/components/line-chart/utils/get-axes-data-from-metasets.d.ts +1 -1
- package/package.json +2 -2
- package/dist/assets/get-draggableData-1N6iP-hc.js +0 -2
- package/dist/assets/line-chart-B-yjnfON.js +0 -1
- package/dist/assets/line-chart.test-case.stories-CdIDC-oO.js +0 -428
|
@@ -1,428 +0,0 @@
|
|
|
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-B-yjnfON.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-1N6iP-hc.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};
|