Logo
UI Elements

Line Chart

Show trends with straight or smooth curves and optional fill

Overview

Line Chart plots a sequence of labeled values. V2 adds smooth curves, a filled area beneath the line, automatic value ranges, and more control over labels.

Preview

Usage

Create a Line Chart and add data points in display order.

Choose Straight or Smooth Curve Mode.

Enable Auto Scale, or provide a manual Value Range.

Choose whether the range should include zero.


Customization

  • Enable Show Fill for an area chart and adjust the top and bottom fill opacity.
  • Curve Subdivisions controls smooth-curve detail.
  • Category and scale labels can be shown independently; use Label Rotation for crowded categories.

Public API

Use LineChart in the Evo.UI namespace.

Properties

Setting a property refreshes the chart. After editing dataPoints or a shape settings field directly, call DrawChart().

NameTypeDescription
AutoScaleboolUses the data range automatically. Disable to use Value Range.
ValueRangeVector2Minimum and maximum of the value axis while Auto Scale is disabled.
IncludeZeroboolIncludes zero in the automatically calculated range.
ScaleDivisionsintNumber of intervals on the numeric axis, from 1 to 50.
LineThicknessfloatData line width in local UI units, from 0 to 20.
CurveCurveModeConnects samples with straight lines or a smooth curve.
CurveSubdivisionsintMaximum subdivisions per smooth segment, from 2 to 32.
ShowFillboolDisplays the filled area under the line.
FillOpacityfloatFill alpha multiplier at the top of the plot, from 0 to 1.
FillBottomOpacityfloatFraction of the fill alpha kept at the bottom of the plot, from 0 to 1.
ShowPointsboolDisplays a marker at each data point.
PointSizefloatDiameter of each data marker in local UI units, from 0 to 50.
ShowGridboolShows grid lines.
VerticalGridLinesintNumber of intervals across the horizontal axis, from 1 to 40.
GridLineThicknessfloatGrid line width in local UI units, from 0 to 20.
ShowAxisboolShows the axis lines.
AxisThicknessfloatAxis line width in local UI units, from 0.1 to 20.
ShowCategoryLabelsboolShows category names.
LabelFontSizefloatCategory label font size. Labels may shrink to fit short columns.
LabelPaddingfloatGap between category labels and the plot in local UI units.
LabelRotationModeLabelRotationHow bottom-axis labels turn when crowded.
ShowScaleLabelsboolShows numeric labels along the value axis.
ScaleFontSizefloatNumeric axis font size. Scale labels may shrink to fit the plot.
ScalePaddingfloatGap between numeric scale labels and the plot in local UI units.
ShowValuesboolShows numeric values beside bars or points.
ValueFontSizefloatData value font size. Values may shrink to fit the plot.
ValuePaddingfloatGap between data values and their points in local UI units.
DisplayFormatNumberDisplayFormatNumeric format used by value and scale labels.

Fields

NameTypeDescription
dataPointsList<DataPoint>Ordered labeled values.

Methods

NameParametersDescription
UpdateData()List<DataPoint> newDataReplaces the data list.
AddDataPoint()string label, float valueAdds a labeled value.
SetDataPoint()int index, string label, float valueChanges an existing point.
SetDataPoint()DataPoint targetData, string label, float valueChanges an existing point.
RemoveDataPoint()int indexRemoves a point by index.
ClearData()NoneClears data.
SetPointSize()float newSizeChanges marker size.
DrawChart()NoneRefreshes geometry and labels.

Example

LineChartExample.cs
using UnityEngine;
using Evo.UI;

public class LineChartExample : MonoBehaviour
{
    [SerializeField] private LineChart target;

    private void Start()
    {
        target.ClearData();
        target.Curve = LineChart.CurveMode.Smooth;
        target.ShowFill = true;
        target.LineThickness = 4f;
        target.AddDataPoint("Mon", 20f);
        target.AddDataPoint("Tue", 38f);
        target.AddDataPoint("Wed", 29f);

        // Call this when modifying the data entries directly
        target.DrawChart();
    }
}

On this page