protected override void PrepareDataPoint(DataPoint dataPoint, object dataContext) { base.PrepareDataPoint(dataPoint, dataContext); CandlestickDataPoint candlestickDataPoint = (CandlestickDataPoint)dataPoint; candlestickDataPoint.SetBinding(CandlestickDataPoint.OpenProperty, OpenValueBinding); candlestickDataPoint.SetBinding(CandlestickDataPoint.CloseProperty, CloseValueBinding); candlestickDataPoint.SetBinding(CandlestickDataPoint.HighProperty, HighValueBinding); candlestickDataPoint.SetBinding(CandlestickDataPoint.LowProperty, LowValueBinding); }
/// <summary> /// This method updates a single data point. /// </summary> /// <param name="dataPoint">The data point to update.</param> protected override void UpdateDataPoint(DataPoint dataPoint) { CandlestickDataPoint candlestickDataPoint = (CandlestickDataPoint)dataPoint; FrameworkElement fe = ActualIndependentRangeAxis as FrameworkElement; if (fe != null) { if (fe.ActualWidth == 0.0) { return; } } if (!axesHasBeenUpdated) { return; } double PlotAreaHeight = ActualDependentRangeAxis.GetPlotAreaCoordinate(ActualDependentRangeAxis.Range.Maximum); double dataPointX = ActualIndependentRangeAxis.GetPlotAreaCoordinate(ValueHelper.ToComparable(dataPoint.ActualIndependentValue)); double highPointY = ActualDependentRangeAxis.GetPlotAreaCoordinate(candlestickDataPoint.High); double lowPointY = ActualDependentRangeAxis.GetPlotAreaCoordinate(candlestickDataPoint.Low); double openPointY = ActualDependentRangeAxis.GetPlotAreaCoordinate(candlestickDataPoint.Open); double closePointY = ActualDependentRangeAxis.GetPlotAreaCoordinate(candlestickDataPoint.Close); if (closePointY > openPointY) { candlestickDataPoint.Background = positiveBrush; } else { candlestickDataPoint.Background = negativeBrush; } candlestickDataPoint.UpdateBody(ActualDependentRangeAxis); if (ValueHelper.CanGraph(dataPointX)) { dataPoint.Height = Math.Abs(highPointY - lowPointY); dataPoint.Width = 5.0; dataPoint.UpdateLayout(); Canvas.SetLeft(dataPoint, Math.Round(dataPointX - (dataPoint.ActualWidth / 2))); Canvas.SetTop(dataPoint, Math.Round(PlotAreaHeight - highPointY)); } }