Spotfire Axis Names on Line Charts

If you’ve been following along, you know that my series on learning the Spotfire expression language is something of a long haul. It turns out that explaining Axis Names is a long and detailed affair. I am committed to it, and so this week I’m going thru axis names for line charts. If you missed it, check out Axis Names on Bar Charts.

Blog or Video

Axis Names for Line Charts

Warning

Contrary to what the TIBCO documentation says, there are only 3 axis names for line charts. The TIBCO documentation thru at least 10.6 (I didn’t check past that) says there are 4 axis names. But, that is an error in the documentation. There is not “Feature” axis name. The 3 axis names used with line charts are Axis.X, Axis.Line, and Axis.Color.

With that said, here are examples of how to use the 3 axis names available to line charts.

Axis.X

Axis.X refers to the column of data on the x-axis of the bar chart. This data can be a date hierarchy, a categorical column of data, or a categorical hierarchy. The expression below calculates a cumulative sum. The way to interpret this expression is — Calculate the current node (current month) by summing oil for all previous nodes (months). If the x-axis was setup with quarters, it would calculate a cumulative sum by quarter, which makes this expression very dynamic. You can change what’s on the x-axis without modifying the expression.

Expression: Sum([OIL]) over (AllPrevious([Axis.X]))

Warning

When working with dates and Axis.X, you must use a hierarchy. Without a hierarchy, you’ll get an error. You can get around this requirement by creating a single level hierarchy.

If I change the column on the x-axis to a categorical column of data, the expression will still calculate relative to the order of values on the x-axis. This cumulative sum assumes Reservoir B comes first, Reservoir E second, and Reservoir Y third.

Axis.Line

Axis.Line references the column of data applied to the Line by variable. In the examples below, I am showing a line for each LEASE, and I have filtered to 3 leases.

The way to interpret this expression is — sum oil for each node (month) and well (as indicated by Line by LEASE). Divide that value by the sum of oil for all lines (or all LEASES). This calculates the percentage that each lease contributes to the total for the month.

Expression: Expression: Sum([OIL]) / Sum([OIL]) over (All([Axis.Line]))
The sum of the 3 values for each month always adds up to 100%

Now, what if you want each line to have a different color? I’ll get to that with Axis.Color, discussed below. First, let’s look at another use of Axis.Line.

In the visualization below, the blue lines represent the average oil production for 3 leases. The yellow line is the average oil for all lines or leases. The expression can be interpreted as — Calculate the average oil for all lines.

Expression: Avg([OIL]) over (All([Axis.Line]))

Now, as I worked thru visualization examples after I created the chart above, I wanted to modify it so that each lease had its own color. Unfortunately, that is not possible. When my own attempts at this failed, I reached out to TIBCO support who informed me this was as good as it gets. But let’s take a look at how we can add more color to one of the previous examples.

Axis.Color

The visualization shown below is a bit dull. I’d like to give each line a different color. The most intuitive way to accomplish this is to add LEASE to the color by variable. But, you’ll find out this does not work….

Adding LEASE to the Color by selector results in 3 lines that sit on top of each other with a value of 1 or 100%. This change gives the wrong result because Spotfire uses color in the expression without expressly referencing it. I explained this in the Axis Names for Bar Charts post. The same thing happens in bar charts.

Instead, you must change the expression to reference Axis.Color and also remove LEASE from the Line by selector. Just modifying the expression will not generate the right result.

Expression: Sum([OIL]) / Sum([OIL]) over (All([Axis.Color]))

Reminder

Warning

When using node navigation with Axis.Color and Axis.Line, remember that node navigation methods like Previous and Next are going to navigate among the unique values used in Color by or Line by. Jumping to the “next” or “previous” color might not be meaningful.

And that explains how to use axis names in Spotfire line charts. Next, I’ll look at cross tables.

Spotfire Version

Content created with Spotfire 10.3.

Check Out Other Posts in the Series

3 thoughts on “Spotfire Axis Names on Line Charts”

  1. Pingback: How to Improve Spotfire Load Times » The Analytics Corner

  2. Pingback: Calculate the Last Value on a Visualization » The Analytics Corner

  3. Pingback: Spotfire Prompts to Install Over and Over » The Analytics Corner

Leave a Reply

Your email address will not be published. Required fields are marked *