AxisExpression Property

Spotfire 14.3 API Reference
Gets or sets the expression that defines how data is mapped to this axis.

Namespace:  Spotfire.Dxp.Application.Visuals
Assembly:  Spotfire.Dxp.Application (in Spotfire.Dxp.Application.dll) Version: 65.0.19510.3242 (65.0.19510.3242)
Syntax

C#
public string Expression { get; set; }

Property Value

Type: String
The expression.
Exceptions

ExceptionCondition
ArgumentNullExceptionIf set to null.
ArgumentException If a continuous expression is set on an axis that can only be categorical.
-or-
If a categorical expression is set on an axis that can only be continuous.
-or-
If set to an invalid categorical expression.
ExpressionParseExceptionIf set to an expression that could not be parsed.
Remarks

Expressions are either continuous or categorical. Categorical expressions are embraced by angle brackets: The expression X is continuous, whereas the expression <X> is categorical.

In its simplest form an expression is simply a column name, such as Sales. In aggregated visualization this is often combined with an aggregation method, as in Sum(Sales).

An axis may support categorical expressions, continuous expressions, or both. This depends on the axis in question. The Y axis of a scatter plot, for instance, can be either continuous or categorical, but the Y axis of a bar chart only supports continuous expressions.

When building expressions programmatically, identifiers such as column names should be escaped. This is to ensure that special characters such as square brackets and spaces are treated correctly. This can be done using the ExpressionUtilities class, or by using the NameEscapedForExpression property of DataColumn.

Examples

The following sample demonstrates how to set the Expression property on axes in a bar chart.
C#
public void CreateBarchart(AnalysisApplication application)
{
    // Create the bar chart
    BarChart barChart = application.Document.ActivePageReference.Visuals.AddNew<BarChart>();

    // Connect the bar chart to data
    DataManager dataManager = application.Document.Data;
    barChart.Data.DataTableReference = dataManager.Tables.DefaultTableReference;

    // Set filtering for the visualization
    barChart.Data.UseActiveFiltering = true;

    // Set marking for the visualization
    barChart.Data.MarkingReference = dataManager.Markings.DefaultMarkingReference;

    // Put the column named Year on the x-axis. Put angles around it to make it categorical.
    barChart.XAxis.Expression = "<Year>";

    // Put sum of column sales on the y-axis. This is a continuous expression.
    barChart.YAxis.Expression = "Sum(Sales)";

    // And finally color categorically by the column named Region
    barChart.ColorAxis.Expression = "<Region>";
}
Version Information

Supported in: 14.3, 14.2, 14.1, 14.0, 12.5, 12.4, 12.3, 12.2, 12.1, 12.0, 11.8
See Also

Reference