Chart
namespace Griff.Scenes;
public sealed class Chart : Component, IDrawable, INetStateA line or bar graph for the HUD or the world: a few series (a name and a color each) of numbers, the last Keep of each, drawn in its Size with value lines and their numbers, a legend and labels along the bottom. A script feeds it (Add a point, Set a whole series, Clear), or with no code a series names an output of the Track entity (“Cards: #4C9AFF = Cards Today”) and the chart takes a point of it every SampleEvery seconds of game time: a factory’s throughput over three days, a stock price, a population. Its range fits the points unless Max says.
This is a component: its saved properties are on its component page.
Properties
Section titled “Properties”Background
Section titled “Background”public Color Background { get; set; }Behind the whole chart. Transparent for none.
Bounds
Section titled “Bounds”public ValueTuple<float, float> Bounds { get; }The values the chart’s bottom and top stand for now: Min and Max, or fitted to the points.
public string? Font { get; set; }The font of its words, or empty for the built-in one.
Format
Section titled “Format”public string? Format { get; set; }How the numbers on the value lines are written, a .NET number format (“0”, “0.0”, “#,0”, “0%”). Empty writes them short: 950, 1.2k, 15k, 2.5M.
GridColor
Section titled “GridColor”public Color GridColor { get; set; }The value lines across the chart.
public int Keep { get; set; }How many points each series keeps: adding one past this drops the oldest, so the chart scrolls.
public ChartKind Kind { get; set; }Draws a line through the points, or a bar for each.
Legend
Section titled “Legend”public bool Legend { get; set; }Shows each series’ name in its color along the top.
LineWidth
Section titled “LineWidth”public float LineWidth { get; set; }How thick a series’ line is, in world units before the transform’s scale.
public float Max { get; set; }The value at the top of the chart, points past it cut off there. 0 fits the highest point, rounded up to a round number (1, 1.2, 1.5, 2, 2.5, 3, 4, 5, 6 or 8 times a power of ten).
public float Min { get; set; }The value at the bottom of the chart; a point below it stretches the chart down while Max is 0.
public int Order { get; set; }Higher draws on top, like Order.
Palette
Section titled “Palette”public static IReadOnlyList<Color> Palette { get; }The colors a series without its own takes, in order.
SampleEvery
Section titled “SampleEvery”public float SampleEvery { get; set; }For a series with an output: how many seconds of game time between points (it takes one as the game starts too), so a sped-up game fills it faster and a paused one not at all. 0 takes none, leaving it to scripts.
Series
Section titled “Series”public IReadOnlyList<string> Series { get; set; }The series, one per row: a name, its color, and optionally an output of the Track entity it samples, e.g. “Cards: #4C9AFF” (fed by a script) or “Cards: #4C9AFF = Cards Today” (sampled with no code). A series a script adds by name that isn’t here takes the next color of the Palette.
SeriesNames
Section titled “SeriesNames”public IReadOnlyList<string> SeriesNames { get; }The series’ names, the Series rows’ first and then those scripts added.
public Vector2 Size { get; set; }World units before the transform’s scale, centered on the entity: the legend and labels are inside it.
TextColor
Section titled “TextColor”public Color TextColor { get; set; }The numbers, the legend’s names and the labels along the bottom.
TextSize
Section titled “TextSize”public float TextSize { get; set; }The height of a line of its words, in world units before the transform’s scale.
public string? Track { get; set; }The entity whose outputs the series sample, e.g. “Factory”, or “*” for whichever has them. Empty is this entity, or the nearest one it’s inside with the output.
XLabels
Section titled “XLabels”public IReadOnlyList<string> XLabels { get; set; }Words along the bottom, spread evenly from the left end to the right, e.g. “3 days ago”, “2 days ago”, “Yesterday”, “Today”. Empty leaves the bottom bare.
Methods
Section titled “Methods”public void Add(float value)Adds a point to the end of the first series, dropping its oldest past Keep.
public void Add(string series, float value)Adds a point to the end of the series called series (made, in the next color, if there isn’t one), dropping its oldest past Keep.
public void Clear()Takes every series’ points away (a series a script added goes too).
public void Clear(string series)Takes the points of the series called series away.
LinkLabel
Section titled “LinkLabel”public override string? LinkLabel(string property)Points
Section titled “Points”public IReadOnlyList<float> Points(string series)The points of the series called series, oldest first; empty if there’s no such series.
public void Set(string series, IEnumerable<float> values)Gives the series called series these points, oldest first (only the last Keep are kept).