Esempio n. 1
0
        /// <summary>
        /// This method updates a single data point.
        /// </summary>
        /// <param name="dataPoint">The data point to update.</param>
        protected override void UpdateDataPoint(DataPoint dataPoint)
        {
            double PlotAreaHeight = ActualDependentRangeAxis.GetPlotAreaCoordinate(ActualDependentRangeAxis.Range.Maximum);
            double dataPointX     = ActualIndependentRangeAxis.GetPlotAreaCoordinate(ValueHelper.ToComparable(dataPoint.ActualIndependentValue));
            double dataPointY     = ActualDependentRangeAxis.GetPlotAreaCoordinate(ValueHelper.ToDouble(dataPoint.ActualDependentValue));

            if (ValueHelper.CanGraph(dataPointX) && ValueHelper.CanGraph(dataPointY))
            {
                // Set dimensions
                if (!double.IsNaN(MarkerHeight))
                {
                    dataPoint.Height = MarkerHeight;
                }

                if (!double.IsNaN(MarkerWidth))
                {
                    dataPoint.Width = MarkerWidth;
                }

                // Call UpdateLayout to ensure ActualWidth/ActualHeight are correct
                if (dataPoint.ActualWidth == 0.0 || dataPoint.ActualHeight == 0.0)
                {
                    dataPoint.UpdateLayout();
                }

                // Set the Position
                Canvas.SetLeft(
                    dataPoint,
                    Math.Round(dataPointX - (dataPoint.ActualWidth / 2)));
                Canvas.SetTop(
                    dataPoint,
                    Math.Round(PlotAreaHeight - (dataPointY + (dataPoint.ActualHeight / 2))));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// This method updates a single data point.
        /// </summary>
        /// <param name="dataPoint">The data point to update.</param>
        protected override void UpdateDataPoint(DataPoint dataPoint)
        {
            StockBarDataPoint candlestickDataPoint = (StockBarDataPoint)dataPoint;

            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 (!singleBlockWidth.HasValue)
            {
                Range <Double> doubleRange = ActualIndependentRangeAxis.Range.ToDoubleRange();

                Double rangeLength = doubleRange.Maximum - doubleRange.Minimum;

                if (rangeLength > 0.0)
                {
                    singleBlockWidth = PlotArea.Width * 1.0 / rangeLength;

                    if (singleBlockWidth < 4.0)
                    {
                        singleBlockWidth = 4.0;
                    }
                }
                else
                {
                    singleBlockWidth = 4.0;
                }
            }

            if (ValueHelper.CanGraph(dataPointX))
            {
                candlestickDataPoint.Background = new SolidColorBrush(Colors.Transparent);

                dataPoint.Height = Math.Abs(highPointY - lowPointY);

                dataPoint.Width = singleBlockWidth.Value * 0.8;

                if (dataPoint.Width > 16.0)
                {
                    dataPoint.Width = 16.0;
                }

                candlestickDataPoint.UpdateBody(ActualDependentRangeAxis);

                //if (dataPoint.ActualWidth == 0.0 || dataPoint.ActualHeight == 0.0)
                {
                    dataPoint.UpdateLayout();
                }

                Canvas.SetLeft(dataPoint, Math.Round(dataPointX - (dataPoint.ActualWidth / 2)));

                Canvas.SetTop(dataPoint, Math.Round(PlotAreaHeight - highPointY));
            }
        }
        /// <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));
            }
        }
        /// <summary>
        /// Updates the visual representation of the data point.
        /// </summary>
        /// <param name="dataPoint">The data point to update.</param>
        protected override void UpdateDataPoint(DataPoint dataPoint)
        {
            double maximum = ActualDependentRangeAxis.GetPlotAreaCoordinate(ActualDependentRangeAxis.Range.Maximum);

            if (ValueHelper.CanGraph(maximum))
            {
                double x = ActualIndependentRangeAxis.GetPlotAreaCoordinate(ValueHelper.ToComparable(dataPoint.ActualIndependentValue));
                double y = ActualDependentRangeAxis.GetPlotAreaCoordinate(ValueHelper.ToDouble(dataPoint.ActualDependentValue));

                if (ValueHelper.CanGraph(x) && ValueHelper.CanGraph(y))
                {
                    if (!double.IsNaN(MarkerHeight))
                    {
                        dataPoint.Height = MarkerHeight;
                    }
                    if (!double.IsNaN(MarkerWidth))
                    {
                        dataPoint.Width = MarkerWidth;
                    }

                    // Call UpdateLayout to ensure ActualWidth/ActualHeight are correct
                    if (dataPoint.ActualWidth == 0.0 || dataPoint.ActualHeight == 0.0)
                    {
                        dataPoint.UpdateLayout();
                    }

                    double coordinateY = Math.Round(maximum - (y + (dataPoint.ActualHeight / 2)));
                    Canvas.SetTop(dataPoint, coordinateY);
                    double coordinateX = Math.Round(x - (dataPoint.ActualWidth / 2));
                    Canvas.SetLeft(dataPoint, coordinateX);
                }

                if (!UpdatingAllDataPoints)
                {
                    UpdatePointsCollection();
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// This method updates a single data point.
        /// </summary>
        /// <param name="dataPoint">The data point to update.</param>
        protected override void UpdateDataPoint(DataPoint dataPoint)
        {
            double PlotAreaHeight = ActualDependentRangeAxis.GetPlotAreaCoordinate(ActualDependentRangeAxis.Range.Maximum);
            double dataPointX = ActualIndependentRangeAxis.GetPlotAreaCoordinate(ValueHelper.ToComparable(dataPoint.ActualIndependentValue));
            double dataPointY = ActualDependentRangeAxis.GetPlotAreaCoordinate(ValueHelper.ToDouble(dataPoint.ActualDependentValue));

            if (ValueHelper.CanGraph(dataPointX) && ValueHelper.CanGraph(dataPointY))
            {
                // Set dimensions
                if (!double.IsNaN(MarkerHeight))
                {
                    dataPoint.Height = MarkerHeight;
                }

                if (!double.IsNaN(MarkerWidth))
                {
                    dataPoint.Width = MarkerWidth;
                }

                // Call UpdateLayout to ensure ActualWidth/ActualHeight are correct
                if (dataPoint.ActualWidth == 0.0 || dataPoint.ActualHeight == 0.0)
                {
                    dataPoint.UpdateLayout();
                }

                // Set the Position
                Canvas.SetLeft(
                    dataPoint,
                    Math.Round(dataPointX - (dataPoint.ActualWidth / 2)));
                Canvas.SetTop(
                    dataPoint,
                    Math.Round(PlotAreaHeight - (dataPointY + (dataPoint.ActualHeight / 2))));
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Updates the visual representation of the data point.
        /// </summary>
        /// <param name="dataPoint">The data point to update.</param>
        protected override void UpdateDataPoint(DataPoint dataPoint)
        {
            double maximum = ActualDependentRangeAxis.GetPlotAreaCoordinate(ActualDependentRangeAxis.Range.Maximum);
            if (ValueHelper.CanGraph(maximum))
            {
                double x = ActualIndependentRangeAxis.GetPlotAreaCoordinate(ValueHelper.ToComparable(dataPoint.ActualIndependentValue));
                double y = ActualDependentRangeAxis.GetPlotAreaCoordinate(ValueHelper.ToDouble(dataPoint.ActualDependentValue));

                if (ValueHelper.CanGraph(x) && ValueHelper.CanGraph(y))
                {
                    if (!double.IsNaN(MarkerHeight))
                    {
                        dataPoint.Height = MarkerHeight;
                    }
                    if (!double.IsNaN(MarkerWidth))
                    {
                        dataPoint.Width = MarkerWidth;
                    }

                    // Call UpdateLayout to ensure ActualWidth/ActualHeight are correct
                    if (dataPoint.ActualWidth == 0.0 || dataPoint.ActualHeight == 0.0)
                    {
                        dataPoint.UpdateLayout();
                    }

                    double coordinateY = Math.Round(maximum - (y + (dataPoint.ActualHeight / 2)));
                    Canvas.SetTop(dataPoint, coordinateY);
                    double coordinateX = Math.Round(x - (dataPoint.ActualWidth / 2));
                    Canvas.SetLeft(dataPoint, coordinateX);
                }

                if (!UpdatingAllDataPoints)
                {
                    UpdatePointsCollection();
                }
            }
        }