Configuration

An object that specifies configuration options for the Sparkline widget.

argumentField

Specifies the data source field that provides arguments for a sparkline.

Type:

String

Default Value: 'arg'

barNegativeColor

Sets a color for the bars indicating negative values. Available for a sparkline of the bar type only.

Type:

String

Default Value: '#d7d7d7'

This option supports the following colors:

To set a color for the bars indicating positive values, specify the barPositiveColor option.

barPositiveColor

Sets a color for the bars indicating positive values. Available for a sparkline of the bar type only.

Type:

String

Default Value: '#a9a9a9'

This option supports the following colors:

To set a color for the bars indicating negative values, specify the barNegativeColor option.

dataSource

Specifies a data source for the sparkline.

Cannot be used in themes.

This option accepts one of the following.

  • Array of objects
    A simple JavaScript array containing a collection of plain objects.

  • URL
    A URL to JSON data or to a service returning data in JSON format.

  • DataSource or its configuration object
    A DataSource is an object that provides a handy API for data processing. A DataSource is a stateful object, which means that it saves data processing settings and applies them each time data is loaded. All underlying data access logic of a DataSource is isolated in a Store. A Store provides an API for reading and modifying data. Unlike the DataSource, a Store is a stateless object.

NOTE
Data field names should not contain the following characters: ., ,, :, [, and ]. Their presence may cause issues in the widget's operation.
See Also

elementAttr

Specifies the attributes to be attached to the widget's root element.

Type:

Object

Default Value: {}
jQuery
$(function(){
    $("#sparklineContainer").dxSparkline({
        // ...
        elementAttr: {
            id: "elementId",
            class: "class-name"
        }
    });
});
Angular
HTML
TypeScript
<dx-sparkline ...
    [elementAttr]="{ id: 'elementId', class: 'class-name' }">
</dx-sparkline>
import { DxSparklineModule } from "devextreme-angular";
// ...
export class AppComponent {
    // ...
}
@NgModule({
    imports: [
        // ...
        DxSparklineModule
    ],
    // ...
})
ASP.NET MVC Control
Razor C#
Razor VB
@(Html.DevExtreme().Sparkline()
    .ElementAttr("class", "class-name")
    // ===== or =====
    .ElementAttr(new {
        @id = "elementId",
        @class = "class-name"
    })
    // ===== or =====
    .ElementAttr(new Dictionary<string, object>() {
        { "id", "elementId" },
        { "class", "class-name" }
    })

)
@(Html.DevExtreme().Sparkline() _
    .ElementAttr("class", "class-name")
    ' ===== or =====
    .ElementAttr(New With {
        .id = "elementId",
        .class = "class-name"
    })
    ' ===== or =====
    .ElementAttr(New Dictionary(Of String, Object) From {
        { "id", "elementId" },
        { "class", "class-name" }
    })
)

firstLastColor

Sets a color for the boundary of both the first and last points on a sparkline.

Type:

String

Default Value: '#666666'

This option supports the following colors:

Make sure that the showFirstLast option is set to true, so that this option takes effect.

To specify a color for the area inside of the point boundary, use the pointColor option.

ignoreEmptyPoints

Specifies whether a sparkline ignores null data points or not.

Type:

Boolean

Default Value: false

By default, if a data source has data points with a null argument or value, a sparkline may draw series with unnecessary gaps between points. To prevent this behavior from occurring, set the ignoreEmptyPoints option to true.

lineColor

Sets a color for a line on a sparkline. Available for the sparklines of the line- and area-like types.

Type:

String

Default Value: '#666666'

This option supports the following colors:

lineWidth

Specifies a width for a line on a sparkline. Available for the sparklines of the line- and area-like types.

Type:

Number

Default Value: 2

lossColor

Sets a color for the bars indicating the values that are less than the winloss threshold. Available for a sparkline of the winloss type only.

Type:

String

Default Value: '#d7d7d7'

This option supports the following colors:

To set a color for the bars indicating the values greater than a winloss threshold, specify the winColor option.

margin

Generates space around the widget.

Type:

Object

WidgetMargin DevExtreme ChartJS

maxColor

Sets a color for the boundary of the maximum point on a sparkline.

Type:

String

Default Value: '#e55253'

This option supports the following colors:

So that this option takes effect, make sure that the showMinMax option is set to true.

To set a color for the minimum point on a sparkline, specify the minColor option.

To specify a color for the area inside of the point boundary, use the pointColor option.

maxValue

Specifies the maximum value of the sparkline's value axis.

Type:

Number

Default Value: undefined

minColor

Sets a color for the boundary of the minimum point on a sparkline.

Type:

String

Default Value: '#e8c267'

This option supports the following colors:

Make sure that the showMinMax option is set to true, so that this option takes effect.

To set a color for the maximum point on a sparkline, specify the maxColor option.

To specify a color for the area inside of the point boundary, use the pointColor option.

minValue

Specifies the minimum value of the sparkline value axis.

Type:

Number

Default Value: undefined

onDisposing

A function that is executed before the widget is disposed of.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
component:

Sparkline

The widget's instance.

element:

Element (jQuery or HTML)

The widget's container. It is an HTML Element or a jQuery Element when you use jQuery.

model:

Object

The model data. Available only if you use Knockout.

Default Value: null

onDrawn

A function that is executed when the widget's rendering has finished.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
component:

Sparkline

The widget's instance.

element:

Element (jQuery or HTML)

The widget's container. It is an HTML Element or a jQuery Element when you use jQuery.

model:

Object

The model data. Available only if you use Knockout.

Default Value: null
Cannot be used in themes.

onExported

A function that is executed after the widget is exported.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
component:

Sparkline

The widget's instance.

element:

Element (jQuery or HTML)

The widget's container. It is an HTML Element or a jQuery Element when you use jQuery.

model:

Object

The model data. Available only if you use Knockout.

Default Value: null

onExporting

A function that is executed before the widget is exported.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
component:

Sparkline

The widget's instance.

element:

Element (jQuery or HTML)

The widget's container. It is an HTML Element or a jQuery Element when you use jQuery.

model:

Object

The model data. Available only if you use Knockout.

fileName:

String

The name of the file to which the widget is about to be exported.

cancel:

Boolean

Allows you to prevent exporting.

format:

String

The resulting file format. One of PNG, PDF, JPEG, SVG and GIF.

Default Value: null

onFileSaving

A function that is executed before a file with exported widget is saved to the user's local storage.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
component:

Sparkline

The widget's instance.

element:

Element (jQuery or HTML)

The widget's container. It is an HTML Element or a jQuery Element when you use jQuery.

fileName:

String

The name of the file to be saved.

format:

String

The format of the file to be saved.
Possible Values: 'PNG' | 'PDF' | 'JPEG' | 'SVG' | 'GIF'

data:

BLOB

Exported data as a BLOB.

cancel:

Boolean

Allows you to prevent file saving.

Default Value: null

onIncidentOccurred

A function that is executed when an error or warning occurs.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
component:

Sparkline

The widget's instance.

element:

Element (jQuery or HTML)

The widget's container. It is an HTML Element or a jQuery Element when you use jQuery.

model:

Object

The model data. Available only if you use Knockout.

target: any

Information on the occurred incident.

Default Value: null

The widget notifies you of errors and warnings by passing messages to the browser console. Each message contains the incident's ID, a brief description, and a link to the Errors and Warnings section where further information about this incident can be found.

The onIncidentOccurred function allows you to handle errors and warnings the way you require. The object passed to it contains the target field. This field provides information about the occurred incident and contains the following properties:

  • id
    The incident's ID. The full list of IDs can be found in the Errors and Warnings section.
  • type
    The incident's type: "error" or "warning".
  • args
    The argument of the incident's message. Depends on the incident. For example, it may be the name of the data source field that was specified incorrectly, or the name of the option that was not set properly.
  • text
    The text passed to the browser's console. Includes the args content, if there is any.
  • widget
    The name of the widget that produced the error or warning.
  • version
    The used DevExtreme version.

onInitialized

A function that is executed only once, after the widget is initialized.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
component:

Sparkline

The widget's instance.

element:

Element (jQuery or HTML)

The widget's container. It is an HTML Element or a jQuery Element when you use jQuery.

Default Value: null

You cannot access widget elements in this function because it is executed before they are ready. Use the onDrawn function instead.

onOptionChanged

A function that is executed after a widget option is changed.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
component:

Sparkline

The widget's instance.

name:

String

The option's short name.

fullName:

String

The option's full name.

value: any

The option's new value.

element:

Element (jQuery or HTML)

The widget's container. It is an HTML Element or a jQuery Element when you use jQuery.

model:

Object

The model data. Available only if you use Knockout.

Default Value: null

onTooltipHidden

A function that is executed when a tooltip becomes hidden.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
component:

Sparkline

The widget's instance.

element:

Element (jQuery or HTML)

The widget's container. It is an HTML Element or a jQuery Element when you use jQuery.

model:

Object

The model data. Available only if you use Knockout.

Default Value: null
Cannot be used in themes.

onTooltipShown

A function that is executed when a tooltip appears.

Type:

Function

Function parameters:
e:

Object

Information about the event.

Object structure:
component:

Sparkline

The widget's instance.

element:

Element (jQuery or HTML)

The widget's container. It is an HTML Element or a jQuery Element when you use jQuery.

model:

Object

The model data. Available only if you use Knockout.

Default Value: null
Cannot be used in themes.

pathModified

Notifies the widget that it is embedded into an HTML page that uses a tag modifying the path.

Type:

Boolean

Default Value: false
Cannot be used in themes.

If you place the widget on a page that uses a tag modifying the path (<base>, <iframe>, etc.), some of the widget elements may get mixed up or disappear. To solve this problem, set the pathModified option to true.

See Also

pointColor

Sets a color for points on a sparkline. Available for the sparklines of the line- and area-like types.

Type:

String

Default Value: '#ffffff'

This option supports the following colors:

pointSize

Specifies the diameter of sparkline points in pixels. Available for the sparklines of line- and area-like types.

Type:

Number

Default Value: 4

pointSymbol

Specifies a symbol to use as a point marker on a sparkline. Available for the sparklines of the line- and area-like types.

Type:

String

Default Value: 'circle'
Accepted Values: 'circle' | 'cross' | 'polygon' | 'square' | 'triangle'

Use the VizPointSymbol enum to specify this option when the widget is used as an ASP.NET MVC Control. This enum accepts the following values: Circle, Square, Polygon, Triangle, and Cross.

rtlEnabled

Switches the widget to a right-to-left representation.

Type:

Boolean

Default Value: false
Cannot be used in themes.

When this option is set to true, the widget text flows from right to left, and the layout of elements is reversed. To switch the entire application/site to the right-to-left representation, assign true to the rtlEnabled field of the object passed to the DevExpress.config(config) method.

JavaScript
DevExpress.config({
    rtlEnabled: true
});

showFirstLast

Specifies whether or not to indicate both the first and last values on a sparkline.

Type:

Boolean

Default Value: true

When this option is set to true, the first and last values are highlighted and painted in the color specified by the firstLastColor option.

showMinMax

Specifies whether or not to indicate both the minimum and maximum values on a sparkline.

Type:

Boolean

Default Value: false

When this option is set to true, the minimum and maximum values are highlighted and painted in the colors specified by the minColor and maxColor options correspondingly.

size

Specifies the widget's size in pixels.

Type:

Object

Default Value: undefined

By default, the widget occupies the entire area of the container. If you need to set a particular size for the widget, different from the container's size, assign a height and width in pixels to height and width properties of the size object.

Using the size object, you can hide the widget. For this purpose, simply assign 0 to both the height and width of the widget.

NOTE
The size configuration object reserves space for the main widget elements, while displaying a tooltip may require extra space. To reserve the area around the widget for the tooltip, you can apply a margin to the widget's container.

theme

Sets the name of the theme the widget uses.

Type:

String

Default Value: 'generic.light'
Accepted Values: 'generic.dark' | 'generic.light' | 'generic.contrast' | 'ios7.default' | 'generic.carmine' | 'generic.darkmoon' | 'generic.darkviolet' | 'generic.greenmist' | 'generic.softblue' | 'material.blue.light' | 'material.lime.light' | 'material.orange.light' | 'material.purple.light' | 'material.teal.light'

A theme is a widget configuration that gives the widget a distinctive appearance. Use can use one of the predefined themes or create a custom one. Changing the option values in the widget's configuration object overrides the theme's corresponding values.

NOTE
The following themes were deprecated or renamed: 'desktop', 'desktop-dark', 'android', 'android-holo-light', *android5.light*, 'ios', 'win8', 'win8-white', 'win8.white', 'win8.black', 'win10.white', 'win10.black'. In new applications, use themes listed in the accepted values.

Use the VizTheme enum to specify this option when the widget is used as an ASP.NET MVC Control. This enum accepts the following values: GenericLight, GenericDark, GenericContrast, GenericCarmine, GenericDarkMoon, GenericSoftBlue, GenericDarkViolet, GenericGreenMist, IOS7Default, MaterialBlueLight, MaterialLimeLight, MaterialOrangeLight, MaterialPurpleLight, MaterialTealLight.

tooltip

Configures the tooltip.

Type:

Object

A tooltip is a miniature rectangle displaying widget data. The tooltip appears when the end-user hovers the cursor over the widget. You can enable/disable the tooltip, change its appearance and format its text using fields of the tooltip configuration object.

NOTE
The tooltip is displayed outside the widget's container. If you plan to use the tooltip, make sure there is enough space around your widget to display it. For example, you can apply a margin to the widget's container to reserve the area around the widget for the tooltip.

type

Determines the type of a sparkline.

Type:

String

Default Value: 'line'
Accepted Values: 'area' | 'bar' | 'line' | 'spline' | 'splinearea' | 'steparea' | 'stepline' | 'winloss'

A sparkline type determines the visual representation of data. Different options of the Sparkline widget are available for different types. The table below reflects options that can be configured for the sparkline of a certain type.

line spline stepline area splinearea steparea bar winloss
  • argumentField
  • dataSource
  • firstLastColor
  • lineColor
  • lineWidth
  • minColor
  • maxColor
  • pointColor
  • pointSize
  • pointSymbol
  • showFirstLast
  • showMinMax
  • size
  • theme
  • tooltip
  • valueField
  • argumentField
  • dataSource
  • firstLastColor
  • lineColor
  • lineWidth
  • minColor
  • maxColor
  • pointColor
  • pointSize
  • pointSymbol
  • showFirstLast
  • showMinMax
  • size
  • theme
  • tooltip
  • valueField
  • argumentField
  • dataSource
  • firstLastColor
  • lineColor
  • lineWidth
  • minColor
  • maxColor
  • pointColor
  • pointSize
  • pointSymbol
  • showFirstLast
  • showMinMax
  • size
  • theme
  • tooltip
  • valueField
  • argumentField
  • dataSource
  • firstLastColor
  • lineColor
  • lineWidth
  • minColor
  • maxColor
  • pointColor
  • pointSize
  • pointSymbol
  • showFirstLast
  • showMinMax
  • size
  • theme
  • tooltip
  • valueField
  • argumentField
  • dataSource
  • firstLastColor
  • lineColor
  • lineWidth
  • minColor
  • maxColor
  • pointColor
  • pointSize
  • pointSymbol
  • showFirstLast
  • showMinMax
  • size
  • theme
  • tooltip
  • valueField
  • argumentField
  • dataSource
  • firstLastColor
  • lineColor
  • lineWidth
  • minColor
  • maxColor
  • pointColor
  • pointSize
  • pointSymbol
  • showFirstLast
  • showMinMax
  • size
  • theme
  • tooltip
  • valueField
  • argumentField
  • barNegativeColor
  • barPositiveColor
  • dataSource
  • firstLastColor
  • minColor
  • maxColor
  • showFirstLast
  • showMinMax
  • size
  • theme
  • tooltip
  • valueField
  • argumentField
  • dataSource
  • firstLastColor
  • lossColor
  • minColor
  • maxColor
  • showFirstLast
  • showMinMax
  • size
  • theme
  • tooltip
  • valueField
  • winColor
  • winlossThreshold

To see the sparklines of each type in operation, refer to our Visualization Gallery.

Use the SparklineType enum to specify this option when the widget is used as an ASP.NET MVC Control. This enum accepts the following values: Line, Spline, StepLine, Area, SplineArea, StepArea, Bar, and WinLoss.

View Area Sparkline Demo View Bar Sparkline Demo View Winloss Sparkline Demo

valueField

Specifies the data source field that provides values for a sparkline.

Type:

String

Default Value: 'val'

winColor

Sets a color for the bars indicating the values greater than a winloss threshold. Available for a sparkline of the winloss type only.

Type:

String

Default Value: '#a9a9a9'

This option supports the following colors:

To set a color for the bars indicating the values that are less than the winloss threshold, specify the lossColor option.

winlossThreshold

Specifies a value that serves as a threshold for the sparkline of the winloss type.

Type:

Number

Default Value: 0

In the winloss sparkline, values are represented by bars that either grow up or go down from an invisible line. This line is determined by a threshold value. If a data source value is greater than this threshold value, the bar grows up. Otherwise, it goes down.

You can paint the 'win' and 'loss' bars differently. For this purpose, specify the required colors using the winColor and lossColor options respectively.