Beispiel #1
0
        public override double ConvertToPercent(object value)
        {
            if (value == null)
            {
                return(double.NaN);
            }
            this.RecalculateIfEmpty();
            Range <double> fromRange = new Range <double>(this.ActualMinimum, this.ActualMaximum);
            double         num       = Convert.ToDouble(value, (IFormatProvider)CultureInfo.InvariantCulture);

            if (DoubleHelper.LessWithPrecision(num, fromRange.Minimum) || DoubleHelper.GreaterWithPrecision(num, fromRange.Maximum))
            {
                return(double.NaN);
            }
            return(RangeHelper.Project(fromRange, num, Scale.PercentRange));
        }
Beispiel #2
0
        private void ZoomPlotArea(bool isZoomIn, double xCenterValue, double yCenterValue)
        {
            double delta = isZoomIn ? 1.2 : 5.0 / 6.0;

            foreach (Axis axis in (Collection <Axis>) this.Axes)
            {
                if (axis.ActualIsZoomEnabled)
                {
                    if (this.IsHorizontalAxis(axis))
                    {
                        axis.Scale.ZoomBy(xCenterValue, delta);
                    }
                    else
                    {
                        axis.Scale.ZoomBy(yCenterValue, delta);
                    }
                    axis.ShowScrollZoomBar = DoubleHelper.GreaterWithPrecision(axis.Scale.ActualZoom, 1.0);
                }
            }
        }
Beispiel #3
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;
            }
        }
Beispiel #4
0
        public override double ConvertToPercent(object value)
        {
            if (value == null)
            {
                return(double.NaN);
            }
            double         num        = Convert.ToDouble(value, (IFormatProvider)CultureInfo.InvariantCulture);
            Range <double> fromRange  = new Range <double>(this.ActualMinimum, this.ActualMaximum);
            double         precision1 = DoubleHelper.GetPrecision(num, fromRange.Minimum, fromRange.Maximum);

            if (DoubleHelper.LessWithPrecision(num, fromRange.Minimum, precision1) || DoubleHelper.GreaterWithPrecision(num, fromRange.Maximum, precision1))
            {
                return(double.NaN);
            }
            double precision2 = DoubleHelper.GetPrecision(1, new double[0]);

            return(DoubleHelper.RoundWithPrecision(RangeHelper.Project(fromRange, num, Scale.PercentRange), precision2));
        }