Skip to content

ChartEditorGUI

ClassChartGuruChartGuru.Editor
public static class ChartEditorGUI

Shared utility for drawing ChartGuru text overlays (axis labels, data labels, legend) in Unity Editor GUI contexts (Inspector, EditorWindow, etc.).

Usage:

// After rendering the chart texture:
renderer.RenderToTexture(previewTexture, 0f, false);
GUI.DrawTexture(previewRect, previewTexture, ScaleMode.StretchToFill);

// Draw all text overlays on top:
ChartEditorGUI.DrawChartText(previewRect, renderer, chart);

This is the same two-layer approach used by the Chart Designer window: Layer 1 (GL): ChartRenderer.RenderToTexture() — chart geometry Layer 2 (IMGUI): ChartEditorGUI.DrawChartText() — text labels on top

public static void DrawChartText(Rect previewRect, ChartRenderer renderer, Chart chart)

Draws all text overlays (axis labels, titles, legend, optionally data labels) for a chart that has already been rendered via ChartGuru.ChartRenderer.RenderToTexture(UnityEngine.RenderTexture).

Call this immediately after GUI.DrawTexture(previewRect, texture).

Parameters

Name Type Description
previewRect UnityEngine.Rect The GUI rect where the chart texture was drawn.
renderer ChartGuru.ChartRenderer The ChartRenderer that rendered the texture (provides layout data).
chart ChartGuru.Chart The Chart object (provides theme, size, axis config).

DrawChartText(Rect, ChartRenderer, Chart, ChartEditorTextOptions)

Section titled “DrawChartText(Rect, ChartRenderer, Chart, ChartEditorTextOptions)”
public static void DrawChartText(Rect previewRect, ChartRenderer renderer, Chart chart, ChartEditorTextOptions options)

Draws all text overlays with custom options.

Parameters

Name Type Description
previewRect UnityEngine.Rect
renderer ChartGuru.ChartRenderer
chart ChartGuru.Chart
options ChartGuru.ChartEditorTextOptions

ComputeContentHeight(ChartRenderer, Chart)

Section titled “ComputeContentHeight(ChartRenderer, Chart)”
public static float ComputeContentHeight(ChartRenderer renderer, Chart chart)

Computes the effective content height for a chart preview, accounting for X-axis labels, titles, and bottom legend that extend below the plot area. Use this when you need the chart texture and text to scale together without clipping.

Parameters

Name Type Description
renderer ChartGuru.ChartRenderer
chart ChartGuru.Chart

Returns

System.Single — No return description is available.