Click or drag to resize

DoubleMatrixRowCollectionXDataColumn Property

Gets or sets the column index of the entries which are to be returned by the XData property of the rows in the collection.

Namespace:  Novacta.Analytics
Assembly:  Novacta.Analytics (in Novacta.Analytics.dll) Version: 2.0.0
Syntax
public int XDataColumn { get; set; }

Property Value

Type: Int32
The column index used when evaluating the XData property of the collected rows.
Exceptions
ExceptionCondition
ArgumentOutOfRangeExceptionvalue is less than zero.
-or-
value is greater than or equal to the NumberOfColumns of the matrix whose rows this instance is collecting.
Remarks

Entries of a DoubleMatrixRow instance corresponding to a specific column index can be get or set through the indexer ItemInt32. When the indexer sets the entry, the row fires the PropertyChanged event, notifying that the name of the changed property is "Item[]"; as a consequence, subscribers to the event can't know what is the column index of the changed entry. This can be problematic if you want to use DoubleMatrixRow instances as binding sources, for example when binding charts or grids to matrix data.

To overcome such difficulties, the DoubleMatrixRow class defines, among others, the XData property. This property returns a specific entry of the row, that one having as column index the value returned by the XDataColumn property of the DoubleMatrixRowCollection which the row belongs to. In this way, XData can be easily used as a path property when binding to DoubleMatrixRow sources.

If set, the XData property fires the PropertyChanged event, and the new value becomes the entry of Matrix having row and column indexes given by Index and XDataColumn, respectively.

Examples

In the following example, the XDataColumn of a collection of matrix rows is set, and the XData property of its rows is evaluated.

C#
using System;

namespace Novacta.Analytics.CodeExamples
{
    public class RowXDataExample0  
    {
        public void Main()
        {
            // Create a matrix.
            var data = new double[12] {
                1, 5,  9,
                2, 6, 10,
                3, 7, 11,
                4, 8, 12
            };
            var matrix = DoubleMatrix.Dense(4, 3, data, StorageOrder.RowMajor);
            Console.WriteLine("Data matrix:");
            Console.WriteLine(matrix);
            Console.WriteLine();

            // Get the collection of matrix rows.
            var rows = matrix.AsRowCollection();

            // Set the column corresponding to property XData.
            rows.XDataColumn = 2;

            // Get the XData value for each row.
            foreach (var row in rows) {
                Console.WriteLine("XData for Row {0}: {1}", row.Index, row.XData);
            }

            // Set the XData property: this code updates the data matrix, too.
            foreach (var row in rows) {
                row.XData = row.Index * 100.0;
            }

            Console.WriteLine();
            Console.WriteLine("Updated data matrix:");
            Console.WriteLine(matrix);
            Console.WriteLine();
        }
    }
}

// Executing method Main() produces the following output:
// 
// Data matrix:
// 1                5                9                
// 2                6                10               
// 3                7                11               
// 4                8                12               
// 
// 
// 
// XData for Row 0: 9
// XData for Row 1: 10
// XData for Row 2: 11
// XData for Row 3: 12
// 
// Updated data matrix:
// 1                5                0                
// 2                6                100              
// 3                7                200              
// 4                8                300              
// 
// 

See Also