Skip to content

RadarDomainHelper

ClassChartGuruChartGuru
public static class RadarDomainHelper

Shared helper that resolves the radial domain of radar marks, the values at the center and on the outer ring, and maps values onto the radius. Without an explicit Y-axis domain the center is zero and the data maximum is pushed up to a "nice" round value, mirroring the "extend display domain" behaviour of Cartesian charts, so the polygon never grazes the outer ring and numeric data labels (drawn at the data-point radius) stay clear of the spoke-tip category labels (drawn just outside the outer ring). An explicit domain maps its minimum to the center.

The polygon in ChartRenderer.RenderRadarGL, the data-label anchors in ChartLayoutEngine.ComputeRadarDataLabels, the ring values in RadarLabelLayout.Build and radar hit testing all place values with RadarDomainHelper.ResolveRadialDomain(Chart) and RadarDomainHelper.RadialFraction(float, Vector2), so the rings, their values and the shape agree. They also share ChartGuru.RadarDomainHelper.SpokeDirection(int, int), the direction of each spoke.

public static Vector2 ResolveRadialDomain(Chart chart)

The radial domain: x is the value at the center and y the value on the outer ring. An explicit Y-axis domain keeps both ends, so a 50 to 100 domain draws 50 at the center; otherwise the center is zero and the outer ring is RadarDomainHelper.ResolveRadialMax(Chart).

Parameters

NameType
chartChartGuru.Chart

Returns

UnityEngine.Vector2

public static float RadialFraction(float value, Vector2 domain)

The share of the radius at which value sits in domain: 0 at the center for the domain minimum and 1 on the outer ring for the maximum. Values below the minimum stay at the center; values above the maximum reach past the outer ring.

Parameters

NameType
valueSystem.Single
domainUnityEngine.Vector2

Returns

System.Single

public static float ResolveRadialMax(Chart chart)

Returns the value that should map to the outer polygon ring (radius * 1.0). Honours an explicit Y-axis domain when supplied; otherwise returns a nice-rounded ceiling that leaves visible headroom above the data max. Always returns a strictly-positive value.

Parameters

NameType
chartChartGuru.Chart

Returns

System.Single

public static float ComputeNiceCeiling(float dataMax)

Picks a “nice” upper bound >= dataMax such that the data sits at roughly <= 85% of the outer ring, then snapped up to a clean multiple (1, 1.25, 1.5, 2, 2.5, 3, 4, 5, 6, 8, 10) of a power of ten. Public for unit-testability.

Parameters

NameType
dataMaxSystem.Single

Returns

System.Single