GetSlotIndexByTime()

View as Markdown

Definition

Returns the slot index relative to the chart control corresponding to a specified time value.

Notes:

  • A “Slot” is used in Equidistant bar spacing and represents a position on the chart canvas background which may or may not contain a bar. The concept of “Slots” does NOT exist on a TimeBased bar spacing type.
  • If you are looking for information on a bar series, please see ChartBars.GetBarIdxByTime().

Method Return Value

A double representing a slot index.

Syntax

\<chartcontrol\>.GetSlotIndexByTime(DateTime time)

This method CANNOT be called on BarSpacingType.TimeBased charts. You will need to ensure an Equidistant bar spacing type is used, otherwise errors will be thrown.

Method Parameters

ParameterDescription
timeA DateTime Structure used to determine a slot index

Examples

1protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
2{
3 // ensure that GetSlotIndexByTime is called on TimeBased charts
4 if(chartControl.BarSpacingType != BarSpacingType.TimeBased)
5 {
6 // get the slot index of the first time painted on the chart
7 double slotIndex = chartControl.GetSlotIndexByTime(chartControl.FirstTimePainted);
8
9 Print(slotIndex);
10 }
11}