コード例 #1
0
ファイル: Axis.cs プロジェクト: tdhieu/openvss
        private static void ConvertValueToDateTimeOrNumeric(String propertyName, Object newValue, ref Double numericVal, ref DateTime dateTimeValue, out ChartValueTypes valueType)
        {
            // Double / Int32 value entered in Managed Code
            if (newValue.GetType().Equals(typeof(Double)) || newValue.GetType().Equals(typeof(Int32)))
            {
                numericVal = Convert.ToDouble(newValue);
                valueType = ChartValueTypes.Numeric;
            }
            // DateTime value entered in Managed Code
            else if ((newValue.GetType().Equals(typeof(DateTime))))
            {
                dateTimeValue = (DateTime)newValue;
                valueType = ChartValueTypes.DateTime;
            }
            // Double / Int32 / DateTime entered in XAML
            else if ((newValue.GetType().Equals(typeof(String))))
            {
                DateTime dateTimeresult;
                Double doubleResult;

                if (String.IsNullOrEmpty(newValue.ToString()))
                {
                    numericVal = Double.NaN;
                    valueType = ChartValueTypes.Numeric;
                }
                // Double entered in XAML
                else if (Double.TryParse((string)newValue, System.Globalization.NumberStyles.Number, System.Globalization.CultureInfo.InvariantCulture, out doubleResult))
                {
                    numericVal = doubleResult;
                    valueType = ChartValueTypes.Numeric;
                }
                // DateTime entered in XAML
                else if (DateTime.TryParse((string)newValue, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out dateTimeresult))
                {
                    dateTimeValue = dateTimeresult;
                    valueType = ChartValueTypes.DateTime;
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine("Invalid Input for " + propertyName);
                    throw new Exception("Invalid Input for " + propertyName);
                }
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("Invalid Input for " + propertyName);
                throw new Exception("Invalid Input for " + propertyName);
            }
        }
コード例 #2
0
        /// <summary>
        /// Get Date difference in days
        /// </summary>
        /// <param name="dateTime1">First Date</param>
        /// <param name="dateTime2">Second Date</param>
        /// <param name="minDateRange">Minimum TimeSpan between two dates in list of dates from InternalDataPoints interval</param>
        /// <param name="intervalTypes">Type of interval is applied</param>
        /// <returns>Date Difference</returns>
        public static Double DateDiff(DateTime dateTime1, DateTime dateTime2, TimeSpan minDateDifference, TimeSpan maxDateDifference, IntervalTypes intervalTypes, ChartValueTypes xValueType)
        {
            TimeSpan timespan = dateTime1.Subtract(dateTime2);
            Double retVal = 1;

            CALCULATE_WITH_NEW_INTERVAL_TYPE:

            switch (intervalTypes)
            {   
                case IntervalTypes.Auto:
                    intervalTypes = GetAutoIntervalType(minDateDifference, maxDateDifference, intervalTypes);
                    goto CALCULATE_WITH_NEW_INTERVAL_TYPE;

                case IntervalTypes.Years:

                    // Double noOfYears = (DateTime.IsLeapYear(dateToUpdate.Year) ? 366 : 365) * increment;
                    // return new DateTime(dateToUpdate.Year + (int) increment,1,1,0,0,0,0, DateTimeKind.Unspecified);
                    // 1 minutes (y / year) = 0.000001902587519025875 months (mth)
                    retVal = 0.000001902587519025875 * timespan.TotalMinutes;
                    //retVal = Math.Abs(dateTime1.Date.Year - dateTime2.Date.Year);
                    break;

                case IntervalTypes.Months:

                    //if (xValueType == ChartValueTypes.Date)
                    //    retVal = (dateTime1.Year * 12 + dateTime1.Month) - (dateTime2.Year * 12 + dateTime2.Month);
                    //else
                    {
                        // 1 hour (h / hr) = 0.00 137 months (mth)
                        retVal = 0.00137 * timespan.TotalHours;
                    }

                    break;

                case IntervalTypes.Weeks:
                    retVal = timespan.TotalDays / 7;
                    break;

                case IntervalTypes.Days:
                    retVal = timespan.TotalDays;
                    break;

                case IntervalTypes.Hours:
                    retVal = timespan.TotalHours;
                    break;

                case IntervalTypes.Minutes:
                    retVal = timespan.TotalMinutes;
                    break;

                case IntervalTypes.Seconds:
                    retVal = timespan.TotalSeconds;
                    break;

                case IntervalTypes.Milliseconds:
                    retVal = timespan.TotalMilliseconds;
                    break;
            }

            return retVal;
        }
コード例 #3
0
        /// <summary>
        /// Recalculates a DateTime interval obtained from maximum and minimum DateTime.
        /// </summary>
        /// <param name="width">Width of available space</param>
        /// <param name="height">Height of available space</param>
        /// <param name="axisOrientation">Axis orientation</param>
        /// <param name="minDateTime">Minimum DateTime value</param>
        /// <param name="maxDateTime">Maximum DateTime Value</param>
        /// <param name="type">Current Interval type</param>
        /// <param name="maxInterval">Max Interval</param>
        /// <returns>Calculated auto interval</returns>
        public static double CalculateAutoInterval(Double width, Double height, AxisOrientation axisOrientation, DateTime minDateTime, DateTime maxDateTime, out IntervalTypes type, Double maxInterval, ChartValueTypes xValueType)
        {   
            TimeSpan timeSpan = maxDateTime.Subtract(minDateTime);

            // Algorithm will interval close to 10.
            // We need to align the time span for PrefferedNumberOfIntervals
            double maxIntervals = axisOrientation == AxisOrientation.Horizontal ? maxInterval * 0.8 : maxInterval;
            double rangeMultiplicator = (axisOrientation == AxisOrientation.Horizontal ? width : height) / (200 * 10 / maxIntervals);
            
            timeSpan = new TimeSpan((long)((double)timeSpan.Ticks / rangeMultiplicator));

            // TotalMinutes
            double totalMinutes = timeSpan.TotalMinutes;

            if (xValueType != ChartValueTypes.Date)
            {
                // For Range less than 60 seconds interval is 5 sec
                if (totalMinutes <= 1.0)
                {
                    // Milli Seconds
                    double milliSeconds = timeSpan.TotalMilliseconds;

                    if (milliSeconds <= 10)
                    {
                        type = IntervalTypes.Milliseconds;
                        return 1;
                    }
                    if (milliSeconds <= 50)
                    {
                        type = IntervalTypes.Milliseconds;
                        return 4;
                    }
                    if (milliSeconds <= 200)
                    {
                        type = IntervalTypes.Milliseconds;
                        return 20;
                    }
                    if (milliSeconds <= 500)
                    {
                        type = IntervalTypes.Milliseconds;
                        return 50;
                    }

                    // Seconds
                    double seconds = timeSpan.TotalSeconds;

                    if (seconds <= 7)
                    {
                        type = IntervalTypes.Seconds;
                        return 1;
                    }
                    else if (seconds <= 15)
                    {
                        type = IntervalTypes.Seconds;
                        return 2;
                    }
                    else if (seconds <= 30)
                    {
                        type = IntervalTypes.Seconds;
                        return 5;
                    }
                    else if (seconds <= 60)
                    {
                        type = IntervalTypes.Seconds;
                        return 10;
                    }
                }
                else if (totalMinutes <= 2.0)
                {
                    // Range less than 120 seconds interval is 10 sec
                    type = IntervalTypes.Seconds;
                    return 20;
                }
                else if (totalMinutes <= 3.0)
                {
                    // Range less than 180 seconds interval is 30 sec
                    type = IntervalTypes.Seconds;
                    return 30;
                }
                else if (totalMinutes <= 10)
                {
                    // Range less than 10 minutes interval is 1 min
                    type = IntervalTypes.Minutes;
                    return 1;
                }
                else if (totalMinutes <= 20)
                {
                    // Range less than 20 minutes interval is 1 min
                    type = IntervalTypes.Minutes;
                    return 2;
                }
                else if (totalMinutes <= 60)
                {
                    // Range less than 60 minutes interval is 5 min
                    type = IntervalTypes.Minutes;
                    return 5;
                }
                else if (totalMinutes <= 120)
                {
                    // Range less than 120 minutes interval is 10 min
                    type = IntervalTypes.Minutes;
                    return 10;
                }
                else if (totalMinutes <= 180)
                {
                    // Range less than 180 minutes interval is 30 min
                    type = IntervalTypes.Minutes;
                    return 30;
                }
                else if (totalMinutes <= 60 * 12)
                {
                    // Range less than 12 hours interval is 1 hour
                    type = IntervalTypes.Hours;
                    return 1;
                }
                else if (totalMinutes <= 60 * 24)
                {
                    // Range less than 24 hours interval is 4 hour
                    type = IntervalTypes.Hours;
                    return 4;
                }
                else if (totalMinutes <= 60 * 24 * 2)
                {
                    // Range less than 2 days interval is 6 hour
                    type = IntervalTypes.Hours;
                    return 6;
                }
                else if (totalMinutes <= 60 * 24 * 3)
                {
                    // Range less than 3 days interval is 12 hour
                    type = IntervalTypes.Hours;
                    return 12;
                }
            }
            
            if (totalMinutes <= 60 * 24 * 10)
            {
                // Range less than 10 days interval is 1 day
                type = IntervalTypes.Days;
                return 1;
            }
            else if (totalMinutes <= 60 * 24 * 20)
            {
                // Range less than 20 days interval is 2 day
                type = IntervalTypes.Days;
                return 2;
            }
            else if (totalMinutes <= 60 * 24 * 30)
            {
                // Range less than 30 days interval is 3 day
                type = IntervalTypes.Days;
                return 3;
            }
            else if (totalMinutes <= 60 * 24 * 30.5 * 2)
            {
                // Range less than 2 months interval is 1 week
                type = IntervalTypes.Weeks;
                return 1;
            }
            else if (totalMinutes <= 60 * 24 * 30.5 * 5)
            {
                // Range less than 5 months interval is 2weeks
                type = IntervalTypes.Weeks;
                return 2;
            }
            else if (totalMinutes <= 60 * 24 * 30.5 * 12)
            {
                // Range less than 12 months interval is 1 month
                type = IntervalTypes.Months;
                return 1;
            }
            else if (totalMinutes <= 60 * 24 * 30.5 * 24)
            {
                // Range less than 24 months interval is 3 month
                type = IntervalTypes.Months;
                return 3;
            }
            else if (totalMinutes <= 60 * 24 * 30.5 * 48)
            {
                // Range less than 48 months interval is 6 months 
                type = IntervalTypes.Months;
                return 6;
            }

            // Range more than 48 months interval is year 
            type = IntervalTypes.Years;
            double years = totalMinutes / 60 / 24 / 365;
            if (years < 5)
            {
                return 1;
            }
            else if (years < 10)
            {
                return 2;
            }

            // Make a correction of the interval
            return Math.Floor(years / 5);
        }
コード例 #4
0
        internal void FillLabels(bool removeFirstRow)
        {
            if (!LabelStyle.Enabled || !enabled)
            {
                return;
            }
            if (chartArea != null && chartArea.chartAreaIsCurcular && axisType != AxisName.Y)
            {
                ICircularChartType circularChartType = chartArea.GetCircularChartType();
                if (circularChartType == null || !circularChartType.XAxisLabelsSupported())
                {
                    return;
                }
            }
            bool flag = false;

            foreach (CustomLabel customLabel in CustomLabels)
            {
                if (customLabel.customLabel && (customLabel.RowIndex == 0 || chartArea.chartAreaIsCurcular))
                {
                    flag = true;
                }
                if (customLabel.customLabel && base.Common.Chart != null && base.Common.Chart.LocalizeTextHandler != null)
                {
                    customLabel.Text = base.Common.Chart.LocalizeTextHandler(customLabel, customLabel.Text, 0, ChartElementType.AxisLabels);
                }
            }
            if (removeFirstRow)
            {
                if (flag)
                {
                    return;
                }
                for (int i = 0; i < CustomLabels.Count; i++)
                {
                    if (CustomLabels[i].RowIndex == 0)
                    {
                        CustomLabels.RemoveAt(i);
                        i = -1;
                    }
                }
            }
            ArrayList arrayList = null;

            switch (axisType)
            {
            case AxisName.X:
                arrayList = chartArea.GetXAxesSeries(AxisType.Primary, ((Axis)this).SubAxisName);
                break;

            case AxisName.Y:
                arrayList = chartArea.GetYAxesSeries(AxisType.Primary, ((Axis)this).SubAxisName);
                break;

            case AxisName.X2:
                arrayList = chartArea.GetXAxesSeries(AxisType.Secondary, ((Axis)this).SubAxisName);
                break;

            case AxisName.Y2:
                arrayList = chartArea.GetYAxesSeries(AxisType.Secondary, ((Axis)this).SubAxisName);
                break;
            }
            if (arrayList.Count == 0)
            {
                return;
            }
            string[] array = new string[arrayList.Count];
            for (int j = 0; j < arrayList.Count; j++)
            {
                array[j] = (string)arrayList[j];
            }
            bool flag2         = SeriesXValuesZeros(array);
            bool indexedSeries = true;

            if (!flag2)
            {
                indexedSeries = IndexedSeries(array);
            }
            int num = 0;

            if (labelStyle.ShowEndLabels)
            {
                num = 1;
            }
            IChartType chartType = base.Common.ChartTypeRegistry.GetChartType(chartArea.GetFirstSeries().ChartTypeName);
            bool       flag3     = false;

            if (!chartType.RequireAxes)
            {
                return;
            }
            flag3 = ((axisType != AxisName.Y && axisType != AxisName.Y2) ? true : false);
            if (flag3 && !SeriesXValuesZeros((string[])arrayList.ToArray(typeof(string))))
            {
                flag3 = false;
            }
            if (flag3 && (labelStyle.IntervalOffset != 0.0 || labelStyle.Interval != 0.0))
            {
                flag3 = false;
            }
            ChartValueTypes chartValueTypes = (axisType != 0 && axisType != AxisName.X2) ? base.Common.DataManager.Series[arrayList[0]].YValueType : base.Common.DataManager.Series[arrayList[0]].indexedXValueType;

            if (labelStyle.IntervalType != 0 && labelStyle.IntervalType != DateTimeIntervalType.Number && chartValueTypes != ChartValueTypes.Time && chartValueTypes != ChartValueTypes.Date && chartValueTypes != ChartValueTypes.DateTimeOffset)
            {
                chartValueTypes = ChartValueTypes.DateTime;
            }
            double viewMaximum = GetViewMaximum();
            double viewMinimum = GetViewMinimum();

            if (flag3)
            {
                int numberOfPoints = base.Common.DataManager.GetNumberOfPoints((string[])arrayList.ToArray(typeof(string)));
                if (num == 1)
                {
                    CustomLabels.Add(-0.5, 0.5, ValueConverter.FormatValue(base.Common.Chart, this, 0.0, LabelStyle.Format, chartValueTypes, ChartElementType.AxisLabels), customLabel: false);
                }
                for (int k = 0; k < numberOfPoints; k++)
                {
                    CustomLabels.Add((double)k + 0.5, (double)k + 1.5, ValueConverter.FormatValue(base.Common.Chart, this, k + 1, LabelStyle.Format, chartValueTypes, ChartElementType.AxisLabels), customLabel: false);
                }
                if (num == 1)
                {
                    CustomLabels.Add((double)numberOfPoints + 0.5, (double)numberOfPoints + 1.5, ValueConverter.FormatValue(base.Common.Chart, this, numberOfPoints + 1, LabelStyle.Format, chartValueTypes, ChartElementType.AxisLabels), customLabel: false);
                }
                foreach (string item in arrayList)
                {
                    int l = (num == 1) ? 1 : 0;
                    foreach (DataPoint point in base.Common.DataManager.Series[item].Points)
                    {
                        for (; CustomLabels[l].RowIndex > 0; l++)
                        {
                        }
                        if ((axisType == AxisName.X || axisType == AxisName.X2) && point.AxisLabel.Length > 0)
                        {
                            CustomLabels[l].Text = point.AxisLabel;
                            if (base.Common.Chart != null && base.Common.Chart.LocalizeTextHandler != null)
                            {
                                CustomLabels[l].Text = base.Common.Chart.LocalizeTextHandler(point, CustomLabels[l].Text, point.ElementId, ChartElementType.DataPoint);
                            }
                        }
                        l++;
                    }
                }
            }
            else
            {
                if (viewMinimum == viewMaximum)
                {
                    return;
                }
                Series series = null;
                if (axisType == AxisName.X || axisType == AxisName.X2)
                {
                    ArrayList xAxesSeries = chartArea.GetXAxesSeries((axisType != 0) ? AxisType.Secondary : AxisType.Primary, ((Axis)this).SubAxisName);
                    if (xAxesSeries.Count > 0)
                    {
                        series = base.Common.DataManager.Series[xAxesSeries[0]];
                        if (series != null && !series.XValueIndexed)
                        {
                            series = null;
                        }
                    }
                }
                DateTimeIntervalType dateTimeIntervalType = (labelStyle.IntervalOffsetType == DateTimeIntervalType.Auto) ? labelStyle.IntervalType : labelStyle.IntervalOffsetType;
                double num2 = viewMinimum;
                if (!chartArea.chartAreaIsCurcular || axisType == AxisName.Y || axisType == AxisName.Y2)
                {
                    num2 = AlignIntervalStart(num2, labelStyle.Interval, labelStyle.IntervalType, series);
                }
                if (labelStyle.IntervalOffset != 0.0 && series == null)
                {
                    num2 += GetIntervalSize(num2, labelStyle.IntervalOffset, dateTimeIntervalType, series, 0.0, DateTimeIntervalType.Number, forceIntIndex: true, forceAbsInterval: false);
                }
                if (chartValueTypes == ChartValueTypes.DateTime || chartValueTypes == ChartValueTypes.Date || chartValueTypes == ChartValueTypes.Time || chartValueTypes == ChartValueTypes.DateTimeOffset || series != null)
                {
                    double num3 = num2;
                    if ((viewMaximum - num2) / GetIntervalSize(num2, labelStyle.Interval, labelStyle.IntervalType, series, 0.0, DateTimeIntervalType.Number, forceIntIndex: true) > 10000.0)
                    {
                        return;
                    }
                    int    num4 = 0;
                    double num5 = viewMaximum - GetIntervalSize(viewMaximum, labelStyle.Interval, labelStyle.IntervalType, series, labelStyle.IntervalOffset, dateTimeIntervalType, forceIntIndex: true) / 2.0;
                    double num6 = viewMinimum + GetIntervalSize(viewMinimum, labelStyle.Interval, labelStyle.IntervalType, series, labelStyle.IntervalOffset, dateTimeIntervalType, forceIntIndex: true) / 2.0;
                    while ((decimal)num3 <= (decimal)viewMaximum)
                    {
                        double intervalSize = GetIntervalSize(num3, labelStyle.Interval, labelStyle.IntervalType, series, labelStyle.IntervalOffset, dateTimeIntervalType, forceIntIndex: true);
                        double num7         = num3;
                        if (base.Logarithmic)
                        {
                            num7 = Math.Pow(logarithmBase, num7);
                        }
                        if (num4++ > 10000 || (num == 0 && num3 >= num5))
                        {
                            break;
                        }
                        double num8       = num3 - intervalSize * 0.5;
                        double toPosition = num3 + intervalSize * 0.5;
                        if (num == 0 && num3 <= num6)
                        {
                            num3 += intervalSize;
                            continue;
                        }
                        if ((decimal)num8 > (decimal)viewMaximum)
                        {
                            num3 += intervalSize;
                            continue;
                        }
                        string pointLabel = GetPointLabel(arrayList, num7, !flag2, indexedSeries);
                        if (pointLabel.Length == 0)
                        {
                            if (num3 <= maximum && (num3 != maximum || !base.Common.DataManager.Series[arrayList[0]].XValueIndexed))
                            {
                                CustomLabels.Add(num8, toPosition, ValueConverter.FormatValue(base.Common.Chart, this, num7, LabelStyle.Format, chartValueTypes, ChartElementType.AxisLabels), customLabel: false);
                            }
                        }
                        else
                        {
                            CustomLabels.Add(num8, toPosition, pointLabel, customLabel: false);
                        }
                        num3 += intervalSize;
                    }
                    return;
                }
                if (num2 != viewMinimum)
                {
                    num = 1;
                }
                int num9 = 0;
                for (double num10 = num2 - (double)num * labelStyle.Interval; num10 < viewMaximum - 1.5 * labelStyle.Interval * (double)(1 - num); num10 = (double)((decimal)num10 + (decimal)labelStyle.Interval))
                {
                    num9++;
                    if (num9 > 10000)
                    {
                        break;
                    }
                    double num7   = Axis.RemoveNoiseFromDoubleMath(num10) + Axis.RemoveNoiseFromDoubleMath(labelStyle.Interval);
                    double value  = Math.Log(labelStyle.Interval);
                    double value2 = Math.Log(Math.Abs(num7));
                    int    num11  = (int)Math.Abs(value) + 5;
                    if (num11 > 15)
                    {
                        num11 = 15;
                    }
                    if (Math.Abs(value) < Math.Abs(value2) - 5.0)
                    {
                        num7 = Math.Round(num7, num11);
                    }
                    if ((viewMaximum - num2) / labelStyle.Interval > 10000.0)
                    {
                        break;
                    }
                    if (base.Logarithmic)
                    {
                        num7 = Math.Pow(logarithmBase, num7);
                    }
                    double num8       = (double)((decimal)num10 + (decimal)labelStyle.Interval * 0.5m);
                    double toPosition = (double)((decimal)num10 + (decimal)labelStyle.Interval * 1.5m);
                    if (!((decimal)num8 > (decimal)viewMaximum) && !((decimal)((num8 + toPosition) / 2.0) > (decimal)viewMaximum))
                    {
                        string pointLabel2 = GetPointLabel(arrayList, num7, !flag2, indexedSeries);
                        if (pointLabel2.Length > 15 && num7 < 1E-06)
                        {
                            num7 = 0.0;
                        }
                        if (pointLabel2.Length == 0)
                        {
                            if (!base.Common.DataManager.Series[arrayList[0]].XValueIndexed || !(num10 > maximum))
                            {
                                CustomLabels.Add(num8, toPosition, ValueConverter.FormatValue(base.Common.Chart, this, num7, LabelStyle.Format, chartValueTypes, ChartElementType.AxisLabels), customLabel: false);
                            }
                        }
                        else
                        {
                            CustomLabels.Add(num8, toPosition, pointLabel2, customLabel: false);
                        }
                    }
                }
            }
        }
コード例 #5
0
        private void GetValuesFromData(Axis axis, out double autoMinimum, out double autoMaximum)
        {
            int numberOfAllPoints = GetNumberOfAllPoints();

            if (!axis.refreshMinMaxFromData && !double.IsNaN(axis.minimumFromData) && !double.IsNaN(axis.maximumFromData) && axis.numberOfPointsInAllSeries == numberOfAllPoints)
            {
                autoMinimum = axis.minimumFromData;
                autoMaximum = axis.maximumFromData;
                return;
            }
            AxisType type = AxisType.Primary;

            if (axis.axisType == AxisName.X2 || axis.axisType == AxisName.Y2)
            {
                type = AxisType.Secondary;
            }
            string[] array       = (string[])GetXAxesSeries(type, axis.SubAxisName).ToArray(typeof(string));
            string[] seriesNames = (string[])GetYAxesSeries(type, axis.SubAxisName).ToArray(typeof(string));
            if (axis.axisType == AxisName.X2 || axis.axisType == AxisName.X)
            {
                if (stacked)
                {
                    try
                    {
                        base.Common.DataManager.GetMinMaxXValue(out autoMinimum, out autoMaximum, array);
                    }
                    catch (Exception)
                    {
                        throw new InvalidOperationException(SR.ExceptionAxisStackedChartsDataPointsNumberMismatch);
                    }
                }
                else if (secondYScale)
                {
                    autoMaximum = base.Common.DataManager.GetMaxXWithRadiusValue((ChartArea)this, array);
                    autoMinimum = base.Common.DataManager.GetMinXWithRadiusValue((ChartArea)this, array);
                    ChartValueTypes xValueType = base.Common.DataManager.Series[array[0]].XValueType;
                    if (xValueType != ChartValueTypes.Date && xValueType != ChartValueTypes.DateTime && xValueType != ChartValueTypes.Time && xValueType != ChartValueTypes.DateTimeOffset)
                    {
                        axis.roundedXValues = true;
                    }
                }
                else
                {
                    base.Common.DataManager.GetMinMaxXValue(out autoMinimum, out autoMaximum, array);
                }
            }
            else if (stacked)
            {
                try
                {
                    if (hundredPercent)
                    {
                        autoMaximum = base.Common.DataManager.GetMaxHundredPercentStackedYValue(hundredPercentNegative, 0, seriesNames);
                        autoMinimum = base.Common.DataManager.GetMinHundredPercentStackedYValue(hundredPercentNegative, 0, seriesNames);
                    }
                    else
                    {
                        double val  = double.MinValue;
                        double val2 = double.MaxValue;
                        double num  = double.MinValue;
                        double num2 = double.MaxValue;
                        foreach (string[] item in SplitSeriesInStackedGroups(seriesNames))
                        {
                            double maxStackedYValue         = base.Common.DataManager.GetMaxStackedYValue(0, item);
                            double minStackedYValue         = base.Common.DataManager.GetMinStackedYValue(0, item);
                            double maxUnsignedStackedYValue = base.Common.DataManager.GetMaxUnsignedStackedYValue(0, item);
                            double minUnsignedStackedYValue = base.Common.DataManager.GetMinUnsignedStackedYValue(0, item);
                            val  = Math.Max(val, maxStackedYValue);
                            val2 = Math.Min(val2, minStackedYValue);
                            num  = Math.Max(num, maxUnsignedStackedYValue);
                            num2 = Math.Min(num2, minUnsignedStackedYValue);
                        }
                        autoMaximum = Math.Max(val, num);
                        autoMinimum = Math.Min(val2, num2);
                    }
                    if (axis.Logarithmic && autoMinimum < 1.0)
                    {
                        autoMinimum = 1.0;
                    }
                }
                catch (Exception)
                {
                    throw new InvalidOperationException(SR.ExceptionAxisStackedChartsDataPointsNumberMismatch);
                }
            }
            else if (secondYScale)
            {
                autoMaximum = base.Common.DataManager.GetMaxYWithRadiusValue((ChartArea)this, seriesNames);
                autoMinimum = base.Common.DataManager.GetMinYWithRadiusValue((ChartArea)this, seriesNames);
            }
            else
            {
                bool flag = false;
                if (base.Common != null && base.Common.Chart != null)
                {
                    foreach (Series item2 in base.Common.Chart.Series)
                    {
                        if (item2.ChartArea == ((ChartArea)this).Name)
                        {
                            IChartType chartType = base.Common.ChartTypeRegistry.GetChartType(item2.ChartTypeName);
                            if (chartType != null && chartType.ExtraYValuesConnectedToYAxis)
                            {
                                flag = true;
                                break;
                            }
                        }
                    }
                }
                if (flag)
                {
                    base.Common.DataManager.GetMinMaxYValue(out autoMinimum, out autoMaximum, seriesNames);
                }
                else
                {
                    base.Common.DataManager.GetMinMaxYValue(0, out autoMinimum, out autoMaximum, seriesNames);
                }
            }
            axis.maximumFromData           = autoMaximum;
            axis.minimumFromData           = autoMinimum;
            axis.refreshMinMaxFromData     = false;
            axis.numberOfPointsInAllSeries = numberOfAllPoints;
        }
コード例 #6
0
        public void SetPointAttribute(object obj, string attributeName, string format)
        {
            string text = obj as string;

            if (text == null)
            {
                double          num       = double.NaN;
                ChartValueTypes valueType = ChartValueTypes.Auto;
                if (obj is DateTime)
                {
                    num       = ((DateTime)obj).ToOADate();
                    valueType = ChartValueTypes.Date;
                }
                else
                {
                    num = this.ConvertValue(obj);
                }
                if (!double.IsNaN(num))
                {
                    try
                    {
                        text = ValueConverter.FormatValue(base.series.chart, this, num, format, valueType, ChartElementType.DataPoint);
                    }
                    catch
                    {
                        text = obj.ToString();
                    }
                }
                else
                {
                    text = obj.ToString();
                }
            }
            if (text.Length > 0)
            {
                if (string.Compare(attributeName, "AxisLabel", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    this.AxisLabel = text;
                }
                else if (string.Compare(attributeName, "Tooltip", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    base.ToolTip = text;
                }
                else if (string.Compare(attributeName, "Href", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    base.Href = text;
                }
                else if (string.Compare(attributeName, "Label", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    this.Label = text;
                }
                else if (string.Compare(attributeName, "LegendTooltip", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    base.LegendToolTip = text;
                }
                else if (string.Compare(attributeName, "LegendText", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    base.LegendText = text;
                }
                else if (string.Compare(attributeName, "LabelToolTip", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    base.LabelToolTip = text;
                }
                else
                {
                    base[attributeName] = text;
                }
            }
        }
コード例 #7
0
        public static string FormatValue(Chart chart, object obj, double value, string format, ChartValueTypes valueType, ChartElementType elementType)
        {
            string text  = format;
            string text2 = "";

            if (chart != null && chart.FormatNumberHandler != null)
            {
                int elementId = 0;
                if (obj is DataPoint)
                {
                    elementId = ((DataPoint)obj).ElementId;
                }
                text2 = chart.FormatNumberHandler(obj, value, format, valueType, elementId, elementType);
                if (text2.Length > 0)
                {
                    return(text2);
                }
            }
            if (text != null && text.Length > 0)
            {
                int num = text.IndexOf('{', 0);
                if (num >= 0)
                {
                    while (num >= 0)
                    {
                        if (!text.Substring(num).StartsWith("{0:", StringComparison.Ordinal))
                        {
                            if (num >= 1 && text.Substring(num - 1, 1) == "{")
                            {
                                continue;
                            }
                            text = text.Insert(num + 1, "0:");
                        }
                        num = text.IndexOf('{', num + 1);
                    }
                }
                else
                {
                    text = "{0:" + text + "}";
                }
            }
            switch (valueType)
            {
            case ChartValueTypes.DateTime:
            case ChartValueTypes.Date:
            case ChartValueTypes.DateTimeOffset:
                if (text.Length == 0)
                {
                    text = "{0:d}";
                    if (valueType == ChartValueTypes.DateTimeOffset)
                    {
                        text += " +0";
                    }
                }
                text2 = string.Format(CultureInfo.CurrentCulture, text, DateTime.FromOADate(value));
                break;

            case ChartValueTypes.Time:
                if (text.Length == 0)
                {
                    text = "{0:t}";
                }
                text2 = string.Format(CultureInfo.CurrentCulture, text, DateTime.FromOADate(value));
                break;

            default:
            {
                bool flag = false;
                if (text.Length == 0)
                {
                    text = "{0:G}";
                }
                try
                {
                    text2 = string.Format(CultureInfo.CurrentCulture, text, value);
                }
                catch (Exception)
                {
                    flag = true;
                }
                if (flag)
                {
                    flag = false;
                    try
                    {
                        text2 = string.Format(CultureInfo.CurrentCulture, text, (long)value);
                    }
                    catch (Exception)
                    {
                        flag = true;
                    }
                }
                if (!flag)
                {
                    break;
                }
                return(format);
            }
            }
            return(text2);
        }
コード例 #8
0
		public void Add(double labelsStep, DateTimeIntervalType intervalType, double min, double max, string format, int rowIndex, LabelMark mark)
		{
			if (min == 0.0 && max == 0.0 && axis != null && !double.IsNaN(axis.Minimum) && !double.IsNaN(axis.Maximum))
			{
				min = axis.Minimum;
				max = axis.Maximum;
			}
			double num = Math.Min(min, max);
			double num2 = Math.Max(min, max);
			double num3 = num;
			double num4 = 0.0;
			while (num3 < num2)
			{
				switch (intervalType)
				{
				case DateTimeIntervalType.Number:
					num4 = num3 + labelsStep;
					break;
				case DateTimeIntervalType.Milliseconds:
					num4 = DateTime.FromOADate(num3).AddMilliseconds(labelsStep).ToOADate();
					break;
				case DateTimeIntervalType.Seconds:
					num4 = DateTime.FromOADate(num3).AddSeconds(labelsStep).ToOADate();
					break;
				case DateTimeIntervalType.Minutes:
					num4 = DateTime.FromOADate(num3).AddMinutes(labelsStep).ToOADate();
					break;
				case DateTimeIntervalType.Hours:
					num4 = DateTime.FromOADate(num3).AddHours(labelsStep).ToOADate();
					break;
				case DateTimeIntervalType.Days:
					num4 = DateTime.FromOADate(num3).AddDays(labelsStep).ToOADate();
					break;
				case DateTimeIntervalType.Weeks:
					num4 = DateTime.FromOADate(num3).AddDays(7.0 * labelsStep).ToOADate();
					break;
				case DateTimeIntervalType.Months:
					num4 = DateTime.FromOADate(num3).AddMonths((int)labelsStep).ToOADate();
					break;
				case DateTimeIntervalType.Years:
					num4 = DateTime.FromOADate(num3).AddYears((int)labelsStep).ToOADate();
					break;
				default:
					throw new ArgumentException(SR.ExceptionAxisLabelsIntervalTypeUnsupported(intervalType.ToString()));
				}
				if (num4 > num2)
				{
					num4 = num2;
				}
				ChartValueTypes valueType = ChartValueTypes.Double;
				if (intervalType != DateTimeIntervalType.Number)
				{
					valueType = ((axis.GetAxisValuesType() != ChartValueTypes.DateTimeOffset) ? ChartValueTypes.DateTime : ChartValueTypes.DateTimeOffset);
				}
				string text = ValueConverter.FormatValue(axis.chart, axis, num3 + (num4 - num3) / 2.0, format, valueType, ChartElementType.AxisLabels);
				CustomLabel customLabel = new CustomLabel(num3, num4, text, rowIndex, mark);
				customLabel.axis = axis;
				array.Add(customLabel);
				num3 = num4;
			}
			Invalidate();
		}