GetTimeByX()

View as Markdown

Definition

Returns a time value related to the primary Bars slot index at a specified x-coordinate relative to the ChartControl.

Since the time is based upon a coordinate of the chart canvas, the value returned by GetTimeByX() can be expected to change as new bars are painted on the chart, or as the chart is scrolled backward or forward on the x-axis.

Method Return Value

A DateTime object corresponding to a slot index at a specified x-coordinate.

Syntax

\<chartcontrol\>.GetTimeByX(int x)

Method Parameters

ParameterDescription
xThe x-coordinate used to find a time value

Examples

1protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
2{
3 // Find the timestamp of the bar at x-coordinate 100
4 DateTime slotTime = chartControl.GetTimeByX(100);
5
6 // Print the date of slotTime
7 Print(slotTime);
8}