Data mapping
SwiftChart accepts data in three forms. Pick whichever matches the shape you already have — no transformation required.
1. Auto-detect
chart.setData([ { month: 'Jan', sales: 420, cost: 280 }, { month: 'Feb', sales: 510, cost: 320 },]);The first string field becomes the X axis. All number fields become series.
2. Explicit mapping
chart.setData(data, { x: 'timestamp', y: ['metric_a', 'metric_b'], seriesNames: ['CPU', 'Memory'],});Use this when your X field isn’t a string, or when you want to pick specific Y fields.
3. Pre-built { labels, datasets }
chart.setData([], { labels: ['Q1', 'Q2', 'Q3'], datasets: [{ label: 'Revenue', data: [100, 200, 350] }],});The escape hatch — useful when migrating from Chart.js or building data on the fly.
See DataMapping and ResolvedData in the Core API reference.