()
| 60 | }; |
| 61 | |
| 62 | async function main() { |
| 63 | const container = document.getElementById('chart'); |
| 64 | if (!container) { |
| 65 | throw new Error('Chart container not found'); |
| 66 | } |
| 67 | |
| 68 | const xMin = 0; |
| 69 | const xMax = 100; |
| 70 | const yMin = 0; |
| 71 | const yMax = 100; |
| 72 | |
| 73 | // Total points: ~10k (split across series). |
| 74 | const fixed = createPoints(4500, 1, { xMin, xMax, yMin, yMax }); |
| 75 | const perPointSize = createPoints(4500, 2, { |
| 76 | xMin, |
| 77 | xMax, |
| 78 | yMin, |
| 79 | yMax, |
| 80 | includeSize: true, |
| 81 | sizeMin: 1.25, |
| 82 | sizeMax: 7.5, |
| 83 | }); |
| 84 | const functionSize = createPoints(1000, 3, { xMin, xMax, yMin, yMax }); |
| 85 | |
| 86 | const options: ChartGPUOptions = { |
| 87 | grid: { left: 70, right: 24, top: 24, bottom: 56 }, |
| 88 | xAxis: { type: 'value', min: xMin, max: xMax, name: 'X' }, |
| 89 | yAxis: { type: 'value', min: yMin, max: yMax, name: 'Y' }, |
| 90 | palette: ['#4a9eff', '#ff4ab0', '#40d17c'], |
| 91 | animation: { duration: 900, easing: 'cubicOut', delay: 0 }, |
| 92 | series: [ |
| 93 | { |
| 94 | type: 'scatter', |
| 95 | name: 'fixed symbolSize (3)', |
| 96 | data: fixed, |
| 97 | symbolSize: 3, |
| 98 | color: '#4a9eff', |
| 99 | }, |
| 100 | { |
| 101 | type: 'scatter', |
| 102 | name: 'per-point size ([x,y,size])', |
| 103 | data: perPointSize, |
| 104 | // This is a fallback; per-point `size` takes precedence when present. |
| 105 | symbolSize: 2, |
| 106 | color: '#ff4ab0', |
| 107 | }, |
| 108 | { |
| 109 | type: 'scatter', |
| 110 | name: 'symbolSize function', |
| 111 | data: functionSize, |
| 112 | symbolSize: ([x]) => 1.5 + 4 * Math.abs(Math.sin(x * 0.12)), |
| 113 | color: '#40d17c', |
| 114 | }, |
| 115 | ], |
| 116 | }; |
| 117 | |
| 118 | const chart = await ChartGPU.create(container, options); |
| 119 |
no test coverage detected