public CandleChartData.CandleValue InterpolateCandleInRect(CandleChartData.CandleValue candle, Rect viewRect) { CandleChartData.CandleValue res = new CandleChartData.CandleValue(); res.Open = ChartCommon.interpolateInRectY(viewRect, candle.Open); res.Close = ChartCommon.interpolateInRectY(viewRect, candle.Close); res.High = ChartCommon.interpolateInRectY(viewRect, candle.High); res.Low = ChartCommon.interpolateInRectY(viewRect, candle.Low); if (res.High < res.Low) { double tmp = res.High; res.High = res.Low; res.Low = tmp; tmp = res.Open; res.Open = res.Close; res.Close = tmp; } double candleEnd = candle.Start + candle.Duration; candleEnd = ChartCommon.interpolateInRectX(viewRect, candleEnd); double start = ChartCommon.interpolateInRectX(viewRect, candle.Start); double duration = candleEnd - start; if (start > candleEnd) { double tmp = start; start = candleEnd; candleEnd = tmp; } if (ThicknessMode == CandleThicknessMode.Constant) { Deflate(ref start, ref duration, ThicknessConstant / duration); } res.Start = start; res.Duration = duration; return(res); }