Bullet Configuration

An object that specifies configuration options for the Bullet widget.

color

Specifies a color for the bullet bar.

Type: String
Default Value: '#e8c267'

This option supports the following colors.

To specify a color for the target and zero level lines, use the targetColor option.

Show Example:
jQuery

In this example, the bullet bar color is changed to powderblue using the color option.

<div id="bulletContainer" style="height:35px;max-width:300px;margin:0 auto;padding-top:65px;position:relative"></div>
$(function () {
    $("#bulletContainer").dxBullet({
        startScaleValue: 0,
        endScaleValue: 100,
        target: 68,
        value: 42,
        color: 'powderblue'
    });
})

endScaleValue

Specifies an end value for the invisible scale.

Type: Number
Default Value: undefined
Cannot be used in themes.

The primary, target and zero values of the Bullet widget are held within a range. This range is represented by an invisible scale. To specify the boundary values of this scale, set the startScaleValue and endScaleValue options.

Specify the same start and end scale values for several bullets when you display them in a column so that they can be compared visually.

Show Example:
jQuery

In this example, the scale is defined using the startScaleValue and endScaleValue options.

<div id="bulletContainer" style="height:35px;max-width:300px;margin:0 auto;padding-top:65px;position:relative"></div>
$(function () {
    $("#bulletContainer").dxBullet({
        startScaleValue: 0,
        endScaleValue: 100,
        target: 54,
        value: 59,
        color: 'greenyellow'
    });
})

margin

Generates space around the widget.

Type: Object

WidgetMargin DevExtreme ChartJS

onDisposing

A handler for the disposing event.

Type: function
Function parameters:
e: Object
Provides function parameters.
Object structure:
component: Object
Provides access to the widget instance.
element: jQuery
An HTML element of the widget.
model: Object
Provides access to the data that is available for binding against the element. Available only in the Knockout approach.
Default Value: null

Assign a function to perform a custom action when the widget is being removed.

NOTE: The function assigned to this option is executed only if the widget is removed using the remove(), empty(), or html() jQuery methods.

onDrawn

A handler for the drawn event.

Type: function(e)
Function parameters:
e: Object
Information about the event.
Object structure:
component: Object
The widget instance.
element: Object
The widget's container.
Cannot be used in themes.

Assign a callback function to this option if you need to perform specific actions when the widget has finished drawing itself. When implementing this function, you can access the drawn widget using the function's parameter.

onExported

A handler for the exported event.

Type: function(e)
Function parameters:
e: Object
Information about the event.
Object structure:
component: Object
The widget instance.
element: jQuery
The widget's container.
model: Object
Data that is available for binding against the element. Available only in the Knockout approach.
Default Value: null

To perform a custom action after data from the widget is exported, assign a function to this option. For example, this function can notify the user that the exporting has been completed. Within this function, you can use the object passed to it as the parameter.

See Also
  • onExporting - allows you to request exporting details and prevent exporting.
  • onFileSaving - allows you to access exported data and/or prevent it from being saved into a file on the user's local storage.

onExporting

A handler for the exporting event.

Type: function(e)
Function parameters:
e: Object
Information about the event.
Object structure:
component: Object
The widget instance.
element: jQuery
The widget's container.
model: Object
Data that is available for binding against the element. Available only in Knockout and AngularJS approaches.
fileName: String
The name of the file to which the widget is about to be exported.
cancel: Boolean
Assign true to this field if you need to prevent exporting.
Default Value: null

To perform a custom action before data from the widget is exported, assign a function to this option. Within this function, you can use the object passed to it as the parameter. For example, using the cancel field of this object, you can cancel exporting.

See Also
  • onExported - allows you to notify an end user when exporting is completed.
  • onFileSaving - allows you to access exported data and/or prevent it from being saved into a file on the user's local storage.

onFileSaving

A handler for the fileSaving event.

Type: function(e)
Function parameters:
e: Object
Information about the event.
Object structure:
component: Object
The widget instance.
element: jQuery
The widget's container.
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
Assign true to this field if you need to prevent the file from being saved.
Default Value: null

To perform a custom action before a file with exported data is saved on the user's local storage, assign a function to this option. Within this function, you can use the object passed to it as the parameter. For example, using the cancel field of this object, you can cancel file saving.

See Also
  • onExporting - allows you to request exporting details and prevent exporting.
  • onExported - allows you to notify an end user when exporting is completed.

onIncidentOccurred

A handler for the incidentOccurred event.

Type: function(e)
Function parameters:
e: Object
Information about the event.
Object structure:
component: Object
The widget instance.
element: Object
The widget's container.
target: Object
Information about the occurred incident.

When an error or warning appears, the widget notifies you by passing a message to the browser console. This message contains the ID of the incident, a brief description, and a link to the Errors and Warnings section where further information about this incident can be found. However, you can handle errors and warnings in the way that you require. To do this, implement a callback function performing the required actions and assign it to the onIncidentOccurred option. Within this function, you can use information about the incident that occurred. This information can be accessed from the target field of the object passed to the callback function as a parameter. This information includes the following.

  • id
    Contains the ID of the incident. The full list of IDs can be found in the Errors and Warnings section.
  • type
    Contains the type of the incident. This field equals 'error' for errors or 'warning' for warnings.
  • args
    Contains the argument of the incident's message. The content of this field varies greatly, depending on the incident. For example, it may contain the name of the data source field that was not specified correctly, or the name of the option that was not set properly.
  • text
    Contains the text passed to the browser console. This text includes the content of the args field, if there are any.
  • widget
    Contains the name of the widget that produced the error or warning.
  • version
    Contains the currently used version of the ChartJS library.

onInitialized

A handler for the initialized event.

Type: function
Function parameters:
e: Object
Provides function parameters.
Object structure:
component: Object
Provides access to the widget instance.
element: jQuery
An HTML element of the widget.
Default Value: null

Assign a function to perform a custom action when the widget is initialized.

onOptionChanged

A handler for the optionChanged event.

Type: function
Function parameters:
e: Object
Provides function parameters.
Object structure:
component: Object
Provides access to the widget instance.
name: String
Specifies the name of the option whose value is changed.
fullName: String
Specifies a full name of the option whose value is changed. The full name is formed by concatenating the names of the options that are presented in the hierarchy of the given option. The names are delimited by commas.
value: any
Specifies a new value for the option.
element: jQuery
An HTML element of the widget.
model: Object
Provides access to the data that is available for binding against the element. Available only in the Knockout approach.
Default Value: null

Assign a function to perform a custom action after an option of the component is changed.

onTooltipHidden

A handler for the tooltipHidden event.

Type: function(e)
Function parameters:
e: Object
Information about the event.
Object structure:
component: Object
The widget instance.
element: Object
The widget's container.
Cannot be used in themes.

The sparkline's tooltip becomes invisible when a user moves the mouse cursor outside of the widget.

When a tooltip is made hidden, you can perform specific actions by handling the tooltipHidden event. To do this, implement a handling function and assign it to this option. When implementing a handling function, use the object passed to it as its parameter. This object will provide you with the widget instance and its container.

onTooltipShown

A handler for the tooltipShown event.

Type: function(e)
Function parameters:
e: Object
Information about the event.
Object structure:
component: Object
The widget instance.
element: Object
The widget's container.
Cannot be used in themes.

The sparkline's tooltip appears when a user hovers the mouse cursor over it.

When a tooltip appears, you can perform specific actions by handling the tooltipShown event. To do this, implement a handling function and assign it to this option. When implementing this function, use the object passed to it as its parameter. This object will provide you with the widget instance and its container.

pathModified

Notifies a widget that it is embedded into an HTML page that uses a path modifier.

Type: Boolean
Default Value: false
Cannot be used in themes.

If you place a widget on a page that uses a path modifier, notify the widget about it by setting the pathModified option to true. As an example of such modifiers, the base HTML tag can be considered. Also, we recommend you enable this option if you place the widget inside the <iframe> tag.

rtlEnabled

Specifies whether or not the widget supports right-to-left representation.

Type: Boolean
Default Value: false
Cannot be used in themes.

The most common scenario is switching all the widgets to a right-to-left reading order. In this instance, set the DevExpress.rtlEnabled field to true. If you need to switch the reading order in a particular widget, use the rtlEnabled configuration option of this widget.

showTarget

Specifies whether or not to show the target line.

Type: Boolean
Default Value: true
Show Example:
jQuery

Toggle the check box below to show/hide the bullet target line.

<div id="bulletContainer" style="height:35px;max-width:300px;margin:0 auto;padding-top:65px;position:relative"></div>
<div id="checkboxContainer" style="height:20px;max-width:200px;margin:5px auto;text-align:center">
    <input type="checkbox" id="showTargetCheckbox" checked> Show the Target Line
</div>
$(function () {
    $("#bulletContainer").dxBullet({
        startScaleValue: 0,
        endScaleValue: 100,
        target: 86,
        value: 94
    });

    $('#showTargetCheckbox').change(function () {
        var bullet = $('#bulletContainer').dxBullet('instance');
        bullet.option({
            showTarget: this.checked
        });
    });
})

showZeroLevel

Specifies whether or not to show the line indicating zero on the invisible scale.

Type: Boolean
Default Value: true
Show Example:
jQuery

Toggle the check box below to show/hide the bullet zero level line.

<div id="bulletContainer" style="height:35px;max-width:300px;margin:0 auto;padding-top:65px;position:relative"></div>
<div id="checkboxContainer" style="height:20px;max-width:200px;margin:5px auto;text-align:center">
    <input type="checkbox" id="showZeroLevelCheckbox" checked> Show the Zero Level Line
</div>
$(function () {
    $("#bulletContainer").dxBullet({
        startScaleValue: 0,
        endScaleValue: 100,
        target: 68,
        value: 75,
        color: 'plum'
    });

    $('#showZeroLevelCheckbox').change(function () {
        var bullet = $('#bulletContainer').dxBullet('instance');
        bullet.option({
            showZeroLevel: this.checked
        });
    });
})

size

Specifies the size of the widget in pixels.

Type: Object

By default, the widget occupies the entire area of the parent 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.

Show Example:
jQuery

In this example, the size of the widget differs from the container size.

<div id="bulletContainer" style="height:60px;max-width:700px;margin:0 auto;border:1px solid skyblue"></div>
$(function () {
    $("#bulletContainer").dxBullet({
        startScaleValue: 0,
        endScaleValue: 100,
        target: 68,
        value: 42,
        color: 'rosybrown',
        tooltip: { enabled: false },
        size: {
            height: 35,
            width: 400
        }
    });
})

startScaleValue

Specifies a start value for the invisible scale.

Type: Number
Default Value: 0
Cannot be used in themes.

The main, target and zero values of the Bullet widget are contained within a range. This range is represented by an invisible scale. To specify the boundary values of this scale, set the startScaleValue and endScaleValue options.

Specify the same start and end scale values for several bullets when you display them in a column so that they can be comparable visually.

Show Example:
jQuery

In this example, the scale is defined using the startScaleValue and endScaleValue options.

<div id="bulletContainer" style="height:35px;max-width:300px;margin:0 auto;padding-top:65px;position:relative"></div>
$(function () {
    $("#bulletContainer").dxBullet({
        startScaleValue: 0,
        endScaleValue: 100,
        target: 54,
        value: 34,
        color: 'cornflowerblue'
    });
})

target

Specifies the value indicated by the target line.

Type: Number
Default Value: 0
Cannot be used in themes.
See Also
Show Example:
jQuery

In this example, the target value is specified using the target option.

<div id="bulletContainer" style="height:35px;max-width:300px;margin:0 auto;padding-top:65px;position:relative"></div>
$(function () {
    $("#bulletContainer").dxBullet({
        startScaleValue: 0,
        endScaleValue: 1000,
        target: 459,
        value: 694,
        color: 'tomato'
    });
})

targetColor

Specifies a color for both the target and zero level lines.

Type: String
Default Value: '#666666'

This option supports the following colors.

To specify a color for the bullet bar, use the color option.

Show Example:
jQuery

In this example, the color of the target and zero lines is changed to firebrick using the targetColor option.

<div id="bulletContainer" style="height:35px;max-width:300px;margin:0 auto;padding-top:65px;position:relative"></div>
$(function () {
    $("#bulletContainer").dxBullet({
        startScaleValue: 0,
        endScaleValue: 1000,
        target: 459,
        value: 694,
        targetColor: 'firebrick'
    });
})

targetWidth

Specifies the width of the target line.

Type: Number
Default Value: 4

Show Example:
jQuery

In this example, the target line width is changed using the targetWidth option.

<div id="bulletContainer" style="height:35px;max-width:300px;margin:0 auto;padding-top:65px;position:relative"></div>
$(function () {
    $("#bulletContainer").dxBullet({
        startScaleValue: -100,
        endScaleValue: 700,
        target: 600,
        value: 584,
        targetColor: 'green',
        //targetWidth: 8,
        showZeroLevel: true
    });
})

theme

Sets the name of the theme to be used in the widget.

Type: String
Default Value: 'generic.light'
Accepted Values: 'generic.light' | 'generic.dark' | 'generic.contrast' | 'android5.light' | 'ios7.default' | 'win10.black' | 'win10.white'

Use this property to set a predefined or custom theme. The options defining chart appearance will be set to the values that are set in the specified theme. You can override some of these values within the chart's configuration object.

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

Show Example:
jQuery

In this example, a green theme is implemented on the base of the default theme. This theme is applied to the Bullet widget using the theme option.

<div id="bulletContainer" style="height:35px;max-width:300px;margin:0 auto;padding-top:65px;position:relative"></div>
var myTheme = {
    name: 'bulletGreenTheme',
    bullet: {
        color: 'lightgreen',
        targetColor: 'forestgreen',
        tooltip: {
            color: 'limegreen'
        }
    }
};
DevExpress.viz.registerTheme(myTheme, 'generic.light');
$(function () {
    $("#bulletContainer").dxBullet({
        theme: 'bulletGreenTheme',
        startScaleValue: 5,
        endScaleValue: 100,
        target: 68,
        value: 50
    });
})

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.

Show Example:
jQuery

In this example, several tooltip options are altered. The tooltip is colored in 'seashell' using the color option. The main and target values are displayed in the 'fixedPoint' format with a precision of 2. In addition, tooltip font options are changed.

<div id="bulletContainer" style="height:35px;max-width:300px;margin:0 auto;padding-top:65px;position:relative"></div>
$(function () {
    $("#bulletContainer").dxBullet({
        startScaleValue: 0,
        endScaleValue: 100,
        target: 68.9513,
        value: 79.441,
        color: 'powderblue',
        tooltip: {
            color: 'seashell',
            format: {
                type: 'fixedPoint',
                precision: 2
            },
            font: {
                color: 'crimson',
                size: 10,
                family: 'Zapf-Chancery, cursive',
                opacity: 0.75,
                weight: 400
            }
        }
    });
})

value

Specifies the primary value indicated by the bullet bar.

Type: Number
Default Value: 0
Cannot be used in themes.
Show Example:
jQuery

In this example, you can change the value indicated by the bullet bar using the button below. If this value is greater than the target value, the bullet bar becomes red. Otherwise, it is colored in blue.

<div id="bulletContainer" style="height:35px;max-width:300px;margin:0 auto"></div>
<div id="controlContainer" style="height:20px;max-width:300px;margin:5px auto;text-align:center">
    <input type="button" id="changeValueButton" value="Change the Bullet Value by 1">
</div>
$(function () {
    $("#bulletContainer").dxBullet({
        startScaleValue: 0,
        endScaleValue: 10,
        target: 6,
        value: 0,
        tooltip: { enabled: false },
        color: 'blue'
    });

    var moveAscending = true;
    $('#changeValueButton').click(function () {
        var bullet = $('#bulletContainer').dxBullet('instance');
        var val = bullet.option('value');
        var scaleStart = bullet.option('startScaleValue');
        var scaleEnd = bullet.option('endScaleValue');
        var targetValue = bullet.option('target');
        if (val == scaleStart) { moveAscending = true };
        if (val == scaleEnd) { moveAscending = false };
        if (val == targetValue) {
            moveAscending ? bullet.option('color', 'red') : bullet.option('color', 'blue');
        };
        moveAscending ? val++ : val--;
        bullet.option('value', val);
    });
})