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

Function createChart

examples/worker-rendering/main.ts:369–417  ·  view source on GitHub ↗
(
  mode: RenderMode,
  dataType: DataType,
  data: DataPoint[] | OHLCDataPoint[]
)

Source from the content-addressed store, hash-verified

367// ============================================================================
368
369async function createChart(
370 mode: RenderMode,
371 dataType: DataType,
372 data: DataPoint[] | OHLCDataPoint[]
373): Promise<ChartGPUInstance> {
374 const container = document.getElementById('chart');
375 if (!container) {
376 throw new Error('Chart container not found');
377 }
378
379 const options: ChartGPUOptions = {
380 grid: { left: 60, right: 24, top: 24, bottom: 60 }, // Increased bottom for slider
381 xAxis: { type: 'value', name: 'Index' },
382 yAxis: { type: 'value', name: 'Value' },
383 palette: ['#06b6d4', '#6366f1', '#10b981', '#f59e0b', '#ef4444'],
384 animation: false, // Disable for performance
385 dataZoom: [
386 {
387 type: 'inside',
388 xAxisIndex: 0,
389 start: 0,
390 end: 100,
391 },
392 {
393 type: 'slider',
394 xAxisIndex: 0,
395 start: 0,
396 end: 100,
397 },
398 ],
399 series: [
400 {
401 type: dataType === 'candlestick' ? 'candlestick' : dataType,
402 name: `${dataType} series`,
403 data: data as any,
404 color: '#06b6d4',
405 lineStyle: dataType === 'line' ? { width: 1.5, opacity: 0.9 } : undefined,
406 sampling: 'lttb',
407 samplingThreshold: 5000,
408 } as any,
409 ],
410 };
411
412 if (mode === 'worker') {
413 return await ChartGPU.createInWorker(container, options);
414 } else {
415 return await ChartGPU.create(container, options);
416 }
417}
418
419function disposeChart(): void {
420 // Clean up performance subscription

Callers 1

handleGenerateFunction · 0.70

Calls 1

createMethod · 0.80

Tested by

no test coverage detected