SparklineColumn

Displays a sparkline (a small inline chart that gives an at-a-glance view of trends in a data series) in a grid cell.

Sparkline column
//<code-header>
fiddle.title = 'Sparkline column';
//</code-header>
class Row extends GridRowModel {
    static fields = [
        { name : 'name' },
        { name : 'monthlySales' }
    ];
}

const
    months = ['Jan', 'Feb', 'Mar', 'Apr', 'May'],
    products = [
        'Blue jeans mens L', 'Sweatshirt XL', 'Black turtleneck womens M', 'Red flannel shirt mens S', 'White tank top womens XS', 'Denim jacket mens L'
    ],
    data = ArrayHelper.populate(6, n => ({
        id           : n,
        name         : products[n],
        // The Sparkline column expects an array of numeric values in its configured `field`, on each record
        monthlySales : months.map(m => Math.round(Math.random() * 80 + 20)),
        rating       : Math.round(Math.random() * 5)
    }));

// grid with SparklineColumn
const grid = new Grid({
    appendTo   : targetElement,
    // makes grid as high as it needs to be to fit rows
    autoHeight : true,
    rowHeight  : 35,
    data,
    columns    : [
        {
            text   : 'Name',
            field  : 'name',
            width  : 300,
            editor : {
                type     : 'textfield',
                required : true
            }
        },
        {
            id    : 'line',
            text  : 'Sparkline',
            width : 120,
            type  : 'sparkline',
            field : 'monthlySales'
        },
        {
            id        : 'bar',
            text      : 'Bar',
            width     : 120,
            type      : 'sparkline',
            chartType : 'bar',
            field     : 'monthlySales'
        },
        {
            id        : 'pie',
            text      : 'Pie',
            width     : 80,
            type      : 'sparkline',
            chartType : 'pie',
            field     : 'monthlySales'
        },
        ...months.map((monthName, i) => ({
            text     : monthName,
            width    : 80,
            editor   : false,
            renderer : ({ record }) => record.monthlySales[i]
        }))
    ]
});

The column's field should be a property on your Grid data model containing an array of numbers that make up the data series to display in the sparkline.

SparklineColumn supports chartTypes of line, bar, and pie.

new Grid({
    columns : [
        {
             type      : 'sparkline',
             chartType : 'line',
             field     : 'values' // field named here should contain
                                  // an array of numbers
        }
    ]
});

Note that this column requires using thin bundles or thin npm packages in your application, and importing the chart bundle / package. It does not work with normal packages, module or umd bundles.

Configs

86

Common

autoWidthColumn
fieldColumn
fitModeColumn
flexColumn
listenersEvents
maxWidthColumn
textColumn
widgetsWidgetColumn
widthColumn

Other

chartType: line | bar | pie= line

The type of chart.

highlightColor: String= #ff0000

The hex color to use to highlight the minimum and maximum values when highlightMinMax is true. Applicable for chartTypes line and bar.

highlightMinMax: Boolean= true

Whether to highlight the minimum and maximum values in highlightColor. Applicable for chartTypes line and bar.

chartChartColumn
formulaColumn
pinnedColumn
readOnlyColumn

Accessibility

ariaLabelColumn

Export

Integration

vueColumn

Interaction

collapsedColumn
draggableColumn
editorColumn
groupableColumn
hideableColumn
resizableColumn
sealedColumn
sortableColumn

Layout

alignColumn
hiddenColumn
lockedColumn
minWidthColumn
regionColumn

Menu

Merge cells

mergeableColumn

Misc

localeClassLocalizable
localizableLocalizable
tagsColumn
treeColumn

Rendering

afterRenderCellWidgetColumn
cellClsColumn
chartClsChartColumn
clsColumn
iconColumn
rendererWidgetColumn
tooltipColumn

Summary

sumColumn
summariesColumn

Properties

154

Common

autoWidthColumn
fieldColumn
fitModeColumn
flexColumn
maxWidthColumn
textColumn
widgetsWidgetColumn
widthColumn

Class hierarchy

isSparklineColumn: Boolean= truereadonly
Identifies an object as an instance of SparklineColumn class, or subclass thereof.
isSparklineColumn: Boolean= truereadonlystatic
Identifies an object as an instance of SparklineColumn class, or subclass thereof.
isChartColumnChartColumn
isColumnColumn
isEventsEvents
isLocalizableLocalizable
isModelModel
isModelLinkModelLink
isModelStmModelStm
isTreeNodeTreeNode
isWidgetColumnWidgetColumn

Accessibility

ariaLabelColumn

Editing

copyOfModel
isValidModel

Export

Fields

allFieldsstaticModel
autoExposeFieldsstaticModel
childrenFieldstaticModel
fieldMapstaticModel
fieldsstaticModel
idFieldstaticModel

Grouping

Identification

keyModel

Integration

vueColumn

Interaction

collapsedColumn
draggableColumn
editorColumn
groupableColumn
hideableColumn
resizableColumn
sealedColumn
sortableColumn

JSON

jsonModel

Layout

alignColumn
hiddenColumn
lockedColumn
minWidthColumn
regionColumn

Lifecycle

configBase

Linked records

hasLinksModelLink
isLinkedModelLink
recordLinksModelLink

Menu

Merge cells

mergeableColumn

Misc

localeHelperLocalizable
localeManagerLocalizable
stmModelStm
tagsColumn
treeColumn

Other

$namestaticModel
chartChartColumn
defaultsColumn
elementColumn
formulaColumn
gridColumn
pinnedColumn
readOnlyColumn
relationsstaticModel
subGridColumn
typestaticColumn
visibleColumn

Parent & children

allChildrenTreeNode
childLevelTreeNode
firstChildTreeNode
isLeafTreeNode
isLoadedTreeNode
isParentTreeNode
isRootTreeNode
lastChildTreeNode
nextSiblingTreeNode
parentTreeNode
parentIdTreeNode

Rendering

afterRenderCellWidgetColumn
cellClsColumn
clsColumn
iconColumn
rendererWidgetColumn
tooltipColumn

Summary

sumColumn
summariesColumn

Functions

78

Configuration

applyDefaultsstaticBase

Editing

copyModel
getDataModel
removeModel
setModel

Events

Fields

addFieldstaticModel
getModel
processFieldstaticModel
removeFieldstaticModel

Identification

asIdstaticModel

JSON

toJSONModel

Lifecycle

destroystaticBase

Misc

equalsModel
initClassstaticBase
isOfTypeNamestaticBase
linkModelLink
mixinstaticBase
optionalLstaticLocalizable

Other

hideColumn
LstaticLocalizable
onEvents
relayAllEvents
showColumn
toggleColumn
triggerEvents
unEvents

Parent & children

appendChildTreeNode
bubbleTreeNode
bubbleWhileTreeNode
containsTreeNode
isExpandedTreeNode
removeChildTreeNode
traverseTreeNode

Events

5

Event handlers

5

Typedefs

2