Ejemplo n.º 1
0
 public SplineSegment(ChartPoint point1, ChartPoint point2, ChartPoint point3, ChartPoint point4, ChartSeriesBase series)
 {
 }
Ejemplo n.º 2
0
 public override void SetData(ChartPoint point1, ChartPoint point2, ChartPoint point3, ChartPoint point4)
 {
     XData  = point1.X;
     X1Data = point4.X;
     YData  = point1.Y;
     Y1Data = point4.Y;
     Point1 = point1;
     Point2 = point2;
     Point3 = point3;
     Point4 = point4;
     XRange = new DoubleRange(point1.X, point4.X);
     //WP-581 - YRange differ when using NaN
     YRange = GetYRange(point1.X, point1.Y, point2.X, point2.Y, point3.X, point3.Y, point4.X, point4.Y);
 }
Ejemplo n.º 3
0
 public SplineSegment(ChartPoint point1, ChartPoint point2, ChartPoint point3, ChartPoint point4, SplineSeries series)
 {
     base.Series    = series;
     customTemplate = series.CustomTemplate;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates the segments of ErrorBarSeries
        /// </summary>
        public override void CreateSegments()
        {
            var xValues = GetXValues();

            if (xValues != null)
            {
                var horSdvalue = GetSdErrorValue(xValues);
                var verSdvalue = GetSdErrorValue(YValues);

                double verticalErrorValue;

                if (Type == ErrorBarType.StandardErrors || Type == ErrorBarType.StandardDeviation)
                {
                    _horizontalErrorValue = horSdvalue[1];
                    verticalErrorValue    = verSdvalue[1];
                }
                else
                {
                    _horizontalErrorValue = HorizontalErrorValue;
                    verticalErrorValue    = VerticalErrorValue;
                }

                if (Segments.Count > this.DataCount)
                {
                    ClearUnUsedSegments(this.DataCount);
                }

                var dateTimeAxis = ActualXAxis as DateTimeAxis;

                if (dateTimeAxis != null && dateTimeAxis.IntervalType == DateTimeIntervalType.Auto)
                {
                    dateTimeAxis.ActualRangeChanged += ErrorBarSeries_ActualRangeChanged;
                }
                else if (dateTimeAxis != null && dateTimeAxis.IntervalType != DateTimeIntervalType.Auto)
                {
                    dateTimeAxis.ActualRangeChanged -= ErrorBarSeries_ActualRangeChanged;
                }

                for (var i = 0; i < this.DataCount; i++)
                {
                    switch (Type)
                    {
                    case ErrorBarType.Percentage:
                        if ((ActualXAxis is DateTimeAxis) || (ActualXAxis is CategoryAxis) || (ActualXAxis is DateTimeCategoryAxis))
                        {
                            _horizontalErrorValue = GetPercentageErrorBarValue(i + 1, HorizontalErrorValue);
                            verticalErrorValue    = GetPercentageErrorBarValue(YValues[i], VerticalErrorValue);
                        }
                        else
                        {
                            _horizontalErrorValue = GetPercentageErrorBarValue(xValues[i], HorizontalErrorValue);
                            verticalErrorValue    = GetPercentageErrorBarValue(YValues[i], VerticalErrorValue);
                        }

                        break;

                    case ErrorBarType.Custom:
                        _horizontalErrorValue = HorizontalCustomValues.Count > 0 ? HorizontalCustomValues[i] : 0;
                        verticalErrorValue    = VerticalCustomValues.Count > 0 ? VerticalCustomValues[i] : 0;
                        break;
                    }

                    ChartPoint leftPt;
                    ChartPoint rightPt;
                    ChartPoint topPt;
                    ChartPoint bottomPt;
                    if (Type == ErrorBarType.StandardDeviation)
                    {
                        if (HorizontalDirection == ErrorBarDirection.Plus)
                        {
                            leftPt  = new ChartPoint(horSdvalue[0], YValues[i]);
                            rightPt = new ChartPoint(GetPlusValue(horSdvalue[0], _horizontalErrorValue, true), YValues[i]);
                        }
                        else if (HorizontalDirection == ErrorBarDirection.Minus)
                        {
                            leftPt  = new ChartPoint(GetMinusValue(horSdvalue[0], _horizontalErrorValue, true), YValues[i]);
                            rightPt = new ChartPoint(horSdvalue[0], YValues[i]);
                        }
                        else
                        {
                            leftPt  = new ChartPoint(GetMinusValue(horSdvalue[0], _horizontalErrorValue, true), YValues[i]);
                            rightPt = new ChartPoint(GetPlusValue(horSdvalue[0], _horizontalErrorValue, true), YValues[i]);
                        }

                        if (VerticalDirection == ErrorBarDirection.Plus)
                        {
                            topPt    = new ChartPoint(xValues[i], verSdvalue[0]);
                            bottomPt = new ChartPoint(xValues[i], GetPlusValue(verSdvalue[0], verticalErrorValue, false));
                        }
                        else if (VerticalDirection == ErrorBarDirection.Minus)
                        {
                            topPt    = new ChartPoint(xValues[i], GetMinusValue(verSdvalue[0], verticalErrorValue, false));
                            bottomPt = new ChartPoint(xValues[i], verSdvalue[0]);
                        }
                        else
                        {
                            topPt    = new ChartPoint(xValues[i], GetMinusValue(verSdvalue[0], verticalErrorValue, false));
                            bottomPt = new ChartPoint(xValues[i], GetPlusValue(verSdvalue[0], verticalErrorValue, false));
                        }
                    }
                    else
                    {
                        if (HorizontalDirection == ErrorBarDirection.Plus)
                        {
                            leftPt  = new ChartPoint(xValues[i], YValues[i]);
                            rightPt = new ChartPoint(GetPlusValue(xValues[i], _horizontalErrorValue, true), YValues[i]);
                        }
                        else if (HorizontalDirection == ErrorBarDirection.Minus)
                        {
                            leftPt  = new ChartPoint(GetMinusValue(xValues[i], _horizontalErrorValue, true), YValues[i]);
                            rightPt = new ChartPoint(xValues[i], YValues[i]);
                        }
                        else
                        {
                            leftPt  = new ChartPoint(GetMinusValue(xValues[i], _horizontalErrorValue, true), YValues[i]);
                            rightPt = new ChartPoint(GetPlusValue(xValues[i], _horizontalErrorValue, true), YValues[i]);
                        }

                        if (VerticalDirection == ErrorBarDirection.Plus)
                        {
                            topPt    = new ChartPoint(xValues[i], YValues[i]);
                            bottomPt = new ChartPoint(xValues[i], GetPlusValue(YValues[i], verticalErrorValue, false));
                        }
                        else if (VerticalDirection == ErrorBarDirection.Minus)
                        {
                            topPt    = new ChartPoint(xValues[i], GetMinusValue(YValues[i], verticalErrorValue, false));
                            bottomPt = new ChartPoint(xValues[i], YValues[i]);
                        }
                        else
                        {
                            topPt    = new ChartPoint(xValues[i], GetMinusValue(YValues[i], verticalErrorValue, false));
                            bottomPt = new ChartPoint(xValues[i], GetPlusValue(YValues[i], verticalErrorValue, false));
                        }
                    }

                    if (i < Segments.Count)
                    {
                        (Segments[i]).SetData(leftPt, rightPt, topPt, bottomPt);
                    }
                    else
                    {
                        var errorBar = new ErrorBarSegment(leftPt, rightPt, topPt, bottomPt, this,
                                                           ActualData[i]);
                        errorBar.SetData(leftPt, rightPt, topPt, bottomPt);
                        Segments.Add(errorBar);
                    }
                }
            }
        }
Ejemplo n.º 5
0
 public StepLineSegment(ChartPoint point1, ChartPoint stepPoint, ChartPoint point2, StepLineSeries series)
 {
     customTemplate = series.CustomTemplate;
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Creates the segments of CandleSeries.
        /// </summary>
        public override void CreateSegments()
        {
            DoubleRange   sbsInfo = this.GetSideBySideInfo(this);
            double        center  = sbsInfo.Median;
            List <double> xValues = null;

            if (ActualXAxis is CategoryAxis && !(ActualXAxis as CategoryAxis).IsIndexed)
            {
                xValues = GroupedXValuesIndexes;
            }
            else
            {
                xValues = GetXValues();
            }
            IList <double> values = GetComparisionModeValues();

            if (xValues != null)
            {
                ClearUnUsedSegments(this.DataCount);

                if (AdornmentsInfo != null)
                {
                    if (AdornmentsInfo.AdornmentsPosition == AdornmentsPosition.TopAndBottom)
                    {
                        ClearUnUsedAdornments(this.DataCount * 4);
                    }
                    else
                    {
                        ClearUnUsedAdornments(this.DataCount * 2);
                    }
                }

                if (this.ActualXAxis is CategoryAxis && (!(this.ActualXAxis as CategoryAxis).IsIndexed))
                {
                    Segments.Clear();
                    Adornments.Clear();
                    for (int i = 0; i < xValues.Count; i++)
                    {
                        if (i < xValues.Count && GroupedSeriesYValues[0].Count > i)
                        {
                            double x1     = xValues[i] + sbsInfo.Start;
                            double x2     = xValues[i] + sbsInfo.End;
                            double y1     = GroupedSeriesYValues[2][i];
                            double y2     = GroupedSeriesYValues[3][i];
                            bool   isbull = false;
                            if (i == 0 || this.ComparisonMode == FinancialPrice.None)
                            {
                                isbull = GroupedSeriesYValues[3][i] > GroupedSeriesYValues[2][i];
                            }
                            else
                            {
                                isbull = values[i] >= values[i - 1];
                            }
                            ChartPoint cdpBottomLeft = new ChartPoint(x1, y1);
                            ChartPoint cdpRightTop   = new ChartPoint(x2, y2);

                            ChartPoint hipoint = new ChartPoint(xValues[i] + center, GroupedSeriesYValues[0][i]);
                            ChartPoint lopoint = new ChartPoint(xValues[i] + center, GroupedSeriesYValues[1][i]);
                            var        segment = new CandleSegment();
                            segment.Series        = this;
                            segment.BullFillColor = BullFillColor;
                            segment.BearFillColor = BearFillColor;
                            segment.Item          = ActualData[i];
                            segment.SetData(cdpBottomLeft, cdpRightTop, hipoint, lopoint, isbull);
                            segment.High  = GroupedSeriesYValues[0][i];
                            segment.Low   = GroupedSeriesYValues[1][i];
                            segment.Open  = GroupedSeriesYValues[2][i];
                            segment.Close = GroupedSeriesYValues[3][i];
                            Segments.Add(segment);

                            if (AdornmentsInfo != null)
                            {
                                AddAdornments(xValues[i], hipoint, lopoint, cdpBottomLeft, cdpBottomLeft, cdpRightTop, cdpRightTop, i, 0);
                            }
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < DataCount; i++)
                    {
                        double x1     = xValues[i] + sbsInfo.Start;
                        double x2     = xValues[i] + sbsInfo.End;
                        double y1     = OpenValues[i];
                        double y2     = CloseValues[i];
                        bool   isbull = false;
                        if (i == 0 || this.ComparisonMode == FinancialPrice.None)
                        {
                            isbull = CloseValues[i] > OpenValues[i];
                        }
                        else
                        {
                            isbull = values[i] >= values[i - 1];
                        }
                        ChartPoint cdpBottomLeft = new ChartPoint(x1, y1);
                        ChartPoint cdpRightTop   = new ChartPoint(x2, y2);

                        ChartPoint hipoint = new ChartPoint(xValues[i] + center, HighValues[i]);
                        ChartPoint lopoint = new ChartPoint(xValues[i] + center, LowValues[i]);

                        if (i < Segments.Count)
                        {
                            (Segments[i]).SetData(cdpBottomLeft, cdpRightTop, hipoint, lopoint, isbull);
                            (Segments[i] as CandleSegment).High  = HighValues[i];
                            (Segments[i] as CandleSegment).Low   = LowValues[i];
                            (Segments[i] as CandleSegment).Open  = OpenValues[i];
                            (Segments[i] as CandleSegment).Close = CloseValues[i];
                            Segments[i].Item = ActualData[i];
                        }
                        else
                        {
                            var segment = new CandleSegment();
                            segment.Series        = this;
                            segment.BullFillColor = BullFillColor;
                            segment.BearFillColor = BearFillColor;
                            segment.Item          = ActualData[i];
                            segment.SetData(cdpBottomLeft, cdpRightTop, hipoint, lopoint, isbull);
                            segment.High  = HighValues[i];
                            segment.Low   = LowValues[i];
                            segment.Open  = OpenValues[i];
                            segment.Close = CloseValues[i];
                            Segments.Add(segment);
                        }

                        if (AdornmentsInfo != null)
                        {
                            AddAdornments(xValues[i], hipoint, lopoint, cdpBottomLeft, cdpBottomLeft, cdpRightTop, cdpRightTop, i, 0);
                        }
                    }
                }

                if (ShowEmptyPoints)
                {
                    UpdateEmptyPointSegments(xValues, true);
                }
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Creates the segments of <see cref="FastRangeAreaBitmapSeries"/>.
        /// </summary>
        public override void CreateSegments()
        {
            ChartPoint point1;
            ChartPoint point2;
            ChartPoint point3;
            ChartPoint point4;

            ChartPoint?       crossPoint = null;
            List <ChartPoint> segPoints  = new List <ChartPoint>();

            List <double> xValues = null;

            if (ActualXAxis is CategoryAxis && !(ActualXAxis as CategoryAxis).IsIndexed)
            {
                xValues = GroupedXValuesIndexes;
            }
            else
            {
                xValues = GetXValues();
            }

            if (xValues != null)
            {
                bool isGrouping = this.ActualXAxis is CategoryAxis ? (this.ActualXAxis as CategoryAxis).IsIndexed : true;
                if (!isGrouping)
                {
                    Segments.Clear();
                    Adornments.Clear();
                    if (double.IsNaN(GroupedSeriesYValues[1][0]) || !double.IsNaN(GroupedSeriesYValues[0][0]))
                    {
                        segPoints.Add(new ChartPoint(xValues[0], GroupedSeriesYValues[1][0]));
                        segPoints.Add(new ChartPoint(xValues[0], GroupedSeriesYValues[0][0]));
                        var segment = new FastRangeAreaSegment(segPoints, false, this)
                        {
                            High = GroupedSeriesYValues[0][0],
                            Low  = GroupedSeriesYValues[1][0],
                            Item = ActualData[0]
                        };

                        AddSegment(segment, segPoints);
                    }

                    segPoints = new List <ChartPoint>();
                    int i;

                    for (i = 0; i < xValues.Count - 1; i++)
                    {
                        if (!double.IsNaN(GroupedSeriesYValues[1][i]) && !double.IsNaN(GroupedSeriesYValues[0][i]))
                        {
                            point1 = new ChartPoint(xValues[i], GroupedSeriesYValues[1][i]);
                            point3 = new ChartPoint(xValues[i], GroupedSeriesYValues[0][i]);

                            if (i == 0 || (i < xValues.Count - 1 && (double.IsNaN(GroupedSeriesYValues[1][i - 1]) || double.IsNaN(GroupedSeriesYValues[0][i - 1]))))
                            {
                                segPoints.Add(point1);
                                segPoints.Add(point3);
                            }

                            if (!double.IsNaN(GroupedSeriesYValues[1][i + 1]) && !double.IsNaN(GroupedSeriesYValues[0][i + 1]))
                            {
                                point2 = new ChartPoint(xValues[i + 1], GroupedSeriesYValues[1][i + 1]);
                                point4 = new ChartPoint(xValues[i + 1], GroupedSeriesYValues[0][i + 1]);

                                // UWP-8718 Use ChartMath.GetCrossPoint since it returns the ChartDataPoint withou rounding the values.
                                crossPoint = ChartMath.GetCrossPoint(point1, point2, point3, point4);

                                if (crossPoint != null)
                                {
                                    var crossPointValue = new ChartPoint(crossPoint.Value.X, crossPoint.Value.Y);
                                    segPoints.Add(crossPointValue);
                                    segPoints.Add(crossPointValue);
                                    var segment = new FastRangeAreaSegment(segPoints, (GroupedSeriesYValues[1][i] > GroupedSeriesYValues[0][i]), this)
                                    {
                                        High = GroupedSeriesYValues[0][i],
                                        Low  = GroupedSeriesYValues[1][i],
                                        Item = ActualData[i]
                                    };

                                    AddSegment(segment, segPoints);
                                    segPoints = new List <ChartPoint>();
                                    segPoints.Add(crossPointValue);
                                    segPoints.Add(crossPointValue);
                                }

                                segPoints.Add(point2);
                                segPoints.Add(point4);
                            }
                            else if (i != 0 && !double.IsNaN(GroupedSeriesYValues[1][i - 1]) && !double.IsNaN(GroupedSeriesYValues[0][i - 1]))
                            {
                                segPoints.Add(point1);
                                segPoints.Add(point3);
                            }
                        }
                        else
                        {
                            if (segPoints.Count > 0)
                            {
                                if (!double.IsNaN(GroupedSeriesYValues[1][i - 1]) && !double.IsNaN(GroupedSeriesYValues[0][i - 1]))
                                {
                                    var segment = new FastRangeAreaSegment(segPoints, false, this)
                                    {
                                        High = GroupedSeriesYValues[0][i - 1],
                                        Low  = GroupedSeriesYValues[1][i - 1],
                                        Item = ActualData[i - 1]
                                    };

                                    AddSegment(segment, segPoints);
                                }
                            }

                            segPoints = new List <ChartPoint>();
                        }
                    }

                    if (segPoints.Count > 0)
                    {
                        var segment = new FastRangeAreaSegment(segPoints, (GroupedSeriesYValues[1][i] > GroupedSeriesYValues[0][i]), this)
                        {
                            High = GroupedSeriesYValues[0][i],
                            Low  = GroupedSeriesYValues[1][i],
                            Item = ActualData[i]
                        };

                        AddSegment(segment, segPoints);
                    }
                    else if (i == xValues.Count - 1 && (double.IsNaN(GroupedSeriesYValues[1][i]) || double.IsNaN(GroupedSeriesYValues[0][i])))
                    {
                        segPoints.Add(new ChartPoint(xValues[i], GroupedSeriesYValues[1][i]));
                        segPoints.Add(new ChartPoint(xValues[i], GroupedSeriesYValues[0][i]));
                        var segment = new FastRangeAreaSegment(segPoints, false, this)
                        {
                            High = GroupedSeriesYValues[0][i],
                            Low  = GroupedSeriesYValues[1][i],
                            Item = ActualData[i]
                        };

                        AddSegment(segment, segPoints);
                    }

                    for (int j = 0; j < xValues.Count; j++)
                    {
                        if (AdornmentsInfo != null)
                        {
                            AddAdornments(xValues[j], 0, GroupedSeriesYValues[0][j], GroupedSeriesYValues[1][j], j);
                        }
                    }
                }
                else
                {
                    Segments.Clear();
                    if (AdornmentsInfo != null)
                    {
                        if (AdornmentsInfo.AdornmentsPosition == AdornmentsPosition.TopAndBottom)
                        {
                            ClearUnUsedAdornments(this.DataCount * 2);
                        }
                        else
                        {
                            ClearUnUsedAdornments(this.DataCount);
                        }
                    }

                    if (xValues != null)
                    {
                        if (double.IsNaN(LowValues[0]) || double.IsNaN(HighValues[0]))
                        {
                            segPoints.Add(new ChartPoint(xValues[0], LowValues[0]));
                            segPoints.Add(new ChartPoint(xValues[0], HighValues[0]));
                            var segment = new FastRangeAreaSegment(segPoints, false, this)
                            {
                                High = HighValues[0],
                                Low  = LowValues[0],
                                Item = ActualData[0]
                            };

                            AddSegment(segment, segPoints);
                        }

                        segPoints = new List <ChartPoint>();
                        int i;
                        for (i = 0; i < DataCount - 1; i++)
                        {
                            if (!double.IsNaN(LowValues[i]) && !double.IsNaN(HighValues[i]))
                            {
                                point1 = new ChartPoint(xValues[i], LowValues[i]);
                                point3 = new ChartPoint(xValues[i], HighValues[i]);

                                if (i == 0 || (i < DataCount - 1 && (double.IsNaN(LowValues[i - 1]) || double.IsNaN(HighValues[i - 1]))))
                                {
                                    segPoints.Add(point1);
                                    segPoints.Add(point3);
                                }

                                if (!double.IsNaN(LowValues[i + 1]) && !double.IsNaN(HighValues[i + 1]))
                                {
                                    point2 = new ChartPoint(xValues[i + 1], LowValues[i + 1]);
                                    point4 = new ChartPoint(xValues[i + 1], HighValues[i + 1]);

                                    // UWP-8718 Use ChartMath.GetCrossPoint since it returns the ChartDataPoint withou rounding the values.
                                    crossPoint = ChartMath.GetCrossPoint(point1, point2, point3, point4);

                                    if (crossPoint != null)
                                    {
                                        var crossPointValue = new ChartPoint(crossPoint.Value.X, crossPoint.Value.Y);
                                        segPoints.Add(crossPointValue);
                                        segPoints.Add(crossPointValue);
                                        var segment = new FastRangeAreaSegment(segPoints, (LowValues[i] > HighValues[i]), this)
                                        {
                                            High = HighValues[i],
                                            Low  = LowValues[i],
                                            Item = ActualData[i]
                                        };

                                        AddSegment(segment, segPoints);
                                        segPoints = new List <ChartPoint>();
                                        segPoints.Add(crossPointValue);
                                        segPoints.Add(crossPointValue);
                                    }

                                    segPoints.Add(point2);
                                    segPoints.Add(point4);
                                }
                            }
                            else
                            {
                                if (segPoints.Count > 0)
                                {
                                    if (!double.IsNaN(LowValues[i - 1]) && !double.IsNaN(HighValues[i - 1]))
                                    {
                                        var segment = new FastRangeAreaSegment(segPoints, false, this)
                                        {
                                            High = HighValues[i - 1],
                                            Low  = LowValues[i - 1],
                                            Item = ActualData[i - 1]
                                        };

                                        AddSegment(segment, segPoints);
                                    }
                                }

                                segPoints = new List <ChartPoint>();
                            }
                        }

                        if (segPoints.Count > 0)
                        {
                            var segment = new FastRangeAreaSegment(segPoints, (LowValues[i] > HighValues[i]), this)
                            {
                                High = HighValues[i],
                                Low  = LowValues[i],
                                Item = ActualData[i]
                            };

                            AddSegment(segment, segPoints);
                        }
                        else if (i == DataCount - 1 && (double.IsNaN(LowValues[i]) || double.IsNaN(HighValues[i])))
                        {
                            segPoints.Add(new ChartPoint(xValues[i], LowValues[i]));
                            segPoints.Add(new ChartPoint(xValues[i], HighValues[i]));
                            var segment = new FastRangeAreaSegment(segPoints, false, this)
                            {
                                High = HighValues[i],
                                Low  = LowValues[i],
                                Item = ActualData[i]
                            };

                            AddSegment(segment, segPoints);
                        }
                    }

                    for (int i = 0; i < xValues.Count; i++)
                    {
                        if (AdornmentsInfo != null)
                        {
                            AddAdornments(xValues[i], 0, HighValues[i], LowValues[i], i);
                        }
                    }
                }
            }

            // Updates the stroke rendering for empty points.
            if (Segments.Count > 1)
            {
                UpdateEmptyPointSegments();
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Creates the segments of FastHiLoOpenCloseBitmapSeries
        /// </summary>
        public override void CreateSegments()
        {
            List <double> xValues   = null;
            var           isGrouped = ActualXAxis is CategoryAxis && !(ActualXAxis as CategoryAxis).IsIndexed;

            if (isGrouped)
            {
                xValues = GroupedXValuesIndexes;
            }
            else
            {
                xValues = GetXValues();
            }

            if (xValues != null)
            {
                if (isGrouped)
                {
                    Segments.Clear();
                    Adornments.Clear();

                    if (Segment == null || Segments.Count == 0)
                    {
                        FastHiLoOpenCloseSegment segment = new FastHiLoOpenCloseSegment(xValues, GroupedSeriesYValues[0], GroupedSeriesYValues[1], GroupedSeriesYValues[2], GroupedSeriesYValues[3], this);
                        segment.Series = this;
                        segment.Item   = ActualData;
                        segment.SetData(xValues, GroupedSeriesYValues[0], GroupedSeriesYValues[1], GroupedSeriesYValues[2], GroupedSeriesYValues[3]);
                        Segment = segment;
                        this.Segments.Add(Segment);
                    }

                    DoubleRange sbsInfo  = this.GetSideBySideInfo(this);
                    double      median   = sbsInfo.Delta / 2;
                    double      center   = sbsInfo.Median;
                    double      Left     = sbsInfo.Start;
                    double      Right    = sbsInfo.End;
                    double      leftpos  = (this as ISegmentSpacing).CalculateSegmentSpacing(SegmentSpacing, Right, Left);
                    double      rightpos = (this as ISegmentSpacing).CalculateSegmentSpacing(SegmentSpacing, Left, Right);

                    if (SegmentSpacing > 0 && SegmentSpacing <= 1)
                    {
                        Left  = leftpos;
                        Right = rightpos;
                    }

                    for (int i = 0; i < xValues.Count; i++)
                    {
                        if (i < xValues.Count && GroupedSeriesYValues[0].Count > i)
                        {
                            ChartPoint highPt       = new ChartPoint(xValues[i] + center, GroupedSeriesYValues[0][i]);
                            ChartPoint lowPt        = new ChartPoint(xValues[i] + center, GroupedSeriesYValues[1][i]);
                            ChartPoint startOpenPt  = new ChartPoint(xValues[i] + Left, GroupedSeriesYValues[2][i]);
                            ChartPoint endOpenPt    = new ChartPoint(xValues[i] + center, GroupedSeriesYValues[2][i]);
                            ChartPoint startClosePt = new ChartPoint(xValues[i] + Right, GroupedSeriesYValues[3][i]);
                            ChartPoint endClosePt   = new ChartPoint(xValues[i] + center, GroupedSeriesYValues[3][i]);

                            if (AdornmentsInfo != null)
                            {
                                AddAdornments(xValues[i], highPt, lowPt, startOpenPt, endOpenPt, startClosePt, endClosePt, i, median);
                            }
                        }
                    }
                }
                else
                {
                    if (AdornmentsInfo != null)
                    {
                        if (AdornmentsInfo.AdornmentsPosition == AdornmentsPosition.TopAndBottom)
                        {
                            ClearUnUsedAdornments(this.DataCount * 4);
                        }
                        else
                        {
                            ClearUnUsedAdornments(this.DataCount * 2);
                        }
                    }

                    if (Segment == null || Segments.Count == 0)
                    {
                        FastHiLoOpenCloseSegment segment = new FastHiLoOpenCloseSegment(xValues, HighValues, LowValues, OpenValues, CloseValues, this);
                        segment.Series = this;
                        segment.Item   = ActualData;
                        segment.SetData(xValues, HighValues, LowValues, OpenValues, CloseValues);

                        Segment = segment;
                        this.Segments.Add(Segment);
                    }
                    else if (xValues != null)
                    {
                        (Segment as FastHiLoOpenCloseSegment).Item = ActualData;
                        (Segment as FastHiLoOpenCloseSegment).SetData(xValues, HighValues, LowValues, OpenValues, CloseValues);
                    }

                    if (AdornmentsInfo != null)
                    {
                        if (AdornmentsInfo.AdornmentsPosition == AdornmentsPosition.TopAndBottom)
                        {
                            ClearUnUsedAdornments(this.DataCount * 4);
                        }
                        else
                        {
                            ClearUnUsedAdornments(this.DataCount * 2);
                        }
                    }

                    DoubleRange sbsInfo  = this.GetSideBySideInfo(this);
                    double      median   = sbsInfo.Delta / 2;
                    double      center   = sbsInfo.Median;
                    double      Left     = sbsInfo.Start;
                    double      Right    = sbsInfo.End;
                    double      leftpos  = (this as ISegmentSpacing).CalculateSegmentSpacing(SegmentSpacing, Right, Left);
                    double      rightpos = (this as ISegmentSpacing).CalculateSegmentSpacing(SegmentSpacing, Left, Right);

                    if (SegmentSpacing > 0 && SegmentSpacing <= 1)
                    {
                        Left  = leftpos;
                        Right = rightpos;
                    }

                    for (int i = 0; i < this.DataCount; i++)
                    {
                        ChartPoint highPt       = new ChartPoint(xValues[i] + center, HighValues[i]);
                        ChartPoint lowPt        = new ChartPoint(xValues[i] + center, LowValues[i]);
                        ChartPoint startOpenPt  = new ChartPoint(xValues[i] + Left, OpenValues[i]);
                        ChartPoint endOpenPt    = new ChartPoint(xValues[i] + center, OpenValues[i]);
                        ChartPoint startClosePt = new ChartPoint(xValues[i] + Right, CloseValues[i]);
                        ChartPoint endClosePt   = new ChartPoint(xValues[i] + center, CloseValues[i]);

                        if (AdornmentsInfo != null)
                        {
                            AddAdornments(xValues[i], highPt, lowPt, startOpenPt, endOpenPt, startClosePt, endClosePt, i, median);
                        }
                    }
                }
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Creates the segments of HiLoOpenCloseSeries
        /// </summary>
        public override void CreateSegments()
        {
            List <double> xValues    = null;
            bool          isGrouping = this.ActualXAxis is CategoryAxis ? (this.ActualXAxis as CategoryAxis).IsIndexed : true;

            if (!isGrouping)
            {
                xValues = GroupedXValuesIndexes;
            }
            else
            {
                xValues = GetXValues();
            }
            IList <double> values = GetComparisionModeValues();
            bool           isBull = false;

            if (xValues != null)
            {
                DoubleRange sbsInfo  = this.GetSideBySideInfo(this);
                double      median   = sbsInfo.Delta / 2;
                double      center   = sbsInfo.Median;
                double      Left     = sbsInfo.Start;
                double      Right    = sbsInfo.End;
                double      leftpos  = (this as ISegmentSpacing).CalculateSegmentSpacing(SegmentSpacing, Right, Left);
                double      rightpos = (this as ISegmentSpacing).CalculateSegmentSpacing(SegmentSpacing, Left, Right);

                if (SegmentSpacing > 0 && SegmentSpacing <= 1)
                {
                    Left  = leftpos;
                    Right = rightpos;
                }

                if (!isGrouping)
                {
                    Segments.Clear();
                    Adornments.Clear();

                    for (int i = 0; i < xValues.Count; i++)
                    {
                        ChartPoint highPt       = new ChartPoint(xValues[i] + center, GroupedSeriesYValues[0][i]);
                        ChartPoint lowPt        = new ChartPoint(xValues[i] + center, GroupedSeriesYValues[1][i]);
                        ChartPoint startOpenPt  = new ChartPoint(xValues[i] + Left, GroupedSeriesYValues[2][i]);
                        ChartPoint endOpenPt    = new ChartPoint(xValues[i] + center, GroupedSeriesYValues[2][i]);
                        ChartPoint startClosePt = new ChartPoint(xValues[i] + Right, GroupedSeriesYValues[3][i]);
                        ChartPoint endClosePt   = new ChartPoint(xValues[i] + center, GroupedSeriesYValues[3][i]);
                        if (i == 0 || this.ComparisonMode == FinancialPrice.None)
                        {
                            isBull = GroupedSeriesYValues[2][i] < GroupedSeriesYValues[3][i];
                        }
                        else
                        {
                            isBull = values[i] >= values[i - 1];
                        }

                        HiLoOpenCloseSegment hiloOpenClose = new HiLoOpenCloseSegment(highPt, lowPt, startOpenPt, endOpenPt, startClosePt, endClosePt, isBull, this, ActualData[i]);
                        hiloOpenClose.SetData(highPt, lowPt, startOpenPt, endOpenPt, startClosePt, endClosePt, isBull);
                        hiloOpenClose.BullFillColor = BullFillColor;
                        hiloOpenClose.BearFillColor = BearFillColor;
                        hiloOpenClose.High          = GroupedSeriesYValues[0][i];
                        hiloOpenClose.Low           = GroupedSeriesYValues[1][i];
                        hiloOpenClose.Open          = GroupedSeriesYValues[2][i];
                        hiloOpenClose.Close         = GroupedSeriesYValues[3][i];
                        hiloOpenClose.Item          = ActualData[i];
                        Segments.Add(hiloOpenClose);
                        if (AdornmentsInfo != null)
                        {
                            AddAdornments(xValues[i], highPt, lowPt, startOpenPt, endOpenPt, startClosePt, endClosePt, i, median);
                        }
                    }
                }
                else
                {
                    if (Segments.Count > this.DataCount)
                    {
                        ClearUnUsedSegments(this.DataCount);
                    }

                    if (AdornmentsInfo != null)
                    {
                        if (AdornmentsInfo.AdornmentsPosition == AdornmentsPosition.TopAndBottom)
                        {
                            ClearUnUsedAdornments(this.DataCount * 4);
                        }
                        else
                        {
                            ClearUnUsedAdornments(this.DataCount * 2);
                        }
                    }

                    for (int i = 0; i < this.DataCount; i++)
                    {
                        ChartPoint highPt       = new ChartPoint(xValues[i] + center, HighValues[i]);
                        ChartPoint lowPt        = new ChartPoint(xValues[i] + center, LowValues[i]);
                        ChartPoint startOpenPt  = new ChartPoint(xValues[i] + Left, OpenValues[i]);
                        ChartPoint endOpenPt    = new ChartPoint(xValues[i] + center, OpenValues[i]);
                        ChartPoint startClosePt = new ChartPoint(xValues[i] + Right, CloseValues[i]);
                        ChartPoint endClosePt   = new ChartPoint(xValues[i] + center, CloseValues[i]);

                        if (i == 0 || this.ComparisonMode == FinancialPrice.None)
                        {
                            isBull = OpenValues[i] < CloseValues[i];
                        }
                        else
                        {
                            isBull = values[i] >= values[i - 1];
                        }

                        if (i < Segments.Count)
                        {
                            Segments[i].Item = ActualData[i];
                            (Segments[i]).SetData(highPt, lowPt, startOpenPt, endOpenPt, startClosePt, endClosePt, isBull);
                            (Segments[i] as HiLoOpenCloseSegment).High  = HighValues[i];
                            (Segments[i] as HiLoOpenCloseSegment).Low   = LowValues[i];
                            (Segments[i] as HiLoOpenCloseSegment).Open  = OpenValues[i];
                            (Segments[i] as HiLoOpenCloseSegment).Close = CloseValues[i];
                        }
                        else
                        {
                            HiLoOpenCloseSegment hiloOpenClose = new HiLoOpenCloseSegment(highPt, lowPt, startOpenPt, endOpenPt, startClosePt, endClosePt, isBull, this, ActualData[i]);
                            hiloOpenClose.SetData(highPt, lowPt, startOpenPt, endOpenPt, startClosePt, endClosePt, isBull);
                            hiloOpenClose.BullFillColor = BullFillColor;
                            hiloOpenClose.BearFillColor = BearFillColor;
                            hiloOpenClose.High          = HighValues[i];
                            hiloOpenClose.Low           = LowValues[i];
                            hiloOpenClose.Open          = OpenValues[i];
                            hiloOpenClose.Close         = CloseValues[i];
                            hiloOpenClose.Item          = ActualData[i];
                            Segments.Add(hiloOpenClose);
                        }

                        if (AdornmentsInfo != null)
                        {
                            AddAdornments(xValues[i], highPt, lowPt, startOpenPt, endOpenPt, startClosePt, endClosePt, i, median);
                        }
                    }
                }

                if (ShowEmptyPoints)
                {
                    UpdateEmptyPointSegments(xValues, true);
                }
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Creates the segments of StepLineSeries.
        /// </summary>
        public override void CreateSegments()
        {
            List <double> xValues    = null;
            bool          isGrouping = this.ActualXAxis is CategoryAxis && !(this.ActualXAxis as CategoryAxis).IsIndexed;

            if (isGrouping)
            {
                xValues = GroupedXValuesIndexes;
            }
            else
            {
                xValues = GetXValues();
            }
            if (xValues == null)
            {
                return;
            }
            double xOffset = 0d;

            if (ActualXAxis is CategoryAxis &&
                (ActualXAxis as CategoryAxis).LabelPlacement == LabelPlacement.BetweenTicks)
            {
                xOffset = 0.5d;
            }

            if (isGrouping)
            {
                Segments.Clear();
                Adornments.Clear();

                for (int i = 0; i < xValues.Count; i++)
                {
                    int        index = i + 1;
                    ChartPoint point1, point2, stepPoint;

                    if (AdornmentsInfo != null)
                    {
                        Adornments.Add(this.CreateAdornment(this, xValues[i], GroupedSeriesYValues[0][i], xValues[i], GroupedSeriesYValues[0][i]));
                        Adornments[i].Item = ActualData[i];
                    }

                    if (index < xValues.Count)
                    {
                        point1    = new ChartPoint(xValues[i] - xOffset, GroupedSeriesYValues[0][i]);
                        point2    = new ChartPoint(xValues[index] - xOffset, GroupedSeriesYValues[0][i]);
                        stepPoint = new ChartPoint(xValues[index] - xOffset, GroupedSeriesYValues[0][index]);
                    }
                    else
                    {
                        if (!(xOffset > 0))
                        {
                            continue;
                        }
                        point1    = new ChartPoint(xValues[i] - xOffset, GroupedSeriesYValues[0][i]);
                        point2    = new ChartPoint(xValues[i] + xOffset, GroupedSeriesYValues[0][i]);
                        stepPoint = new ChartPoint(xValues[i] - xOffset, GroupedSeriesYValues[0][i]);
                    }

                    var segment = new StepLineSegment(point1, stepPoint, point2, this)
                    {
                        Item = ActualData[i]
                    };

                    segment.Series = this;
                    List <ChartPoint> listPoints = new List <ChartPoint>();
                    listPoints.Add(point1);
                    listPoints.Add(stepPoint);
                    listPoints.Add(point2);
                    segment.SetData(listPoints);
                    Segments.Add(segment);
                    listPoints = null;
                }
            }
            else
            {
                ClearUnUsedStepLineSegment(DataCount);
                ClearUnUsedAdornments(DataCount);
                for (int i = 0; i < DataCount; i++)
                {
                    int        index = i + 1;
                    ChartPoint point1, point2, stepPoint;

                    if (AdornmentsInfo != null)
                    {
                        if (i < Adornments.Count)
                        {
                            Adornments[i].SetData(xValues[i], YValues[i], xValues[i], YValues[i]);
                            Adornments[i].Item = ActualData[i];
                        }
                        else
                        {
                            Adornments.Add(this.CreateAdornment(this, xValues[i], YValues[i], xValues[i], YValues[i]));
                            Adornments[i].Item = ActualData[i];
                        }
                    }

                    if (index < DataCount)
                    {
                        point1    = new ChartPoint(xValues[i] - xOffset, YValues[i]);
                        point2    = new ChartPoint(xValues[index] - xOffset, YValues[i]);
                        stepPoint = new ChartPoint(xValues[index] - xOffset, YValues[index]);
                    }
                    else
                    {
                        if (!(xOffset > 0))
                        {
                            continue;
                        }
                        point1    = new ChartPoint(xValues[i] - xOffset, YValues[i]);
                        point2    = new ChartPoint(xValues[i] + xOffset, YValues[i]);
                        stepPoint = new ChartPoint(xValues[i] - xOffset, YValues[i]);
                    }

                    if (i < Segments.Count)
                    {
                        Segments[i].SetData(new List <ChartPoint> {
                            point1, stepPoint, point2
                        });
                        Segments[i].Item = ActualData[i];
                        (Segments[i] as StepLineSegment).YData = YValues[i];
                        if (SegmentColorPath != null && !Segments[i].IsEmptySegmentInterior && ColorValues.Count > 0 && !Segments[i].IsSelectedSegment)
                        {
                            Segments[i].Interior = (Interior != null) ? Interior : ColorValues[i];
                        }
                    }
                    else
                    {
                        var segment = new StepLineSegment(point1, stepPoint, point2, this)
                        {
                            Item = ActualData[i]
                        };
                        segment.Series = this;
                        List <ChartPoint> listPoints = new List <ChartPoint>();
                        listPoints.Add(point1);
                        listPoints.Add(stepPoint);
                        listPoints.Add(point2);
                        segment.SetData(listPoints);
                        Segments.Add(segment);
                        listPoints = null;
                    }
                }
            }

            if (ShowEmptyPoints)
            {
                UpdateEmptyPointSegments(xValues, false);
            }
        }