Search results

Events in Blazor Range Selector component

28 Jul 2021 / 8 minutes to read

This section describes about the Range Selector component’s events, that is triggered when appropriate actions are performed. The events should be provided to the Range Selector through the RangeNavigatorEvents component.

The Range Selector component supports the following events.

Loaded

The Loaded event triggers, after the Range Selector is rendered.

Copied to clipboard
@using Syncfusion.Blazor.Charts

<SfRangeNavigator Value="@Value" ValueType="RangeValueType.DateTime" IntervalType="RangeIntervalType.Years">
<RangeNavigatorEvents Loaded="RangeNavigatorLoaded"></RangeNavigatorEvents>
<RangeNavigatorSeriesCollection>
    <RangeNavigatorSeries DataSource="@StockInfo" XName="Date" Type="RangeNavigatorType.Line" YName="Close">
    </RangeNavigatorSeries>
</RangeNavigatorSeriesCollection>
</SfRangeNavigator>

@code {
public class StockDetails
{
    public DateTime Date { get; set; }
    public double Close { get; set; }
}
public List<StockDetails> StockInfo = new List<StockDetails> {
    new StockDetails { Date = new DateTime(2005, 01, 01), Close = 21 },
    new StockDetails { Date = new DateTime(2006, 01, 01), Close = 24 },
    new StockDetails { Date = new DateTime(2007, 01, 01), Close = 36 },
    new StockDetails { Date = new DateTime(2008, 01, 01), Close = 38 },
    new StockDetails { Date = new DateTime(2009, 01, 01), Close = 54 },
    new StockDetails { Date = new DateTime(2010, 01, 01), Close = 57 },
    new StockDetails { Date = new DateTime(2011, 01, 01), Close = 70 }
};
public DateTime[] Value = new DateTime[] {
    new DateTime(2006, 01, 01), new DateTime(2008, 01, 01)
};
public void RangeNavigatorLoaded(RangeLoadedEventArgs args)
{
    // Here you can customize your code.
}
}

OnPrintCompleted

The OnPrintCompleted event triggers, after the Range Selector is printed.

Copied to clipboard
@using Syncfusion.Blazor.Charts

<SfRangeNavigator Value="@Value" ValueType="RangeValueType.DateTime" IntervalType="RangeIntervalType.Years">
<RangeNavigatorEvents OnPrintCompleted="PrintCompleted"></RangeNavigatorEvents>
<RangeNavigatorSeriesCollection>
    <RangeNavigatorSeries DataSource="@StockInfo" XName="Date" Type="RangeNavigatorType.Line" YName="Close">
    </RangeNavigatorSeries>
</RangeNavigatorSeriesCollection>
</SfRangeNavigator>

@code {
public class StockDetails
{
    public DateTime Date { get; set; }
    public double Close { get; set; }
}
public List<StockDetails> StockInfo = new List<StockDetails> {
    new StockDetails { Date = new DateTime(2005, 01, 01), Close = 21 },
    new StockDetails { Date = new DateTime(2006, 01, 01), Close = 24 },
    new StockDetails { Date = new DateTime(2007, 01, 01), Close = 36 },
    new StockDetails { Date = new DateTime(2008, 01, 01), Close = 38 },
    new StockDetails { Date = new DateTime(2009, 01, 01), Close = 54 },
    new StockDetails { Date = new DateTime(2010, 01, 01), Close = 57 },
    new StockDetails { Date = new DateTime(2011, 01, 01), Close = 70 }
};
public DateTime[] Value = new DateTime[] {
    new DateTime(2006, 01, 01), new DateTime(2008, 01, 01)
};
public void PrintCompleted(EventArgs args)
{
    // Here you can customize your code.
}
}

Changed

The Changed event triggers, whenever the slider position is changed. The following arguments are present in this event:

  • Start - Specifies the start value.
  • End - Specifies the end value.
  • ZoomFactor - Specifies the zoom factor.
  • ZoomPosition - Specifies the zoom position.
  • SelectedData - The selected data collection can be accessed in this argument.
Copied to clipboard
@using Syncfusion.Blazor.Charts

<SfRangeNavigator Value="@Value" ValueType="RangeValueType.DateTime" IntervalType="RangeIntervalType.Years">
<RangeNavigatorEvents Changed="SliderChanged"></RangeNavigatorEvents>
<RangeNavigatorSeriesCollection>
    <RangeNavigatorSeries DataSource="@StockInfo" XName="Date" Type="RangeNavigatorType.Line" YName="Close">
    </RangeNavigatorSeries>
</RangeNavigatorSeriesCollection>
</SfRangeNavigator>

@code {
public class StockDetails
{
    public DateTime Date { get; set; }
    public double Close { get; set; }
}
public List<StockDetails> StockInfo = new List<StockDetails> {
    new StockDetails { Date = new DateTime(2005, 01, 01), Close = 21 },
    new StockDetails { Date = new DateTime(2006, 01, 01), Close = 24 },
    new StockDetails { Date = new DateTime(2007, 01, 01), Close = 36 },
    new StockDetails { Date = new DateTime(2008, 01, 01), Close = 38 },
    new StockDetails { Date = new DateTime(2009, 01, 01), Close = 54 },
    new StockDetails { Date = new DateTime(2010, 01, 01), Close = 57 },
    new StockDetails { Date = new DateTime(2011, 01, 01), Close = 70 }
};
public DateTime[] Value = new DateTime[] {
    new DateTime(2006, 01, 01), new DateTime(2008, 01, 01)
};
public void SliderChanged(ChangedEventArgs args)
{
    // Here you can customize your code.
}
}

Resized

The Resized event triggers, when the browser window is resized. The following arguments are present in this event:

  • CurrentSize - Specifies the current size for the Range Selector.
  • PreviousSize - Specifies the previous size for the Range Selector.
Copied to clipboard
@using Syncfusion.Blazor.Charts

<SfRangeNavigator Value="@Value" ValueType="RangeValueType.DateTime" IntervalType="RangeIntervalType.Years">
<RangeNavigatorEvents Resized="RangeNavigatorResized"></RangeNavigatorEvents>
<RangeNavigatorSeriesCollection>
    <RangeNavigatorSeries DataSource="@StockInfo" XName="Date" Type="RangeNavigatorType.Line" YName="Close">
    </RangeNavigatorSeries>
</RangeNavigatorSeriesCollection>
</SfRangeNavigator>

@code {
public class StockDetails
{
    public DateTime Date { get; set; }
    public double Close { get; set; }
}
public List<StockDetails> StockInfo = new List<StockDetails> {
    new StockDetails { Date = new DateTime(2005, 01, 01), Close = 21 },
    new StockDetails { Date = new DateTime(2006, 01, 01), Close = 24 },
    new StockDetails { Date = new DateTime(2007, 01, 01), Close = 36 },
    new StockDetails { Date = new DateTime(2008, 01, 01), Close = 38 },
    new StockDetails { Date = new DateTime(2009, 01, 01), Close = 54 },
    new StockDetails { Date = new DateTime(2010, 01, 01), Close = 57 },
    new StockDetails { Date = new DateTime(2011, 01, 01), Close = 70 }
};
public DateTime[] Value = new DateTime[] {
    new DateTime(2006, 01, 01), new DateTime(2008, 01, 01)
};
public void RangeNavigatorResized(RangeResizeEventArgs args)
{
    // Here you can customize your code.
}
}

LabelRender

Before rendering each axis label, the LabelRender event is triggered. The following arguments are present in this event:

  • Text - Specifies the current axis label text.
  • Value - Specifies the current axis label value.
  • Region - Specifies the current axis label position.
  • LabelStyle - Specifies the current axis label style.
Copied to clipboard
@using Syncfusion.Blazor.Charts

<SfRangeNavigator Value="@Value" ValueType="RangeValueType.DateTime" IntervalType="RangeIntervalType.Years">
<RangeNavigatorEvents LabelRender="LabelCustomization"></RangeNavigatorEvents>
<RangeNavigatorSeriesCollection>
    <RangeNavigatorSeries DataSource="@StockInfo" XName="Date" Type="RangeNavigatorType.Line" YName="Close">
    </RangeNavigatorSeries>
</RangeNavigatorSeriesCollection>
</SfRangeNavigator>

@code {
public class StockDetails
{
    public DateTime Date { get; set; }
    public double Close { get; set; }
}
public List<StockDetails> StockInfo = new List<StockDetails> {
    new StockDetails { Date = new DateTime(2005, 01, 01), Close = 21 },
    new StockDetails { Date = new DateTime(2006, 01, 01), Close = 24 },
    new StockDetails { Date = new DateTime(2007, 01, 01), Close = 36 },
    new StockDetails { Date = new DateTime(2008, 01, 01), Close = 38 },
    new StockDetails { Date = new DateTime(2009, 01, 01), Close = 54 },
    new StockDetails { Date = new DateTime(2010, 01, 01), Close = 57 },
    new StockDetails { Date = new DateTime(2011, 01, 01), Close = 70 }
};
public DateTime[] Value = new DateTime[] {
    new DateTime(2006, 01, 01), new DateTime(2008, 01, 01)
};
public void LabelCustomization(RangeLabelRenderEventArgs args)
{
    // Here you can customize your code.
}
}

TooltipRender

The TooltipRender event triggers before the tooltip is rendered. The following arguments are present in this event:

  • Text - Specifies the current tooltip text.
  • TextStyle - Specifies the current tooltip text style.
Copied to clipboard
@using Syncfusion.Blazor.Charts

<SfRangeNavigator Value="@Value" ValueType="RangeValueType.DateTime" IntervalType="RangeIntervalType.Years">
<RangeNavigatorEvents TooltipRender="TooltipCustomization"></RangeNavigatorEvents>
<RangeNavigatorSeriesCollection>
    <RangeNavigatorSeries DataSource="@StockInfo" XName="Date" Type="RangeNavigatorType.Line" YName="Close">
    </RangeNavigatorSeries>
</RangeNavigatorSeriesCollection>
</SfRangeNavigator>

@code {
public class StockDetails
{
    public DateTime Date { get; set; }
    public double Close { get; set; }
}
public List<StockDetails> StockInfo = new List<StockDetails> {
    new StockDetails { Date = new DateTime(2005, 01, 01), Close = 21 },
    new StockDetails { Date = new DateTime(2006, 01, 01), Close = 24 },
    new StockDetails { Date = new DateTime(2007, 01, 01), Close = 36 },
    new StockDetails { Date = new DateTime(2008, 01, 01), Close = 38 },
    new StockDetails { Date = new DateTime(2009, 01, 01), Close = 54 },
    new StockDetails { Date = new DateTime(2010, 01, 01), Close = 57 },
    new StockDetails { Date = new DateTime(2011, 01, 01), Close = 70 }
};
public DateTime[] Value = new DateTime[] {
    new DateTime(2006, 01, 01), new DateTime(2008, 01, 01)
};
public void TooltipCustomization(RangeTooltipRenderEventArgs args)
{
    // Here you can customize your code.
}
}

SelectorRender

The SelectorRender event triggers before the period selector is rendered. The following arguments are present in this event:

  • Content - Specifies the content for the calendar in the period selector.
  • EnableCustomFormat - Enables to show the content for the calendar in the period selector. By default it is true.
  • Selector - Specifies the period selector collection.
Copied to clipboard
@using Syncfusion.Blazor.Charts

<SfRangeNavigator Value="@Value" ValueType="RangeValueType.DateTime" IntervalType="RangeIntervalType.Years">
<RangeNavigatorPeriodSelectorSettings>
    <RangeNavigatorPeriods>
        <RangeNavigatorPeriod Interval="1" IntervalType="RangeIntervalType.Months" Text="1M"></RangeNavigatorPeriod>
        <RangeNavigatorPeriod Interval="2" IntervalType="RangeIntervalType.Months" Text="2M"></RangeNavigatorPeriod>
        <RangeNavigatorPeriod Interval="6" IntervalType="RangeIntervalType.Months" Text="6M"></RangeNavigatorPeriod>
        <RangeNavigatorPeriod Text="YTD"></RangeNavigatorPeriod>
        <RangeNavigatorPeriod Interval="1" IntervalType="RangeIntervalType.Years" Text="1Y"></RangeNavigatorPeriod>
        <RangeNavigatorPeriod Interval="2" IntervalType="RangeIntervalType.Years" Text="2Y"></RangeNavigatorPeriod>
        <RangeNavigatorPeriod Text="All"></RangeNavigatorPeriod>
    </RangeNavigatorPeriods>
</RangeNavigatorPeriodSelectorSettings>
<RangeNavigatorEvents SelectorRender="SelectorCustomization"></RangeNavigatorEvents>
<RangeNavigatorSeriesCollection>
    <RangeNavigatorSeries DataSource="@StockInfo" XName="Date" Type="RangeNavigatorType.Line" YName="Close">
    </RangeNavigatorSeries>
</RangeNavigatorSeriesCollection>
</SfRangeNavigator>

@code {
public class StockDetails
{
    public DateTime Date { get; set; }
    public double Close { get; set; }
}
public List<StockDetails> StockInfo = new List<StockDetails> {
    new StockDetails { Date = new DateTime(2005, 01, 01), Close = 21 },
    new StockDetails { Date = new DateTime(2006, 01, 01), Close = 24 },
    new StockDetails { Date = new DateTime(2007, 01, 01), Close = 36 },
    new StockDetails { Date = new DateTime(2008, 01, 01), Close = 38 },
    new StockDetails { Date = new DateTime(2009, 01, 01), Close = 54 },
    new StockDetails { Date = new DateTime(2010, 01, 01), Close = 57 },
    new StockDetails { Date = new DateTime(2011, 01, 01), Close = 70 }
};
public DateTime[] Value = new DateTime[] {
    new DateTime(2006, 01, 01), new DateTime(2008, 01, 01)
};
public void SelectorCustomization(RangeSelectorRenderEventArgs args)
{
    // Here you can customize your code.
}
}