示例#1
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 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;
            }
        }
示例#3
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;
            }
        }
示例#4
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;
            }
        }
示例#5
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;
            }
        }