Sparklines are tiny charts appropriate for showing many trends at once, as a set of small timelines. They are typically drawn without axes or gridlines and are often shown inside data tables, alongside labels.
Whereas the typical chart
is designed to show as much data as possible and is set off from the flow of text, Sparklines are intended to be succinct, memorable, and located where they are discussed. Logi Info and Logi Report provide four Sparkline elements:
|This element produces an area chart, and includes background, gradient, and edge color attributes.|
This element produces a typical bar chart, with bar height varying based on data values. Negative values are displayed below the x-axis.
This element produces a typical line chart, with a configurable line width.
This element produces a chart similar to a bar chart, except the bar heights are all the same and simply indicate whether a data value is above or below a configurable threshold.
Sparklines are often used inside data table columns, but they can be used just about anywhere a regular chart can be used.
Sparklines are very easy to implement and use their own datalayers to retrieve data:
In the example shown above, a Sparkline.Line element has been included in a data table column. Note that the data table has its datalayer and the Sparkline has its own, separate datalayer.
The data used by the Sparkline needs to be limited to that related to the table row that the Sparkline resides in. To do this, if using DataLayer.SQL to retrieve data for the Sparkline, the query can reference the data from the data table's datalayer using an @Data token. So the (Sparkline) query might look like:
SELECT * FROM orders WHERE EmployeeID = @Data.EmployeeID~
If the Sparkline data is retrieved from other datasources, a Compare Filter or Condition Filter can be used to limit the data in the datalayer to just that needed for the chart. For example, if you use a Compare Filter, its Data Column attribute value might be EmployeeID and its Compare Value attribute would be @Data.EmployeeID~.
All that's necessary to produce the Sparkline itself is to identify a data column in the Sparkline Data Column attribute value, as shown above, which provides the y-axis values. Each row in the datalayer is then plotted on its own chart.
The resulting data table, with Sparklines, is shown above. Height and width values may be specified but, if they are not, they will be determined automatically.
Common implementations of Sparklines show data that's grouped by time period and aggregated. Sparkline elements include time-oriented grouping attributes and a built-in aggregation function, so you don't have to manipulate the datalayer data using additional elements (although you may do so).
In the example shown above, the Sparkline Data Column and Aggregate Function attributes are used to sum the Freight data column values, which provides the y-axis values. There are two attributes for grouping data by time, the Time Period and Time Period Data Column attributes, which produce the x-axis values of the chart. In the example, they're set to Week and the OrderDate data column, respectively.
The resulting data table is shown above. This, essentially, allows you to increase the granularity of the Sparkline.
The Time Period attribute will only work with date-related values; even though they're shown in Studio, the Hour, Minute, and Second options are not valid with this element. Similarly, data in the column specified in the Time Period Data Column must be DateTime type data that includes date values, not just time values.
However, if you wish to display values grouped by time, add a Time Period Column element under your datalayer. Use a Group Filter to group the data on the Time Period Column and a Group Aggregate Column element to aggregate it. Enter the ID of the Group Aggregate Column element in the Sparkline element's Sparkline Data Column attribute.
In prior versions, aggregations included columns with Null values by default. This behavior has been changed and Null values are now excluded by default. Create the constant rdCalculationsIncludeNulls and set it to True if you want to restore the old behavior.
Sparklines can be made interactive by using Action elements with them:
In the example shown above, Action.Report, Target.Report and Link Parameters elements are used beneath a Sparkline element. Any of the following Action elements can be used:
Additional Action elements will likely be added in the near future.
Link Parameters associated with these actions can reference both the @Data tokens (the data table data) and @Chart tokens (the Sparkline data) available at runtime.