UI Elements
Line Chart
A fully dynamic line chart
Overview
Line Chart renders a series of numeric data points and connects them using lines. It supports custom styling through the Styler system.
At runtime or in the editor, the chart rebuilds itself whenever data changes or when the RectTransform size updates. All visible elements are generated dynamically.
Properties
Data
| Name | Type | Description |
|---|---|---|
dataPoints | List<DataPoint> | List of label and numeric value pairs |
DataPoint
| Field | Type | Description |
|---|---|---|
label | string | Displayed on X-axis |
value | float | Y value for the point |
tableKey (optional) | string | Localization key when using EVO_LOCALIZATION |
Layout Settings
| Name | Type | Description |
|---|---|---|
padding | RectOffset | Inner padding used to calculate graph area |
labelPadding | float | Distance between X labels and X-axis |
valuePadding | float | Distance between Y-axis values and Y-axis |
lineThickness | float | Thickness of the connecting line |
horizontalGridLines | int | Number of horizontal divisions |
verticalGridLines | int | Number of vertical divisions |
gridLineThickness | float | Thickness of grid lines |
pointSize | float | Size of point markers |
pointSprite | Sprite | Custom sprite for points (optional) |
Styling
| Name | Type | Description |
|---|---|---|
stylingSource | StylingSource | Determines how fonts and colors are resolved |
stylerPreset | StylerPreset | Preset used when stylingSource is StylerPreset |
lineColor | ColorMapping | Color used for data line |
pointColor | ColorMapping | Color used for point markers |
gridColor | ColorMapping | Color for grid lines |
axisColor | ColorMapping | X and Y axis lines |
labelColor | ColorMapping | Color for X and Y labels |
labelFont | FontMapping | Font used for label text |
labelFontSize | float | Size of label text |
Public Methods
| Name | Parameters | Description |
|---|---|---|
DrawChart() | None | Rebuilds and redraws the entire chart |
AddDataPoint(label, value) | string, float | Adds a new entry and redraws |
RemoveDataPoint(index) | int | Removes an entry |
ClearData() | None | Clears all entries |
SetDataPoint(index, label, value) | int, string, float | Updates an entry by index |
SetDataPoint(target, label, value) | DataPoint, string, float | Updates a specific DataPoint |
SetPointSprite(sprite) | Sprite | Updates point sprite |
SetPointSize(newSize) | float | Sets new point size |
Code Example
using UnityEngine;
using Evo.UI;
public class LineChartExample : MonoBehaviour
{
public LineChart chart;
void Start()
{
// Add data
chart.AddDataPoint("January", 40);
chart.AddDataPoint("February", 60);
chart.AddDataPoint("March", 20);
// Update existing point
chart.SetDataPoint(1, "February", 75);
// Replace point sprite
chart.SetPointSprite(customSprite);
// Change point size
chart.SetPointSize(16);
// Redraw chart
chart.DrawChart();
}
}