UGTK / Toolkit / UIModule / Line Chart
Line Chart Module
Summary
The Line Chart module provides a Canva-like line chart with static layout (no ScrollRect), pan/zoom support, and a custom inspector with data table editor.
Setup
- Add
Mn_LineChartcomponent to an empty UI GameObject. - The component will auto-create the hierarchy on first use.
- Assign or create a
SO_LineChartDataasset. - Use the custom inspector tabs to edit data and customize.
Quick Start
Create Sample Data:
- Menu: UGTK/LineChart/Create Sample Data (Canva Example)
- Creates a dataset with Lun..Dom labels and 3 series
Add Chart to Scene:
1. Create empty GameObject under Canvas
2. Add Mn_LineChart component
3. In Inspector → "Dati" tab → Click "Crea Dataset" if needed
4. Assign the dataset
5. Chart auto-rebuilds
Inspector Tabs
Dati Tab: - Data table: Edit X labels and series values - Add/remove series and rows - Toggle series visibility - Live preview updates
Personalizza Tab: - Plot size, gutter size - Grid/axis settings - Point size, line thickness - Y axis range (auto or manual)
Runtime API
// Add point
chart.AddItem(xIndex, yValue, seriesIndex);
// Update point
chart.UpdateItem(xIndex, yValue, seriesIndex);
// Remove point
chart.RemoveItem(xIndex, seriesIndex);
// Set axes
chart.SetAxes(xLabels, yMin, yMax);
// Rebuild
chart.RebuildAll();
Features
- Static Layout: No ScrollRect, chart stays in place
- Pan/Zoom: Drag to pan, scroll wheel to zoom (optional)
- Live Updates: Editor and runtime changes update instantly
- Multiple Series: Support for multiple data series with colors
- Tooltips: Hover/click points to see values
- Auto Range: Y axis auto-calculates from data
File Structure
Runtime:
- Mn_LineChart.cs - Main controller
- SO_LineChartData.cs - Data asset
- Mn_LineChartPoint.cs - Point interaction
- Mn_LineChartTooltip.cs - Tooltip display
- Mn_LineChartPanZoom.cs - Pan/zoom handler
- LineChartPool.cs - Object pooling
Editor:
- Mn_LineChartEditor.cs - Canva-like custom inspector
- LineChartSampleData.cs - Sample data generator
© 2026 Marcello De Bonis. All rights reserved
UGTKengine within an engine