예제 #1
0
파일: XYSeries.cs 프로젝트: sulerzh/chart
        public virtual bool CanPlot(DataPoint dataPoint)
        {
            XYDataPoint xyDataPoint = dataPoint as XYDataPoint;

            if (this.ActualXValueType == DataValueType.Category)
            {
                if (xyDataPoint != null)
                {
                    return(this.XAggregator.CanPlot(xyDataPoint.XValue));
                }
                return(false);
            }
            if (this.ActualYValueType == DataValueType.Category)
            {
                if (xyDataPoint != null)
                {
                    return(this.YAggregator.CanPlot(xyDataPoint.XValue));
                }
                return(false);
            }
            if (xyDataPoint != null && this.XAggregator.CanPlot(xyDataPoint.XValue))
            {
                return(this.YAggregator.CanPlot(xyDataPoint.YValue));
            }
            return(false);
        }
예제 #2
0
        internal override FrameworkElement GetLegendSymbol()
        {
            FrameworkElement viewElement = this.CreateViewElement();
            XYDataPoint      xyDataPoint = Enumerable.FirstOrDefault <XYDataPoint>(Enumerable.Where <XYDataPoint>(Enumerable.OfType <XYDataPoint>((IEnumerable)this.Series.DataPoints), (Func <XYDataPoint, bool>)(p =>
            {
                if (!p.ActualIsEmpty)
                {
                    return(p.IsVisible);
                }
                return(false);
            })));

            if (xyDataPoint != null)
            {
                this.BindViewToDataPoint((DataPoint)xyDataPoint, viewElement, (string)null);
            }
            else
            {
                xyDataPoint        = this.Series.CreateDataPoint() as XYDataPoint;
                xyDataPoint.Series = (Series)this.Series;
                if (this.Series.ItemsBinder != null)
                {
                    this.Series.ItemsBinder.Bind((DataPoint)xyDataPoint, this.Series.DataContext);
                }
                this.BindViewToDataPoint((DataPoint)xyDataPoint, viewElement, (string)null);
                xyDataPoint.Series = (Series)null;
            }
            viewElement.Opacity = xyDataPoint.Opacity;
            viewElement.Effect  = xyDataPoint.Effect;
            viewElement.Width   = 20.0;
            viewElement.Height  = 12.0;
            return(viewElement);
        }
예제 #3
0
        internal override void UpdateDataPointVisibility()
        {
            int index1 = 0;

            DataPointViewState[] dataPointViewStateArray = new DataPointViewState[this.Series.DataPoints.Count];
            foreach (DataPoint dataPoint in (Collection <DataPoint>) this.Series.DataPoints)
            {
                DataPointViewState dataPointViewState = DataPointViewState.Hidden;
                dataPoint.IsVisible = false;
                XYDataPoint dataPointXY = dataPoint as XYDataPoint;
                if (dataPointXY != null && this.ChartArea != null && (this.ChartArea.IsTemplateApplied && this.CanGraph(dataPointXY)) && this.Series.Visibility == Visibility.Visible)
                {
                    dataPoint.IsVisible = true;
                    dataPointViewState  = dataPoint.IsNewlyAdded ? DataPointViewState.Showing : DataPointViewState.Normal;
                    this.ChartArea.UpdateSession.Update((IUpdatable)dataPoint);
                }
                dataPointViewStateArray[index1] = dataPointViewState;
                ++index1;
            }
            this.CheckSimplifiedRenderingMode();
            int index2 = 0;

            foreach (DataPoint dataPoint in (Collection <DataPoint>) this.Series.DataPoints)
            {
                this.SetDataPointViewState(dataPoint, dataPointViewStateArray[index2]);
                dataPoint.IsNewlyAdded = false;
                ++index2;
            }
        }
예제 #4
0
        private Dictionary <XYDataPoint, double> GetDefaultRanking(LabelVisibilityManager.DataPointRange range, LabelVisibilityManager.DataPointRange prevRange, ref bool useMaximum)
        {
            Dictionary <XYDataPoint, double> dictionary = new Dictionary <XYDataPoint, double>();

            if (!range.ProjectedYRange.HasData)
            {
                double num1 = 0.05;
                if (prevRange != null && prevRange.DataPointProjectedYRange.HasData && range.DataPointProjectedYRange.HasData)
                {
                    if (range.DataPointProjectedYRange.Maximum - prevRange.DataPointProjectedYRange.Maximum > num1 && range.DataPointProjectedYRange.Minimum - prevRange.DataPointProjectedYRange.Minimum > num1)
                    {
                        useMaximum = true;
                    }
                    else if (prevRange.DataPointProjectedYRange.Maximum - range.DataPointProjectedYRange.Maximum > num1 && prevRange.DataPointProjectedYRange.Minimum - range.DataPointProjectedYRange.Minimum > num1)
                    {
                        useMaximum = false;
                    }
                    else if (range.DataPointProjectedYRange.Maximum - prevRange.DataPointProjectedYRange.Maximum > num1 && prevRange.DataPointProjectedYRange.Minimum - range.DataPointProjectedYRange.Minimum > num1)
                    {
                        double num2 = Math.Abs(range.DataPointProjectedYRange.Maximum - prevRange.DataPointProjectedYRange.Maximum);
                        double num3 = Math.Abs(range.DataPointProjectedYRange.Minimum - prevRange.DataPointProjectedYRange.Minimum);
                        useMaximum = num2 > num3;
                    }
                    else
                    {
                        useMaximum = !useMaximum;
                    }
                }
            }
            XYDataPoint key = (XYDataPoint)null;
            double      d   = double.NaN;

            foreach (XYDataPoint xyDataPoint in range.DataPoints)
            {
                if (double.IsNaN(d))
                {
                    key = xyDataPoint;
                    d   = xyDataPoint.YValueInScaleUnitsWithoutAnimation;
                }
                else if (useMaximum && d < xyDataPoint.YValueInScaleUnitsWithoutAnimation)
                {
                    key = xyDataPoint;
                    d   = xyDataPoint.YValueInScaleUnitsWithoutAnimation;
                }
                else if (!useMaximum && d >= xyDataPoint.YValueInScaleUnitsWithoutAnimation)
                {
                    key = xyDataPoint;
                    d   = xyDataPoint.YValueInScaleUnitsWithoutAnimation;
                }
            }
            if (key != null)
            {
                dictionary.Add(key, 50.0);
            }
            if (range.ProjectedYRange.HasData)
            {
                useMaximum = !useMaximum;
            }
            return(dictionary);
        }
예제 #5
0
        private void ChangeDataPointYValue(XYDataPoint dataPoint, object newValue)
        {
            if (dataPoint == null)
            {
                return;
            }
            double yvalueInScaleUnits = dataPoint.YValueInScaleUnits;
            double d = this.Series.YAxis.Scale == null ? double.NaN : this.Series.YAxis.Scale.ProjectDataValue(newValue);

            dataPoint.YValueInScaleUnitsWithoutAnimation = d;
            if (!double.IsNaN(d) && !double.IsNaN(yvalueInScaleUnits) && (this.IsSeriesAnimationEnabled && this.ChartArea != null))
            {
                DependencyPropertyAnimationHelper.BeginAnimation(this.ChartArea, "YValueInScaleUnits", (object)yvalueInScaleUnits, (object)d, (Action <object, object>)((value1, value2) =>
                {
                    if (double.IsNaN(dataPoint.YValueInScaleUnitsWithoutAnimation))
                    {
                        return;
                    }
                    dataPoint.YValueInScaleUnits = (double)value2;
                }), dataPoint.Storyboards, this.Series.ActualTransitionDuration, this.Series.ActualTransitionEasingFunction);
            }
            else
            {
                this.SkipToFillValueAnimation(dataPoint, "YValueInScaleUnits");
                dataPoint.YValueInScaleUnits = d;
            }
        }
예제 #6
0
 internal virtual bool CanGraph(XYDataPoint dataPointXY)
 {
     if (ValueHelper.CanGraph(dataPointXY.XValueInScaleUnits) && ValueHelper.CanGraph(dataPointXY.YValueInScaleUnits) && (DoubleHelper.GreaterOrEqualWithPrecision(dataPointXY.XValueInScaleUnits, 0.0) && DoubleHelper.LessOrEqualWithPrecision(dataPointXY.XValueInScaleUnits, 1.0)) && DoubleHelper.GreaterOrEqualWithPrecision(dataPointXY.YValueInScaleUnits, 0.0))
     {
         return(DoubleHelper.LessOrEqualWithPrecision(dataPointXY.YValueInScaleUnits, 1.0));
     }
     return(false);
 }
예제 #7
0
        internal void SkipToFillValueAnimation(XYDataPoint dataPoint, string propertyName)
        {
            string         storyboardKey  = DependencyPropertyAnimationHelper.GetStoryboardKey(propertyName);
            StoryboardInfo storyboardInfo = (StoryboardInfo)null;

            if (!dataPoint.Storyboards.TryGetValue(storyboardKey, out storyboardInfo) || storyboardInfo.Storyboard.Children.Count <= 0)
            {
                return;
            }
            storyboardInfo.Storyboard.SkipToFill();
        }
예제 #8
0
        internal Range <IComparable> GetDataPointYValueRange(XYDataPoint p)
        {
            object index = ValueHelper.ConvertValue(p.XValue, this.Series.ActualXValueType);
            Range <IComparable> pointYvalueRange;

            if (!this.DataPointsByXValueRanges.TryGetValue(index, out pointYvalueRange))
            {
                pointYvalueRange = this.GetDataPointYValueRange(index, this.GetCounterpartDataSeries(true));
                this.DataPointsByXValueRanges[index] = pointYvalueRange;
            }
            return(pointYvalueRange);
        }
예제 #9
0
 protected override void UpdateView(DataPoint dataPoint)
 {
     if (this.IsDataPointVisible(dataPoint))
     {
         XYDataPoint xyDataPoint = dataPoint as XYDataPoint;
         if (xyDataPoint.View != null)
         {
             dataPoint.View.AnchorPoint = this.ChartArea.ConvertScaleToPlotCoordinate(this.Series.XAxis, this.Series.YAxis, xyDataPoint.XValueInScaleUnits, xyDataPoint.YValueInScaleUnits);
             this.ChartArea.UpdateSession.ExecuteOnceAfterUpdating((Action)(() => this.UpdateLinePoints()), (object)new Tuple <Series, string>((Series)this.Series, "__UpdateLinePoints__"), (string)null);
         }
     }
     base.UpdateView(dataPoint);
 }
예제 #10
0
        internal override void OnDataPointAdded(DataPoint dataPoint, bool useShowingAnimation)
        {
            XYDataPoint xyDataPoint = dataPoint as XYDataPoint;

            if (xyDataPoint == null)
            {
                return;
            }
            xyDataPoint.XValueInScaleUnits = this.Series.XAxis.Scale.ProjectDataValue(xyDataPoint.XValue);
            xyDataPoint.YValueInScaleUnits = this.Series.YAxis.Scale.ProjectDataValue(xyDataPoint.YValue);
            xyDataPoint.XValueInScaleUnitsWithoutAnimation = xyDataPoint.XValueInScaleUnits;
            xyDataPoint.YValueInScaleUnitsWithoutAnimation = xyDataPoint.YValueInScaleUnits;
            xyDataPoint.IsNewlyAdded = useShowingAnimation;
        }
예제 #11
0
        internal override bool CanGraph(XYDataPoint dataPointXY)
        {
            BubbleDataPoint bubbleDataPoint = dataPointXY as BubbleDataPoint;

            if (bubbleDataPoint != null && this.BubbleSeries.IsSizeValueUsed && bubbleDataPoint.IsSizeValueUsed)
            {
                double doubleValue = 0.0;
                if (!ValueHelper.TryConvert(bubbleDataPoint.SizeValue, true, out doubleValue) || !ValueHelper.CanGraph(doubleValue) || DoubleHelper.LessOrEqualWithPrecision(bubbleDataPoint.SizeValueInScaleUnits, 0.0))
                {
                    return(false);
                }
            }
            return(base.CanGraph(dataPointXY));
        }
예제 #12
0
        internal override Point GetPositionInAxisUnits(XYDataPoint dataPoint)
        {
            double x   = this.Series.XAxis.AxisPresenter.ConvertScaleToAxisUnits(dataPoint.XValueInScaleUnits) ?? 0.0;
            double num = this.TransformYValueInScaleUnits(dataPoint, dataPoint.YValueInScaleUnits);
            StackedColumnDataPoint stackedColumnDataPoint = dataPoint as StackedColumnDataPoint;

            if (stackedColumnDataPoint != null)
            {
                stackedColumnDataPoint.YValuePercent = num;
            }
            double y = this.Series.YAxis.AxisPresenter.ConvertScaleToAxisUnits(num) ?? 0.0;

            return(new Point(x, y));
        }
예제 #13
0
 protected override void UpdateView(DataPoint dataPoint)
 {
     if (this.IsDataPointViewVisible(dataPoint))
     {
         XYDataPoint xyDataPoint = dataPoint as XYDataPoint;
         if (xyDataPoint != null && dataPoint.View != null)
         {
             Point point = this.ChartArea.ConvertScaleToPlotCoordinate(this.Series.XAxis, this.Series.YAxis, xyDataPoint.XValueInScaleUnits, xyDataPoint.YValueInScaleUnits);
             point.X = Math.Round(point.X);
             point.Y = Math.Round(point.Y);
             dataPoint.View.AnchorPoint = point;
         }
     }
     base.UpdateView(dataPoint);
 }
예제 #14
0
        protected override string GetNameCore()
        {
            StringBuilder stringBuilder = new StringBuilder();

            if (this.DataPoint.IsSelected)
            {
                stringBuilder.Append(Resources.DataPointHighlightedScreenReaderContent);
            }
            stringBuilder.Append(Resources.DataPointDetailsScreenReaderContent);
            string str1 = base.GetNameCore();

            if (string.IsNullOrEmpty(str1) && this.DataPoint.ToolTipContent != null)
            {
                str1 = this.DataPoint.ToolTipContent.AutomationName;
            }
            if (string.IsNullOrEmpty(str1))
            {
                str1 = this.DataPoint.ActualLabelContent as string;
            }
            if (string.IsNullOrEmpty(str1) && this.DataPoint is XYDataPoint)
            {
                XYDataPoint xyDataPoint = (XYDataPoint)this.DataPoint;
                if (xyDataPoint.XValue != null)
                {
                    str1 = ((XYDataPoint)this.DataPoint).XValue.ToString();
                }
                if (xyDataPoint.YValue != null)
                {
                    if (!string.IsNullOrEmpty(str1))
                    {
                        str1 += "; ";
                    }
                    StringFormatConverter stringFormatConverter = new StringFormatConverter();
                    string str2 = ValueHelper.PrepareFormatString(xyDataPoint.StringFormat);
                    str1 += (string)stringFormatConverter.Convert(xyDataPoint.YValue, (Type)null, (object)str2, (CultureInfo)null);
                }
            }
            if (string.IsNullOrEmpty(str1))
            {
                str1 = this.DataPoint.Name;
            }
            if (string.IsNullOrEmpty(str1))
            {
                str1 = this.DataPoint.GetType().Name;
            }
            stringBuilder.Append(str1);
            return(stringBuilder.ToString());
        }
예제 #15
0
        private void UpdateLinePoints()
        {
            if (this.ChartArea == null || !this.IsRootPanelVisible)
            {
                return;
            }
            DateTime        now                         = DateTime.Now;
            PointCollection pointCollection             = new PointCollection();
            Collection <IAppearanceProvider> collection = new Collection <IAppearanceProvider>();
            XYDataPoint xyDataPoint1                    = (XYDataPoint)null;

            if (this.Series.Visibility == Visibility.Visible)
            {
                for (int index = 0; index < this.Series.DataPoints.Count; ++index)
                {
                    XYDataPoint xyDataPoint2 = this.Series.DataPoints[index] as XYDataPoint;
                    if (xyDataPoint2.View != null && this.IsDataPointVisible((DataPoint)xyDataPoint2) && (this.IsValidScaleUnitValue(xyDataPoint2.XValueInScaleUnits) && this.IsValidScaleUnitValue(xyDataPoint2.YValueInScaleUnits)))
                    {
                        if (xyDataPoint1 != null && xyDataPoint1.ActualIsEmpty)
                        {
                            collection.Add((IAppearanceProvider)xyDataPoint1);
                            pointCollection.Add(xyDataPoint2.View.AnchorPoint);
                            if (index < this.Series.DataPoints.Count - 1)
                            {
                                XYDataPoint xyDataPoint3 = this.Series.DataPoints[index + 1] as XYDataPoint;
                                if (xyDataPoint3.ActualIsEmpty)
                                {
                                    collection.Add((IAppearanceProvider)xyDataPoint3);
                                    pointCollection.Add(xyDataPoint2.View.AnchorPoint);
                                }
                            }
                        }
                        collection.Add((IAppearanceProvider)xyDataPoint2);
                        pointCollection.Add(xyDataPoint2.View.AnchorPoint);
                    }
                    xyDataPoint1 = xyDataPoint2;
                }
            }
            if (this.PolylineControl != null)
            {
                this.PolylineControl.Points      = pointCollection;
                this.PolylineControl.Appearances = collection;
                this.PolylineControl.Update();
            }
            this.ChartArea.UpdateSession.AddCounter("LineSeriesPresenter.UpdateLinePoints", DateTime.Now - now);
        }
예제 #16
0
        private double TransformYValueInScaleUnits(XYDataPoint dataPoint, double yValueInScaleUnits)
        {
            if (!this.IsHundredPercent(dataPoint))
            {
                return(yValueInScaleUnits);
            }
            Range <IComparable> pointYvalueRange = this.GetDataPointYValueRange(dataPoint);
            double       val2         = (double)ValueHelper.ConvertValue((object)pointYvalueRange.Minimum, DataValueType.Float);
            double       num          = Math.Max(0.0, (double)ValueHelper.ConvertValue((object)pointYvalueRange.Maximum, DataValueType.Float)) - Math.Min(0.0, val2);
            NumericScale numericScale = this.Series.YAxis.Scale as NumericScale;

            if (num == 0.0)
            {
                return(this.Series.YAxis.Scale.ProjectDataValue(this.Series.YAxis.Scale.ActualCrossingPosition));
            }
            Range <double> fromRange   = new Range <double>(numericScale.Project(0.0), numericScale.Project(num));
            Range <double> targetRange = new Range <double>(numericScale.Project(0.0), numericScale.Project(1.0));

            return(RangeHelper.Project(fromRange, yValueInScaleUnits, targetRange));
        }
예제 #17
0
        internal static XYDataPoint FindDataPoint(PolylineControl polyline, Point position)
        {
            XYDataPoint xyDataPoint1 = (XYDataPoint)null;

            foreach (IAppearanceProvider appearanceProvider in polyline.Appearances)
            {
                XYDataPoint xyDataPoint2 = appearanceProvider as XYDataPoint;
                if (xyDataPoint2 != null && xyDataPoint2.View != null && !xyDataPoint2.ActualIsEmpty)
                {
                    if (xyDataPoint1 == null)
                    {
                        xyDataPoint1 = xyDataPoint2;
                    }
                    else if (LineSeriesPresenter.GetDistance(position, xyDataPoint2.View.AnchorPoint) < LineSeriesPresenter.GetDistance(position, xyDataPoint1.View.AnchorPoint))
                    {
                        xyDataPoint1 = xyDataPoint2;
                    }
                }
            }
            return(xyDataPoint1);
        }
        internal override void AdjustDataPointLabelVisibilityRating(LabelVisibilityManager.DataPointRange range, Dictionary <XYDataPoint, double> dataPointRanks)
        {
            if (range.DataPoints.Count <= 0)
            {
                return;
            }
            XYDataPoint xyDataPoint = range.DataPoints[0] as XYDataPoint;

            foreach (XYDataPoint key in range.DataPoints)
            {
                if (ValueHelper.Compare(key.XValue as IComparable, xyDataPoint.XValue as IComparable) == 0)
                {
                    if (dataPointRanks.ContainsKey(key))
                    {
                        dataPointRanks[key] = 100.0;
                    }
                    else
                    {
                        dataPointRanks.Add(key, 100.0);
                    }
                }
            }
        }
예제 #19
0
        internal override ContentPositions GetAutomaticLabelPosition(DataPoint dataPoint)
        {
            ContentPositions contentPositions1 = ContentPositions.TopCenter;
            ContentPositions contentPositions2 = ContentPositions.BottomCenter;

            if (this.SeriesPresenter.ChartArea != null)
            {
                if (this.SeriesPresenter.ChartArea.Orientation == Orientation.Vertical)
                {
                    contentPositions1 = ContentPositions.MiddleRight;
                    contentPositions2 = ContentPositions.MiddleLeft;
                }
                XYDataPoint xyDataPoint1 = dataPoint as XYDataPoint;
                int         num          = this.SeriesPresenter.Series.DataPoints.IndexOf(dataPoint);
                XYDataPoint xyDataPoint2 = num > 0 ? this.SeriesPresenter.Series.DataPoints[num - 1] as XYDataPoint : (XYDataPoint)null;
                XYDataPoint xyDataPoint3 = num < this.SeriesPresenter.Series.DataPoints.Count - 1 ? this.SeriesPresenter.Series.DataPoints[num + 1] as XYDataPoint : (XYDataPoint)null;
                if (xyDataPoint2 != null && xyDataPoint3 != null && (xyDataPoint1.YValueInScaleUnitsWithoutAnimation < xyDataPoint2.YValueInScaleUnitsWithoutAnimation && xyDataPoint1.YValueInScaleUnitsWithoutAnimation < xyDataPoint3.YValueInScaleUnitsWithoutAnimation) || xyDataPoint2 != null && xyDataPoint3 == null && xyDataPoint1.YValueInScaleUnitsWithoutAnimation < xyDataPoint2.YValueInScaleUnitsWithoutAnimation || xyDataPoint2 == null && xyDataPoint3 != null && xyDataPoint1.YValueInScaleUnitsWithoutAnimation < xyDataPoint3.YValueInScaleUnitsWithoutAnimation)
                {
                    return(contentPositions2);
                }
            }
            return(contentPositions1);
        }
예제 #20
0
        internal override void AdjustDataPointLabelVisibilityRating(LabelVisibilityManager.DataPointRange range, Dictionary <XYDataPoint, double> dataPointRanks)
        {
            XYDataPoint key = (XYDataPoint)null;

            if (range.DataPoints.Count > 0)
            {
                key = range.DataPoints[range.DataPoints.Count / 2] as XYDataPoint;
            }
            if (key == null)
            {
                return;
            }
            if (dataPointRanks.ContainsKey(key))
            {
                Dictionary <XYDataPoint, double> dictionary;
                XYDataPoint index;
                (dictionary = dataPointRanks)[index = key] = dictionary[index] + 150.0;
            }
            else
            {
                dataPointRanks.Add(key, 150.0);
            }
        }
예제 #21
0
        internal override double GetYOffsetInAxisUnits(XYDataPoint dataPoint, Point valuePoint, Point basePoint)
        {
            object xValue          = ValueHelper.ConvertValue(dataPoint.XValue, ((XYSeries)dataPoint.Series).ActualXValueType);
            bool   flag            = valuePoint.Y < basePoint.Y;
            double num1            = 0.0;
            double num2            = 0.0;
            object clusterGroupKey = ((ColumnSeries)this.Series).ClusterGroupKey;

            foreach (XYDataPoint dataPointXY in Enumerable.Where <XYDataPoint>((IEnumerable <XYDataPoint>) this.GetCounterpartDataPoints(xValue, false), (Func <XYDataPoint, bool>)(p => this.IsDataPointViewVisible((DataPoint)p))))
            {
                ColumnSeries columnSeries = dataPointXY.Series as ColumnSeries;
                if (clusterGroupKey != null && columnSeries != null)
                {
                    if (ValueHelper.AreEqual(columnSeries.ClusterGroupKey, clusterGroupKey))
                    {
                        break;
                    }
                }
                Point positionInAxisUnits = this.GetPositionInAxisUnits(dataPointXY);
                if (flag)
                {
                    if (positionInAxisUnits.Y < basePoint.Y)
                    {
                        num1 += basePoint.Y - positionInAxisUnits.Y;
                    }
                }
                else if (positionInAxisUnits.Y > basePoint.Y)
                {
                    num2 += basePoint.Y - positionInAxisUnits.Y;
                }
            }
            if (!flag)
            {
                return(num2);
            }
            return(num1);
        }
예제 #22
0
        public virtual void UpdateDataPointLabelVisibility()
        {
            DateTime now = DateTime.Now;

            if (this._xScalePositions == null)
            {
                this.RecalculateXIntervals();
            }
            if (this._yScalePositions == null)
            {
                this.RecalculateYIntervals();
            }
            if (this._chartArea == null || this._chartArea.Series.Count <= 0)
            {
                return;
            }
            if (this._dataPointRanges.Count == 0)
            {
                this.CreateDataPointRanges();
            }
            List <XYDataPoint> list = new List <XYDataPoint>();
            Dictionary <Type, SeriesPresenter> dictionary = new Dictionary <Type, SeriesPresenter>();

            foreach (Series series in this._chartArea.Series)
            {
                if (!dictionary.ContainsKey(series.SeriesPresenter.GetType()))
                {
                    dictionary.Add(series.SeriesPresenter.GetType(), series.SeriesPresenter);
                }
                if (series.Visibility == Visibility.Visible && series.LabelVisibility == Visibility.Visible)
                {
                    foreach (XYDataPoint xyDataPoint in ((XYSeriesPresenter)series.SeriesPresenter).Series.DataPointsByXValue)
                    {
                        if (xyDataPoint.ActualLabelContent != null && xyDataPoint.XValueInScaleUnitsWithoutAnimation >= 0.0 && (xyDataPoint.XValueInScaleUnitsWithoutAnimation <= 1.0 && xyDataPoint.Visibility == Visibility.Visible))
                        {
                            if (this.IsOnlyXAxisUsed)
                            {
                                list.Add(xyDataPoint);
                            }
                            else if (xyDataPoint.YValueInScaleUnitsWithoutAnimation >= 0.0 && xyDataPoint.YValueInScaleUnitsWithoutAnimation <= 1.0)
                            {
                                list.Add(xyDataPoint);
                            }
                        }
                    }
                }
            }
            if (list.Count < 30)
            {
                foreach (DataPoint dataPoint in list)
                {
                    dataPoint.ActualLabelVisibility = Visibility.Visible;
                }
            }
            else
            {
                foreach (LabelVisibilityManager.DataPointRange dataPointRange in this._dataPointRanges)
                {
                    dataPointRange.DataPoints.Clear();
                    dataPointRange.DataPointProjectedYRange = Range <double> .Empty;
                    for (int index = 0; index < list.Count; ++index)
                    {
                        XYDataPoint xyDataPoint = list[index];
                        if (xyDataPoint.XValueInScaleUnitsWithoutAnimation >= dataPointRange.ProjectedXRange.Minimum && xyDataPoint.XValueInScaleUnitsWithoutAnimation < dataPointRange.ProjectedXRange.Maximum && (!dataPointRange.ProjectedYRange.HasData || xyDataPoint.YValueInScaleUnitsWithoutAnimation >= dataPointRange.ProjectedYRange.Minimum && xyDataPoint.YValueInScaleUnitsWithoutAnimation < dataPointRange.ProjectedYRange.Maximum))
                        {
                            dataPointRange.DataPoints.Add((DataPoint)xyDataPoint);
                            dataPointRange.DataPointProjectedYRange = dataPointRange.DataPointProjectedYRange.Add(xyDataPoint.YValueInScaleUnitsWithoutAnimation);
                            list.RemoveAt(index);
                            --index;
                        }
                    }
                }
                foreach (DataPoint dataPoint in list)
                {
                    dataPoint.ActualLabelVisibility = Visibility.Collapsed;
                }
                bool useMaximum = true;
                LabelVisibilityManager.DataPointRange prevRange = (LabelVisibilityManager.DataPointRange)null;
                foreach (LabelVisibilityManager.DataPointRange range in this._dataPointRanges)
                {
                    Dictionary <XYDataPoint, double> defaultRanking = this.GetDefaultRanking(range, prevRange, ref useMaximum);
                    prevRange = range;
                    foreach (SeriesPresenter seriesPresenter in dictionary.Values)
                    {
                        seriesPresenter.LabelPresenter.AdjustDataPointLabelVisibilityRating(range, defaultRanking);
                    }
                    double num1 = -1.0;
                    foreach (double num2 in defaultRanking.Values)
                    {
                        if (num2 > num1)
                        {
                            num1 = num2;
                        }
                    }
                    foreach (XYDataPoint key in range.DataPoints)
                    {
                        double num2;
                        if (defaultRanking.TryGetValue(key, out num2) && num2 == num1)
                        {
                            key.ActualLabelVisibility = Visibility.Visible;
                        }
                        else
                        {
                            key.ActualLabelVisibility = Visibility.Collapsed;
                        }
                    }
                }
            }
        }
예제 #23
0
        protected override void UpdateView(DataPoint dataPoint)
        {
            if (!this.IsDataPointViewVisible(dataPoint))
            {
                return;
            }
            DateTime    now         = DateTime.Now;
            XYDataPoint xyDataPoint = dataPoint as XYDataPoint;

            if (xyDataPoint != null && this.CanGraph(xyDataPoint))
            {
                DataPointView view = dataPoint.View;
                if (view != null)
                {
                    FrameworkElement mainView = view.MainView;
                    if (mainView != null)
                    {
                        bool            flag                = this.ChartArea.Orientation != Orientation.Horizontal;
                        RectOrientation rectOrientation     = RectOrientation.BottomTop;
                        Point           positionInAxisUnits = this.GetPositionInAxisUnits(xyDataPoint);
                        Point           point1              = new Point(Math.Round(positionInAxisUnits.X), Math.Round(positionInAxisUnits.Y));
                        object          crossingPosition    = this.Series.YAxis.Scale.ActualCrossingPosition;
                        Point           basePoint           = new Point(positionInAxisUnits.X, this.Series.YAxis.AxisPresenter.ConvertDataToAxisUnits(crossingPosition) ?? 0.0);
                        Point           point2              = new Point(Math.Round(basePoint.X), Math.Round(basePoint.Y));
                        double          num1                = point1.X + Math.Round(this.PointClusterOffset);
                        double          num2                = this.MinMaxScreenCoordinates(positionInAxisUnits.Y);
                        double          num3                = Math.Round(this.PointWidth);
                        double          height              = this.MinMaxScreenCoordinates(basePoint.Y - positionInAxisUnits.Y);
                        if (ValueHelper.Compare(xyDataPoint.YValue as IComparable, crossingPosition as IComparable) != 0 && Math.Abs(height) < 2.0 && this.CanAdjustHeight())
                        {
                            height = basePoint.Y - positionInAxisUnits.Y >= 0.0 ? 2.0 : -2.0;
                            num2   = point2.Y - height;
                        }
                        if (height < 0.0)
                        {
                            rectOrientation = RectOrientation.TopBottom;
                            height          = Math.Abs(height);
                            num2           -= height;
                        }
                        double num4 = this.MinMaxScreenCoordinates(this.GetYOffsetInAxisUnits(xyDataPoint, positionInAxisUnits, basePoint));
                        double num5 = Math.Round(num2 - num4);
                        double num6 = this.AdjustColumnHeight(height);
                        if (flag)
                        {
                            if (rectOrientation == RectOrientation.BottomTop)
                            {
                                rectOrientation = RectOrientation.RightLeft;
                            }
                            else if (rectOrientation == RectOrientation.TopBottom)
                            {
                                rectOrientation = RectOrientation.LeftRight;
                            }
                            Canvas.SetLeft((UIElement)mainView, num5);
                            Canvas.SetTop((UIElement)mainView, num1);
                            mainView.Width   = num6;
                            mainView.Height  = num3;
                            view.AnchorRect  = new Rect(num5, num1, num6, num3);
                            view.AnchorPoint = rectOrientation != RectOrientation.RightLeft ? new Point(num5 + num6, num1 + this.PointWidth / 2.0) : new Point(num5, num1 + this.PointWidth / 2.0);
                        }
                        else
                        {
                            Canvas.SetLeft((UIElement)mainView, num1);
                            Canvas.SetTop((UIElement)mainView, num5);
                            mainView.Width   = num3;
                            mainView.Height  = num6;
                            view.AnchorRect  = new Rect(num1, num5, num3, num6);
                            view.AnchorPoint = rectOrientation != RectOrientation.BottomTop ? new Point(num1 + this.PointWidth / 2.0, num5 + num6) : new Point(num1 + this.PointWidth / 2.0, num5);
                        }
                        BarControl barControl = mainView as BarControl;
                        if (barControl != null)
                        {
                            barControl.Orientation = rectOrientation;
                        }
                        view.AnchorRectOrientation = rectOrientation;
                    }
                }
            }
            base.UpdateView(dataPoint);
            if (this.ChartArea == null)
            {
                return;
            }
            this.ChartArea.UpdateSession.AddCounter("ColumnSeriesPresenter.UpdateView", DateTime.Now - now);
        }
예제 #24
0
        internal override void UpdateDataPointVisibility()
        {
            int  index1 = 0;
            bool flag1  = true;
            bool flag2  = true;

            DataPointViewState[] dataPointViewStateArray = new DataPointViewState[this.Series.DataPoints.Count];
            foreach (DataPoint dataPoint1 in (Collection <DataPoint>) this.Series.DataPoints)
            {
                DataPointViewState dataPointViewState = DataPointViewState.Hidden;
                dataPoint1.IsVisible = false;
                XYDataPoint xyDataPoint = dataPoint1 as XYDataPoint;
                if (xyDataPoint != null && this.ChartArea != null && (this.ChartArea.IsTemplateApplied && ValueHelper.CanGraph(xyDataPoint.XValueInScaleUnits)) && ValueHelper.CanGraph(xyDataPoint.YValueInScaleUnits))
                {
                    if (DoubleHelper.GreaterOrEqualWithPrecision(xyDataPoint.XValueInScaleUnits, 0.0) && DoubleHelper.LessOrEqualWithPrecision(xyDataPoint.XValueInScaleUnits, 1.0) && (DoubleHelper.GreaterOrEqualWithPrecision(xyDataPoint.YValueInScaleUnits, 0.0) && DoubleHelper.LessOrEqualWithPrecision(xyDataPoint.YValueInScaleUnits, 1.0)))
                    {
                        if (this.Series.Visibility == Visibility.Visible)
                        {
                            flag1 = false;
                            dataPoint1.IsVisible = true;
                            if (!dataPoint1.IsNewlyAdded)
                            {
                                flag2 = false;
                            }
                            dataPointViewState = dataPoint1.IsNewlyAdded ? DataPointViewState.Showing : DataPointViewState.Normal;
                            if (index1 > 0)
                            {
                                DataPoint dataPoint2 = this.Series.DataPoints[index1 - 1];
                                if (dataPointViewStateArray[index1 - 1] == DataPointViewState.Hidden || dataPointViewStateArray[index1 - 1] == DataPointViewState.Hiding)
                                {
                                    dataPoint2.IsVisible = true;
                                    dataPointViewStateArray[index1 - 1] = dataPointViewState;
                                    this.ChartArea.UpdateSession.Update((IUpdatable)dataPoint2);
                                }
                            }
                            if (index1 < this.Series.DataPoints.Count - 1)
                            {
                                DataPoint dataPoint2 = this.Series.DataPoints[index1 + 1];
                                if (!this._dataPointsToForceVisibility.Contains(dataPoint2))
                                {
                                    this._dataPointsToForceVisibility.Add(dataPoint2);
                                }
                            }
                            this.ChartArea.UpdateSession.Update((IUpdatable)dataPoint1);
                        }
                    }
                    else if (this._dataPointsToForceVisibility.Contains(dataPoint1))
                    {
                        dataPoint1.IsVisible = true;
                        dataPointViewState   = dataPoint1.IsNewlyAdded ? DataPointViewState.Showing : DataPointViewState.Normal;
                    }
                }
                if (this._dataPointsToForceVisibility.Contains(dataPoint1))
                {
                    this._dataPointsToForceVisibility.Remove(dataPoint1);
                }
                dataPointViewStateArray[index1] = dataPointViewState;
                ++index1;
            }
            this.IsSimplifiedRenderingModeCheckRequired = true;
            this.CheckSimplifiedRenderingMode();
            if (!flag2)
            {
                for (int index2 = 0; index2 < EnumerableFunctions.FastCount((IEnumerable)dataPointViewStateArray); ++index2)
                {
                    if (dataPointViewStateArray[index2] == DataPointViewState.Showing)
                    {
                        dataPointViewStateArray[index2] = DataPointViewState.Normal;
                    }
                }
            }
            if (flag1 && this.Series.DataPoints.Count > 0 && (this.ChartArea != null && this.ChartArea.IsTemplateApplied) && (DoubleHelper.LessWithPrecision(((XYDataPoint)this.Series.DataPoints[0]).XValueInScaleUnits, 0.0) && DoubleHelper.GreaterWithPrecision(((XYDataPoint)this.Series.DataPoints[this.Series.DataPoints.Count - 1]).XValueInScaleUnits, 1.0)))
            {
                int index2;
                for (index2 = 1; index2 < this.Series.DataPoints.Count - 2; ++index2)
                {
                    if (DoubleHelper.GreaterOrEqualWithPrecision((this.Series.DataPoints[index2] as XYDataPoint).XValueInScaleUnits, 0.0))
                    {
                        --index2;
                        break;
                    }
                }
                XYDataPoint xyDataPoint1 = this.Series.DataPoints[index2] as XYDataPoint;
                xyDataPoint1.IsVisible          = true;
                dataPointViewStateArray[index2] = xyDataPoint1.IsNewlyAdded ? DataPointViewState.Showing : DataPointViewState.Normal;
                this.ChartArea.UpdateSession.Update((IUpdatable)xyDataPoint1);
                XYDataPoint xyDataPoint2 = this.Series.DataPoints[index2 + 1] as XYDataPoint;
                xyDataPoint2.IsVisible = true;
                dataPointViewStateArray[index2 + 1] = xyDataPoint2.IsNewlyAdded ? DataPointViewState.Showing : DataPointViewState.Normal;
                this.ChartArea.UpdateSession.Update((IUpdatable)xyDataPoint2);
            }
            int index3 = 0;

            foreach (DataPoint dataPoint in (Collection <DataPoint>) this.Series.DataPoints)
            {
                this.SetDataPointViewState(dataPoint, dataPointViewStateArray[index3]);
                dataPoint.IsNewlyAdded = false;
                ++index3;
            }
        }
예제 #25
0
 internal virtual Point GetPositionInAxisUnits(XYDataPoint dataPointXY)
 {
     return(new Point(this.Series.XAxis.AxisPresenter.ConvertScaleToAxisUnits(dataPointXY.XValueInScaleUnits) ?? 0.0, this.Series.YAxis.AxisPresenter.ConvertScaleToAxisUnits(dataPointXY.YValueInScaleUnits) ?? 0.0));
 }
예제 #26
0
 internal virtual double GetYOffsetInAxisUnits(XYDataPoint dataPoint, Point valuePoint, Point basePoint)
 {
     return(0.0);
 }
예제 #27
0
 private bool IsHundredPercent(XYDataPoint dataPoint)
 {
     return(this.IsHundredPercent(dataPoint.Series));
 }