JavaScript/jQuery Chart - crosshair

Configures the crosshair feature.

Type:

Object

Crosshair is a pointer represented by two mutually-crossing lines stretched over the entire chart plot. The crosshair helps a user identify the values of the series points precisely. When enabled, the crosshair follows the cursor and snaps to the nearest series point.

DevExtreme HTML5 Charts Crosshair

To enable the crosshair, set the crosshair.enabled property to true. Assign true to the crosshair.label.visible property as well to make the crosshair labels visible.

Settings specified in the crosshair object apply to both the crosshair lines. If you specify the same settings within the horizontalLine or verticalLine object, they will apply to the particular crosshair line only. Note that individual settings override common ones.

View Demo

color

Specifies the color of the crosshair lines.

Type:

String

Default Value: '#f05b41'

This property supports the following colors:

dashStyle

Specifies the dash style of the crosshair lines.

Type:

String

Default Value: 'solid'
Accepted Values: 'dash' | 'dot' | 'longDash' | 'solid'

The following dash styles are available:

  • solid
    The border is a solid, continuous line.

  • longDash
    The border is displayed using long dashes.

  • dash
    The border is displayed using dashes.

  • dot
    The border is displayed using dots.

  • Any combination of 'longDash', 'dash' and 'dot'
    The border is displayed by repeating the specified combination. For instance, 'dashdotdash'.

enabled

Enables the crosshair.

Type:

Boolean

Default Value: false

horizontalLine

Configures the horizontal crosshair line individually.

Type:

Object

|

Boolean

Crosshair lines can be configured using the following objects.

  • crosshair.horizontalLine
    Configures the horizontal crosshair line only.

  • crosshair.verticalLine
    Configures the vertical crosshair line only.

  • crosshair
    Configures both the crosshair lines.

Properties declared in the horizontalLine and verticalLine objects override the properties declared in the crosshair object.

NOTE
Instead of an object, you can assign a Boolean value to the horizontalLine field. This value will control the visibility of the horizontal crosshair line.

label

Configures the crosshair labels.

Type:

Object

Crosshair labels appear on the chart axes when a user pauses on a series point. They display the argument and the value of this series point.

DevExtreme HTML5 Charts CrosshairLabels

There are two crosshair labels on a chart - one for each crosshair line, and the label object described here configures both. If you need to set properties individually for each label, use the label object within the crosshair.horizontalLine or crosshair.verticalLine object. Individual settings override common ones.

Because the crosshair labels are hidden by default, assign true to the label.visible field if you need them to be shown.

opacity

Specifies how transparent the crosshair lines should be.

Type:

Number

Default Value: undefined

This property accepts a value from 0 to 1, where 0 makes the crosshair lines completely transparent, and 1 makes them opaque.

verticalLine

Configures the vertical crosshair line individually.

Type:

Object

|

Boolean

Crosshair lines can be configured using the following objects.

  • crosshair.horizontalLine
    Configures the horizontal crosshair line only.

  • crosshair.verticalLine
    Configures the vertical crosshair line only.

  • crosshair
    Configures both the crosshair lines.

Properties declared in the horizontalLine and verticalLine objects override the properties declared in the crosshair object.

NOTE
Instead of an object, you can assign a Boolean value to the verticalLine field. This value will control the visibility of the vertical crosshair line.

width

Specifies the width of the crosshair lines.

Type:

Number

Default Value: 1