The key to putting sparklines is to create two calculations that "jitter" the underlying latitude and longitude fields. These calculations will then go on the X (i.e. Columns) and Y (i.e. Rows) shelves, while the location of each sparkline (i.e. latitude and longitude) goes onto the Level of Detail shelf. The sparkline itself is a Line mark with the X axis value on the Path shelf. I also find it helpful to put the Y axis value on the Color shelf to provide a kind of labelling for the axis, but this is not strictly necessary. You can also put a third variable on the Size shelf if the sparkline is not too dense, but I have not done that in this example because there are no unused variables.

I like to create these jittered calculations in two stages. The first stage is to make two calculations called [Sparkline X] and [Sparkline Y] that compute the X and Y values for the sparkline and normalise them both to the range [-1,1]. This makes it easier to centre them on geographical points and scale them to the grid. These calculations should be aggregate calculations so that Tableau will not try to group by them, which would break the line up into a set of discrete points. In my example, the two calculations are:

- [Sparkline X] = (MAX(YEAR([date])) - 1980) / 30
- [Sparkline Y] = AVG([anomaly]) / 2

MAX (or MIN) is a convenient way to make a dimension into an aggregate without changing its value. Notice that each calculation is of the form

- (AGG - midpoint) / (half of the range)

[anomaly] varies from about -2 to +2 in my data set so the midpoint is actually 0, and I am only going to plot YEAR([date]) from about 1950 onwards, which gives a range of about 60 years centred at 1980.

The second stage is to make the actual jittered calculations using two calculations from the first stage:

- [Longitude X] = MAX([long]) + [Sparkline X]
- [Latitude Y] = MAX([lat]) + [Sparkline Y] * .75

The .75 is used to scale the Y axis to the grid used by the data. The X axis seems fine with a scaling of 1 for my grid. Again, notice that these are aggregate calculations and I have used the MAX trick on the [lat] and [long] fields. For this type of data visualisation, you should make sure that [lat] and [long] are Dimensions, not measures. Also, watch out for axis reversal - we tend to say "X and Y" and "Latitude and Longitude", but Latitude should have the Y values, not the X values! One final note: If you create the Latitude/Longitude calculations by right-clicking on your [lat]/[long] fields when they are already marked with the correct geographical role, Tableau will create the new calculation with that role already assigned.

(Incidentally, splitting up the calculations this way is an example of what we Software Engineers call "separation of concerns": the Sparkline calculations are "concerned" with the properties of the X/Y values and the Latitude calculations are "concerned" with the properties of the grid. Then if you need to adjust something, you know exactly where to go to fix it.)

## Comments

Richard,

I think it s problematic to have sparklines that have a map as a background. Cant you render them in a white box instead?

I feel that that aspect ration of the sparklines should be so that the sparklines have a smaller amplitude.

Andreas

Andreas, thanks for your feedback.

The map sources we selected were chosen in part because they don't have excessive background clutter, and the user retains control over a variety of rendering options and data overlays. In particular the map has a washout control which fades the map to emphasize foreground visualizations. I don't know of an easy way to create an opaque bounding region for each sparkline, but you may find you don't need to.

Regarding the aspect ratio, you can certainly control that according to the recipe. Simply change the 0.75 multiplier to one you feel is appropriate for your viz. I liked the original, but using thinner lines with the following calculation gives a good effect as well:

[Longitude Y] = MAX([lat])+ [Sparkline Y] * .50

Outstanding, Richard! Very tasty! We will use the recipe for retail location analyses with our clients (sales, customer satisfaction, direct mail ROI, etc.).

can you make mini bar charts this way? i have too separate values i'd like to place together at various geographic locations

or could you only done this by manipulation of the line mark