Graph Foundry
Script reference
using GraphFoundry;
using UnityEngine;
public class InventoryChart : MonoBehaviour
{
public GraphChart chart;
void Start()
{
chart.Kind = GraphKind.Bar;
chart.SetData(new[] {
new GraphDatum("Wood", 42, new Color(1f, .5f, .44f)),
new GraphDatum("Stone", 28, new Color(.41f, .68f, 1f))
});
chart.OnItemClicked.AddListener(index => Debug.Log(chart.Data[index].label));
}
public void WoodChanged(float amount) => chart.SetValue(0, amount);
}SetData copies the supplied items and replaces the current data atomically. SetValue changes one value. Data exposes a read-only view. A chart supports up to 256 items; extra Inspector entries are ignored with a warning, while SetData rejects oversized input. Data and geometry rebuild only when marked dirty; labels are pooled after creation. This is not a streaming or large-dataset charting system.
For comparison charts, SetData defines categories and resizes existing series by index, preserving existing values and filling added columns with zero. SetSeries copies its input, requires exactly one finite value per category, and rejects more than eight series atomically:
chart.Kind = GraphKind.SeriesBar;
chart.SetData(new[] {
new GraphDatum("Wood", 0, Color.white),
new GraphDatum("Stone", 0, Color.white)
});
chart.SetSeries(new[] {
new GraphSeries("Stored", Color.cyan, new float[] { 42, 28 }),
new GraphSeries("Needed", Color.yellow, new float[] { 30, 36 })
});
chart.SeriesLayout = GraphBarLayout.Grouped; // or Stacked
chart.SetSeriesValue(0, 1, 50); // series index, category index, value
chart.OnSeriesItemClicked.AddListener((series, category) =>
Debug.Log(chart.Series[series].Label + ": " + chart.Data[category].label));The same category/series model works for GraphKind.Line: set its Kind to Line and call SetSeries to draw multiple lines, or pass an empty series collection to return to the row values. Every line uses the same numeric scale; SeriesLayout applies only to comparison bars. The model also works for GraphKind.Radar; give it at least three categories, call SetRange(0, 100), and use SetAxisMaximum(index, maximum) for individual limits (zero restores the shared scale). GetAxisMaximum(index) returns the effective limit. With no series, SetValue updates the radar's one polygon. Series and each series' Values expose read-only views. To rename/recolour a series through code, pass a replacement series collection to SetSeries. Inactive chart types retain their series data when switching types.
Appearance returns the effective local or shared appearance. Assigning it detaches the style; edit a copy and assign it back. Style links a GraphStyle. Shared styles contain appearance only. Font sets the TMP font; it is assigned automatically by the creation tools. SetRange(min, max) enables a fixed range; AutomaticRange = true restores automatic scaling. Refresh() explicitly invalidates geometry and labels.
OnItemClicked emits the original zero-based data index for a left click. Bars hit their visible rounded geometry; pie slices exclude gaps and the donut hole; line charts select markers within 12 UI units. After selecting a chart, arrow keys change its item and Submit invokes the same event. Pointer hover shows the category and value in the chart header. Pie details include its percentage. Charts do not supply full screen-reader accessibility or chart-to-chart keyboard navigation.
Multiple-line points, radar dots and comparison bars also emit OnSeriesItemClicked(seriesIndex, categoryIndex) when using series. OnItemClicked remains a category-only compatibility event. Left/Right changes category; Up/Down changes series; Submit emits both events. For horizontal bars, Up/Down follows the top-to-bottom categories and Left/Right changes series. SelectedSeriesIndex is -1 for single-value charts. Radar points use a minimum 12-unit picking radius. Background clicks do not emit item events.