Ejemplo n.º 1
0
        protected void RefreshMaxAndMinValue <TDataType>(OverLapWrapBuffer <TDataType> datas, int seriesIndex, int samplesAdded, bool removedDataInsideRange)
        {
            int newDataStartIndex = datas.Count - samplesAdded;
            IList <TDataType> newDatas = datas.GetRange(newDataStartIndex, samplesAdded);
            double            newDataMax, newDataMin;

            ParallelHandler.GetMaxAndMin(newDatas, out newDataMax, out newDataMin);
            // 如果删除的点没有超过范围,则这些点不会影响最终Y轴的最大最小值
            if (removedDataInsideRange)
            {
                // 如果Y轴新的最大值超过原来最大值,则新的最大值最大;如果Y轴新的最小值小于原来最小值,则新的最小值最小
                if (newDataMax >= _maxYValues[seriesIndex])
                {
                    _maxYValues[seriesIndex] = newDataMax;
                }
                if (newDataMin <= _minYValues[seriesIndex])
                {
                    _minYValues[seriesIndex] = newDataMin;
                }
            }
            // 如果新添加的数据Y值范围覆盖到原来的范围,则新的数据的范围就是最终的Y轴范围
            else if (newDataMax >= _maxYValues[seriesIndex] && newDataMin <= _minYValues[seriesIndex])
            {
                _maxYValues[seriesIndex] = newDataMax;
                _minYValues[seriesIndex] = newDataMin;
            }
            else
            {
                double max, min;
                ParallelHandler.GetMaxAndMin(datas, out max, out min);
                _maxYValues[seriesIndex] = max;
                _minYValues[seriesIndex] = min;
            }
        }
Ejemplo n.º 2
0
        protected bool IsRemovedDataInsideRange <TDataType>(OverLapWrapBuffer <TDataType> data, int samplesToAdd, int seriesIndex)
        {
            double lastMax         = _maxYValues[seriesIndex];
            double lastMin         = _minYValues[seriesIndex];
            int    samplesToRemove = SamplesInChart + samplesToAdd - DataInfo.Capacity;

            if (samplesToRemove <= 0)
            {
                return(true);
            }
            IList <TDataType> removedDatas = data.GetRange(0, samplesToRemove);
            double            dataMax, dataMin;

            ParallelHandler.GetMaxAndMin(removedDatas, out dataMax, out dataMin);

            // 是否在区域内的判定规则:新的数值范围最大不能超过原来的范围MinDoubleValue
            bool isDataInsideRange = dataMax - lastMax < Constants.MinDoubleValue &&
                                     lastMin - dataMin < Constants.MinDoubleValue;
            // 是否在区域内的判定规则:新的范围的极值极性必须和原来的极值极性相同
            bool isBoundSamePolarity = !(lastMax <= 0 ^ dataMax <= 0) && !(lastMin >= 0 ^ dataMin >= 0);

            return(isDataInsideRange && isBoundSamePolarity);
        }