Skip to content

LabelFormatter

ClassChartGuruChartGuru
public class LabelFormatter

Formats label text using placeholder tokens. Supports placeholders like {value}, {series}, {category}, {percent}, etc.

public LabelFormatter()

Creates a new label formatter with default settings.

public LabelFormatter(CultureInfo culture)

Creates a new label formatter with the specified culture.

Parameters

NameType
cultureSystem.Globalization.CultureInfo

public string Format(string template, LabelContext context)

Formats a label template using the provided context.

Parameters

NameTypeDescription
templateSystem.StringTemplate string with placeholders.
contextChartGuru.LabelContextContext providing values for placeholders.

Returns

System.String: Formatted string with placeholders replaced.

public static string ValueLabel(float value, string format = "F1")

Creates a simple label showing only the value.

Parameters

NameType
valueSystem.Single
formatSystem.String

Returns

System.String

public static string SeriesValueLabel(string seriesName, float value, string format = "F1")

Creates a label showing series name and value.

Parameters

NameType
seriesNameSystem.String
valueSystem.Single
formatSystem.String

Returns

System.String

public static string CategoryValueLabel(string category, float value, string format = "F1")

Creates a label showing category and value.

Parameters

NameType
categorySystem.String
valueSystem.Single
formatSystem.String

Returns

System.String

public static string PieLabel(string name, float percent, string format = "F1")

Creates a pie/donut label showing name and percentage.

Parameters

NameType
nameSystem.String
percentSystem.Single
formatSystem.String

Returns

System.String

public CultureInfo Culture { get; set; }

Gets or sets the culture used for formatting numbers and dates.

Returns

System.Globalization.CultureInfo

public string NumericFormat { get; set; }

Gets or sets the default format for numeric values.

Returns

System.String

public string PercentFormat { get; set; }

Gets or sets the default format for percentage values.

Returns

System.String

public string DateFormat { get; set; }

Gets or sets the default format for date values.

Returns

System.String