private void Render(TimeSeries ts) { float w = ((float) 180)/ts.Values.Count; float h = 80.0f; int margin = 10; StockPoints = new PointCollection(); for (int i = 1; i < ts.Values.Count; ++i) { var p0 = new Point(margin + (i - 1)*w, margin + (1 - ts.Values[i - 1])*h); var p1 = new Point(margin + i*w, margin + (1 - ts.Values[i])*h); StockPoints.Add(p0); StockPoints.Add(p1); } if (INDEX_POINTS == null) { INDEX_POINTS = new PointCollection(); TimeSeries index = DataCache.Instance.Index; for (int i = 1; i < index.Values.Count; ++i) { var p0 = new Point(margin + (i - 1)*w, margin + (1 - index.Values[i - 1])*h); var p1 = new Point(margin + i*w, margin + (1 - index.Values[i])*h); INDEX_POINTS.Add(p0); INDEX_POINTS.Add(p1); } } MathLine trend = ts.GetTrend(); TrendX1 = margin; TrendY1 = margin + (1 - trend.GetY(0))*h; TrendX2 = margin + (ts.Values.Count - 1)*w; TrendY2 = margin + (1 - trend.GetY(ts.Values.Count - 1))*h; TrendColor = new SolidColorBrush(GetTrendColor(trend.B)); }