UGTK cat mascotUGTKengine within an engine Request access

UGTK / Toolkit / Gameplay Systems / Line Chart (3D) Completed

Gameplay Systems — UGTK

Line Chart

Summary

Builds a uGUI line chart at edit-time or runtime: axis grid, dashed gridlines, axis labels (TextMeshPro) and coloured data lines with points, all generated as Image/TextMeshProUGUI children of a RectTransform.

Note: a separate, larger Mn_LineChart also exists under UIModule/LineChart (925 lines, namespaced). This GameplaySystems version is a distinct, simpler implementation (~547 lines, no namespace) — not the same file.


Content


Modules Dependencies

This module has no hard UGTK dependencies. It relies on Unity uGUI (UnityEngine.UI.Image) and TextMeshPro (TMPro) for axis labels.


Setup

Add Mn_LineChart to a UI RectTransform (under a Canvas), fill the vertical/horizontal axis lists and the line data, then press Generate Chart in the Inspector (custom editor) or call GenerateChart().


How To Use


Testing Scene

Open LineChart in the module's Debug/ folder and select Canvas > LineChart Scroll > Content. Everything happens with the editor stopped: change a value, press Generate Chart, and the Game view redraws.

What to do, in order:

  1. Press Generate Chart with the sample data, then change Line Thickness and Point Size and press it again: the whole plot is rebuilt from the serialized lists, so nothing is cached between one press and the next.
  2. Feed it a single point, then two points with the same X.
  3. Feed it values that are all identical.
  4. Feed it a few hundred points.

Steps 2 and 3 are the degenerate cases every chart gets wrong at least once: a single point has no line to draw, and a flat series has zero range, which is a division by zero waiting to happen when the axis is scaled.


Technical Info


© 2026 Marcello De Bonis. All rights reserved