Skip to content

LogScaleHelper

ClassChartGuruChartGuru
public static class LogScaleHelper

Generates "nice" tick values for a logarithmic axis. Emits decade boundaries (powers of AxisConfig.LogBase) inside the requested raw-data range, with optional intra-decade minor ticks (2, 3, ... 9) when the axis only spans a small number of decades and there is room for them. The returned values are in raw data space — callers should run them through AxisConfig.TransformValue(float) to convert to plot-coordinate space.

public static List<float> GenerateTicks(float minRaw, float maxRaw, float logBase, int desiredCount)

Produces tick values for a log-scaled axis spanning minRaw through maxRaw. Both are in raw (un-transformed) space.

Parameters

Name Type Description
minRaw System.Single
maxRaw System.Single
logBase System.Single
desiredCount System.Int32 Hint for how many ticks to emit. Decades are always preferred; minor ticks are inserted only when the decade count is small enough that the requested count cannot be reached otherwise.

Returns

System.Collections.Generic.List{System.Single}

GenerateTicks(float, float, float, int, List, List)

Section titled “GenerateTicks(float, float, float, int, List, List)”
public static void GenerateTicks(float minRaw, float maxRaw, float logBase, int desiredCount, List<float> result, List<float> minorScratch)

Generates readable tick values spanning the active domain, targeting the requested count without exceeding scale constraints.

Parameters

Name Type
minRaw System.Single
maxRaw System.Single
logBase System.Single
desiredCount System.Int32
result System.Collections.Generic.List{System.Single}
minorScratch System.Collections.Generic.List{System.Single}

GenerateDecadeTicks(float, float, float, List)

Section titled “GenerateDecadeTicks(float, float, float, List)”
public static void GenerateDecadeTicks(float minRaw, float maxRaw, float logBase, List<float> result)

The automatic ticks Swift Charts draws on a logarithmic scale: every power of logBase inside minRaw through maxRaw, whatever the desired count, so a domain within one decade, such as 2 through 8, has none. Native captures record this for base-10 scales in Swift Charts.

Parameters

Name Type
minRaw System.Single
maxRaw System.Single
logBase System.Single
result System.Collections.Generic.List{System.Single}