/// <summary>
        /// Updates the data point's visual representation.
        /// </summary>
        /// <param name="dataPoint">The data point.</param>
        protected override void UpdateDataPoint(DataPoint dataPoint)
        {
            double maximumDiameter = Math.Min(PlotAreaSize.Width, PlotAreaSize.Height) * MaximumBubbleSizeAsRatioOfSmallestDimension;

            BubbleDataPoint bubbleDataPoint = (BubbleDataPoint)dataPoint;

            double ratioOfLargestBubble =
                (_rangeOfActualSizeValues.HasData && _rangeOfActualSizeValues.Maximum != 0.0 && bubbleDataPoint.ActualSize >= 0.0) ? Math.Abs(bubbleDataPoint.ActualSize) / _rangeOfActualSizeValues.Maximum : 0.0;

            bubbleDataPoint.Width  = ratioOfLargestBubble * maximumDiameter;
            bubbleDataPoint.Height = ratioOfLargestBubble * maximumDiameter;

            double left =
                (ActualIndependentAxis.GetPlotAreaCoordinate(bubbleDataPoint.ActualIndependentValue)).Value
                - (bubbleDataPoint.Width / 2.0);

            double top =
                (PlotAreaSize.Height
                 - (bubbleDataPoint.Height / 2.0))
                - ActualDependentRangeAxis.GetPlotAreaCoordinate(bubbleDataPoint.ActualDependentValue).Value;

            if (ValueHelper.CanGraph(left) && ValueHelper.CanGraph(top))
            {
                dataPoint.Visibility = Visibility.Visible;

                Canvas.SetLeft(bubbleDataPoint, left);
                Canvas.SetTop(bubbleDataPoint, top);
            }
            else
            {
                dataPoint.Visibility = Visibility.Collapsed;
            }
        }
        /// <summary>
        /// Returns the style to use for all data points.
        /// </summary>
        /// <returns>The style to use for all data points.</returns>
        //protected override Style GetDataPointStyleFromHost()
        //{
        //    return SeriesHost.NextStyle(typeof(CandlestickDataPoint), true);
        //}

        /// <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;

            double PlotAreaHeight = ActualDependentRangeAxis.GetPlotAreaCoordinate(ActualDependentRangeAxis.Range.Maximum).Value;
            double dataPointX     = ActualIndependentRangeAxis.GetPlotAreaCoordinate(dataPoint.ActualIndependentValue).Value;
            double highPointY     = ActualDependentRangeAxis.GetPlotAreaCoordinate(ValueHelper.ToDouble(candlestickDataPoint.High)).Value;
            double lowPointY      = ActualDependentRangeAxis.GetPlotAreaCoordinate(ValueHelper.ToDouble(candlestickDataPoint.Low)).Value;
            double openPointY     = ActualDependentRangeAxis.GetPlotAreaCoordinate(ValueHelper.ToDouble(candlestickDataPoint.Open)).Value;
            double closePointY    = ActualDependentRangeAxis.GetPlotAreaCoordinate(ValueHelper.ToDouble(candlestickDataPoint.Close)).Value;

            candlestickDataPoint.UpdateBody(ActualDependentRangeAxis);

            if (ValueHelper.CanGraph(dataPointX))
            {
                dataPoint.Height = Math.Abs(highPointY - lowPointY);
                dataPoint.Width  = 5.0;

                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));
            }
        }
        protected override void UpdateDataPoint(DataPoint dataPoint)
        {
            BubbleDataPoint bubbleDataPoint = (BubbleDataPoint)dataPoint;

            bubbleDataPoint.Width = 50;

            double left =
                (ActualIndependentAxis.GetPlotAreaCoordinate(bubbleDataPoint.ActualIndependentValue)).Value - bubbleDataPoint.Width / 2;

            double PlotAreaHeight = ActualDependentRangeAxis.GetPlotAreaCoordinate(ActualDependentRangeAxis.Range.Maximum).Value;
            double highPointY     = ActualDependentRangeAxis.GetPlotAreaCoordinate(ToDouble(bubbleDataPoint.ActualDependentValue)).Value;
            double lowPointY      = ActualDependentRangeAxis.GetPlotAreaCoordinate(ToDouble(bubbleDataPoint.ActualDependentValue) - bubbleDataPoint.ActualSize).Value;

            if (CanGraph(left) && CanGraph(PlotAreaHeight - highPointY))
            {
                dataPoint.Visibility = Visibility.Visible;
                dataPoint.Height     = Math.Abs(highPointY - lowPointY);

                Canvas.SetLeft(bubbleDataPoint, left);
                Canvas.SetTop(bubbleDataPoint, PlotAreaHeight - highPointY);
            }
            else
            {
                dataPoint.Visibility = Visibility.Collapsed;
            }
        }
예제 #4
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))));
            }
        }
        /// <summary>
        /// Updates the point collection object.
        /// </summary>
        private void UpdatePointsCollection()
        {
            double maximum = ActualDependentRangeAxis.GetPlotAreaCoordinate(ActualDependentRangeAxis.Range.Maximum);

            if (ValueHelper.CanGraph(maximum))
            {
                IEnumerable <Point> points =
                    ActiveDataPoints
                    .OrderBy(dataPoint => dataPoint.IndependentValue)
                    .Select(dataPoint =>
                            new Point(
                                ActualIndependentRangeAxis.GetPlotAreaCoordinate((IComparable)dataPoint.ActualIndependentValue),
                                maximum - ActualDependentRangeAxis.GetPlotAreaCoordinate((IComparable)dataPoint.ActualDependentValue)));

                if (!points.IsEmpty())
                {
                    this.Points = new PointCollection();
                    foreach (Point point in points)
                    {
                        this.Points.Add(point);
                    }
                }
                else
                {
                    this.Points = null;
                }
            }
        }
예제 #6
0
        /// <summary>
        /// Updates each point.
        /// </summary>
        /// <param name="dataPoint">The data point to update.</param>
        protected override void UpdateDataPoint(DataPoint dataPoint)
        {
            if (SeriesHost == null || PlotArea == null)
            {
                return;
            }

            object            category        = dataPoint.ActualIndependentValue ?? (this.ActiveDataPoints.IndexOf(dataPoint) + 1);
            Range <UnitValue> coordinateRange = GetCategoryRange(category);

            if (!coordinateRange.HasData)
            {
                return;
            }
            else if (coordinateRange.Maximum.Unit != Unit.Pixels || coordinateRange.Minimum.Unit != Unit.Pixels)
            {
                throw new InvalidOperationException(Properties.Resources.DataPointSeriesWithAxes_ThisSeriesDoesNotSupportRadialAxes);
            }

            double minimum = (double)coordinateRange.Minimum.Value;
            double maximum = (double)coordinateRange.Maximum.Value;

            IEnumerable <BarSeries> barSeries = SeriesHost.Series.OfType <BarSeries>().Where(series => series.ActualIndependentAxis == ActualIndependentAxis);
            int    numberOfSeries             = barSeries.Count();
            double coordinateRangeHeight      = (maximum - minimum);
            double segmentHeight = coordinateRangeHeight * 0.8;
            double barHeight     = segmentHeight / numberOfSeries;
            int    seriesIndex   = barSeries.IndexOf(this);

            double dataPointX = ActualDependentRangeAxis.GetPlotAreaCoordinate(ValueHelper.ToDouble(dataPoint.ActualDependentValue)).Value.Value;
            double zeroPointX = ActualDependentRangeAxis.GetPlotAreaCoordinate(ActualDependentRangeAxis.Origin).Value.Value;

            double offset     = seriesIndex * Math.Round(barHeight) + coordinateRangeHeight * 0.1;
            double dataPointY = minimum + offset;

            if (GetIsDataPointGrouped(category))
            {
                // Multiple DataPoints share this category; offset and overlap them appropriately
                IGrouping <object, DataPoint> categoryGrouping = GetDataPointGroup(category);
                int index = categoryGrouping.IndexOf(dataPoint);
                dataPointY += (index * (barHeight * 0.2)) / (categoryGrouping.Count() - 1);
                barHeight  *= 0.8;
                Canvas.SetZIndex(dataPoint, -index);
            }

            if (ValueHelper.CanGraph(dataPointX) && ValueHelper.CanGraph(dataPointY) && ValueHelper.CanGraph(zeroPointX))
            {
                double top    = Math.Round(dataPointY);
                double height = Math.Round(barHeight);

                double left  = Math.Round(Math.Min(dataPointX, zeroPointX) - 0.5);
                double right = Math.Round(Math.Max(dataPointX, zeroPointX) - 0.5);
                double width = right - left + 1;

                Canvas.SetLeft(dataPoint, left);
                Canvas.SetTop(dataPoint, top);
                dataPoint.Width  = width;
                dataPoint.Height = height;
            }
        }
        /// <summary>
        /// Updates the data point's visual representation.
        /// </summary>
        /// <param name="dataPoint">The data point.</param>
        protected override void UpdateDataPoint(DataPoint dataPoint)
        {
            double maximumDiameter = Math.Min(PlotAreaSize.Width, PlotAreaSize.Height) * MaximumBubbleSizeAsRatioOfSmallestDimension;

            BubbleDataPoint bubbleDataPoint = (BubbleDataPoint)dataPoint;

            double ratioOfLargestBubble =
                (MaxOfDataPointActualSizeValues.HasValue && MaxOfDataPointActualSizeValues.Value != 0.0 && bubbleDataPoint.ActualSize >= 0.0) ? Math.Abs(bubbleDataPoint.ActualSize) / MaxOfDataPointActualSizeValues.Value : 0.0;

            bubbleDataPoint.Width  = ratioOfLargestBubble * maximumDiameter;
            bubbleDataPoint.Height = ratioOfLargestBubble * maximumDiameter;

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

            double left =
                (ActualIndependentRangeAxis.GetPlotAreaCoordinate((IComparable)bubbleDataPoint.ActualIndependentValue))
                - (bubbleDataPoint.Width / 2.0);

            double top =
                (PlotAreaSize.Height
                 - (bubbleDataPoint.Height / 2.0))
                - ActualDependentRangeAxis.GetPlotAreaCoordinate((IComparable)bubbleDataPoint.ActualDependentValue);

            if (ValueHelper.CanGraph(left) && ValueHelper.CanGraph(top))
            {
                Canvas.SetLeft(bubbleDataPoint, left);
                Canvas.SetTop(bubbleDataPoint, top);
            }
        }
예제 #8
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>
        /// Updates each point.
        /// </summary>
        /// <param name="dataPoint">The data point to update.</param>
        protected override void UpdateDataPoint(DataPoint dataPoint)
        {
            if (SeriesHost == null || PlotArea == null)
            {
                return;
            }

            object         category        = dataPoint.IndependentValue ?? (this.ActiveDataPoints.IndexOf(dataPoint) + 1);
            Range <double> coordinateRange = ActualIndependentCategoryAxis.GetPlotAreaCoordinateRange(category);

            if (!coordinateRange.HasData)
            {
                return;
            }

            double plotAreaHeight = ActualDependentRangeAxis.GetPlotAreaCoordinate(ActualDependentRangeAxis.Range.Maximum);
            IEnumerable <ColumnSeries> columnSeries = SeriesHost.Series.OfType <ColumnSeries>().Where(series => series.ActualIndependentCategoryAxis == ActualIndependentCategoryAxis);
            int    numberOfSeries       = columnSeries.Count();
            double coordinateRangeWidth = (coordinateRange.Maximum - coordinateRange.Minimum);
            double segmentWidth         = coordinateRangeWidth * 0.8;
            double columnWidth          = segmentWidth / numberOfSeries;
            int    seriesIndex          = columnSeries.IndexOf(this);

            double dataPointY = ActualDependentRangeAxis.GetPlotAreaCoordinate(ValueHelper.ToDouble(dataPoint.ActualDependentValue));
            double zeroPointY = ActualDependentRangeAxis.GetPlotAreaCoordinate(0);

            double offset     = seriesIndex * Math.Round(columnWidth) + coordinateRangeWidth * 0.1;
            double dataPointX = coordinateRange.Minimum + offset;

            if (_categoriesWithMultipleDataPoints.ContainsKey(category))
            {
                // Multiple DataPoints share this category; offset and overlap them appropriately
                IGrouping <object, DataPoint> categoryGrouping = _categoriesWithMultipleDataPoints[category];
                int index = categoryGrouping.IndexOf(dataPoint);
                dataPointX  += (index * (columnWidth * 0.2)) / (categoryGrouping.Count() - 1);
                columnWidth *= 0.8;
                Canvas.SetZIndex(dataPoint, -index);
            }

            if (!double.IsNaN(dataPointY) && !double.IsNaN(dataPointX) && !double.IsNaN(zeroPointY))
            {
                double left  = Math.Round(dataPointX);
                double width = Math.Round(columnWidth);

                double top    = Math.Round(plotAreaHeight - Math.Max(dataPointY, zeroPointY) + 0.5);
                double bottom = Math.Round(plotAreaHeight - Math.Min(dataPointY, zeroPointY) + 0.5);
                double height = bottom - top + 1;

                Canvas.SetLeft(dataPoint, left);
                Canvas.SetTop(dataPoint, top);
                dataPoint.Width  = width;
                dataPoint.Height = height;
            }
        }
예제 #10
0
        /// <summary>
        /// Updates each point.
        /// </summary>
        /// <param name="dataPoint">The data point to update.</param>
        protected override void UpdateDataPoint(DataPoint dataPoint)
        {
            if (SeriesHost == null || PlotArea == null)
            {
                return;
            }

            object         category        = dataPoint.IndependentValue ?? (this.ActiveDataPoints.IndexOf(dataPoint) + 1);
            Range <double> coordinateRange = ActualIndependentCategoryAxis.GetPlotAreaCoordinateRange(category);

            if (!coordinateRange.HasData)
            {
                return;
            }

            IEnumerable <BarSeries> barSeries = SeriesHost.Series.OfType <BarSeries>().Where(series => series.ActualIndependentCategoryAxis == ActualIndependentCategoryAxis);
            int    numberOfSeries             = barSeries.Count();
            double coordinateRangeHeight      = (coordinateRange.Maximum - coordinateRange.Minimum);
            double segmentHeight = coordinateRangeHeight * 0.8;
            double barHeight     = segmentHeight / numberOfSeries;
            int    seriesIndex   = barSeries.IndexOf(this);

            double dataPointX = ActualDependentRangeAxis.GetPlotAreaCoordinate(ValueHelper.ToDouble(dataPoint.ActualDependentValue));
            double zeroPointX = ActualDependentRangeAxis.GetPlotAreaCoordinate(0);

            double offset     = seriesIndex * Math.Round(barHeight) + coordinateRangeHeight * 0.1;
            double dataPointY = coordinateRange.Minimum + offset;

            if (_categoriesWithMultipleDataPoints.ContainsKey(category))
            {
                // Multiple DataPoints share this category; offset and overlap them appropriately
                IGrouping <object, DataPoint> categoryGrouping = _categoriesWithMultipleDataPoints[category];
                int index = categoryGrouping.IndexOf(dataPoint);
                dataPointY += (index * (barHeight * 0.2)) / (categoryGrouping.Count() - 1);
                barHeight  *= 0.8;
                Canvas.SetZIndex(dataPoint, -index);
            }

            if (ValueHelper.CanGraph(dataPointX) && ValueHelper.CanGraph(dataPointY) && ValueHelper.CanGraph(zeroPointX))
            {
                double top    = Math.Round(dataPointY);
                double height = Math.Round(barHeight);

                double left  = Math.Round(Math.Min(dataPointX, zeroPointX) - 0.5);
                double right = Math.Round(Math.Max(dataPointX, zeroPointX) - 0.5);
                double width = right - left + 1;

                Canvas.SetLeft(dataPoint, left);
                Canvas.SetTop(dataPoint, top);
                dataPoint.Width  = width;
                dataPoint.Height = height;
            }
        }
        /// <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));
            }
        }
예제 #12
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).Value.Value;
            double dataPointX     = ActualIndependentAxis.GetPlotAreaCoordinate(dataPoint.ActualIndependentValue).Value.Value;
            double dataPointY     = ActualDependentRangeAxis.GetPlotAreaCoordinate(dataPoint.ActualDependentValue).Value.Value;

            if (ValueHelper.CanGraph(dataPointX) && ValueHelper.CanGraph(dataPointY))
            {
                // Set the Position
                Canvas.SetLeft(
                    dataPoint,
                    Math.Round(dataPointX - (dataPoint.ActualWidth / 2)));
                Canvas.SetTop(
                    dataPoint,
                    Math.Round(PlotAreaHeight - (dataPointY + (dataPoint.ActualHeight / 2))));
            }
        }
예제 #13
0
        /// <summary>
        ///     Updates the Series shape object from a collection of Points.
        /// </summary>
        /// <param name="points">Collection of Points.</param>
        protected override void UpdateShapeFromPoints(IEnumerable <Point> points)
        {
            UnitValue originCoordinate  = ActualDependentRangeAxis.GetPlotAreaCoordinate(ActualDependentRangeAxis.Origin);
            UnitValue maximumCoordinate =
                ActualDependentRangeAxis.GetPlotAreaCoordinate(ActualDependentRangeAxis.Range.Maximum);

            if (points.Any() && ValueHelper.CanGraph(originCoordinate.Value) &&
                ValueHelper.CanGraph(maximumCoordinate.Value))
            {
                double originY = Math.Floor(originCoordinate.Value);
                var    figure  = new PathFigure();
                figure.IsClosed = true;
                figure.IsFilled = true;

                double maximum = maximumCoordinate.Value;
                Point  startPoint;
                IEnumerator <Point> pointEnumerator = points.GetEnumerator();
                pointEnumerator.MoveNext();
                startPoint        = new Point(pointEnumerator.Current.X, maximum - originY);
                figure.StartPoint = startPoint;

                Point lastPoint;
                do
                {
                    lastPoint = pointEnumerator.Current;
                    figure.Segments.Add(new LineSegment {
                        Point = pointEnumerator.Current
                    });
                } while (pointEnumerator.MoveNext());
                figure.Segments.Add(new LineSegment {
                    Point = new Point(lastPoint.X, maximum - originY)
                });

                if (figure.Segments.Count > 1)
                {
                    var geometry = new PathGeometry();
                    geometry.Figures.Add(figure);
                    Geometry = geometry;
                }
            }
            else
            {
                Geometry = null;
            }
        }
        /// <summary>
        /// Overrides the requested axis range to include the width and height
        /// necessary for the bubbles.
        /// </summary>
        /// <param name="rangeAxis">The range axis.</param>
        /// <param name="range">The data range.</param>
        /// <returns>The requested axis range.</returns>
        protected override Range <IComparable> OverrideRequestedAxisRange(IRangeAxis rangeAxis, Range <IComparable> range)
        {
            if (ActiveDataPoints.Any())
            {
                if (rangeAxis == ActualIndependentRangeAxis)
                {
                    double smallestXCoordinate =
                        ActiveDataPoints
                        .Select(dataPoint =>
                                ActualIndependentRangeAxis.GetPlotAreaCoordinate((IComparable)dataPoint.IndependentValue) - dataPoint.ActualWidth)
                        .Min();

                    double largestXCoordinate =
                        ActiveDataPoints
                        .Select(dataPoint =>
                                ActualIndependentRangeAxis.GetPlotAreaCoordinate((IComparable)dataPoint.IndependentValue) + dataPoint.ActualWidth)
                        .Max();

                    return(new Range <IComparable>(
                               ActualIndependentRangeAxis.GetPlotAreaCoordinateValueRange(smallestXCoordinate).Minimum,
                               ActualIndependentRangeAxis.GetPlotAreaCoordinateValueRange(largestXCoordinate).Maximum));
                }
                else if (rangeAxis == ActualDependentRangeAxis)
                {
                    double smallestYCoordinate =
                        ActiveDataPoints
                        .Select(dataPoint =>
                                ActualDependentRangeAxis.GetPlotAreaCoordinate((IComparable)dataPoint.DependentValue) - dataPoint.ActualHeight)
                        .Min();

                    double largestYCoordinate =
                        ActiveDataPoints
                        .Select(dataPoint =>
                                ActualDependentRangeAxis.GetPlotAreaCoordinate((IComparable)dataPoint.DependentValue) + dataPoint.ActualHeight)
                        .Max();

                    return(new Range <IComparable>(
                               ActualDependentRangeAxis.GetPlotAreaCoordinateValueRange(smallestYCoordinate).Minimum,
                               ActualDependentRangeAxis.GetPlotAreaCoordinateValueRange(largestYCoordinate).Maximum));
                }
            }
            return(new Range <IComparable>());
        }
        /// <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();
                }
            }
        }
예제 #16
0
        /// <summary>
        /// Updates the point collection object.
        /// </summary>
        protected override void UpdateShape()
        {
            double maximum = ActualDependentRangeAxis.GetPlotAreaCoordinate(ActualDependentRangeAxis.Range.Maximum).Value.Value;

            Func <DataPoint, Point> createPoint =
                dataPoint =>
                new Point(
                    ActualIndependentAxis.GetPlotAreaCoordinate(dataPoint.ActualIndependentValue).Value.Value,
                    maximum - ActualDependentRangeAxis.GetPlotAreaCoordinate(dataPoint.ActualDependentValue).Value.Value);

            IEnumerable <Point> points = null;

            if (ValueHelper.CanGraph(maximum))
            {
                if (ActualIndependentAxis is IRangeAxis)
                {
                    points = DataPointsByIndependentValue.Select(createPoint);
                }
                else
                {
                    points =
                        ActiveDataPoints
                        .Select(createPoint)
                        .OrderBy(point => point.X);
                }

                if (!points.IsEmpty())
                {
                    this.Points = new PointCollection();
                    foreach (Point point in points)
                    {
                        this.Points.Add(point);
                    }
                    return;
                }
            }
            this.Points = null;
        }
예제 #17
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).Value.Value;

            if (ValueHelper.CanGraph(maximum))
            {
                double x = ActualIndependentAxis.GetPlotAreaCoordinate(dataPoint.ActualIndependentValue).Value.Value;
                double y = ActualDependentRangeAxis.GetPlotAreaCoordinate(dataPoint.ActualDependentValue).Value.Value;

                if (ValueHelper.CanGraph(x) && ValueHelper.CanGraph(y))
                {
                    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 (!UpdatingDataPoints)
            {
                UpdateShape();
            }
        }
예제 #18
0
        protected override void UpdateDataPoint(DataPoint dataPoint)
        {
            if (SeriesHost == null || PlotArea == null)
            {
                return;
            }

            object            category        = dataPoint.IndependentValue ?? (this.ActiveDataPoints.IndexOf(dataPoint) + 1);
            Range <UnitValue> coordinateRange = GetCategoryRange(category);

            if (!coordinateRange.HasData)
            {
                return;
            }
            else if (coordinateRange.Maximum.Unit != Unit.Pixels || coordinateRange.Minimum.Unit != Unit.Pixels)
            {
                throw new InvalidOperationException("This Series Does Not Support Radial Axes");
            }

            double minimum = (double)coordinateRange.Minimum.Value;
            double maximum = (double)coordinateRange.Maximum.Value;

            double plotAreaHeight = ActualDependentRangeAxis.GetPlotAreaCoordinate(ActualDependentRangeAxis.Range.Maximum).Value.Value;
            IEnumerable <StackedColumnSeries> columnSeries = SeriesHost.Series.OfType <StackedColumnSeries>().Where(series => series.ActualIndependentAxis == ActualIndependentAxis);
            int    numberOfSeries       = columnSeries.Count();
            double coordinateRangeWidth = (maximum - minimum);
            double segmentWidth         = coordinateRangeWidth * 0.8;

            double columnWidth = segmentWidth; // / numberOfSeries;
            int    seriesIndex = columnSeries.IndexOf(this);

            double dataPointY = ActualDependentRangeAxis.GetPlotAreaCoordinate(ValueHelper.ToDouble(dataPoint.ActualDependentValue)).Value.Value;
            double zeroPointY = ActualDependentRangeAxis.GetPlotAreaCoordinate(ActualDependentRangeAxis.Origin).Value.Value;

            // Need to shift the columns up to take account of the other columns that are already rendered, to make them
            // appear stacked
            int dataPointIndex = ActiveDataPoints.IndexOf(dataPoint);

            for (int i = numberOfSeries - 1; i > seriesIndex; i--)
            {
                StackedColumnSeries prevSeries = columnSeries.ElementAt <StackedColumnSeries>(i);

                if (prevSeries.ActiveDataPointCount >= dataPointIndex + 1)
                {
                    DataPoint currDataPoint = prevSeries.ActiveDataPoints.ElementAt <DataPoint>(dataPointIndex);

                    // Need to move positive columns up and negative ones down
                    if ((double)dataPoint.ActualDependentValue > 0 && (double)currDataPoint.ActualDependentValue > 0)
                    {
                        dataPointY += currDataPoint.Height;
                        zeroPointY += currDataPoint.Height;
                    }
                    else if ((double)dataPoint.ActualDependentValue < 0 && (double)currDataPoint.ActualDependentValue < 0)
                    {
                        dataPointY -= currDataPoint.Height;
                        zeroPointY -= currDataPoint.Height;
                    }
                }
            }

            double offset     = 0;
            double dataPointX = minimum + offset;

            if (GetIsDataPointGrouped(category))
            {
                IGrouping <object, DataPoint> categoryGrouping = GetDataPointGroup(category);
                int index = categoryGrouping.IndexOf(dataPoint);
                dataPointX  += (index * (columnWidth * 0.2)) / (categoryGrouping.Count() - 1);
                columnWidth *= 0.8;
                Canvas.SetZIndex(dataPoint, -index);
            }

            if (ValueHelper.CanGraph(dataPointY) && ValueHelper.CanGraph(dataPointX) && ValueHelper.CanGraph(zeroPointY))
            {
                double left  = Math.Round(dataPointX);
                double width = Math.Round(columnWidth);

                double top    = Math.Round(plotAreaHeight - Math.Max(dataPointY, zeroPointY) + 0.5);
                double bottom = Math.Round(plotAreaHeight - Math.Min(dataPointY, zeroPointY) + 0.5);
                double height = bottom - top + 1;

                Canvas.SetLeft(dataPoint, left);
                Canvas.SetTop(dataPoint, top);
                dataPoint.Width  = width;
                dataPoint.Height = height;
            }
        }
예제 #19
0
        /// <summary>
        /// Updates the placement of the DataItems (data points) of the series.
        /// </summary>
        /// <param name="dataItems">DataItems in need of an update.</param>
        protected override void UpdateDataItemPlacement(IEnumerable <DefinitionSeries.DataItem> dataItems)
        {
            if ((null != ActualDependentAxis) && (null != ActualIndependentAxis))
            {
                double         plotAreaMaximumDependentCoordinate = ActualDependentAxis.GetPlotAreaCoordinate(ActualDependentRangeAxis.Range.Maximum).Value;
                double         lineTopBuffer = 1;
                List <Point>[] points        = new List <Point> [SeriesDefinitions.Count];
                for (int i = 0; i < points.Length; i++)
                {
                    points[i] = new List <Point>();
                }
                foreach (IndependentValueGroup group in IndependentValueGroupsOrderedByIndependentValue)
                {
                    double sum = IsStacked100 ?
                                 group.DataItems.Sum(di => Math.Abs(ValueHelper.ToDouble(di.DataPoint.ActualDependentValue))) :
                                 1;
                    if (0 == sum)
                    {
                        sum = 1;
                    }
                    double x = ActualIndependentAxis.GetPlotAreaCoordinate(group.IndependentValue).Value;
                    if (ValueHelper.CanGraph(x))
                    {
                        double           lastValue      = 0;
                        Point            lastPoint      = new Point(x, Math.Max(plotAreaMaximumDependentCoordinate - ActualDependentRangeAxis.GetPlotAreaCoordinate(lastValue).Value, lineTopBuffer));
                        int              i              = -1;
                        SeriesDefinition lastDefinition = null;
                        foreach (DataItem dataItem in group.DataItems)
                        {
                            if (lastDefinition != dataItem.SeriesDefinition)
                            {
                                i++;
                            }

                            while (dataItem.SeriesDefinition != SeriesDefinitions[i])
                            {
                                points[i].Add(lastPoint);
                                i++;
                            }

                            DataPoint dataPoint = dataItem.DataPoint;
                            double    value     = IsStacked100 ?
                                                  (ValueHelper.ToDouble(dataItem.DataPoint.ActualDependentValue) * (100 / sum)) :
                                                  ValueHelper.ToDouble(dataItem.DataPoint.ActualDependentValue);
                            if (ValueHelper.CanGraph(value))
                            {
                                value += lastValue;
                                dataItem.ActualStackedDependentValue = value;
                                double y = ActualDependentRangeAxis.GetPlotAreaCoordinate(value).Value;
                                lastValue   = value;
                                lastPoint.Y = Math.Max(plotAreaMaximumDependentCoordinate - y, lineTopBuffer);
                                points[i].Add(lastPoint);

                                dataItem.CenterPoint = new Point(x, plotAreaMaximumDependentCoordinate - y);
                                double left = dataItem.CenterPoint.X - (dataPoint.ActualWidth / 2);
                                double top  = dataItem.CenterPoint.Y - (dataPoint.ActualHeight / 2);

                                Canvas.SetLeft(dataItem.Container, Math.Round(left));
                                Canvas.SetTop(dataItem.Container, Math.Round(top));
                                dataPoint.Visibility = Visibility.Visible;
                            }
                            else
                            {
                                points[i].Add(lastPoint);
                                dataPoint.Visibility = Visibility.Collapsed;
                            }

                            lastDefinition = dataItem.SeriesDefinition;
                        }
                    }
                    else
                    {
                        foreach (DataPoint dataPoint in group.DataItems.Select(di => di.DataPoint))
                        {
                            dataPoint.Visibility = Visibility.Collapsed;
                        }
                    }
                }
                UpdateShape(points);
            }
        }
예제 #20
0
        /// <summary>
        /// Updates each point.
        /// </summary>
        /// <param name="dataPoint">The data point to update.</param>
        protected override void UpdateDataPoint(DataPoint dataPoint)
        {
            TimeIntervalDataPoint intervalDataPoint = (TimeIntervalDataPoint)dataPoint;

            if (SeriesHost == null)
            {
                return;
            }

            //object category = dataPoint.ActualIndependentValue ?? (this.ActiveDataPoints.IndexOf(dataPoint) + 1);
            //Range<UnitValue> coordinateRange = GetCategoryRange(category);

            /*if (!coordinateRange.HasData)
             * {
             *  return;
             * }
             * else if (coordinateRange.Maximum.Unit != Unit.Pixels || coordinateRange.Minimum.Unit != Unit.Pixels)
             * {
             *  throw new InvalidOperationException();
             * }
             *
             * double minimum = (double)coordinateRange.Minimum.Value;
             * double maximum = (double)coordinateRange.Maximum.Value;*/

            // we'll just ignore the category axis and position the intervals where we want

            IEnumerable <TimeIntervalSeries> barSeries = SeriesHost.Series.OfType <TimeIntervalSeries>().Where(series => series.ActualIndependentAxis == ActualIndependentAxis);
            int    numberOfSeries        = barSeries.Count();
            double coordinateRangeHeight = 10.0;
            double segmentHeight         = coordinateRangeHeight * 0.8;
            //double barHeight = segmentHeight / numberOfSeries;
            int seriesIndex = barSeries.IndexOf(this);

            double startTimePointX = ActualDependentRangeAxis.GetPlotAreaCoordinate(intervalDataPoint.StartTime).Value;
            double endTimePointX   = ActualDependentRangeAxis.GetPlotAreaCoordinate(intervalDataPoint.EndTime).Value;

            double       offset       = /*seriesIndex * Math.Round(barHeight) +*/ coordinateRangeHeight * 0.1;
            CategoryAxis categoryAxis = ActualIndependentAxis as CategoryAxis;
            double       dataPointY   = categoryAxis.ActualHeight - 10.0 * numberOfSeries + seriesIndex * 10 + offset;

            /*if (GetIsDataPointGrouped(category))
             * {
             *  // Multiple DataPoints share this category; offset and overlap them appropriately
             *  IGrouping<object, DataPoint> categoryGrouping = GetDataPointGroup(category);
             *  int index = categoryGrouping.IndexOf(dataPoint);
             *  dataPointY += (index * (barHeight * 0.2)) / (categoryGrouping.Count() - 1);
             *  barHeight *= 0.8;
             *  Canvas.SetZIndex(dataPoint, -index);
             * }*/

            if (ValueHelper.CanGraph(startTimePointX) && ValueHelper.CanGraph(endTimePointX) && ValueHelper.CanGraph(dataPointY))
            {
                dataPoint.Visibility = Visibility.Visible;

                double top    = Math.Round(dataPointY);
                double height = Math.Round(segmentHeight);

                double left  = Math.Round(Math.Min(startTimePointX, endTimePointX) - 0.5);
                double right = Math.Round(Math.Max(startTimePointX, endTimePointX) - 0.5);
                double width = right - left + 1;

                Canvas.SetLeft(dataPoint, left);
                Canvas.SetTop(dataPoint, top);
                dataPoint.Width  = width;
                dataPoint.Height = height;
            }
            else
            {
                dataPoint.Visibility = Visibility.Collapsed;
            }
        }
예제 #21
0
        /// <summary>
        /// Updates each point.
        /// </summary>
        /// <param name="dataPoint">The data point to update.</param>
        protected override void UpdateDataPoint(DataPoint dataPoint)
        {
            if (SeriesHost == null || PlotArea == null)
            {
                return;
            }

            object            category        = dataPoint.ActualIndependentValue ?? (this.ActiveDataPoints.IndexOf(dataPoint) + 1);
            Range <UnitValue> coordinateRange = GetCategoryRange(category);

            if (!coordinateRange.HasData)
            {
                return;
            }
            else if (coordinateRange.Maximum.Unit != Unit.Pixels || coordinateRange.Minimum.Unit != Unit.Pixels)
            {
                throw new InvalidOperationException(Properties.Resources.DataPointSeriesWithAxes_ThisSeriesDoesNotSupportRadialAxes);
            }

            double minimum = (double)coordinateRange.Minimum.Value;
            double maximum = (double)coordinateRange.Maximum.Value;

            double plotAreaHeight = ActualDependentRangeAxis.GetPlotAreaCoordinate(ActualDependentRangeAxis.Range.Maximum).Value;
            IEnumerable <ColumnSeries> columnSeries = SeriesHost.Series.OfType <ColumnSeries>().Where(series => series.ActualIndependentAxis == ActualIndependentAxis);
            int    numberOfSeries       = columnSeries.Count();
            double coordinateRangeWidth = (maximum - minimum);
            double segmentWidth         = coordinateRangeWidth * (1 - ColumnGapRatio);
            double columnWidth          = segmentWidth / numberOfSeries;
            int    seriesIndex          = columnSeries.IndexOf(this);

            double dataPointY = ActualDependentRangeAxis.GetPlotAreaCoordinate(ValueHelper.ToDouble(dataPoint.ActualDependentValue)).Value;
            double zeroPointY = ActualDependentRangeAxis.GetPlotAreaCoordinate(ActualDependentRangeAxis.Origin).Value;

            double gap        = (columnWidth * ColumnGapRatio);
            double offset     = seriesIndex * Math.Round(columnWidth) + gap; // + coordinateRangeWidth;
            double dataPointX = minimum + offset;

            if (GetIsDataPointGrouped(category))
            {
                // Multiple DataPoints share this category; offset and overlap them appropriately
                IGrouping <object, DataPoint> categoryGrouping = GetDataPointGroup(category);
                int index = categoryGrouping.IndexOf(dataPoint);
                dataPointX  += (index * gap) / (categoryGrouping.Count() - 1);
                columnWidth *= 0.8;
                Canvas.SetZIndex(dataPoint, -index);
            }

            if (ValueHelper.CanGraph(dataPointY) && ValueHelper.CanGraph(dataPointX) && ValueHelper.CanGraph(zeroPointY))
            {
                dataPoint.Visibility = Visibility.Visible;

                double left  = Math.Round(dataPointX);
                double width = Math.Round(columnWidth);

                double top    = Math.Round(plotAreaHeight - Math.Max(dataPointY, zeroPointY) + 0.5);
                double bottom = Math.Round(plotAreaHeight - Math.Min(dataPointY, zeroPointY) + 0.5);
                double height = bottom - top + 1;

                Canvas.SetLeft(dataPoint, left);
                Canvas.SetTop(dataPoint, top);
                dataPoint.Width  = width;
                dataPoint.Height = height;
            }
            else
            {
                dataPoint.Visibility = Visibility.Collapsed;
            }
        }
예제 #22
0
        /// <summary>
        /// Updates the point collection object.
        /// </summary>
        protected override void UpdateShape()
        {
            double maximum = ActualDependentRangeAxis.GetPlotAreaCoordinate(ActualDependentRangeAxis.Range.Maximum).Value.Value;

            Func <DataPoint, Point> createPoint =
                dataPoint =>
                new Point(
                    ActualIndependentAxis.GetPlotAreaCoordinate(dataPoint.ActualIndependentValue).Value.Value,
                    maximum - ActualDependentRangeAxis.GetPlotAreaCoordinate(dataPoint.ActualDependentValue).Value.Value);

            IEnumerable <Point> points = null;

            if (ValueHelper.CanGraph(maximum))
            {
                if (ActualIndependentAxis is IRangeAxis)
                {
                    points = this.DataPointsByIndependentValue.Select(createPoint);
                }
                else
                {
                    points =
                        ActiveDataPoints
                        .Select(createPoint)
                        .OrderBy(point => point.X);
                }

                if (!points.IsEmpty())
                {
                    double     originY = Math.Floor(ActualDependentRangeAxis.GetPlotAreaCoordinate(ActualDependentRangeAxis.Origin).Value.Value);
                    PathFigure figure  = new PathFigure();
                    figure.IsClosed = true;
                    figure.IsFilled = true;

                    Point startPoint;
                    IEnumerator <Point> pointEnumerator = points.GetEnumerator();
                    if (pointEnumerator.MoveNext())
                    {
                        startPoint        = new Point(pointEnumerator.Current.X, maximum - originY);
                        figure.StartPoint = startPoint;
                    }
                    else
                    {
                        this.Geometry = null;
                        return;
                    }

                    Point lastPoint;
                    do
                    {
                        lastPoint = pointEnumerator.Current;
                        figure.Segments.Add(new LineSegment {
                            Point = pointEnumerator.Current
                        });
                    }while (pointEnumerator.MoveNext());
                    figure.Segments.Add(new LineSegment {
                        Point = new Point(lastPoint.X, maximum - originY)
                    });

                    if (figure.Segments.Count > 1)
                    {
                        PathGeometry geometry = new PathGeometry();
                        geometry.Figures.Add(figure);
                        this.Geometry = geometry;
                        return;
                    }
                }
            }
            this.Geometry = null;
        }