MCPcopy Index your code
hub / github.com/ChartGPU/ChartGPU / main

Function main

examples/interactive/main.ts:150–238  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

148};
149
150async function main(): Promise<void> {
151 const containerTop = document.querySelector('#chart-top');
152 const containerBottom = document.querySelector('#chart-bottom');
153 if (!(containerTop instanceof HTMLElement) || !(containerBottom instanceof HTMLElement)) {
154 throw new Error('Chart containers not found');
155 }
156
157 // Time-series data (epoch-ms), sorted increasing by construction.
158 const now = Date.now();
159 const startMs = now - 1000 * 60 * 60 * 24 * 14; // 14 days back
160 const count = 800;
161 const stepMs = 1000 * 60 * 30; // 30 minutes
162
163 const topA = createTimeSeries(count, {
164 startMs,
165 stepMs,
166 fn: (i) => {
167 const t = i / (count - 1);
168 const season = Math.sin(t * Math.PI * 8);
169 const trend = t * 1.2;
170 return 40 + 12 * season + 18 * trend;
171 },
172 });
173
174 const topB = createTimeSeries(count, {
175 startMs,
176 stepMs,
177 fn: (i) => {
178 const t = i / (count - 1);
179 const season = Math.cos(t * Math.PI * 6 + 0.7);
180 const spikes = Math.max(0, Math.sin(t * Math.PI * 18)) * 10;
181 return 30 + 10 * season + spikes + t * 10;
182 },
183 });
184
185 const botA = createTimeSeries(count, {
186 startMs,
187 stepMs,
188 fn: (i) => {
189 const t = i / (count - 1);
190 const wobble = Math.sin(t * Math.PI * 10) * Math.cos(t * Math.PI * 3);
191 return 120 + 35 * wobble - t * 20;
192 },
193 });
194
195 const botB = createTimeSeries(count, {
196 startMs,
197 stepMs,
198 fn: (i) => {
199 const t = i / (count - 1);
200 const slow = Math.sin(t * Math.PI * 2.5 + 1.1);
201 const accel = Math.pow(t, 2) * 25;
202 return 95 + 22 * slow + accel;
203 },
204 });
205
206 const chartTop = await ChartGPU.create(
207 containerTop,

Callers 1

main.tsFile · 0.70

Calls 8

connectChartsFunction · 0.85
createMethod · 0.80
createTimeSeriesFunction · 0.70
createOptionsFunction · 0.70
onMethod · 0.65
resizeMethod · 0.65
disposeMethod · 0.65

Tested by

no test coverage detected