Example #1
0
        private static void ApplyLayoutRoundingVertical(CombinedSeries series, RangeSeriesRoundLayoutContext roundLayoutContext)
        {
            double         previousStackRight = -1;
            RangeDataPoint firstPoint;

            Dictionary <double, double> normalizedValueToY = new Dictionary <double, double>();

            foreach (CombineGroup group in series.Groups)
            {
                foreach (CombineStack stack in group.Stacks)
                {
                    firstPoint = stack.Points[0] as RangeDataPoint;
                    if (!firstPoint.isEmpty)
                    {
                        roundLayoutContext.SnapPointToGridLine(firstPoint);

                        // Handles visual glitches that might occur between clustered range bars.
                        RangeSeriesRoundLayoutContext.SnapNormalizedValueToPreviousY(firstPoint, normalizedValueToY);

                        SnapLeftToPreviousRight(firstPoint, previousStackRight);
                        previousStackRight = firstPoint.layoutSlot.Right;
                    }
                    else
                    {
                        previousStackRight = -1;
                    }
                }
                previousStackRight = -1;
            }
        }
Example #2
0
        private CombinedSeries GetCombinedSeries(ISupportCombineMode combinableSeries)
        {
            Type type = combinableSeries.GetType();
            ChartSeriesCombineMode combineMode = combinableSeries.CombineMode;
            AxisModel stackValueAxis           = this.valueAxesExtractor(combinableSeries as IPlotAreaElementModelWithAxes);

            foreach (CombinedSeries series in this.CombinedSeries)
            {
                if (series.SeriesType == type && series.CombineMode == combineMode && (combineMode == ChartSeriesCombineMode.Cluster ||
                                                                                       ((combineMode == ChartSeriesCombineMode.Stack || combineMode == ChartSeriesCombineMode.Stack100) && series.StackValueAxis == stackValueAxis)))
                {
                    return(series);
                }
            }

            CombinedSeries newSeries = new CombinedSeries();

            newSeries.SeriesType     = type;
            newSeries.CombineMode    = combineMode;
            newSeries.CombineIndex   = this.CombinedSeries.Count;
            newSeries.StackAxis      = this.StackAxis;
            newSeries.StackValueAxis = stackValueAxis;
            this.CombinedSeries.Add(newSeries);

            return(newSeries);
        }
        private static void ApplyLayoutRoundingVertical(CombinedSeries series, CategoricalSeriesRoundLayoutContext info)
        {
            double previousStackRight = -1;
            CategoricalDataPoint firstPoint;
            CategoricalDataPoint point;
            CategoricalDataPoint previousPositivePoint = null;
            CategoricalDataPoint previousNegativePoint = null;

            foreach (CombineGroup group in series.Groups)
            {
                foreach (CombineStack stack in group.Stacks)
                {
                    // first point is on the plot line
                    firstPoint = stack.Points[0] as CategoricalDataPoint;
                    if (previousStackRight != -1)
                    {
                        firstPoint.layoutSlot.X = previousStackRight;
                    }
                    info.SnapPointToPlotLine(firstPoint);
                    info.SnapPointToGridLine(firstPoint);

                    int count = stack.Points.Count;
                    previousPositivePoint = firstPoint;
                    previousNegativePoint = firstPoint;

                    for (int i = 1; i < count; i++)
                    {
                        point = stack.Points[i] as CategoricalDataPoint;

                        if (point.numericalPlot == null || double.IsNaN(point.layoutSlot.Center.X) || double.IsNaN(point.layoutSlot.Center.Y))
                        {
                            continue;
                        }

                        if (previousStackRight != -1)
                        {
                            point.layoutSlot.X = previousStackRight;
                        }

                        //// inverse axis with negative point is equivalent to regular axis with positive point
                        if (point.isPositive ^ point.numericalPlot.Axis.IsInverse)
                        {
                            point.layoutSlot.Y    = previousPositivePoint.layoutSlot.Y - point.layoutSlot.Height;
                            previousPositivePoint = point;
                        }
                        else
                        {
                            point.layoutSlot.Y    = previousNegativePoint.layoutSlot.Bottom;
                            previousNegativePoint = point;
                        }
                        info.SnapPointToGridLine(point);
                    }

                    previousStackRight = firstPoint.isEmpty ? -1 : firstPoint.layoutSlot.Right;
                }

                previousStackRight = -1;
            }
        }
Example #4
0
        private static CombinedSeriesRoundLayoutStrategy GetRoundLayoutStrategy(CombinedSeries series)
        {
            if (series.Series.Count > 0)
            {
                return(series.Series[0].GetCombinedRoundLayoutStrategy());
            }

            return(null);
        }
Example #5
0
        private static CombinedSeriesPlotStrategy GetPlotStrategy(CombinedSeries series)
        {
            if (series.Series.Count > 0)
            {
                return(series.Series[0].GetCombinedPlotStrategy());
            }

            return(null);
        }
Example #6
0
        public void Update(IList <ChartSeriesModel> series, AxisModel stackAxis)
        {
            if (this.isUpdated)
            {
                return;
            }

            this.StackAxis = stackAxis;

            if (stackAxis.Type == AxisType.First)
            {
                this.valueAxesExtractor = sm => sm.SecondAxis;
            }
            else
            {
                this.valueAxesExtractor = sm => sm.FirstAxis;
            }

            foreach (ChartSeriesModel model in series)
            {
                if (!model.presenter.IsVisible)
                {
                    continue;
                }

                AxisModel stackValueAxis = this.valueAxesExtractor(model as IPlotAreaElementModelWithAxes);
                if (!this.StackValueAxes.Contains(stackValueAxis))
                {
                    this.StackValueAxes.Add(stackValueAxis);
                }

                ISupportCombineMode combinableSeries = model as ISupportCombineMode;
                if (combinableSeries == null || combinableSeries.CombineMode == ChartSeriesCombineMode.None)
                {
                    this.NonCombinedSeries.Add(model);
                    continue;
                }

                CombinedSeries combinedSeries = this.GetCombinedSeries(combinableSeries);
                combinedSeries.Series.Add(model);

                this.HasCombination = true;
            }

            if (this.HasCombination)
            {
                this.BuildGroups();
            }

            this.isUpdated = true;
        }
        public override void Plot(CombinedSeries series, int combinedSeriesCount)
        {
            double groupPosition;
            double groupLength;
            double groupStartPosition;
            double stackPosition;
            double stackLength;
            double stackStartPosition;

            foreach (CombineGroup group in series.Groups)
            {
                CategoricalDataPointBase firstPoint = group.Stacks[0].Points[0] as CategoricalDataPointBase;
                CategoricalAxisPlotInfo  plotInfo   = firstPoint.categoricalPlot;
                if (plotInfo == null)
                {
                    continue;
                }

                groupLength = plotInfo.Length / combinedSeriesCount;
                stackLength = groupLength / group.Stacks.Count;

                groupStartPosition = plotInfo.Position - plotInfo.Length / 2;
                groupPosition      = groupStartPosition + groupLength / 2 + (series.CombineIndex * groupLength);

                stackStartPosition = groupPosition - groupLength / 2;
                stackPosition      = stackStartPosition + stackLength / 2;

                foreach (CombineStack stack in group.Stacks)
                {
                    foreach (CategoricalDataPointBase point in stack.Points)
                    {
                        plotInfo = point.categoricalPlot;
                        if (plotInfo != null)
                        {
                            plotInfo.Position = stackPosition;
                            plotInfo.Length   = stackLength;
                        }
                    }

                    stackPosition += stackLength;
                }
            }
        }
Example #8
0
        public override void ApplyLayoutRounding(ChartAreaModel chart, CombinedSeries series)
        {
            RangeBarSeriesModel rangeSeriesModel = series.Series[0] as RangeBarSeriesModel;

            if (rangeSeriesModel == null)
            {
                Debug.Assert(false, "Invalid combined series.");
                return;
            }

            RangeSeriesRoundLayoutContext info = new RangeSeriesRoundLayoutContext(rangeSeriesModel);

            if (info.PlotDirection == AxisPlotDirection.Vertical)
            {
                ApplyLayoutRoundingVertical(series, info);
            }
            else
            {
                ApplyLayoutRoundingHorizontal(series, info);
            }
        }
Example #9
0
        private void ProcessSeries(CombinedSeries combinedSeries)
        {
            Dictionary <object, CombineGroup> groupsByKey = new Dictionary <object, CombineGroup>(8);
            Dictionary <CombineStack, double> positiveValuesSumByStack = new Dictionary <CombineStack, double>();
            Dictionary <CombineStack, double> negativeValuesSumByStack = new Dictionary <CombineStack, double>();
            CombineStack stack;
            double       min;
            double       max;
            bool         positive;

            foreach (ChartSeriesModel series in combinedSeries.Series)
            {
                if (!series.presenter.IsVisible)
                {
                    continue;
                }

                AxisModel stackValueAxis = this.valueAxesExtractor(series as IPlotAreaElementModelWithAxes);
                if (!this.MinimumStackSums.ContainsKey(stackValueAxis))
                {
                    this.MinimumStackSums.Set(stackValueAxis, double.PositiveInfinity);
                    this.MaximumStackSums.Set(stackValueAxis, double.NegativeInfinity);
                }

                this.MinimumStackSums.TryGetValue(stackValueAxis, out min);
                this.MaximumStackSums.TryGetValue(stackValueAxis, out max);

                foreach (DataPoint point in series.DataPointsInternal)
                {
                    object key = this.StackAxis.GetCombineGroupKey(point);
                    if (key == null)
                    {
                        continue;
                    }

                    CombineGroup group;
                    if (!groupsByKey.TryGetValue(key, out group))
                    {
                        group            = new CombineGroup();
                        group.Key        = key;
                        groupsByKey[key] = group;
                        combinedSeries.Groups.Add(group);
                    }

                    stack = group.GetStack(series as ISupportCombineMode);
                    stack.Points.Add(point);

                    if (!positiveValuesSumByStack.ContainsKey(stack))
                    {
                        positiveValuesSumByStack[stack] = 0d;
                        negativeValuesSumByStack[stack] = 0d;
                    }

                    double positivesSum = positiveValuesSumByStack[stack];
                    double negativesSum = negativeValuesSumByStack[stack];

                    double stackSumValue;
                    if (!stackValueAxis.TryGetStackSumValue(point, out stackSumValue, out positive, ref positivesSum, ref negativesSum))
                    {
                        continue;
                    }

                    positiveValuesSumByStack[stack] = positivesSum;
                    negativeValuesSumByStack[stack] = negativesSum;

                    if (positive)
                    {
                        stack.PositiveSum = stackSumValue;
                    }
                    else
                    {
                        stack.NegativeSum = stackSumValue;
                    }

                    min = Math.Min(min, stack.NegativeSum);
                    max = Math.Max(max, stack.PositiveSum);
                }

                this.MinimumStackSums.Set(stackValueAxis, min);
                this.MaximumStackSums.Set(stackValueAxis, max);
            }
        }
 public abstract void ApplyLayoutRounding(ChartAreaModel chart, CombinedSeries series);
 public abstract void Plot(CombinedSeries series, int combinedSeriesCount);