Assembly: Spotfire.Dxp.Application (in Spotfire.Dxp.Application.dll) Version: 14.10.7525.5058 (14.10.7525.5058)
Property Value
Type: StringThe expression.
Exception | Condition |
---|---|
System ArgumentNullException | If set to null. |
System 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. |
Spotfire.Dxp.Data.Exceptions ExpressionParseException | If set to an expression that could not be parsed. |
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.
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>"; }