UGTK cat mascotUGTKengine within an engine Request access

UGTK / Toolkit / Ui Module / Line Chart System Completed

Ui Module — UGTK

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

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

  1. Add Mn_LineChartGrid to an empty UI GameObject.
  2. Press Build / Repair to auto-create the ScrollRect hierarchy.
  3. Configure axes, grid, and data in the Inspector.

How To Use

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:

  1. Untick a series under Visible series: its line disappears from the plot and the axis rescales to what is left.
  2. Edit a cell in the table. The point moves as soon as you press Enter.
  3. Press + Add Row and give the new row a label.
  4. Feed a single point, and then two points sharing the same X.
  5. Feed a series where every value is identical.
  6. 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:


© 2026 Marcello De Bonis. All rights reserved


© 2026 Marcello De Bonis. All rights reserved