I'm using the following code to match the mouse position to the bar index in real time, this is my objective, that in a smooth and responsive way the bar index is highlighted on the chart.
protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
{
Print(string.Format("Render Event on {0}", DateTime.Now));
//var point = e.MouseDevice.GetPosition(this.ChartControl);
var point = this.ChartControl.MouseDownPoint;
Print(string.Format("X {0} Y {1}", point.X, point.Y));
DateTime slotTime = this.ChartControl.GetTimeByX((int)point.X);
if (Bars == null)
return;
int barsAgo = CurrentBar - Bars.GetBar(slotTime);
Draw.TextFixed(this, "TEXT", string.Format("{0}", CurrentBar - barsAgo), TextPosition.TopRight);
}
Regards,

Comment