GetSlotIndexByTime()

<< Click to Display Table of Contents >>

Navigation:  NinjaScript > Language Reference > Common > Charts > ChartControl >

GetSlotIndexByTime()

Previous page Return to chapter overview Next page

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)

 

Warning:  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

time

A DateTime Structure used to determine a slot index

 

 

Example

ns

protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
{
  // ensure that GetSlotIndexByTime is called on TimeBased charts
  if(chartControl.BarSpacingType != BarSpacingType.TimeBased)
  {
    // get the slot index of the first time painted on the chart
    double slotIndex = chartControl.GetSlotIndexByTime(chartControl.FirstTimePainted);
     
    Print(slotIndex);
  }
}