Sparkline Column

Summary

  • Sparkline Columns are AdapTable Columns which wrap AG Grid's Sparkline Charts functionality
  • This allows them to be easily created, edited and saved at runtime
  • Most Sparkline Columns contain an array of numbers, but advanced columns can contain Tuples and Objects

Sparkline Columns allow Sparklines to be easily displayed in Column form and then saved in Layouts.

The Sparklines are the AG Grid Sparklines provided as part of their excellent Charting package.

Sparkline Columns can be provided by developers at Design Time or created / edited by run-time users.

Hint

  • Sparkline Columns created at design time must have an appropriate Array Cell Data Type
  • The Column Type has to be numberArray, tupleArray or objectArray

Sparkline Types

AG Grid Sparkline Columns can be of 4 types:

Each of these types is fully supported by AdapTable.

A Sparkline Column works on an array of data, rather than a single value.

Caution

To use Sparkline Columns - you must have the AG Grid SparklinesModule Module installed

Numeric Array

Sparkline data most typically takes the form of standard numeric arrays (e.g. history data).

Styled Column: Sparkline
Fork
  • This Example provides a fictitious History column which supplies an Array of Numbers
  • We provide 4 different Sparkline Columns all of which use the same History column but provide a different, appropriately named, Sparkline type:
    • History - Line
    • History - Area
    • History - Bar
    • History - Column
Try It Out
  • Create a Sparkline Column in the Wizard for the History Column
  • Click the Edit First Row button in the Dashboard to change the History value - and see all 4 Sparklines update

Advanced Array Types

More advanced Sparkline Columns can use complex, rather than numeric, arrays.

These arrays can be of 3 types:

Tuple Array

In a Tuple Array the data is provided in a array of arrays each of which has 2 values:

[ [14, 22], [5, 13], [19, 30] ]

Note

Tuple Arrays should provide a Cell Data Type of tupleArray

Standard Object Array

AG Grid Sparklines can also receive objects.

These objects, by convention, will contain 2 properties: x and y:

[ {x: 14, y: 22}, {x: 5, y: 13},  {x: 19, y: 30} ]

Note

Standard Object Arrays should provide a Cell Data Type of objectArray

Non-Standard Object Array

AG Grid Sparklines can also be created with objects that do not have the standard x and y properties.

However they are still required to contain 2 properties, which are needed for the 2 axes:

[ {xVal: 14, yVal: 22}, {xVal: 5, yVal: 13},  {xVal: 19, yVal: 30} ]

Note

Non-Standard Object Arrays should also provide a Cell Data Type of objectArray

Styled Column: Sparkline Advanced
Fork
  • This example contains 3 Sparkline Columns which render data that is not of numeric array form
  • They each show the same Data Set as in the demo above, but provided in 3 slightly different formats - each using different Sparkline types:
    • History - Tuple supplies the data as an array of Tuples - displayed in a Column Sparkline
    • History - Object supplies the data as an array of standard objects (i.e. x, y) - displayed in an Area Sparkline
    • History - Object Non Standard supplies the data as an array of non-standard objects - displayed in a Line Sparkline

Sparkline Calculated Columns

Sparkline Columns can be used by Calculated Columns to render Array data.

Most typically the Calculated Column will use the TO_ARRAY Expression Function to create the data.

Sparkline Columns: Calculated
Fork
  • This demo contains 2 Calculated Columns which use TO_ARRAY to create an Array and render the result as Sparkline Columns:
    • Statistics - shows an Area Sparkline with 4 columns as an array: Open Issues, Closed Issues, Open PRs, Closed PRs
    • Github - shows a Bar Sparkline with an array of Github Stars and Github Watchers multiplied by 30

Sparkline Calculated Columns

(Recorded with AdapTable v14.0)

FAQ

Can we export Sparkline Columns when using the VisualExcel Report Format? Not currently, but we plan to look at this in a forthcoming release

I cannot see the Sparkline Column in my Grid? Make sure you have the AG Grid SparklinesModule Module installed

Why are there no columns visible in the Wizard when I try to create a sparkline? AdapTable will only display columns which have an appropriate Cell Data Types for a Sparkline Column. This needs to be one of numberArray, tupleArray or objectArray