UGTK / Toolkit / Ui Module / Line Chart System Completed
Line Chart
Summary
The Line Chart UI module provides a reusable UGUI chart with auto-managed ScrollRect,
grid lines, axis labels, and multi-series data visualization.
Content
Modules Dependencies
- TextMeshPro: the axis labels and the point tooltips are TMP text.
The chart draws its lines with Unity UI, so it lives on a Canvas like any other UI element. Nothing else in UGTK is required.
Setup
- Add
Mn_LineChartGridto an empty UI GameObject. - Press Build / Repair to auto-create the ScrollRect hierarchy.
- Configure axes, grid, and data in the Inspector.
How To Use
- Axes:
- X Axis supports category list, date range, or pattern generator.
- Y Axis supports label list or numeric range.
- Layout is fixed to match the paint style: X labels bottom, Y labels left.
- Labels are outside the grid and stay visible.
- Data:
- Use a
SO_LineChartDatasetfor multi-series data (recommended), or edit the local data on the component. - Visualization:
- Lines, Bars, or Area fill (per component).
- Optional markers per series.
- Toggle grid rendering with
showGrid. - Axis lines stay visible with
showAxes.
Minimal runtime usage:
// Add points (series 0)
chart.AddItem(0, 0, 2); // discrete
chart.AddItem(0, 1, 42.5f); // numeric
chart.RefreshData();
Testing Scene
Open LineChartScene in the module's Debug/ folder and select Canvas > LineChart. The
inspector is a small spreadsheet: a Data table of labels and series, and a Chart
configuration block with a tick per series. Everything redraws with the editor stopped.
What to do, in order:
- Untick a series under Visible series: its line disappears from the plot and the axis rescales to what is left.
- Edit a cell in the table. The point moves as soon as you press Enter.
- Press + Add Row and give the new row a label.
- Feed a single point, and then two points sharing the same X.
- Feed a series where every value is identical.
- Feed several hundred points.
Steps 4 and 5 are the degenerate cases: one point has no line, and a flat series has zero range, which is a division by zero the moment the axis is scaled to fit.
Technical Info
Scripts:
- Mn_LineChartGrid: Main controller (auto-builds UGUI + renders chart).
- SO_LineChartDataset: ScriptableObject dataset with multi-series points.
- LineChartAxisSettings: Axis label providers and settings.
- Mn_LineChartAreaFill: UGUI mesh fill for area mode.
© 2026 Marcello De Bonis. All rights reserved
© 2026 Marcello De Bonis. All rights reserved
UGTKengine within an engine


