Example #1
0
        protected override Range <IComparable> GetActualYDataRange()
        {
            StackedColumnSeriesPresenter columnSeriesPresenter = this.SeriesPresenter as StackedColumnSeriesPresenter;
            List <XYSeries>    counterpartDataSeries           = columnSeriesPresenter.GetCounterpartDataSeries(true);
            List <IComparable> list = new List <IComparable>();

            if (counterpartDataSeries.Count == 1 && !this.ActualIsHundredPercent)
            {
                return(base.GetActualYDataRange());
            }
            foreach (XYDataPoint xyDataPoint in (Collection <DataPoint>) this.DataPoints)
            {
                if (xyDataPoint.YValue != null)
                {
                    object xValue             = ValueHelper.ConvertValue(xyDataPoint.XValue, this.ActualXValueType);
                    Range <IComparable> range = columnSeriesPresenter.GetDataPointYValueRange(xValue, counterpartDataSeries);
                    if (range.HasData)
                    {
                        range = columnSeriesPresenter.ConvertToPercentRange(range);
                        list.Add(range.Minimum);
                        list.Add(range.Maximum);
                    }
                }
            }
            return(RangeEnumerableExtensions.GetRange <IComparable>((IEnumerable <IComparable>)list));
        }
        internal Range <IComparable> GetDataPointYValueRange(object xValue, List <XYSeries> series)
        {
            if (this.Series.ActualYValueType == DataValueType.Auto)
            {
                return(Range <IComparable> .Empty);
            }
            List <IComparable> list = new List <IComparable>();
            object             obj  = new object();
            Dictionary <object, List <IComparable> > dictionary = new Dictionary <object, List <IComparable> >();
            object index1 = ValueHelper.ConvertValue(xValue, this.Series.ActualXValueType);

            foreach (ColumnSeries columnSeries in Enumerable.OfType <ColumnSeries>((IEnumerable)series))
            {
                foreach (XYDataPoint xyDataPoint in columnSeries.DataPointsByXValue[index1])
                {
                    if (xyDataPoint.YValue != null)
                    {
                        IComparable comparable = ValueHelper.ConvertValue(xyDataPoint.YValue, this.Series.ActualYValueType) as IComparable;
                        object      key        = columnSeries.ClusterGroupKey ?? obj;
                        if (!dictionary.ContainsKey(key))
                        {
                            dictionary[key] = new List <IComparable>((IEnumerable <IComparable>) new IComparable[1]
                            {
                                comparable
                            });
                        }
                        else
                        {
                            dictionary[key].Add(comparable);
                        }
                    }
                }
            }
            IComparable comparable1 = (IComparable)null;
            IComparable comparable2 = (IComparable)null;
            IComparable comparable3 = ValueHelper.ConvertValue((this.Series.YAxis == null || this.Series.YAxis.Scale == null ? (object)0.0 : this.Series.YAxis.Scale.ActualCrossingPosition) ?? (object)0.0, this.Series.ActualYValueType) as IComparable;

            list.Add(comparable3);
            foreach (object index2 in dictionary.Keys)
            {
                if (index2 == obj)
                {
                    IComparable comparable4 = (IComparable)null;
                    IComparable comparable5 = (IComparable)null;
                    foreach (IComparable comparable6 in dictionary[index2])
                    {
                        if (comparable6.CompareTo((object)comparable3) > 0)
                        {
                            comparable4 = comparable4 == null ? comparable6 : ValueHelper.AddComparableValues(comparable4, comparable6);
                        }
                        else
                        {
                            comparable5 = comparable5 == null ? comparable6 : ValueHelper.AddComparableValues(comparable5, comparable6);
                        }
                    }
                    if (comparable4 != null)
                    {
                        list.Add(comparable4);
                    }
                    if (comparable5 != null)
                    {
                        list.Add(comparable5);
                    }
                }
                else
                {
                    Range <IComparable> range = RangeEnumerableExtensions.GetRange <IComparable>((IEnumerable <IComparable>)dictionary[index2]);
                    if (range.HasData)
                    {
                        IComparable comparable4 = range.Minimum;
                        IComparable comparable5 = range.Maximum;
                        IComparable comparable6 = comparable3;
                        if (comparable6.GetType() != comparable4.GetType())
                        {
                            comparable6 = Convert.ChangeType((object)comparable6, comparable4.GetType(), (IFormatProvider)CultureInfo.InvariantCulture) as IComparable;
                        }
                        if (comparable4.CompareTo((object)comparable6) > 0)
                        {
                            comparable4 = comparable6;
                        }
                        if (comparable5.CompareTo((object)comparable6) < 0)
                        {
                            comparable5 = comparable6;
                        }
                        comparable1 = comparable1 == null ? comparable5 : ValueHelper.AddComparableValues(comparable1, comparable5);
                        comparable2 = comparable2 == null ? comparable4 : ValueHelper.AddComparableValues(comparable2, comparable4);
                        if (comparable1 != null)
                        {
                            list.Add(ValueHelper.ConvertValue((object)comparable1, this.Series.ActualYValueType) as IComparable);
                        }
                        if (comparable2 != null)
                        {
                            list.Add(ValueHelper.ConvertValue((object)comparable2, this.Series.ActualYValueType) as IComparable);
                        }
                    }
                }
            }
            return(RangeEnumerableExtensions.GetRange <IComparable>((IEnumerable <IComparable>)list));
        }