Logo
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

NameTypeDescription
dataPointsList<DataPoint>List of label and numeric value pairs

DataPoint

FieldTypeDescription
labelstringDisplayed on X-axis
valuefloatY value for the point
tableKey (optional)stringLocalization key when using EVO_LOCALIZATION

Layout Settings

NameTypeDescription
paddingRectOffsetInner padding used to calculate graph area
labelPaddingfloatDistance between X labels and X-axis
valuePaddingfloatDistance between Y-axis values and Y-axis
lineThicknessfloatThickness of the connecting line
horizontalGridLinesintNumber of horizontal divisions
verticalGridLinesintNumber of vertical divisions
gridLineThicknessfloatThickness of grid lines
pointSizefloatSize of point markers
pointSpriteSpriteCustom sprite for points (optional)

Styling

NameTypeDescription
stylingSourceStylingSourceDetermines how fonts and colors are resolved
stylerPresetStylerPresetPreset used when stylingSource is StylerPreset
lineColorColorMappingColor used for data line
pointColorColorMappingColor used for point markers
gridColorColorMappingColor for grid lines
axisColorColorMappingX and Y axis lines
labelColorColorMappingColor for X and Y labels
labelFontFontMappingFont used for label text
labelFontSizefloatSize of label text

Public Methods

NameParametersDescription
DrawChart()NoneRebuilds and redraws the entire chart
AddDataPoint(label, value)string, floatAdds a new entry and redraws
RemoveDataPoint(index)intRemoves an entry
ClearData()NoneClears all entries
SetDataPoint(index, label, value)int, string, floatUpdates an entry by index
SetDataPoint(target, label, value)DataPoint, string, floatUpdates a specific DataPoint
SetPointSprite(sprite)SpriteUpdates point sprite
SetPointSize(newSize)floatSets new point size

Code Example

LineChartExample.cs
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();
    }
}

On this page