Crosshair in ASP.NET Core Chart Component

18 Nov 20181 minute to read

Crosshair has a vertical and horizontal line to view the value of the axis at mouse or touch position.

Crosshair lines can be enabled by using enable property in the crosshair.

Tooltip for axis

Tooltip label for an axis can be enabled by using enable property of crosshairTooltip in the corresponding axis.

Customization

The fill and textStyle property of the crosshairTooltip is used to customize the background color and font style of the crosshair label respectively. Color and width of the crosshair line can be customized by using the line property in the crosshair.

Crosshair label customization

The CrosshairLabelRender event is triggered before each crosshair axis label is rendered. This event allows you to customize the label content and appearance, or prevent a label from being displayed.

Event arguments:

  • text – The label text that can be modified.
  • value – The data value at the crosshair position.
  • axisName – The axis identifier (for example, primaryXAxis).
  • axisOrientation – The orientation of the axis (Horizontal or Vertical).
  • textStyle – Font properties used to customize the label text.
  • fill – Background color of the label.
  • cancel – Set this property to true to skip rendering the label.

Snap to data

Enabling the SnapToData property in the crosshair aligns it with the nearest data point instead of following the exact mouse position.

Trackball

Trackball is used to track a data point closest to the mouse or touch position. Trackball marker indicates the closest point and trackball tooltip displays the information about the point.

Trackball can be enabled by setting the enable property of the crosshair to true and shared property in tooltip to true in chart.

Crosshair highlight

The HighlightCategory property in the crosshair highlights the background of the entire category when hovered over. The crosshair color can be customized using the Color property within the Line configuration.