Version

Data Legend

The UltraDataLegend is a component that works much like the Legend, but it shows values of series and provides many configuration properties for filtering series rows and values columns, styling and formatting values. This legend updates when moving the mouse inside of the plot area of the UltraDataChart and has a persistent state that remembers the last hovered point when the user’s mouse pointer exits the plot area. It displays this content using a set of three type of rows and four types of columns.

Data Legend Rows

The rows of the UltraDataLegend include the header row, series row(s), and the summary row.

The header row displays the axis label of the point that is hovered, and can be changed using the HeaderText property.

The series row can actually be a set of rows corresponding to each series plotted in the chart. These rows will display the legend badge, series title, actual/abbreviated value of the the series, and abbreviation symbol and unit, if specified.

Finally, there is a summary row that displays the total of all series values. The default summary title can be changed using the SummaryTitleText property of the legend. Also, you can use the SummaryType property to customize whether you display the Total, Min, Max, or Average of series values in the summary row.

The following code snippet demonstrates setting the properties mentioned above to have a UltraDataLegend with a Total summary type with a custom title for the summary and a custom header:

In C#:

dataLegend1.Target = dataChart1;
dataLegend1.HeaderText = "My Custom Data Legend Header";
dataLegend1.SummaryType = Infragistics.Controls.Charts.DataLegendSummaryType.Total;
dataLegend1.SummaryTitleText = "Grand Total";

Data Legend Columns

The columns of the UltraDataLegend include the title, label, value, and units columns. Each series in the chart can have multiple columns for label, value, and units depending on the IncludedColumns or ExcludedColumns collections of the legend.

The title column displays legend badges and series titles, which come from the Title property of the different Series plotted in the chart.

The label column displays the name or abbreviation of the different property paths in the IncludedColumns or ExcludedColumns collections of the legend.

The value column displays series values as abbreviated text which can be formatted using the ValueFormatAbbreviation property to apply the same abbreviation for all numbers by setting this property to Auto or Shared. Alternatively, a user can select other abbreviations such as Independent, Kilo, Million, etc. Precision of abbreviated values is controlled using the ValueFormatMinFractions and ValueFormatMaxFractions for minimum and maximum digits, respectively.

The units column displays an abbreviation symbol and/or unit text, which can be set either on the UltraDataLegend by setting the UnitsText for all columns or using the the following properties on each series in the chart:

  • Category Series (e.g. ColumnSeries)

    • ValueMemberAsLegendUnit="K"

  • Financial Price Series:

    • OpenMemberAsLegendUnit="K"

    • LowMemberAsLegendUnit="K"

    • HighMemberAsLegendUnit="K"

    • CloseMemberAsLegendUnit="K"

  • Range Series:

    • LowMemberAsLegendUnit="K"

    • HighMemberAsLegendUnit="K"

  • Radial Series:

    • ValueMemberAsLegendUnit="K"

  • Polar Series:

    • RadiusMemberAsLegendUnit="K"

    • AngleMemberAsLegendUnit="K"

For each of the above-listed properties, there is a corresponding MemberAsLegendLabel property as well to determine the text in the label columns mentioned previously.

The columns included in the IncludedColumns or ExcludedColumns collections generally correspond to the value paths of your underlying data items, but the financial series has the option to include some special ones in addition to the High, Low, Open, and Close paths that are required for the financial series to plot correctly. You have the ability to show TypicalPrice, Change, and Volume options within the legend.

The following code snippet demonstrates a pair of ColumnSeries with the ValueMemberAsLegendUnit properties set and the minimum/maximum fractions set on the UltraDataLegend:

In C#:

EnergyData energyDataSource = new EnergyData();

CategoryXAxis xAxis = new CategoryXAxis()
{
    ItemsSource = energyDataSource,
    Label = "Location"
};

NumericYAxis yAxis = new NumericYAxis();

ColumnSeries series1 = new ColumnSeries()
{
    XAxis = xAxis,
    YAxis = yAxis,
    ItemsSource = energyDataSource,
    ValueMemberPath = "Coal",
    ValueMemberAsLegendUnit = "K"
};

ColumnSeries series2 = new ColumnSeries()
{
    XAxis = xAxis,
    YAxis = yAxis,
    ItemsSource = energyDataSource,
    ValueMemberPath = "Solar",
    ValueMemberAsLegendUnit = "K"
};

dataChart1.Axes.Add(xAxis);
dataChart1.Axes.Add(yAxis);

dataChart1.Series.Add(series1);
dataChart1.Series.Add(series2);

dataLegend1.Target = dataLegend1;
dataLegend1.ValueFormatMinFractions = 2;
dataLegend1.ValueFormatMaxFractions = 4;

Data Legend Styling

The UltraDataLegend provides properties for styling each type of column. Each of these properties begins with Title, Label, Value, or Units, and you can style the text’s color, font, and margin. For example, if you wanted to set the text color of each of these, you would set the TitleTextColor, LabelTextColor, ValueTextColor, and UnitsTextColor properties.

The following code snippet demonstrates how to set the styling properties mentioned above:

In C#:

dataLegend1.Target = dataChart1;
dataLegend1.TitleTextColor = Brushes.LightGray;
dataLegend1.LabelTextColor = Brushes.LightGray;
dataLegend1.ValueTextColor = Brushes.Green;
dataLegend1.UnitsTextColor = Brushes.Green;
dataLegend1.UnitsText = "K";

Data Legend Value Formatting

The UltraDataLegend provides automatic abbreviation of large numbers using its ValueFormatAbbreviation property. This adds a multiplier in the units column such as kilo, million, billion, etc.

You can customize the number of fractional digits that are displayed by setting the ValueFormatMinFractions and ValueFormatMaxFractions. This will allow you to determine the minimum and maximum number of digits that appear after the decimal point, respectively.

The following code snippet demonstrates how to set the minimum and maximum fractions of the UltraDataLegend:

In C#:

dataLegend1.Target = dataChart1;
dataLegend1.ValueFormatMinFractions = 2;
dataLegend1.ValueFormatMaxFractions = 4;

Data Legend Value Mode

You have the ability to change the default decimal display of values within the UltraDataLegend to be currency by changing the ValueFormatMode property of the control. The UltraDataLegend also exposes the ability to modify the culture of the displayed currency symbol by using its ValueFormatCulture property and setting it to its corresponding culture tag.

For example, the following code snippet will create a UltraDataLegend with the ValueFormatCulture set to "en-GB" and the ValueFormatMode set to "Currency":

In C#:

dataLegend1.Target = dataChart1;
dataLegend1.ValueFormatMode = Infragistics.Controls.Charts.DataLegendValueMode.Currency;
dataLegend1.ValueFormatCulture = "en-GB";

Data Legend Grouping

DataLegendGroup can be set, on all types of series, to a string that will categorize a group of series in Data Legend. Each group will have its own summary row displayed before another group of series is displayed: By default, DataLegend will hide names of groups, but you can display group names by setting the - GroupRowVisible property to true.

Several properties are exposed including grouping portions of the legend.

Data Legend Styling Events

The UltraDataLegend has three events that fire when rendering their corresponding row. These events are listed below with a description of what they are designed to be used for:

  • StyleHeaderRow: This event fires once when rendering the header row.

  • StyleSeriesRow: This event fires once for each series row which allows conditional styling of the values of the series.

  • StyleSeriesColumn: This event fires once for each series column, which allows conditional styling of the different columns for the series in the chart.

  • StyleSummaryRow: This event fires once when rendering the summary row.

  • StyleSummaryColumn: This event fires once when rendering the summary column.

Each of the above events exposes a DataLegendStylingRowEventArgs` parameter as its arguments, which lets you customize each item’s text, text color, and the overall visibility of the row. The event arguments also expose event-specific properties. For example, since the StyleSeriesRow event fires for each series, the event arguments will return the series index and series title for the row that represents the series.

The following code snippet demonstrates usage of the above row styling events:

In C#:

private void Legend_StyleSummaryRow(object sender, Infragistics.Controls.Charts.DataLegendStylingRowEventArgs row)
{
    row.TitleText = "Grand Total: ";
    row.TitleTextColor = Brushes.DimGray;
}

private void Legend_StyleSeriesRow(object sender, Infragistics.Controls.Charts.DataLegendStylingRowEventArgs row)
{
    row.BadgeShape = Infragistics.Controls.Charts.LegendItemBadgeShape.Square;
    row.TitleText = (row.SeriesIndex + 1) + ". " + row.SeriesTitle;
    row.TitleTextColor = new SolidColorBrush(Colors.DimGray);
}

private void Legend_StyleHeaderRow(object sender, Infragistics.Controls.Charts.DataLegendStylingRowEventArgs row)
{
    row.TitleText = "Date: " + row.TitleText;
    row.TitleTextColor = Brushes.DimGray;
}