Search results

Crosshair

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.

crosshair.razor
@using Syncfusion.EJ2.Blazor.Charts

<EjsChart Width="60%">
        <ChartPrimaryXAxis ValueType="Syncfusion.EJ2.Blazor.Charts.ValueType.DateTime"></ChartPrimaryXAxis>

        <ChartCrosshairSettings Enable="true"></ChartCrosshairSettings>
        
        <ChartSeriesCollection>
            <ChartSeries XName="X" YName="Y" DataSource="@SalesDetails" Type="ChartSeriesType.Line">
            </ChartSeries>
        </ChartSeriesCollection>
</EjsChart>

@code{
    public class ChartData
    {
        public DateTime X;
        public double Y;
    }
    public List<ChartData> SalesDetails = new List<ChartData>
    {
         new ChartData { X = new DateTime(2000, 01, 01), Y = 4  },
         new ChartData { X = new DateTime(2001, 01, 01), Y = 3.0 },
         new ChartData { X = new DateTime(2002, 01, 01), Y = 3.8 },
         new ChartData { X = new DateTime(2003, 01, 01), Y = 3.4 },
         new ChartData { X = new DateTime(2004, 01, 01), Y = 3.2 },
         new ChartData { X = new DateTime(2005, 01, 01), Y = 3.9 },
    };
}

Crosshair

Tooltip for axis

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

axis-tooltip.razor
@using Syncfusion.EJ2.Blazor.Charts

<EjsChart Width="60%">
        <ChartPrimaryXAxis ValueType="Syncfusion.EJ2.Blazor.Charts.ValueType.DateTime">
            <ChartAxisCrosshairTooltip Enable="true"></ChartAxisCrosshairTooltip>
        </ChartPrimaryXAxis>

        <ChartCrosshairSettings Enable="true"></ChartCrosshairSettings>

        <ChartPrimaryYAxis>
            <ChartAxisCrosshairTooltip Enable="true"></ChartAxisCrosshairTooltip> 
        </ChartPrimaryYAxis>

        <ChartSeriesCollection>
            <ChartSeries DataSource="@SalesDetails" XName="X" YName="Y" Type="ChartSeriesType.Line">
            </ChartSeries>
        </ChartSeriesCollection>
</EjsChart>

@code{
    public class ChartData
    {
        public DateTime X;
        public double Y;
    }
    public List<ChartData> SalesDetails = new List<ChartData>
    {
         new ChartData { X = new DateTime(2000, 01, 01), Y = 4  },
         new ChartData { X = new DateTime(2001, 01, 01), Y = 3.0 },
         new ChartData { X = new DateTime(2002, 01, 01), Y = 3.8 },
         new ChartData { X = new DateTime(2003, 01, 01), Y = 3.4 },
         new ChartData { X = new DateTime(2004, 01, 01), Y = 3.2 },
         new ChartData { X = new DateTime(2005, 01, 01), Y = 3.9 },
    };
}

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.

custom.razor
@using Syncfusion.EJ2.Blazor.Charts

<EjsChart Width="60%">
        <ChartPrimaryXAxis ValueType="Syncfusion.EJ2.Blazor.Charts.ValueType.DateTime">
        </ChartPrimaryXAxis>

        <ChartCrosshairSettings Enable="true">
            <CharCrosshairLine Width="2" Color="green"></CharCrosshairLine>
        </ChartCrosshairSettings>
        
        <ChartSeriesCollection> 
            <ChartSeries DataSource="@SalesDetails" XName="X" YName="Y" Type="ChartSeriesType.Line">
            </ChartSeries> 
        </ChartSeriesCollection> 
</EjsChart> 

@code{
    public class ChartData
    {
        public DateTime X;
        public double Y;
    }
    public List<ChartData> SalesDetails = new List<ChartData>
    {
         new ChartData { X = new DateTime(2000, 01, 01), Y = 4  },
         new ChartData { X = new DateTime(2001, 01, 01), Y = 3.0 },
         new ChartData { X = new DateTime(2002, 01, 01), Y = 3.8 },
         new ChartData { X = new DateTime(2003, 01, 01), Y = 3.4 },
         new ChartData { X = new DateTime(2004, 01, 01), Y = 3.2 },
         new ChartData { X = new DateTime(2005, 01, 01), Y = 3.9 },
    };
}

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.

trackball.razor
@using Syncfusion.EJ2.Blazor.Charts

<EjsChart Width="60%">
        <ChartPrimaryXAxis ValueType="Syncfusion.EJ2.Blazor.Charts.ValueType.DateTime">
        </ChartPrimaryXAxis> 

        <ChartCrosshairSettings Enable="true" LineType="LineType.Vertical"></ChartCrosshairSettings> 
  
        <ChartTooltipSettings Enable="true" Shared="true" Format="${series.name} : ${point.x} : ${point.y}"></ChartTooltipSettings>
  
        <ChartSeriesCollection> 
            <ChartSeries DataSource="@SalesDetails" XName="XValue" YName="YValue" Type="ChartSeriesType.Line">
            </ChartSeries> 
            <ChartSeries DataSource="@SalesDetails" XName="XValue" YName="YValue1" Type="ChartSeriesType.Line">
            </ChartSeries> 
            <ChartSeries DataSource="@SalesDetails" XName="XValue" YName="YValue2" Type="ChartSeriesType.Line">
            </ChartSeries> 
        </ChartSeriesCollection> 
</EjsChart> 

@code{
    public class ChartData
    {
        public DateTime XValue;
        public double YValue;
        public double YValue1;
        public double YValue2;
    }
    public List<ChartData> SalesDetails = new List<ChartData>
    {
         new ChartData { XValue = new DateTime(2000, 2, 11), YValue = 14, YValue1 = 39, YValue2 = 60 },
         new ChartData { XValue = new DateTime(2000, 9, 4), YValue = 20, YValue1 = 30, YValue2 = 55 },
         new ChartData { XValue = new DateTime(2001, 2, 11), YValue = 25, YValue1 = 28, YValue2 = 48 },
         new ChartData { XValue = new DateTime(2001, 9, 16), YValue = 21, YValue1 = 35, YValue2 = 57 },
         new ChartData { XValue = new DateTime(2002, 2, 7), YValue = 13, YValue1 = 39, YValue2 = 62 },
         new ChartData { XValue = new DateTime(2002, 9, 7), YValue = 18, YValue1 = 41, YValue2 = 64 },
         new ChartData { XValue = new DateTime(2003, 2, 11), YValue = 24, YValue1 = 45, YValue2 = 57 },
         new ChartData { XValue = new DateTime(2003, 9, 14), YValue = 23, YValue1 = 48, YValue2 = 53 },
         new ChartData { XValue = new DateTime(2004, 2, 6), YValue = 19, YValue1 = 54, YValue2 = 63 },
         new ChartData { XValue = new DateTime(2004, 9, 6), YValue = 31, YValue1 = 55, YValue2 = 50 },
         new ChartData { XValue = new DateTime(2005, 2, 11), YValue = 39, YValue1 = 57, YValue2 = 66 },
         new ChartData { XValue = new DateTime(2005, 9, 11), YValue = 50, YValue1 = 60, YValue2 = 65 },
         new ChartData { XValue = new DateTime(2006, 2, 11), YValue = 24, YValue1 = 60, YValue2 = 79 },
    };
}

Trackball

See Also