Пример #1
0
        internal static void GetMinMaxValue(Series series, DataZoom dataZoom, int axisIndex, bool isValueAxis,
                                            bool inverse, bool yValue, out float minVaule, out float maxValue)
        {
            float min            = int.MaxValue;
            float max            = int.MinValue;
            var   isPercentStack = SeriesHelper.IsPercentStack(series, SerieType.Bar);

            if (!SeriesHelper.IsStack(series) || (isValueAxis && !yValue))
            {
                for (int i = 0; i < series.list.Count; i++)
                {
                    var serie = series.GetSerie(i);
                    if (serie.axisIndex != axisIndex)
                    {
                        continue;
                    }

                    if (series.IsActive(i))
                    {
                        if (isPercentStack && SeriesHelper.IsPercentStack(series, serie.name, SerieType.Bar))
                        {
                            if (100 > max)
                            {
                                max = 100;
                            }
                            if (0 < min)
                            {
                                min = 0;
                            }
                        }
                        else
                        {
                            var showData = serie.GetDataList(dataZoom);
                            foreach (var data in showData)
                            {
                                var currData = data.GetData(yValue ? 1 : 0, inverse);
                                if (currData > max)
                                {
                                    max = currData;
                                }
                                if (currData < min)
                                {
                                    min = currData;
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                SeriesHelper.GetStackSeries(series, ref _stackSeriesForMinMax);
                foreach (var ss in _stackSeriesForMinMax)
                {
                    _serieTotalValueForMinMax.Clear();
                    for (int i = 0; i < ss.Value.Count; i++)
                    {
                        var serie = ss.Value[i];
                        if (serie.axisIndex != axisIndex || !series.IsActive(i))
                        {
                            continue;
                        }
                        var showData = serie.GetDataList(dataZoom);
                        if (SeriesHelper.IsPercentStack(series, serie.stack, SerieType.Bar))
                        {
                            for (int j = 0; j < showData.Count; j++)
                            {
                                _serieTotalValueForMinMax[j] = 100;
                            }
                        }
                        else
                        {
                            for (int j = 0; j < showData.Count; j++)
                            {
                                if (!_serieTotalValueForMinMax.ContainsKey(j))
                                {
                                    _serieTotalValueForMinMax[j] = 0;
                                }
                                var currData = (yValue ? showData[j].GetData(1) : showData[j].GetData(0));
                                if (inverse)
                                {
                                    currData = -currData;
                                }
                                _serieTotalValueForMinMax[j] = _serieTotalValueForMinMax[j] + currData;
                            }
                        }
                    }
                    float tmax = int.MinValue;
                    float tmin = int.MaxValue;
                    foreach (var tt in _serieTotalValueForMinMax)
                    {
                        if (tt.Value > tmax)
                        {
                            tmax = tt.Value;
                        }
                        if (tt.Value < tmin)
                        {
                            tmin = tt.Value;
                        }
                    }
                    if (tmax > max)
                    {
                        max = tmax;
                    }
                    if (tmin < min)
                    {
                        min = tmin;
                    }
                }
            }
            if (max == int.MinValue && min == int.MaxValue)
            {
                minVaule = 0;
                maxValue = 0;
            }
            else
            {
                minVaule = min > 1 ? Mathf.FloorToInt(min) : min;
                maxValue = max > 1 ? Mathf.CeilToInt(max) : max;
            }
        }
Пример #2
0
        public static void GetMinMaxValue(Series series, DataZoom dataZoom, int axisIndex, bool isValueAxis,
                                          bool inverse, bool yValue, out double minVaule, out double maxValue, bool isPolar = false)
        {
            double min            = double.MaxValue;
            double max            = double.MinValue;
            var    isPercentStack = SeriesHelper.IsPercentStack(series, SerieType.Bar);

            if (!SeriesHelper.IsStack(series) || (isValueAxis && !yValue))
            {
                for (int i = 0; i < series.list.Count; i++)
                {
                    var serie = series.GetSerie(i);
                    if ((isPolar && serie.polarIndex != axisIndex) ||
                        (!isPolar && serie.yAxisIndex != axisIndex))
                    {
                        continue;
                    }
                    if (isPercentStack && SeriesHelper.IsPercentStack(series, serie.name, SerieType.Bar))
                    {
                        if (100 > max)
                        {
                            max = 100;
                        }
                        if (0 < min)
                        {
                            min = 0;
                        }
                    }
                    else
                    {
                        var showData = serie.GetDataList(dataZoom);
                        foreach (var data in showData)
                        {
                            if (serie.type == SerieType.Candlestick)
                            {
                                var dataMin = data.GetMinData(inverse);
                                var dataMax = data.GetMaxData(inverse);
                                if (dataMax > max)
                                {
                                    max = dataMax;
                                }
                                if (dataMin < min)
                                {
                                    min = dataMin;
                                }
                            }
                            else
                            {
                                var currData = data.GetData(yValue ? 1 : 0, inverse);
                                if (!serie.IsIgnoreValue(currData))
                                {
                                    if (currData > max)
                                    {
                                        max = currData;
                                    }
                                    if (currData < min)
                                    {
                                        min = currData;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                SeriesHelper.GetStackSeries(series, ref _stackSeriesForMinMax);
                foreach (var ss in _stackSeriesForMinMax)
                {
                    _serieTotalValueForMinMax.Clear();
                    for (int i = 0; i < ss.Value.Count; i++)
                    {
                        var serie = ss.Value[i];
                        if ((isPolar && serie.polarIndex != axisIndex) ||
                            (!isPolar && serie.yAxisIndex != axisIndex))
                        {
                            continue;
                        }
                        var showData = serie.GetDataList(dataZoom);
                        if (SeriesHelper.IsPercentStack(series, serie.stack, SerieType.Bar))
                        {
                            for (int j = 0; j < showData.Count; j++)
                            {
                                _serieTotalValueForMinMax[j] = 100;
                            }
                        }
                        else
                        {
                            for (int j = 0; j < showData.Count; j++)
                            {
                                if (!_serieTotalValueForMinMax.ContainsKey(j))
                                {
                                    _serieTotalValueForMinMax[j] = 0;
                                }
                                double currData = 0;
                                if (serie.type == SerieType.Candlestick)
                                {
                                    currData = showData[j].GetMaxData(false);
                                }
                                else
                                {
                                    currData = yValue ? showData[j].GetData(1) : showData[j].GetData(0);
                                }
                                if (inverse)
                                {
                                    currData = -currData;
                                }
                                if (!serie.IsIgnoreValue(currData))
                                {
                                    _serieTotalValueForMinMax[j] = _serieTotalValueForMinMax[j] + currData;
                                }
                            }
                        }
                    }
                    double tmax = double.MinValue;
                    double tmin = double.MaxValue;
                    foreach (var tt in _serieTotalValueForMinMax)
                    {
                        if (tt.Value > tmax)
                        {
                            tmax = tt.Value;
                        }
                        if (tt.Value < tmin)
                        {
                            tmin = tt.Value;
                        }
                    }
                    if (tmax > max)
                    {
                        max = tmax;
                    }
                    if (tmin < min)
                    {
                        min = tmin;
                    }
                }
            }
            if (max == double.MinValue && min == double.MaxValue)
            {
                minVaule = 0;
                maxValue = 0;
            }
            else
            {
                minVaule = min > 1 ? Math.Floor(min) : min;
                maxValue = max > 1 ? Math.Ceiling(max) : max;
            }
        }