ChartLayoutConstants
public static class ChartLayoutConstantsCentralized layout constants for consistent positioning across all chart rendering paths. These values are the single source of truth for all position calculations. Use GetScaled*() methods to obtain scale-aware values based on chart dimensions.
Fields
Section titled “Fields”
ReferenceChartSize
Section titled “ReferenceChartSize”public static readonly Vector2 ReferenceChartSizeReference chart size where base font sizes and spacing values look correct. Scaling is calculated relative to this size.
Returns
UnityEngine.Vector2 — No return description is available.
DefaultMinTextScaleFactor
Section titled “DefaultMinTextScaleFactor”public const float DefaultMinTextScaleFactor = 0.25Default minimum text scale factor to prevent text from becoming unreadably small. Can be overridden per-theme via ChartTheme.MinTextScaleFactor.
Returns
System.Single — No return description is available.
DefaultMaxTextScaleFactor
Section titled “DefaultMaxTextScaleFactor”public const float DefaultMaxTextScaleFactor = 2.5Default maximum text scale factor to prevent text from becoming too large. Can be overridden per-theme via ChartTheme.MaxTextScaleFactor.
Returns
System.Single — No return description is available.
MinLayoutFontSize
Section titled “MinLayoutFontSize”public const float MinLayoutFontSize = 8Minimum font size in pixels for layout calculations. Even if fonts render smaller, layout reserves at least this much space.
Returns
System.Single — No return description is available.
MinVisibleFontSize
Section titled “MinVisibleFontSize”public const float MinVisibleFontSize = 6Minimum font size in pixels below which text should be hidden rather than rendered. Set to 0 to always render text regardless of size.
Returns
System.Single — No return description is available.
PieRadiusFraction
Section titled “PieRadiusFraction”public const float PieRadiusFraction = 0.5Fraction of the smaller plot dimension used as the maximum pie/donut radius. Layout, sector rendering, hit geometry, and label positioning must all use this.
Returns
System.Single — No return description is available.
CharWidthMultiplier
Section titled “CharWidthMultiplier”public const float CharWidthMultiplier = 0.6Base character width multiplier relative to font size. Average character width is approximately 60% of font size for proportional fonts.
Returns
System.Single — No return description is available.
LineHeightMultiplier
Section titled “LineHeightMultiplier”public const float LineHeightMultiplier = 1.3Line height multiplier relative to font size. Typical line height is 120-140% of font size.
Returns
System.Single — No return description is available.
ChartEdgePadding
Section titled “ChartEdgePadding”public const float ChartEdgePadding = 8Base padding from chart edges. Ensures elements don’t touch the border.
Returns
System.Single — No return description is available.
ElementSpacing
Section titled “ElementSpacing”public const float ElementSpacing = 4Standard spacing between layout elements (e.g., axis title to axis labels).
Returns
System.Single — No return description is available.
XAxisLabelOffsetY
Section titled “XAxisLabelOffsetY”public const float XAxisLabelOffsetY = 5Vertical offset from plot area bottom edge to X-axis tick labels. In Cartesian coords: plotArea.yMin - this value.
Returns
System.Single — No return description is available.
XAxisTitleOffsetY
Section titled “XAxisTitleOffsetY”public const float XAxisTitleOffsetY = 30Base vertical offset from plot area bottom edge to X-axis title. Actual position calculated dynamically based on axis labels presence.
Returns
System.Single — No return description is available.
YAxisLabelOffsetXLeft
Section titled “YAxisLabelOffsetXLeft”public const float YAxisLabelOffsetXLeft = 10Horizontal offset from plot area left edge to Y-axis tick labels (left side). In Cartesian coords: plotArea.xMin - this value.
Returns
System.Single — No return description is available.
YAxisLabelOffsetXRight
Section titled “YAxisLabelOffsetXRight”public const float YAxisLabelOffsetXRight = 5Horizontal offset from plot area right edge to Y-axis tick labels (right side). In Cartesian coords: plotArea.xMax + this value.
Returns
System.Single — No return description is available.
YAxisTitleOffsetX
Section titled “YAxisTitleOffsetX”public const float YAxisTitleOffsetX = 15Base horizontal offset for Y-axis title positioning.
Returns
System.Single — No return description is available.
DataLabelOffsetY
Section titled “DataLabelOffsetY”public const float DataLabelOffsetY = 8Vertical offset from mark top to data label. For bars: label appears this many pixels above the bar top.
Returns
System.Single — No return description is available.
DataLabelOffsetX
Section titled “DataLabelOffsetX”public const float DataLabelOffsetX = 6Horizontal offset from horizontal bar end to data label. For horizontal bars: label appears this many pixels to the right of the bar.
Returns
System.Single — No return description is available.
DataLabelBoundsPadding
Section titled “DataLabelBoundsPadding”public const float DataLabelBoundsPadding = 3Padding from plot area edges for data labels to prevent overdraw with grid lines and axes. Labels will be kept this many pixels inside the plot area bounds.
Returns
System.Single — No return description is available.
DataLabelHeightMultiplier
Section titled “DataLabelHeightMultiplier”public const float DataLabelHeightMultiplier = 1.3Multiplier to estimate label height from font size. Accounts for line height and descenders. Typical value is 1.2-1.4. Usage: labelHeight = fontSize * DataLabelHeightMultiplier
Returns
System.Single — No return description is available.
DataLabelCharWidthMultiplier
Section titled “DataLabelCharWidthMultiplier”public const float DataLabelCharWidthMultiplier = 0.6Multiplier to estimate character width from font size. Approximation for average character width. Typical value is 0.5-0.7. Usage: charWidth = fontSize * DataLabelCharWidthMultiplier
Returns
System.Single — No return description is available.
LegendTopOffsetY
Section titled “LegendTopOffsetY”public const float LegendTopOffsetY = 25Vertical offset from plot area top edge to legend (when Position=Top). In Cartesian coords: plotArea.yMax + this value.
Returns
System.Single — No return description is available.
LegendBottomOffsetY
Section titled “LegendBottomOffsetY”public const float LegendBottomOffsetY = 55Vertical offset from plot area bottom edge to legend (when Position=Bottom). In Cartesian coords: plotArea.yMin - this value.
Returns
System.Single — No return description is available.
LegendSideOffsetX
Section titled “LegendSideOffsetX”public const float LegendSideOffsetX = 15Horizontal offset from plot area for side legends (Left/Right).
Returns
System.Single — No return description is available.
LegendSwatchSize
Section titled “LegendSwatchSize”public const float LegendSwatchSize = 8Size of legend color swatch (square).
Returns
System.Single — No return description is available.
LegendSwatchPadding
Section titled “LegendSwatchPadding”public const float LegendSwatchPadding = 6Padding between swatch and label text.
Returns
System.Single — No return description is available.
LegendItemSpacing
Section titled “LegendItemSpacing”public const float LegendItemSpacing = 16Spacing between legend items (horizontal layout).
Returns
System.Single — No return description is available.
LegendBorderPadding
Section titled “LegendBorderPadding”public const float LegendBorderPadding = 4Minimum inset between horizontal legends and the chart frame.
Returns
System.Single — No return description is available.
LegendSidePlotPadding
Section titled “LegendSidePlotPadding”public const float LegendSidePlotPadding = 6Inner padding between an outside leading legend and the plot area.
Returns
System.Single — No return description is available.
MinSideLegendWidth
Section titled “MinSideLegendWidth”public const float MinSideLegendWidth = 80Minimum width for side-positioned legends (Leading/Trailing). Ensures enough space for swatch + text.
Returns
System.Single — No return description is available.
LegendRowSpacing
Section titled “LegendRowSpacing”public const float LegendRowSpacing = 4Row spacing for multi-row legends.
Returns
System.Single — No return description is available.
DefaultPadding
Section titled “DefaultPadding”public const float DefaultPadding = 8Default padding around chart elements.
Returns
System.Single — No return description is available.
SidePaddingPercent
Section titled “SidePaddingPercent”public const float SidePaddingPercent = 0.05Side padding as percentage of plot area width for continuous charts.
Returns
System.Single — No return description is available.
RightPaddingPercent
Section titled “RightPaddingPercent”public const float RightPaddingPercent = 0.08Right padding as percentage for bar charts to leave room for labels.
Returns
System.Single — No return description is available.
TopPaddingPercent
Section titled “TopPaddingPercent”public const float TopPaddingPercent = 0.08Top padding as percentage of plot area Height (8%). Used by most chart types to leave room at top.
Returns
System.Single — No return description is available.
LineSidePaddingPercent
Section titled “LineSidePaddingPercent”public const float LineSidePaddingPercent = 0.02Side padding for line charts as percentage of plot area Width (2%).
Returns
System.Single — No return description is available.
PointSidePaddingPercent
Section titled “PointSidePaddingPercent”public const float PointSidePaddingPercent = 0.05Side padding for point/scatter charts as percentage of plot area Width (5%).
Returns
System.Single — No return description is available.
TinyPaddingPixels
Section titled “TinyPaddingPixels”public const float TinyPaddingPixels = 2Fixed pixel padding for tiny/compact charts.
Returns
System.Single — No return description is available.
TinyPointPaddingPixels
Section titled “TinyPointPaddingPixels”public const float TinyPointPaddingPixels = 4Fixed pixel padding for tiny point charts (slightly larger).
Returns
System.Single — No return description is available.
Methods
Section titled “Methods”
GetTextScaleFactor(Vector2, float, float)
Section titled “GetTextScaleFactor(Vector2, float, float)”public static float GetTextScaleFactor(Vector2 chartSize, float minScale = 0.25, float maxScale = 2.5)Calculates the text scale factor based on chart dimensions. Uses the smaller dimension ratio to ensure text fits in constrained spaces.
Parameters
| Name | Type | Description |
|---|---|---|
chartSize |
UnityEngine.Vector2 | Current chart dimensions |
minScale |
System.Single | Minimum scale factor (default: DefaultMinTextScaleFactor) |
maxScale |
System.Single | Maximum scale factor (default: DefaultMaxTextScaleFactor) |
Returns
System.Single — No return description is available.
GetContentScaleFactor(Vector2, LegendPosition, float, float)
Section titled “GetContentScaleFactor(Vector2, LegendPosition, float, float)”public static float GetContentScaleFactor(Vector2 chartSize, LegendPosition position, float minScale = 0.25, float maxScale = 2.5)Calculates a content scale factor that constrains by the dimension relevant to the legend’s position. Top/Bottom legends spread horizontally, so only width matters. Leading/Trailing legends stack vertically, so only height matters. Left/Right (inside-plot) and Hidden fall back to the standard min-based factor. Also used for scaling symbols and other content elements.
Parameters
| Name | Type | Description |
|---|---|---|
chartSize |
UnityEngine.Vector2 | |
position |
ChartGuru.LegendPosition | |
minScale |
System.Single | |
maxScale |
System.Single |
Returns
System.Single — No return description is available.
GetScaledFontSize(float, float)
Section titled “GetScaledFontSize(float, float)”public static float GetScaledFontSize(float baseFontSize, float scaleFactor)Gets the scaled font size for rendering. Returns actual scaled size, clamped to MinVisibleFontSize. Use this for actual text rendering.
Parameters
| Name | Type | Description |
|---|---|---|
baseFontSize |
System.Single | |
scaleFactor |
System.Single |
Returns
System.Single — No return description is available.
GetLayoutFontSize(float, float)
Section titled “GetLayoutFontSize(float, float)”public static float GetLayoutFontSize(float baseFontSize, float scaleFactor)Gets the font size to use for layout space calculations. Always returns at least MinLayoutFontSize to ensure space is reserved for labels.
Parameters
| Name | Type | Description |
|---|---|---|
baseFontSize |
System.Single | |
scaleFactor |
System.Single |
Returns
System.Single — No return description is available.
IsTextVisible(float, float)
Section titled “IsTextVisible(float, float)”public static bool IsTextVisible(float baseFontSize, float scaleFactor)Returns true if text at this scaled size should be visible.
Parameters
| Name | Type | Description |
|---|---|---|
baseFontSize |
System.Single | |
scaleFactor |
System.Single |
Returns
System.Boolean — No return description is available.
EstimateTextWidth(string, float)
Section titled “EstimateTextWidth(string, float)”public static float EstimateTextWidth(string text, float fontSize)Estimates the width of a text string based on font size.
Parameters
| Name | Type | Description |
|---|---|---|
text |
System.String | |
fontSize |
System.Single |
Returns
System.Single — No return description is available.
EstimateTextHeight(float)
Section titled “EstimateTextHeight(float)”public static float EstimateTextHeight(float fontSize)Estimates the height of a single line of text based on font size.
Parameters
| Name | Type | Description |
|---|---|---|
fontSize |
System.Single |
Returns
System.Single — No return description is available.
EstimateRotatedTextHeight(float, float, LabelRotation)
Section titled “EstimateRotatedTextHeight(float, float, LabelRotation)”public static float EstimateRotatedTextHeight(float textWidth, float textHeight, LabelRotation rotation)No description is available for this member.
Parameters
| Name | Type | Description |
|---|---|---|
textWidth |
System.Single | |
textHeight |
System.Single | |
rotation |
ChartGuru.LabelRotation |
Returns
System.Single — No return description is available.
EstimateXAxisLabelHeight(float, float, int, int)
Section titled “EstimateXAxisLabelHeight(float, float, int, int)”public static float EstimateXAxisLabelHeight(float fontSize, float availableWidth, int labelCount, int avgLabelLength = 4)Estimates the height needed for X-axis labels, accounting for potential rotation. For small charts where labels are likely to be rotated, allocates more vertical space.
Parameters
| Name | Type | Description |
|---|---|---|
fontSize |
System.Single | The font size for labels. |
availableWidth |
System.Single | The available width for the X-axis. |
labelCount |
System.Int32 | Number of X-axis labels. |
avgLabelLength |
System.Int32 | Average character length of labels (default 4). |
Returns
System.Single — Estimated height needed for X-axis labels.
TruncateWithEllipsis(string, float, float)
Section titled “TruncateWithEllipsis(string, float, float)”public static string TruncateWithEllipsis(string text, float maxWidth, float fontSize)Truncates text with ellipsis if it exceeds the maximum width. Returns the original text if it fits, or truncated text with “…” appended.
Parameters
| Name | Type | Description |
|---|---|---|
text |
System.String | |
maxWidth |
System.Single | |
fontSize |
System.Single |
Returns
System.String — No return description is available.
GetScaledChartEdgePadding(float)
Section titled “GetScaledChartEdgePadding(float)”public static float GetScaledChartEdgePadding(float scaleFactor)Gets scaled chart edge padding.
Parameters
| Name | Type | Description |
|---|---|---|
scaleFactor |
System.Single |
Returns
System.Single — No return description is available.
GetScaledElementSpacing(float)
Section titled “GetScaledElementSpacing(float)”public static float GetScaledElementSpacing(float scaleFactor)Gets scaled element spacing.
Parameters
| Name | Type | Description |
|---|---|---|
scaleFactor |
System.Single |
Returns
System.Single — No return description is available.
GetScaledXAxisLabelOffsetY(float)
Section titled “GetScaledXAxisLabelOffsetY(float)”public static float GetScaledXAxisLabelOffsetY(float scaleFactor)Gets scaled X-axis label offset.
Parameters
| Name | Type | Description |
|---|---|---|
scaleFactor |
System.Single |
Returns
System.Single — No return description is available.
GetScaledXAxisTitleOffsetY(float)
Section titled “GetScaledXAxisTitleOffsetY(float)”public static float GetScaledXAxisTitleOffsetY(float scaleFactor)Gets scaled X-axis title offset.
Parameters
| Name | Type | Description |
|---|---|---|
scaleFactor |
System.Single |
Returns
System.Single — No return description is available.
GetScaledYAxisLabelOffsetXLeft(float)
Section titled “GetScaledYAxisLabelOffsetXLeft(float)”public static float GetScaledYAxisLabelOffsetXLeft(float scaleFactor)Gets scaled Y-axis label offset for left-positioned axis.
Parameters
| Name | Type | Description |
|---|---|---|
scaleFactor |
System.Single |
Returns
System.Single — No return description is available.
GetScaledYAxisLabelOffsetXRight(float)
Section titled “GetScaledYAxisLabelOffsetXRight(float)”public static float GetScaledYAxisLabelOffsetXRight(float scaleFactor)Gets scaled Y-axis label offset for right-positioned axis.
Parameters
| Name | Type | Description |
|---|---|---|
scaleFactor |
System.Single |
Returns
System.Single — No return description is available.
GetScaledYAxisTitleOffsetX(float)
Section titled “GetScaledYAxisTitleOffsetX(float)”public static float GetScaledYAxisTitleOffsetX(float scaleFactor)Gets scaled Y-axis title offset.
Parameters
| Name | Type | Description |
|---|---|---|
scaleFactor |
System.Single |
Returns
System.Single — No return description is available.
GetScaledDataLabelOffsetY(float)
Section titled “GetScaledDataLabelOffsetY(float)”public static float GetScaledDataLabelOffsetY(float scaleFactor)Gets scaled data label vertical offset.
Parameters
| Name | Type | Description |
|---|---|---|
scaleFactor |
System.Single |
Returns
System.Single — No return description is available.
GetScaledDataLabelOffsetX(float)
Section titled “GetScaledDataLabelOffsetX(float)”public static float GetScaledDataLabelOffsetX(float scaleFactor)Gets scaled data label horizontal offset.
Parameters
| Name | Type | Description |
|---|---|---|
scaleFactor |
System.Single |
Returns
System.Single — No return description is available.
GetScaledDataLabelBoundsPadding(float)
Section titled “GetScaledDataLabelBoundsPadding(float)”public static float GetScaledDataLabelBoundsPadding(float scaleFactor)Gets scaled data label bounds padding.
Parameters
| Name | Type | Description |
|---|---|---|
scaleFactor |
System.Single |
Returns
System.Single — No return description is available.
GetScaledLegendSwatchSize(float)
Section titled “GetScaledLegendSwatchSize(float)”public static float GetScaledLegendSwatchSize(float scaleFactor)Gets scaled legend swatch size.
Parameters
| Name | Type | Description |
|---|---|---|
scaleFactor |
System.Single |
Returns
System.Single — No return description is available.
GetScaledLegendSwatchPadding(float)
Section titled “GetScaledLegendSwatchPadding(float)”public static float GetScaledLegendSwatchPadding(float scaleFactor)Gets scaled legend swatch padding.
Parameters
| Name | Type | Description |
|---|---|---|
scaleFactor |
System.Single |
Returns
System.Single — No return description is available.
GetScaledLegendSidePlotPadding(float)
Section titled “GetScaledLegendSidePlotPadding(float)”public static float GetScaledLegendSidePlotPadding(float scaleFactor)Gets scaled side legend padding next to the plot area.
Parameters
| Name | Type | Description |
|---|---|---|
scaleFactor |
System.Single |
Returns
System.Single — No return description is available.
GetScaledLegendItemSpacing(float)
Section titled “GetScaledLegendItemSpacing(float)”public static float GetScaledLegendItemSpacing(float scaleFactor)Gets scaled legend item spacing.
Parameters
| Name | Type | Description |
|---|---|---|
scaleFactor |
System.Single |
Returns
System.Single — No return description is available.
GetScaledMinSideLegendWidth(float)
Section titled “GetScaledMinSideLegendWidth(float)”public static float GetScaledMinSideLegendWidth(float scaleFactor)Gets scaled minimum side legend width.
Parameters
| Name | Type | Description |
|---|---|---|
scaleFactor |
System.Single |
Returns
System.Single — No return description is available.
GetScaledLegendRowSpacing(float)
Section titled “GetScaledLegendRowSpacing(float)”public static float GetScaledLegendRowSpacing(float scaleFactor)Gets scaled legend row spacing.
Parameters
| Name | Type | Description |
|---|---|---|
scaleFactor |
System.Single |
Returns
System.Single — No return description is available.
GetScaledLegendSymbolSize(float, ChartTheme)
Section titled “GetScaledLegendSymbolSize(float, ChartTheme)”public static float GetScaledLegendSymbolSize(float scaleFactor, ChartTheme theme)Gets scaled legend symbol size, using theme value if available.
Parameters
| Name | Type | Description |
|---|---|---|
scaleFactor |
System.Single | |
theme |
ChartGuru.ChartTheme |
Returns
System.Single — No return description is available.
GetScaledLegendItemSpacing(float, ChartTheme)
Section titled “GetScaledLegendItemSpacing(float, ChartTheme)”public static float GetScaledLegendItemSpacing(float scaleFactor, ChartTheme theme)Gets scaled legend item spacing, using theme value if available.
Parameters
| Name | Type | Description |
|---|---|---|
scaleFactor |
System.Single | |
theme |
ChartGuru.ChartTheme |
Returns
System.Single — No return description is available.
GetLegendItemSpacing(ChartTheme)
Section titled “GetLegendItemSpacing(ChartTheme)”public static float GetLegendItemSpacing(ChartTheme theme)Gets the legend item spacing, using theme value if available.
Parameters
| Name | Type | Description |
|---|---|---|
theme |
ChartGuru.ChartTheme |
Returns
System.Single — No return description is available.
GetLegendSymbolSize(ChartTheme)
Section titled “GetLegendSymbolSize(ChartTheme)”public static float GetLegendSymbolSize(ChartTheme theme)Gets the legend symbol size, using theme value if available.
Parameters
| Name | Type | Description |
|---|---|---|
theme |
ChartGuru.ChartTheme |
Returns
System.Single — No return description is available.
GetChartPadding(ChartType, float, float, bool, bool, bool)
Section titled “GetChartPadding(ChartType, float, float, bool, bool, bool)”public static ChartLayoutConstants.ChartPadding GetChartPadding(ChartType chartType, float plotWidth, float plotHeight, bool isTiny = false, bool hasNegativeValues = false, bool isNormalizedStacking = false)Gets the appropriate padding values for a chart type. Returns consistent values between series rendering and threshold zones.
Parameters
| Name | Type | Description |
|---|---|---|
chartType |
ChartGuru.ChartType | The type of chart being rendered |
plotWidth |
System.Single | The width of the plot area in pixels |
plotHeight |
System.Single | The height of the plot area in pixels |
isTiny |
System.Boolean | Whether this is a tiny/compact chart |
hasNegativeValues |
System.Boolean | Whether the chart has negative Values (affects bottom padding) |
isNormalizedStacking |
System.Boolean | Whether using normalized Stacking (no top padding) |
Returns
ChartGuru.ChartLayoutConstants.ChartPadding — ChartPadding struct with side, top, and bottom padding values