/// <summary> /// Creates the segments of FastLineSeries. /// </summary> public override void CreateSegments() { if (GroupedSeriesYValues != null && GroupedSeriesYValues[0].Contains(double.NaN)) { List <List <double> > yValList; List <List <double> > xValList; this.CreateEmptyPointSegments(GroupedSeriesYValues[0], out yValList, out xValList); } else if (YValues.Contains(double.NaN)) { List <List <double> > yValList; List <List <double> > xValList; this.CreateEmptyPointSegments(YValues, out yValList, out xValList); } else { bool isGrouping = this.ActualXAxis is CategoryAxis ? (this.ActualXAxis as CategoryAxis).IsIndexed : true; if (!isGrouping) { xValues = GroupedXValuesIndexes; } else { xValues = (ActualXValues is IList <double> && !IsIndexed) ? ActualXValues as IList <double> : GetXValues(); } if (!isGrouping) { Segments.Clear(); Adornments.Clear(); if (Segment == null || Segments.Count == 0) { FastLineSegment segment = new FastLineSegment(xValues, GroupedSeriesYValues[0], this); Segment = segment; Segments.Add(segment); } } else { ClearUnUsedAdornments(this.DataCount); if (Segment == null || Segments.Count == 0) { FastLineSegment segment = new FastLineSegment(xValues, YValues, this); Segment = segment; Segments.Add(segment); } else if (ActualXValues != null) { Segment.SetData(xValues, YValues); (Segment as FastLineSegment).SetRange(); Segment.Item = ActualData; } } isAdornmentPending = true; } }
/// <summary> /// Called when DataSource property changed /// </summary> /// <param name="oldValue">The Old Value</param> /// <param name="newValue">The New Value</param> protected override void OnDataSourceChanged(IEnumerable oldValue, IEnumerable newValue) { if (this.AdornmentsInfo != null) { Adornments.Clear(); this.AdornmentsInfo.UpdateElements(); } base.OnDataSourceChanged(oldValue, newValue); }
/// <summary> /// Creates the segment of PyramidSeries. /// </summary> public override void CreateSegments() { Adornments.Clear(); this.Segments.Clear(); int count = DataCount; List <double> xValues = GetXValues(); IList <double> toggledYValues = null; if (ToggledLegendIndex.Count > 0) { toggledYValues = GetYValues(); } else { toggledYValues = YValues; } double sumValues = 0; double gapRatio = this.GapRatio; ChartPyramidMode pyramidMode = this.PyramidMode; for (int i = 0; i < count; i++) { sumValues += Math.Max(0, Math.Abs(double.IsNaN(toggledYValues[i]) ? 0 : toggledYValues[i])); } double gapHeight = gapRatio / (count - 1); if (pyramidMode == ChartPyramidMode.Linear) { this.CalculateLinearSegments(sumValues, gapRatio, count, xValues); } else { this.CalculateSurfaceSegments(sumValues, count, gapHeight, xValues); } if (ShowEmptyPoints) { UpdateEmptyPointSegments(xValues, false); } if (ActualArea != null) { ActualArea.IsUpdateLegend = true; } }
/// <summary> /// Called when DataSource property changed /// </summary> /// <param name="oldValue"></param> /// <param name="newValue"></param> protected override void OnDataSourceChanged(System.Collections.IEnumerable oldValue, System.Collections.IEnumerable newValue) { if (AdornmentsInfo != null) { Adornments.Clear(); AdornmentsInfo.UpdateElements(); } base.OnDataSourceChanged(oldValue, newValue); var area = this.Area; if (area != null) { area.IsUpdateLegend = area.HasDataPointBasedLegend(); } }
/// <summary> /// Creates the segments of FunnelSeries. /// </summary> public override void CreateSegments() { Segments.Clear(); Adornments.Clear(); List <double> xValues = GetXValues(); double sumValues = 0d, gapRatio = this.GapRatio; int count = DataCount; int explodedIndex = this.ExplodeIndex; ChartFunnelMode funnelmode = this.FunnelMode; IList <double> toggledYValues = null; if (ToggledLegendIndex.Count > 0) { toggledYValues = GetYValues(); } else { toggledYValues = YValues; } for (int i = 0; i < count; i++) { sumValues += Math.Max(0, Math.Abs(double.IsNaN(toggledYValues[i]) ? 0 : toggledYValues[i])); } if (funnelmode == ChartFunnelMode.ValueIsHeight) { this.CalculateValueIsHeightSegments(toggledYValues, xValues, sumValues, gapRatio, count, explodedIndex); } else { this.CalculateValueIsWidthSegments(toggledYValues, xValues, sumValues, gapRatio, count, explodedIndex); } if (ShowEmptyPoints) { UpdateEmptyPointSegments(xValues, false); } if (ActualArea != null) { ActualArea.IsUpdateLegend = true; } }
/// <summary> /// Creates the segments of FastLineBitmapSeries. /// </summary> public override void CreateSegments() { var isGrouped = ActualXAxis is CategoryAxis && !(ActualXAxis as CategoryAxis).IsIndexed; if (isGrouped) { xValues = GroupedXValuesIndexes; } else { xValues = (ActualXValues is IList <double>) ? ActualXValues as IList <double> : GetXValues(); } if (isGrouped) { Segments.Clear(); Adornments.Clear(); if (Segment == null || Segments.Count == 0) { FastLineBitmapSegment segment = new FastLineBitmapSegment(xValues, GroupedSeriesYValues[0], this); Segment = segment; Segments.Add(segment); } } else { ClearUnUsedAdornments(this.DataCount); if (Segment == null || Segments.Count == 0) { FastLineBitmapSegment segment = new FastLineBitmapSegment(xValues, YValues, this); Segment = segment; Segments.Add(segment); } else if (ActualXValues != null) { Segment.SetData(xValues, YValues); (Segment as FastLineBitmapSegment).SetRange(); Segment.Item = ActualData; } } isAdornmentPending = true; }
/// <summary> /// Creates the segments of FastScatterBitmapSeries /// </summary> public override void CreateSegments() { bool isGrouping = this.ActualXAxis is CategoryAxis && !(this.ActualXAxis as CategoryAxis).IsIndexed; if (isGrouping) { xValues = GroupedXValuesIndexes; } else { xValues = GetXValues(); } if (isGrouping) { Segments.Clear(); Adornments.Clear(); if (Segments == null || Segments.Count == 0) { Segment = new FastScatterBitmapSegment(xValues, GroupedSeriesYValues[0], this); Segments.Add(Segment); } } else { ClearUnUsedAdornments(this.DataCount); if (Segments == null || Segments.Count == 0) { Segment = new FastScatterBitmapSegment(xValues, YValues, this); Segments.Add(Segment); } else if (ActualXValues != null) { Segment.SetData(xValues, YValues); (Segment as FastScatterBitmapSegment).SetRange(); Segment.Item = ActualData; } } isAdornmentsBending = true; }
/// <summary> /// Creates the segments of RangeColumn Series. /// </summary> public override void CreateSegments() { double x1, x2, y1, y2; 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) { DoubleRange sbsInfo = this.GetSideBySideInfo(this); if (isGrouping) { Segments.Clear(); Adornments.Clear(); for (int i = 0; i < this.DataCount; i++) { if (i < xValues.Count && GroupedSeriesYValues[0].Count > i) { x1 = xValues[i] + sbsInfo.Start; x2 = xValues[i] + sbsInfo.End; y1 = GroupedSeriesYValues[0][i]; y2 = IsMultipleYPathRequired ? GroupedSeriesYValues[1][i] : 0; RangeColumnSegment rangeColumn = new RangeColumnSegment(x1, y1, x2, y2, this, ActualData[i]); rangeColumn.High = GroupedSeriesYValues[0][i]; rangeColumn.Low = IsMultipleYPathRequired ? GroupedSeriesYValues[1][i] : 0; Segments.Add(rangeColumn); if (AdornmentsInfo != null) { AddAdornments(xValues[i], sbsInfo.Start + sbsInfo.Delta / 2, y1, y2, i); } } } } else { if (Segments.Count > this.DataCount) { ClearUnUsedSegments(this.DataCount); } if (AdornmentsInfo != null) { if (AdornmentsInfo.AdornmentsPosition == AdornmentsPosition.TopAndBottom) { ClearUnUsedAdornments(this.DataCount * 2); } else { ClearUnUsedAdornments(this.DataCount); } } for (int i = 0; i < this.DataCount; i++) { x1 = xValues[i] + sbsInfo.Start; x2 = xValues[i] + sbsInfo.End; y1 = HighValues[i]; y2 = IsMultipleYPathRequired ? LowValues[i] : 0; if (i < Segments.Count) { (Segments[i].Item) = ActualData[i]; (Segments[i]).SetData(x1, y1, x2, y2); (Segments[i] as RangeColumnSegment).High = y1; (Segments[i] as RangeColumnSegment).Low = y2; if (SegmentColorPath != null && !Segments[i].IsEmptySegmentInterior && ColorValues.Count > 0 && !Segments[i].IsSelectedSegment) { Segments[i].Interior = (Interior != null) ? Interior : ColorValues[i]; } } else { RangeColumnSegment rangeColumn = new RangeColumnSegment(x1, y1, x2, y2, this, ActualData[i]); rangeColumn.High = y1; rangeColumn.Low = y2; Segments.Add(rangeColumn); } if (AdornmentsInfo != null) { AddAdornments(xValues[i], sbsInfo.Start + sbsInfo.Delta / 2, y1, y2, i); } } } if (ShowEmptyPoints) { UpdateEmptyPointSegments(xValues, true); } } }
/// <summary> /// Creates the segments of FastStackingColumnBitmapSeries /// </summary> public override void CreateSegments() { var isGrouped = ActualXAxis is CategoryAxis && !(ActualXAxis as CategoryAxis).IsIndexed; if (isGrouped) { xValues = GroupedXValuesIndexes; } else { xValues = (ActualXValues is List <double>) ? ActualXValues as List <double> : GetXValues(); } IList <double> x1Values, x2Values, y1Values, y2Values; x1Values = new List <double>(); x2Values = new List <double>(); y1Values = new List <double>(); y2Values = new List <double>(); var stackingValues = GetCumulativeStackValues(this); if (stackingValues != null) { YRangeStartValues = stackingValues.StartValues; YRangeEndValues = stackingValues.EndValues; if (xValues != null) { DoubleRange sbsInfo = this.GetSideBySideInfo(this); if (isGrouped) { Segments.Clear(); Adornments.Clear(); int segmentCount = 0; for (int i = 0; i < DistinctValuesIndexes.Count; i++) { for (int j = 0; j < DistinctValuesIndexes[i].Count; j++) { if (j < xValues.Count) { x1Values.Add(i + sbsInfo.Start); x2Values.Add(i + sbsInfo.End); y1Values.Add(YRangeEndValues[segmentCount]); y2Values.Add(YRangeStartValues[segmentCount]); segmentCount++; } } } if (Segment != null && (IsActualTransposed && Segment is FastStackingColumnSegment) || (!IsActualTransposed && Segment is FastBarBitmapSegment)) { Segments.Clear(); } if (Segment == null || Segments.Count == 0) { if (this.IsActualTransposed) { Segment = new FastBarBitmapSegment(x1Values, y1Values, x2Values, y2Values, this); } else { Segment = new FastStackingColumnSegment(x1Values, y1Values, x2Values, y2Values, this); } Segment.SetData(x1Values, y1Values, x2Values, y2Values); this.Segments.Add(Segment); } if (AdornmentsInfo != null) { segmentCount = 0; for (int i = 0; i < DistinctValuesIndexes.Count; i++) { for (int j = 0; j < DistinctValuesIndexes[i].Count; j++) { int index = DistinctValuesIndexes[i][j]; if (this.AdornmentsInfo.AdornmentsPosition == AdornmentsPosition.Top) { AddColumnAdornments(i, GroupedSeriesYValues[0][index], x1Values[segmentCount], y1Values[segmentCount], segmentCount, sbsInfo.Delta / 2); } else if (this.AdornmentsInfo.AdornmentsPosition == AdornmentsPosition.Bottom) { AddColumnAdornments(i, GroupedSeriesYValues[0][index], x1Values[segmentCount], y2Values[segmentCount], segmentCount, sbsInfo.Delta / 2); } else { AddColumnAdornments(i, GroupedSeriesYValues[0][index], x1Values[segmentCount], y1Values[segmentCount] + (y2Values[segmentCount] - y1Values[segmentCount]) / 2, segmentCount, sbsInfo.Delta / 2); } segmentCount++; } } } } else { ClearUnUsedAdornments(this.DataCount); if (!this.IsIndexed) { for (int i = 0; i < this.DataCount; i++) { x1Values.Add(xValues[i] + sbsInfo.Start); x2Values.Add(xValues[i] + sbsInfo.End); y1Values.Add(YRangeEndValues[i]); y2Values.Add(YRangeStartValues[i]); } } else { for (int i = 0; i < this.DataCount; i++) { x1Values.Add(i + sbsInfo.Start); x2Values.Add(i + sbsInfo.End); y1Values.Add(YRangeEndValues[i]); y2Values.Add(YRangeStartValues[i]); } } if (Segment != null && (IsActualTransposed && Segment is FastStackingColumnSegment) || (!IsActualTransposed && Segment is FastBarBitmapSegment)) { Segments.Clear(); } if (Segment == null || Segments.Count == 0) { if (this.IsActualTransposed) { Segment = new FastBarBitmapSegment(x1Values, y1Values, x2Values, y2Values, this); } else { Segment = new FastStackingColumnSegment(x1Values, y1Values, x2Values, y2Values, this); } Segment.SetData(x1Values, y1Values, x2Values, y2Values); this.Segments.Add(Segment); } else if (xValues != null) { if (Segment is FastBarBitmapSegment) { (Segment as FastBarBitmapSegment).SetData(x1Values, y1Values, x2Values, y2Values); } else { (Segment as FastStackingColumnSegment).SetData(x1Values, y1Values, x2Values, y2Values); } } if (AdornmentsInfo != null) { for (int i = 0; i < this.DataCount; i++) { if (i < this.DataCount) { if (this.AdornmentsInfo.AdornmentsPosition == AdornmentsPosition.Top) { AddColumnAdornments(xValues[i], YValues[i], x1Values[i], y1Values[i], i, sbsInfo.Delta / 2); } else if (this.AdornmentsInfo.AdornmentsPosition == AdornmentsPosition.Bottom) { AddColumnAdornments(xValues[i], YValues[i], x1Values[i], y2Values[i], i, sbsInfo.Delta / 2); } else { AddColumnAdornments(xValues[i], YValues[i], x1Values[i], y1Values[i] + (y2Values[i] - y1Values[i]) / 2, i, sbsInfo.Delta / 2); } } } } } } } }
/// <summary> /// Creates the segments of ScatterSeries /// </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) { if (isGrouping) { Segments.Clear(); Adornments.Clear(); for (int i = 0; i < xValues.Count; i++) { if (i < GroupedSeriesYValues[0].Count) { ScatterSegment scatterSegment = new ScatterSegment(xValues[i], GroupedSeriesYValues[0][i], this); scatterSegment.Series = this; scatterSegment.SetData(xValues[i], GroupedSeriesYValues[0][i]); scatterSegment.YData = GroupedSeriesYValues[0][i]; scatterSegment.XData = xValues[i]; scatterSegment.Item = ActualData[i]; Segments.Add(scatterSegment); if (AdornmentsInfo != null) { AddAdornments(xValues[i], GroupedSeriesYValues[0][i], i); } } } } else { ClearUnUsedSegments(this.DataCount); ClearUnUsedAdornments(this.DataCount); for (int i = 0; i < this.DataCount; i++) { if (i < Segments.Count) { (Segments[i].Item) = ActualData[i]; (Segments[i]).SetData(xValues[i], YValues[i]); (Segments[i] as ScatterSegment).XData = xValues[i]; (Segments[i] as ScatterSegment).Item = ActualData[i]; if (SegmentColorPath != null && !Segments[i].IsEmptySegmentInterior && ColorValues.Count > 0 && !Segments[i].IsSelectedSegment) { Segments[i].Interior = (Interior != null) ? Interior : ColorValues[i]; } } else { ScatterSegment scatterSegment = new ScatterSegment(xValues[i], YValues[i], this); scatterSegment.Series = this; scatterSegment.SetData(xValues[i], YValues[i]); scatterSegment.YData = YValues[i]; scatterSegment.XData = xValues[i]; scatterSegment.Item = ActualData[i]; Segments.Add(scatterSegment); } if (AdornmentsInfo != null) { AddAdornments(xValues[i], YValues[i], i); } } } if (ShowEmptyPoints) { UpdateEmptyPointSegments(xValues, false); } } }
/// <summary> /// Creates the Segments of BubbleSeries /// </summary> public override void CreateSegments() { double maximumSize = 0d, segmentRadius = 0d; List <double> xValues = null; var isGrouped = (ActualXAxis is CategoryAxis && !(ActualXAxis as CategoryAxis).IsIndexed); if (isGrouped) { xValues = GroupedXValuesIndexes; } else { xValues = GetXValues(); } maximumSize = (from val in sizeValues select val).Max(); double minRadius = this.MinimumRadius; double maxradius = this.MaximumRadius; double radius = maxradius - minRadius; if (xValues != null) { if (isGrouped) { Segments.Clear(); Adornments.Clear(); for (int i = 0; i < xValues.Count; i++) { var relativeSize = radius * Math.Abs(sizeValues[i] / maximumSize); relativeSize = double.IsNaN(relativeSize) ? 0 : relativeSize; if (ShowZeroBubbles) { segmentRadius = minRadius + relativeSize; } else { segmentRadius = (sizeValues[i] != 0) ? (minRadius + relativeSize) : 0; } if (i < xValues.Count && GroupedSeriesYValues[0].Count > i) { BubbleSegment bubbleSegment = new BubbleSegment(xValues[i], GroupedSeriesYValues[0][i], segmentRadius, this); bubbleSegment.Series = this; bubbleSegment.Size = segmentRadius; bubbleSegment.SetData(xValues[i], GroupedSeriesYValues[0][i]); bubbleSegment.Item = ActualData[i]; bubbleSegment.Size = sizeValues[i]; Segments.Add(bubbleSegment); } if (AdornmentsInfo != null) { AddAdornmentAtXY(xValues[i], GroupedSeriesYValues[0][i], i); } } } else { ClearUnUsedSegments(this.DataCount); ClearUnUsedAdornments(this.DataCount); for (int i = 0; i < this.DataCount; i++) { var relativeSize = radius * Math.Abs(sizeValues[i] / maximumSize); relativeSize = double.IsNaN(relativeSize) ? 0 : relativeSize; if (ShowZeroBubbles) { segmentRadius = minRadius + relativeSize; } else { segmentRadius = (sizeValues[i] != 0) ? (minRadius + relativeSize) : 0; } if (i < Segments.Count) { (Segments[i]).SetData(xValues[i], YValues[i]); (Segments[i] as BubbleSegment).SegmentRadius = segmentRadius; (Segments[i] as BubbleSegment).Item = ActualData[i]; (Segments[i] as BubbleSegment).Size = sizeValues[i]; (Segments[i] as BubbleSegment).YData = YValues[i]; (Segments[i] as BubbleSegment).XData = xValues[i]; if (SegmentColorPath != null && !Segments[i].IsEmptySegmentInterior && ColorValues.Count > 0 && !Segments[i].IsSelectedSegment) { Segments[i].Interior = (Interior != null) ? Interior : ColorValues[i]; } } else { BubbleSegment bubbleSegment = new BubbleSegment(xValues[i], YValues[i], segmentRadius, this); bubbleSegment.Series = this; bubbleSegment.SetData(xValues[i], YValues[i]); bubbleSegment.Item = ActualData[i]; bubbleSegment.Size = sizeValues[i]; Segments.Add(bubbleSegment); } if (AdornmentsInfo != null) { AddAdornmentAtXY(xValues[i], YValues[i], i); } } } if (ShowEmptyPoints) { UpdateEmptyPointSegments(xValues, false); } } }
/// <summary> /// Creates the segments of StepAreaSeries. /// </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.Count == 0) { return; } double Origin = this.ActualXAxis.Origin; if (ActualXAxis != null && ActualXAxis.Origin == 0 && ActualYAxis is LogarithmicAxis && (ActualYAxis as LogarithmicAxis).Minimum != null) { Origin = (double)(ActualYAxis as LogarithmicAxis).Minimum; } double xOffset = 0d; if (ActualXAxis is CategoryAxis && (ActualXAxis as CategoryAxis).LabelPlacement == LabelPlacement.BetweenTicks) { xOffset = 0.5d; } if (isGrouping) { Segments.Clear(); Adornments.Clear(); var stepAreaPoints = new List <ChartPoint> { new ChartPoint((xValues[xValues.Count - 1] + xOffset), Origin), new ChartPoint(xValues[0] - xOffset, Origin) }; for (int i = 0; i < xValues.Count; i++) { stepAreaPoints.Add(new ChartPoint(xValues[i] - xOffset, GroupedSeriesYValues[0][i])); if (i != xValues.Count - 1) { stepAreaPoints.Add(new ChartPoint(xValues[i + 1] - xOffset, GroupedSeriesYValues[0][i])); } } if (xOffset > 0) { stepAreaPoints.Add(new ChartPoint((xValues[xValues.Count - 1]) + xOffset, GroupedSeriesYValues[0][xValues.Count - 1])); } if (Segments.Count == 0) { var segment = new StepAreaSegment(stepAreaPoints, this) { Series = this, Item = ActualData, XRange = DoubleRange.Empty, YRange = DoubleRange.Empty }; segment.SetData(stepAreaPoints); Segments.Add(segment); } if (AdornmentsInfo != null) { AddAreaAdornments(GroupedSeriesYValues[0]); } } else { ClearUnUsedAdornments(DataCount); var stepAreaPoints = new List <ChartPoint> { new ChartPoint((xValues[DataCount - 1] + xOffset), Origin), new ChartPoint(xValues[0] - xOffset, Origin) }; for (int i = 0; i < DataCount; i++) { stepAreaPoints.Add(new ChartPoint(xValues[i] - xOffset, YValues[i])); if (i != DataCount - 1) { stepAreaPoints.Add(new ChartPoint(xValues[i + 1] - xOffset, YValues[i])); } } if (xOffset > 0) { stepAreaPoints.Add(new ChartPoint((xValues[DataCount - 1]) + xOffset, YValues[DataCount - 1])); } if (Segments.Count == 0) { var segment = new StepAreaSegment(stepAreaPoints, this) { Series = this, Item = ActualData, XRange = DoubleRange.Empty, YRange = DoubleRange.Empty }; segment.SetData(stepAreaPoints); Segments.Add(segment); } else { Segments[0].Item = ActualData; Segments[0].SetData(stepAreaPoints); } if (AdornmentsInfo != null) { AddAreaAdornments(YValues); } } }
/// <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); } } }
public override void CreateSegments() { double[] highCoef = null; double[] lowCoef = null; List <ChartPoint> segmentPoints = new List <ChartPoint>(); List <ChartPoint> HighStartControlPoints = new List <ChartPoint>(); List <ChartPoint> HighEndControlPoints = new List <ChartPoint>(); List <ChartPoint> LowStartControlPoints = new List <ChartPoint>(); List <ChartPoint> LowEndControlPoints = 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) { var groupDataCount = xValues.Count; Segments.Clear(); Adornments.Clear(); if (SplineType == SplineType.Monotonic) { GetMonotonicSpline(xValues, GroupedSeriesYValues[0]); HighStartControlPoints = startControlPoints; HighEndControlPoints = endControlPoints; GetMonotonicSpline(xValues, GroupedSeriesYValues[1]); LowStartControlPoints = startControlPoints; LowEndControlPoints = endControlPoints; } else if (SplineType == SplineType.Cardinal) { GetCardinalSpline(xValues, GroupedSeriesYValues[0]); HighStartControlPoints = startControlPoints; HighEndControlPoints = endControlPoints; GetCardinalSpline(xValues, GroupedSeriesYValues[1]); LowStartControlPoints = startControlPoints; LowEndControlPoints = endControlPoints; } else { this.NaturalSpline(xValues, GroupedSeriesYValues[0], out highCoef); this.NaturalSpline(xValues, GroupedSeriesYValues[1], out lowCoef); } for (int i = 0; i < groupDataCount; i++) { if (!double.IsNaN(GroupedSeriesYValues[1][i]) && !double.IsNaN(GroupedSeriesYValues[0][i])) { if (i == 0 || (i < DataCount - 1 && (double.IsNaN(GroupedSeriesYValues[1][i - 1]) || double.IsNaN(GroupedSeriesYValues[0][i - 1])))) { ChartPoint highInitialPoint = new ChartPoint(xValues[i], GroupedSeriesYValues[1][i]); segmentPoints.Add(highInitialPoint); ChartPoint lowInitialPoint = new ChartPoint(xValues[i], GroupedSeriesYValues[0][i]); segmentPoints.Add(lowInitialPoint); } else { ChartPoint highStartPoint = new ChartPoint(xValues[i - 1], GroupedSeriesYValues[0][i - 1]); ChartPoint highEndPoint = new ChartPoint(xValues[i], GroupedSeriesYValues[0][i]); ChartPoint lowStartPoint = new ChartPoint(xValues[i - 1], GroupedSeriesYValues[1][i - 1]); ChartPoint lowEndPoint = new ChartPoint(xValues[i], GroupedSeriesYValues[1][i]); ChartPoint startControlPoint; ChartPoint endControlPoint; if (SplineType == SplineType.Monotonic) { segmentPoints.AddRange(new ChartPoint[] { HighStartControlPoints[i - 1], HighEndControlPoints[i - 1], highEndPoint }); segmentPoints.AddRange(new ChartPoint[] { lowStartPoint, LowStartControlPoints[i - 1], LowEndControlPoints[i - 1] }); } else if (SplineType == SplineType.Cardinal) { segmentPoints.AddRange(new ChartPoint[] { HighStartControlPoints[i - 1], HighEndControlPoints[i - 1], highEndPoint }); segmentPoints.AddRange(new ChartPoint[] { lowStartPoint, LowStartControlPoints[i - 1], LowEndControlPoints[i - 1] }); } else { GetBezierControlPoints(highStartPoint, highEndPoint, highCoef[i - 1], highCoef[i], out startControlPoint, out endControlPoint); segmentPoints.AddRange(new ChartPoint[] { startControlPoint, endControlPoint, highEndPoint }); GetBezierControlPoints(lowStartPoint, lowEndPoint, lowCoef[i - 1], lowCoef[i], out startControlPoint, out endControlPoint); segmentPoints.AddRange(new ChartPoint[] { lowStartPoint, startControlPoint, endControlPoint }); } } } else { if (segmentPoints.Count > 0) { ChartPoint endpoint = new ChartPoint(xValues[i - 1], GroupedSeriesYValues[1][i - 1]); segmentPoints.Add(endpoint); var Segment = new SplineRangeAreaSegment(segmentPoints, this); Segment.SetData(segmentPoints); Segments.Add(Segment); } segmentPoints = new List <ChartPoint>(); } } if (segmentPoints.Count > 0) { ChartPoint endpoint = new ChartPoint(xValues[groupDataCount - 1], GroupedSeriesYValues[1][groupDataCount - 1]); segmentPoints.Add(endpoint); var Segment = new SplineRangeAreaSegment(segmentPoints, this); Segment.SetData(segmentPoints); Segments.Add(Segment); } 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 (SplineType == SplineType.Monotonic) { GetMonotonicSpline(xValues, HighValues); HighStartControlPoints = startControlPoints; HighEndControlPoints = endControlPoints; GetMonotonicSpline(xValues, LowValues); LowStartControlPoints = startControlPoints; LowEndControlPoints = endControlPoints; } else if (SplineType == SplineType.Cardinal) { GetCardinalSpline(xValues, HighValues); HighStartControlPoints = startControlPoints; HighEndControlPoints = endControlPoints; GetCardinalSpline(xValues, LowValues); LowStartControlPoints = startControlPoints; LowEndControlPoints = endControlPoints; } else { this.NaturalSpline(xValues, HighValues, out highCoef); this.NaturalSpline(xValues, LowValues, out lowCoef); } for (int i = 0; i < DataCount; i++) { if (!double.IsNaN(LowValues[i]) && !double.IsNaN(HighValues[i])) { if (i == 0 || (i < DataCount - 1 && (double.IsNaN(LowValues[i - 1]) || double.IsNaN(HighValues[i - 1])))) { ChartPoint highInitialPoint = new ChartPoint(xValues[i], LowValues[i]); segmentPoints.Add(highInitialPoint); ChartPoint lowInitialPoint = new ChartPoint(xValues[i], HighValues[i]); segmentPoints.Add(lowInitialPoint); } else { ChartPoint highStartPoint = new ChartPoint(xValues[i - 1], HighValues[i - 1]); ChartPoint highEndPoint = new ChartPoint(xValues[i], HighValues[i]); ChartPoint lowStartPoint = new ChartPoint(xValues[i - 1], LowValues[i - 1]); ChartPoint lowEndPoint = new ChartPoint(xValues[i], LowValues[i]); ChartPoint startControlPoint; ChartPoint endControlPoint; if (SplineType == SplineType.Monotonic) { segmentPoints.AddRange(new ChartPoint[] { HighStartControlPoints[i - 1], HighEndControlPoints[i - 1], highEndPoint }); segmentPoints.AddRange(new ChartPoint[] { lowStartPoint, LowStartControlPoints[i - 1], LowEndControlPoints[i - 1] }); } else if (SplineType == SplineType.Cardinal) { segmentPoints.AddRange(new ChartPoint[] { HighStartControlPoints[i - 1], HighEndControlPoints[i - 1], highEndPoint }); segmentPoints.AddRange(new ChartPoint[] { lowStartPoint, LowStartControlPoints[i - 1], LowEndControlPoints[i - 1] }); } else { GetBezierControlPoints(highStartPoint, highEndPoint, highCoef[i - 1], highCoef[i], out startControlPoint, out endControlPoint); segmentPoints.AddRange(new ChartPoint[] { startControlPoint, endControlPoint, highEndPoint }); GetBezierControlPoints(lowStartPoint, lowEndPoint, lowCoef[i - 1], lowCoef[i], out startControlPoint, out endControlPoint); segmentPoints.AddRange(new ChartPoint[] { lowStartPoint, startControlPoint, endControlPoint }); } } } else { if (segmentPoints.Count > 0) { ChartPoint endpoint = new ChartPoint(xValues[i - 1], LowValues[i - 1]); segmentPoints.Add(endpoint); var Segment = new SplineRangeAreaSegment(segmentPoints, this); Segment.SetData(segmentPoints); Segments.Add(Segment); } segmentPoints = new List <ChartPoint>(); } } if (segmentPoints.Count > 0) { ChartPoint endpoint = new ChartPoint(xValues[DataCount - 1], LowValues[DataCount - 1]); segmentPoints.Add(endpoint); var Segment = new SplineRangeAreaSegment(segmentPoints, this); Segment.SetData(segmentPoints); Segments.Add(Segment); } for (int i = 0; i < xValues.Count; i++) { if (AdornmentsInfo != null) { AddAdornments(xValues[i], 0, HighValues[i], LowValues[i], i); } } } } }
/// <summary> /// Creates the segments of ColumnSeries. /// </summary> public override void CreateSegments() { List <double> xValues = null; bool isGrouping = this.ActualXAxis is CategoryAxis3D && !(this.ActualXAxis as CategoryAxis3D).IsIndexed; if (isGrouping) { xValues = this.GroupedXValuesIndexes; } else { xValues = this.GetXValues(); } var zValues = GetZValues(); var isZAxis = zValues != null && zValues.Count > 0; double median; if (xValues == null) { return; } var area3D = this.ActualArea as SfChart3D; var depthInfo = GetSegmentDepth(isZAxis ? area3D.ActualDepth : area3D.Depth); var sbsInfo = GetSideBySideInfo(this); DoubleRange zsbsInfo = DoubleRange.Empty; if (isZAxis) { zsbsInfo = this.GetZSideBySideInfo(this); } median = sbsInfo.Delta / 2; double z1, z2; double start = depthInfo.Start; double end = depthInfo.End; int segmentCount = 0; if (isGrouping && this.GroupedSeriesYValues[0] != null && GroupedSeriesYValues[0].Count > 0) { Segments.Clear(); Adornments.Clear(); GroupedActualData.Clear(); for (int i = 0; i < DistinctValuesIndexes.Count; i++) { var list = (from index in DistinctValuesIndexes[i] select new List <double> { GroupedSeriesYValues[0][index], index }).ToList(); double startValue = isZAxis ? zsbsInfo.Start : depthInfo.Start; var divider = zsbsInfo.Delta / list.Count; var segmentWidth = divider * 0.75; var segmentSpace = divider * 0.25; for (int j = 0; j < list.Count; j++) { var yValue = list[j][0]; var x1 = i + sbsInfo.Start; var x2 = i + sbsInfo.End; var y1 = yValue; var y2 = ActualXAxis != null ? ActualXAxis.Origin : 0; var actualStart = 0d; var actualEnd = 0d; GroupedActualData.Add(this.ActualData[(int)list[j][1]]); if (list.Count > 1) { if (isZAxis) { start = startValue; end = start + segmentWidth; startValue = end + segmentSpace; actualStart = start; actualEnd = end; start = zValues[i] + start; end = zValues[i] + end; } else { var count = list.Count; var space = depthInfo.End / ((count * 2) + count + 1); start = startValue + space; end = start + depthInfo.End / (count * 2); startValue = end; } } else { if (isZAxis) { actualStart = zsbsInfo.Start; actualEnd = zsbsInfo.End; start = zValues[i] + zsbsInfo.Start; end = zValues[i] + zsbsInfo.End; } else { start = depthInfo.Start; end = depthInfo.End; } } Segments.Add(new ColumnSegment3D(x1, y1, x2, y2, start, end, this) { XData = xValues[j], YData = yValue, Item = GroupedActualData[segmentCount] }); if (this.AdornmentsInfo == null) { continue; } double xAdornmentPosition = 0d; double zAdornmentPosition = 0d; xAdornmentPosition = this.GetXAdornmentAnglePosition(i, sbsInfo); if (isZAxis) { zAdornmentPosition = this.GetZAdornmentAnglePosition(zValues[i], new DoubleRange(actualStart, actualEnd)); } else { zAdornmentPosition = this.GetZAdornmentAnglePosition(start, end); } switch (AdornmentsInfo.AdornmentsPosition) { case AdornmentsPosition.Top: this.AddColumnAdornments(i, yValue, xAdornmentPosition, y1, segmentCount, median, zAdornmentPosition); break; case AdornmentsPosition.Bottom: this.AddColumnAdornments(i, yValue, xAdornmentPosition, y2, segmentCount, median, zAdornmentPosition); break; default: this.AddColumnAdornments(i, yValue, xAdornmentPosition, y1 + (y2 - y1) / 2, segmentCount, median, zAdornmentPosition); break; } segmentCount++; } } } else { this.ClearUnUsedSegments(this.DataCount); this.ClearUnUsedAdornments(this.DataCount); for (var i = 0; i < this.DataCount; i++) { if (i >= this.DataCount) { continue; } var x1 = xValues[i] + sbsInfo.Start; var x2 = xValues[i] + sbsInfo.End; var y1 = YValues[i]; var y2 = ActualXAxis != null ? ActualXAxis.Origin : 0; if (isZAxis) { z1 = zValues[i] + zsbsInfo.Start; z2 = zValues[i] + zsbsInfo.End; } else { z1 = depthInfo.Start; z2 = depthInfo.End; } if (i < Segments.Count) { (Segments[i]).SetData(x1, y1, x2, y2, z1, z2); ((ColumnSegment3D)Segments[i]).YData = this.YValues[i]; ((ColumnSegment3D)Segments[i]).Plans = null; ((ColumnSegment3D)Segments[i]).XData = xValues[i]; if (isZAxis) { ((ColumnSegment3D)Segments[i]).ZData = zValues[i]; } ((ColumnSegment3D)Segments[i]).Item = this.ActualData[i]; } else { Segments.Add(new ColumnSegment3D(x1, y1, x2, y2, z1, z2, this) { XData = xValues[i], YData = YValues[i], ZData = isZAxis ? zValues[i] : 0, Item = ActualData[i] }); } if (this.AdornmentsInfo == null) { continue; } double xAdornmentPosition = 0d; double zAdornmentPosition = 0d; xAdornmentPosition = this.GetXAdornmentAnglePosition(xValues[i], sbsInfo); if (isZAxis) { zAdornmentPosition = this.GetZAdornmentAnglePosition(zValues[i], zsbsInfo); } else { zAdornmentPosition = this.GetZAdornmentAnglePosition(start, end); } switch (AdornmentsInfo.AdornmentsPosition) { case AdornmentsPosition.Top: this.AddColumnAdornments(xValues[i], this.YValues[i], xAdornmentPosition, y1, i, median, zAdornmentPosition); break; case AdornmentsPosition.Bottom: this.AddColumnAdornments(xValues[i], this.YValues[i], xAdornmentPosition, y2, i, median, zAdornmentPosition); break; default: this.AddColumnAdornments(xValues[i], this.YValues[i], xAdornmentPosition, y1 + (y2 - y1) / 2, i, median, zAdornmentPosition); break; } } } if (this.ShowEmptyPoints) { this.UpdateEmptyPointSegments(xValues, true); } }
/// <summary> /// Creates the points. /// </summary> protected virtual void CreatePoints() { var seriesCount = GetCircularSeriesCount(); var pieIndex = GetPieSeriesIndex(); Segments.Clear(); // PieSeries3D is not rendered properly while removing data dynamically-WPF-17521 Adornments.Clear(); IList <double> toggledYValues = null; if (ToggledLegendIndex.Count > 0) { toggledYValues = this.GetYValues(); } else { toggledYValues = this.YValues; } if (Area.RootPanelDesiredSize != null) { this.actualWidth = Area.RootPanelDesiredSize.Value.Width; this.actualHeight = Area.RootPanelDesiredSize.Value.Height; } var all = toggledYValues.Select(item => Math.Abs(double.IsNaN(item) ? 0d : item)).Sum(); var count = toggledYValues.Count; if (this.InnerRadius == 0) { double actualRadius = Math.Min(this.actualWidth, this.actualHeight) / 2; double equalParts = actualRadius / seriesCount; this.Radius = (equalParts * (pieIndex + 1)) - (equalParts * (1 - this.InternalCircleCoefficient)); this.InnerRadius = equalParts * pieIndex; } var pieHeight = Area.Depth; if (this.ExplodeIndex >= 0 && this.ExplodeIndex < count || this.ExplodeAll) { this.Radius -= this.ExplodeRadius; } double arcStartAngle = StartAngle, arcEndAngle = EndAngle, diffAngle; diffAngle = arcEndAngle - arcStartAngle; if (Math.Abs(diffAngle) > 360) { diffAngle = diffAngle % 360; } int segindex = 0; for (var i = 0; i < count; i++) { if (!double.IsNaN(this.YValues[i])) { var val = Math.Abs(double.IsNaN(toggledYValues[i]) ? 0 : toggledYValues[i]); arcEndAngle = all == 0 ? 0 : (Math.Abs(val) * ((diffAngle) / all)); var rect = new Rect(0, 0, this.actualWidth, this.actualHeight); if (this.ExplodeIndex == i || this.ExplodeAll) { var offset = new Point( (float)(Math.Cos(Math.PI * (2 * arcStartAngle + arcEndAngle) / 360)), (float)(Math.Sin(Math.PI * (2 * arcStartAngle + arcEndAngle) / 360))); rect = rect.Offset( 0.01f * this.Radius * offset.X * this.ExplodeRadius, 0.01f * this.Radius * offset.Y * this.ExplodeRadius); } if (seriesCount == 1) { this.Center = this.GetActualCenter(new Point(rect.X + rect.Width / 2, rect.Y + rect.Height / 2), this.Radius); } else { this.Center = new Point(this.actualWidth / 2, this.actualHeight / 2); if (this.ExplodeAll || this.ExplodeIndex == i) { this.Center = new Point(rect.X + Center.X, rect.Y + Center.Y); } } var center = new Vector3D(Center.X, Center.Y, 0); if (segindex < Segments.Count) { Segments[segindex].SetData(arcStartAngle, arcStartAngle + arcEndAngle, pieHeight, this.Radius, val, center.X, center.Y, center.Z, this.InnerRadius); if (ToggledLegendIndex.Contains(i)) { Segments[segindex].IsSegmentVisible = false; } else { Segments[segindex].IsSegmentVisible = true; } } else { Segments.Add(new PieSegment3D(this, center, arcStartAngle, arcStartAngle + arcEndAngle, pieHeight, this.Radius, i, val, this.InnerRadius)); } if (this.AdornmentsInfo != null) { this.AddPieAdornments(segindex, toggledYValues[i], arcStartAngle, arcStartAngle + arcEndAngle, i, this.Radius, Area.IsChartRotated() ? Area.Depth + 5d : 0d); } segindex++; arcStartAngle += arcEndAngle; } } }
/// <summary> /// Creates the segments of PieSeries. /// </summary> public override void CreateSegments() { IList <double> toggledYValues = null; List <double> xValues = null; var actualData = ActualData; if (double.IsNaN(GroupTo)) { if (ToggledLegendIndex.Count > 0) { toggledYValues = GetYValues(); } else { toggledYValues = YValues; } xValues = GetXValues(); } else { if (Adornments != null) { Adornments.Clear(); } if (Segments != null) { Segments.Clear(); } var sumOfYValues = (from val in YValues select(val) > 0 ? val : Math.Abs(double.IsNaN(val) ? 0 : val)).Sum(); double xIndexValues = 0d; xValues = (from val in YValues where GetGroupModeValue(val, sumOfYValues) > GroupTo select(xIndexValues++)).ToList(); if (YValues.Count > xValues.Count) { xValues.Add(xIndexValues); } var groupToValues = GetGroupToYValues(); actualData = groupToValues.Item2; if (ToggledLegendIndex.Count > 0) { toggledYValues = GetToggleYValues(groupToValues.Item1); } else { toggledYValues = groupToValues.Item1; } } ClearUnUsedAdornments(this.DataCount); ClearUnUsedSegments(this.DataCount); int explodedIndex = ExplodeIndex; bool explodedAll = ExplodeAll; arcStartAngle = DegreeToRadianConverter(StartAngle); arcEndAngle = DegreeToRadianConverter(EndAngle); if (arcStartAngle == arcEndAngle) { Segments.Clear(); } ARCLENGTH = arcEndAngle - arcStartAngle; if (Math.Abs(Math.Round(ARCLENGTH, 2)) > TotalArcLength) { ARCLENGTH = ARCLENGTH % TotalArcLength; } if (xValues != null) { grandTotal = (from val in toggledYValues select(val) > 0 ? val : Math.Abs(double.IsNaN(val) ? 0 : val)).Sum(); for (int i = 0; i < xValues.Count; i++) { arcEndAngle = grandTotal == 0 ? 0 : (Math.Abs(double.IsNaN(toggledYValues[i]) ? 0 : toggledYValues[i]) * (ARCLENGTH / grandTotal)); if (i < Segments.Count) { (Segments[i] as PieSegment).SetData( arcStartAngle, arcStartAngle + arcEndAngle, this, actualData[i]); (Segments[i] as PieSegment).XData = xValues[i]; (Segments[i] as PieSegment).YData = !double.IsNaN(GroupTo) ? Math.Abs(toggledYValues[i]) : Math.Abs(YValues[i]); (Segments[i] as PieSegment).AngleOfSlice = (2 * arcStartAngle + arcEndAngle) / 2; (Segments[i] as PieSegment).IsExploded = explodedAll || (explodedIndex == i); (Segments[i] as PieSegment).Item = actualData[i]; if (SegmentColorPath != null && !Segments[i].IsEmptySegmentInterior && ColorValues.Count > 0 && !Segments[i].IsSelectedSegment) { Segments[i].Interior = (Interior != null) ? Interior : ColorValues[i]; } if (ToggledLegendIndex.Contains(i)) { Segments[i].IsSegmentVisible = false; } else { Segments[i].IsSegmentVisible = true; } } else { var segment = new PieSegment(arcStartAngle, arcStartAngle + arcEndAngle, this, actualData[i]); segment.SetData(arcStartAngle, arcStartAngle + arcEndAngle, this, actualData[i]); segment.XData = xValues[i]; segment.YData = !double.IsNaN(GroupTo) ? Math.Abs(toggledYValues[i]) : Math.Abs(YValues[i]); segment.AngleOfSlice = (2 * arcStartAngle + arcEndAngle) / 2; segment.IsExploded = explodedAll || explodedIndex == i; segment.Item = actualData[i]; if (ToggledLegendIndex.Contains(i)) { segment.IsSegmentVisible = false; } else { segment.IsSegmentVisible = true; } Segments.Add(segment); } if (AdornmentsInfo != null) { AddPieAdornments(xValues[i], toggledYValues[i], arcStartAngle, arcStartAngle + arcEndAngle, Segments.Count - 1, i, Segments[i] as PieSegment); } arcStartAngle += arcEndAngle; } if (ShowEmptyPoints) { UpdateEmptyPointSegments(xValues, false); } } }
/// <summary> /// Creates the segments of HiLoSeries. /// </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(); } if (xValues != null) { double center = this.GetSideBySideInfo(this).Median; if (!isGrouping) { Segments.Clear(); Adornments.Clear(); for (int i = 0; i < xValues.Count; i++) { if (i < xValues.Count && GroupedSeriesYValues[0].Count > i) { xValues[i] += center; HiLoSegment line = new HiLoSegment(xValues[i], GroupedSeriesYValues[0][i], GroupedSeriesYValues[1][i], this, ActualData[i]); line.High = GroupedSeriesYValues[0][i]; line.Low = GroupedSeriesYValues[1][i]; line.XValue = xValues[i]; Segments.Add(line); if (AdornmentsInfo != null) { AddAdornments(xValues[i], 0, GroupedSeriesYValues[0][i], GroupedSeriesYValues[1][i], i); } } } } else { if (Segments.Count > this.DataCount) { ClearUnUsedSegments(this.DataCount); } if (AdornmentsInfo != null) { if (AdornmentsInfo.AdornmentsPosition == AdornmentsPosition.TopAndBottom) { ClearUnUsedAdornments(this.DataCount * 2); } else { ClearUnUsedAdornments(this.DataCount); } } for (int i = 0; i < this.DataCount; i++) { if (i < Segments.Count) { xValues[i] += center; (Segments[i]).SetData(xValues[i], HighValues[i], LowValues[i]); (Segments[i]).Item = ActualData[i]; (Segments[i] as HiLoSegment).High = HighValues[i]; (Segments[i] as HiLoSegment).Low = LowValues[i]; } else { xValues[i] += center; HiLoSegment line = new HiLoSegment(xValues[i], HighValues[i], LowValues[i], this, ActualData[i]); line.High = HighValues[i]; line.Low = LowValues[i]; line.XValue = xValues[i]; Segments.Add(line); } if (AdornmentsInfo != null) { AddAdornments(xValues[i], 0, HighValues[i], LowValues[i], i); } } } if (ShowEmptyPoints) { UpdateEmptyPointSegments(xValues, true); } } }
/// <summary> /// Creates the segments of FastHiLoSeries. /// </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) { FastHiLoSegment segment = new FastHiLoSegment(xValues as IList <double>, GroupedSeriesYValues[0], GroupedSeriesYValues[1], this); segment.Series = this; segment.Item = ActualData; segment.SetData(xValues as IList <double>, GroupedSeriesYValues[0], GroupedSeriesYValues[1]); Segment = segment; this.Segments.Add(segment); } double center = this.GetSideBySideInfo(this).Median; for (int i = 0; i < xValues.Count; i++) { if (i < xValues.Count) { xValues[i] += center; if (AdornmentsInfo != null && GroupedSeriesYValues[0].Count > i) { AddAdornments(xValues[i], 0, GroupedSeriesYValues[0][i], GroupedSeriesYValues[1][i], i); } } } } else { if (AdornmentsInfo != null) { if (AdornmentsInfo.AdornmentsPosition == AdornmentsPosition.TopAndBottom) { ClearUnUsedAdornments(this.DataCount * 2); } else { ClearUnUsedAdornments(this.DataCount); } } if (Segment == null || Segments.Count == 0) { FastHiLoSegment segment = new FastHiLoSegment(xValues as IList <double>, HighValues, LowValues, this); segment.Series = this; segment.Item = ActualData; segment.SetData(xValues as IList <double>, HighValues, LowValues); Segment = segment; this.Segments.Add(segment); } else if (xValues != null) { (Segment as FastHiLoSegment).Item = this.ActualData; (Segment as FastHiLoSegment).SetData(xValues as IList <double>, HighValues, LowValues); } if (AdornmentsInfo != null) { if (AdornmentsInfo.AdornmentsPosition == AdornmentsPosition.TopAndBottom) { ClearUnUsedAdornments(this.DataCount * 2); } else { ClearUnUsedAdornments(this.DataCount); } } double center = this.GetSideBySideInfo(this).Median; for (int i = 0; i < this.DataCount; i++) { xValues[i] += center; if (AdornmentsInfo != null) { AddAdornments(xValues[i], 0, HighValues[i], LowValues[i], i); } } } } }
/// <summary> /// Creates the segments of AreaSeries. /// </summary> public override void CreateSegments() { List <double> yValues = new List <double>(); bool isGrouped = (ActualXAxis is CategoryAxis && !(ActualXAxis as CategoryAxis).IsIndexed); List <double> xValues = null; if (isGrouped) { xValues = GroupedXValuesIndexes; } else { xValues = GetXValues(); } yValues = YValues.ToList(); if (AdornmentsInfo != null) { ClearUnUsedAdornments(this.DataCount); } if (isGrouped) { if (xValues != null && xValues.Count > 1) { Segments.Clear(); Adornments.Clear(); if (Segment == null || Segments.Count == 0) { Segment = new AreaSegment(xValues, GroupedSeriesYValues[0] as List <double>, this, ActualData); Segment.SetData(xValues, GroupedSeriesYValues[0] as List <double>); Segments.Add(Segment); } } if (AdornmentsInfo != null) { AddAreaAdornments(GroupedSeriesYValues[0]); } } else { if (xValues != null && xValues.Count > 1) { if (Segment == null || Segments.Count == 0) { Segment = new AreaSegment(xValues, yValues, this, ActualData); Segment.SetData(xValues, yValues); Segments.Add(Segment); } else { Segment.Item = ActualData; Segment.SetData(xValues, yValues); } } if (AdornmentsInfo != null) { AddAreaAdornments(YValues); } } }
/// <summary> /// Creates the segments of LineSeries3D. /// </summary> public override void CreateSegments() { List <double> xValues = null; bool isGrouping = this.ActualXAxis is CategoryAxis3D && !(this.ActualXAxis as CategoryAxis3D).IsIndexed; if (isGrouping) { xValues = this.GroupedXValuesIndexes; } else { xValues = this.GetXValues(); } if (xValues == null) { return; } var depthInfo = GetSegmentDepth(this.Area.Depth); if (isGrouping) { Segments.Clear(); Adornments.Clear(); if (this.GroupedSeriesYValues != null && GroupedSeriesYValues[0].Contains(double.NaN)) { List <List <double> > yValList; List <List <double> > xValList; this.CreateEmptyPointSegments(this.GroupedSeriesYValues[0], out yValList, out xValList); } else if (xValues != null) { if (this.Segment == null || Segments.Count == 0) { this.Segment = new LineSegment3D(xValues, GroupedSeriesYValues[0], depthInfo.Start, depthInfo.End, this); this.Segment.SetData(xValues, this.GroupedSeriesYValues[0], depthInfo.Start, depthInfo.End); Segments.Add(this.Segment); } } for (var i = 0; i < xValues.Count; i++) { if (this.AdornmentsInfo != null) { this.AddAdornments(xValues[i], this.GroupedSeriesYValues[0][i], i, depthInfo.Start); } } } else { this.ClearUnUsedSegments(this.DataCount); this.ClearUnUsedAdornments(this.DataCount); if (YValues.Contains(double.NaN)) { List <List <double> > yValList; List <List <double> > xValList; this.CreateEmptyPointSegments(this.YValues, out yValList, out xValList); } else if (xValues != null) { if (this.Segment == null || Segments.Count == 0) { this.Segment = new LineSegment3D(xValues, YValues, depthInfo.Start, depthInfo.End, this); this.Segment.SetData(xValues, this.YValues, depthInfo.Start, depthInfo.End); Segments.Add(this.Segment); } else { this.Segment.SetData(xValues, this.YValues, depthInfo.Start, depthInfo.End); } } for (var i = 0; i < this.DataCount; i++) { if (this.AdornmentsInfo != null) { this.AddAdornments(xValues[i], this.YValues[i], i, depthInfo.Start); } } } }
/// <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(); } }
/// <summary> /// Creates the doughnut segments. /// </summary> public override void CreateSegments() { IList <double> toggledYValues = null; List <double> xValues = null; var actualData = ActualData; if (double.IsNaN(GroupTo)) { if (ToggledLegendIndex.Count > 0) { toggledYValues = GetYValues(); } else { toggledYValues = YValues; } xValues = GetXValues(); } else { if (Adornments != null) { Adornments.Clear(); } if (Segments != null) { Segments.Clear(); } var sumOfYValues = (from val in YValues select(val) > 0 ? val : Math.Abs(double.IsNaN(val) ? 0 : val)).Sum(); double xIndexValues = 0d; xValues = (from val in YValues where GetGroupModeValue(val, sumOfYValues) > GroupTo select(xIndexValues++)).ToList(); if (YValues.Count > xValues.Count) { xValues.Add(xIndexValues); } var groupToValues = GetGroupToYValues(); actualData = groupToValues.Item2; if (ToggledLegendIndex.Count > 0) { toggledYValues = GetToggleYValues(groupToValues.Item1); } else { toggledYValues = groupToValues.Item1; } } double arcEndAngle = DegreeToRadianConverter(EndAngle), arcStartAngle = DegreeToRadianConverter(StartAngle); if (arcStartAngle == arcEndAngle) { Segments.Clear(); } ARCLENGTH = arcEndAngle - arcStartAngle; if (Math.Abs(Math.Round(ARCLENGTH, 2)) > TotalArcLength) { ARCLENGTH = ARCLENGTH % TotalArcLength; } ClearUnUsedAdornments(this.DataCount); ClearUnUsedSegments(this.DataCount); int explodedIndex = ExplodeIndex; bool explodedAll = ExplodeAll; if (xValues != null) { var grandTotal = (from val in toggledYValues select(val) > 0 ? val : Math.Abs(double.IsNaN(val) ? 0 : val)).Sum(); var isMultipleDoughnut = !double.IsNaN(MaximumValue) && IsStackedDoughnut && GetDoughnutSeriesCount() == 1; bool isEndValueExceed = false; var visibleSegmentCount = 0; for (int i = 0; i < xValues.Count; i++) { isEndValueExceed = false; if (isMultipleDoughnut) { isEndValueExceed = (toggledYValues[i] >= MaximumValue); arcEndAngle = grandTotal == 0 ? 0 : (Math.Abs(double.IsNaN(toggledYValues[i]) ? 0 : isEndValueExceed ? MaximumValue : toggledYValues[i]) * (ARCLENGTH / MaximumValue)); } else { arcEndAngle = grandTotal == 0 ? 0 : (Math.Abs(double.IsNaN(toggledYValues[i]) ? 0 : toggledYValues[i]) * (ARCLENGTH / grandTotal)); } if (i < Segments.Count) { var doughnutSegment = Segments[i] as DoughnutSegment; doughnutSegment.SetData(arcStartAngle, arcStartAngle + arcEndAngle, this); doughnutSegment.XData = xValues[i]; doughnutSegment.YData = !double.IsNaN(GroupTo) ? Math.Abs(toggledYValues[i]) : Math.Abs(YValues[i]); doughnutSegment.AngleOfSlice = (2 * arcStartAngle + arcEndAngle) / 2; doughnutSegment.IsExploded = explodedAll || (explodedIndex == i); doughnutSegment.Item = actualData[i]; doughnutSegment.IsEndValueExceed = isEndValueExceed; doughnutSegment.DoughnutSegmentIndex = visibleSegmentCount; if (SegmentColorPath != null && !Segments[i].IsEmptySegmentInterior && ColorValues.Count > 0 && !Segments[i].IsSelectedSegment) { Segments[i].Interior = (Interior != null) ? Interior : ColorValues[i]; } if (ToggledLegendIndex.Contains(i)) { Segments[i].IsSegmentVisible = false; } else { Segments[i].IsSegmentVisible = true; } doughnutSegment.UpdateTrackInterior(i); } else { DoughnutSegment segment = new DoughnutSegment(arcStartAngle, arcStartAngle + arcEndAngle, this) { XData = xValues[i], YData = !double.IsNaN(GroupTo) ? Math.Abs(toggledYValues[i]) : Math.Abs(YValues[i]), AngleOfSlice = (2 * arcStartAngle + arcEndAngle) / 2, IsExploded = explodedAll || (explodedIndex == i), Item = actualData[i], IsEndValueExceed = isEndValueExceed, DoughnutSegmentIndex = visibleSegmentCount }; segment.SetData(arcStartAngle, arcStartAngle + arcEndAngle, this); if (ToggledLegendIndex.Contains(i)) { segment.IsSegmentVisible = false; } else { segment.IsSegmentVisible = true; } Segments.Add(segment); segment.UpdateTrackInterior(i); } if (AdornmentsInfo != null) { AddDoughnutAdornments( xValues[i], toggledYValues[i], arcStartAngle, arcStartAngle + arcEndAngle, Segments.Count - 1, i); } if (!double.IsNaN(toggledYValues[i])) { visibleSegmentCount++; } if (!IsStackedDoughnut) { arcStartAngle += arcEndAngle; } } if (ShowEmptyPoints) { UpdateEmptyPointSegments(xValues, false); } UpdateSegmentGapAngle(); } }
/// <summary> /// Creates the segments of FastCandleBitmapSeries /// </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(); double center = this.GetSideBySideInfo(this).Median; if (AdornmentsInfo != null) { for (int i = 0; i < xValues.Count; i++) { if (i < xValues.Count && GroupedSeriesYValues[0].Count > i) { xValues[i] += center; ChartPoint hipoint = new ChartPoint(xValues[i], GroupedSeriesYValues[0][i]); ChartPoint lopoint = new ChartPoint(xValues[i], GroupedSeriesYValues[1][i]); ChartPoint oppoint = new ChartPoint(xValues[i], GroupedSeriesYValues[2][i]); ChartPoint clpoint = new ChartPoint(xValues[i], GroupedSeriesYValues[3][i]); AddAdornments(xValues[i], hipoint, lopoint, oppoint, oppoint, clpoint, clpoint, i, 0); } } } if (Segment == null || Segments.Count == 0) { Segment = new FastCandleBitmapSegment(xValues, GroupedSeriesYValues[2], GroupedSeriesYValues[3], GroupedSeriesYValues[0], GroupedSeriesYValues[1], this); Segment.Series = this; Segment.Item = ActualData; Segment.SetData(xValues, GroupedSeriesYValues[2], GroupedSeriesYValues[3], GroupedSeriesYValues[0], GroupedSeriesYValues[1]); this.Segments.Add(Segment); } } else { ClearUnUsedSegments(this.DataCount); if (AdornmentsInfo != null) { if (AdornmentsInfo.AdornmentsPosition == AdornmentsPosition.TopAndBottom) { ClearUnUsedAdornments(this.DataCount * 4); } else { ClearUnUsedAdornments(this.DataCount * 2); } double center = this.GetSideBySideInfo(this).Median; for (int i = 0; i < this.DataCount; i++) { xValues[i] += center; ChartPoint hipoint = new ChartPoint(xValues[i], HighValues[i]); ChartPoint lopoint = new ChartPoint(xValues[i], LowValues[i]); ChartPoint oppoint = new ChartPoint(xValues[i], OpenValues[i]); ChartPoint clpoint = new ChartPoint(xValues[i], CloseValues[i]); AddAdornments(xValues[i], hipoint, lopoint, oppoint, oppoint, clpoint, clpoint, i, 0); } } if (Segment == null || Segments.Count == 0) { Segment = new FastCandleBitmapSegment(xValues, OpenValues, CloseValues, HighValues, LowValues, this); Segment.Series = this; Segment.Item = ActualData; Segment.SetData(xValues, OpenValues, CloseValues, HighValues, LowValues); this.Segments.Add(Segment); } else { (Segment as FastCandleBitmapSegment).Item = ActualData; (Segment as FastCandleBitmapSegment).SetData(xValues, OpenValues, CloseValues, HighValues, LowValues); } } } }
/// <summary> /// Creates the segments of FastBarBitmapSeries /// </summary> public override void CreateSegments() { var isGrouped = (ActualXAxis is CategoryAxis && !(ActualXAxis as CategoryAxis).IsIndexed); if (isGrouped) { xValues = GroupedXValuesIndexes; } else { xValues = GetXValues(); } IList <double> x1Values, x2Values, y1Values, y2Values; x1Values = new List <double>(); x2Values = new List <double>(); y1Values = new List <double>(); y2Values = new List <double>(); if (xValues != null) { DoubleRange sbsInfo = this.GetSideBySideInfo(this); double origin = ActualXAxis != null ? ActualXAxis.Origin : 0; if (ActualXAxis != null && ActualXAxis.Origin == 0 && ActualYAxis is LogarithmicAxis && (ActualYAxis as LogarithmicAxis).Minimum != null) { origin = (double)(ActualYAxis as LogarithmicAxis).Minimum; } if (isGrouped) { Segments.Clear(); Adornments.Clear(); GroupedActualData.Clear(); for (int i = 0; i < DistinctValuesIndexes.Count; i++) { var list = (from index in DistinctValuesIndexes[i] where GroupedSeriesYValues[0].Count > index select new List <double> { GroupedSeriesYValues[0][index], index }). OrderByDescending(val => val[0]).ToList(); for (int j = 0; j < list.Count; j++) { var yValue = list[j][0]; GroupedActualData.Add(ActualData[(int)list[j][1]]); if (i < xValues.Count && GroupedSeriesYValues[0].Count > i) { x1Values.Add(i + sbsInfo.Start); x2Values.Add(i + sbsInfo.End); y1Values.Add(yValue); y2Values.Add(ActualXAxis != null ? ActualXAxis.Origin : 0); // Setting origin value for fastbar segment } } } if (Segment != null && (!IsActualTransposed && Segment is FastBarBitmapSegment) || (IsActualTransposed && Segment is FastColumnBitmapSegment)) { Segments.Clear(); } if (Segment == null || Segments.Count == 0) { if (IsActualTransposed) { Segment = new FastBarBitmapSegment(x1Values, y1Values, x2Values, y2Values, this); } else { Segment = new FastColumnBitmapSegment(x1Values, y1Values, x2Values, y2Values, this); } Segment.SetData(x1Values, y1Values, x2Values, y2Values); this.Segments.Add(Segment); } if (AdornmentsInfo != null) { int count = 0; for (int i = 0; i < DistinctValuesIndexes.Count; i++) { var list = (from index in DistinctValuesIndexes[i] select new List <double> { GroupedSeriesYValues[0][index], index }). OrderByDescending(val => val[0]).ToList(); for (int j = 0; j < DistinctValuesIndexes[i].Count; j++) { var yValue = list[j][0]; if (i < xValues.Count) { if (this.AdornmentsInfo.AdornmentsPosition == AdornmentsPosition.Top) { AddColumnAdornments(i, yValue, x1Values[count], y1Values[count], count, sbsInfo.Delta / 2); } else if (this.AdornmentsInfo.AdornmentsPosition == AdornmentsPosition.Bottom) { AddColumnAdornments(i, yValue, x1Values[count], y2Values[count], count, sbsInfo.Delta / 2); } else { AddColumnAdornments(i, yValue, x1Values[count], y1Values[count] + (y2Values[count] - y1Values[count]) / 2, count, sbsInfo.Delta / 2); } } count++; } } } } else { if (!this.IsIndexed) { for (int i = 0; i < this.DataCount; i++) { x1Values.Add(xValues[i] + sbsInfo.Start); x2Values.Add(xValues[i] + sbsInfo.End); y1Values.Add(YValues[i]); y2Values.Add(ActualXAxis != null ? ActualXAxis.Origin : 0); // Setting origin value for fastbar segment } } else { for (int i = 0; i < this.DataCount; i++) { x1Values.Add(i + sbsInfo.Start); x2Values.Add(i + sbsInfo.End); y1Values.Add(YValues[i]); y2Values.Add(origin); } } if (Segment != null && (!IsActualTransposed && Segment is FastBarBitmapSegment) || (IsActualTransposed && Segment is FastColumnBitmapSegment)) { Segments.Clear(); } if (Segment == null || Segments.Count == 0) { if (IsActualTransposed) { Segment = new FastBarBitmapSegment(x1Values, y1Values, x2Values, y2Values, this); } else { Segment = new FastColumnBitmapSegment(x1Values, y1Values, x2Values, y2Values, this); } Segment.SetData(x1Values, y1Values, x2Values, y2Values); this.Segments.Add(Segment); } if (Segment is FastBarBitmapSegment) { (Segment as FastBarBitmapSegment).Item = ActualData; (Segment as FastBarBitmapSegment).SetData(x1Values, y1Values, x2Values, y2Values); } else { (Segment as FastColumnBitmapSegment).Item = ActualData; (Segment as FastColumnBitmapSegment).SetData(x1Values, y1Values, x2Values, y2Values); } if (AdornmentsInfo != null) { ClearUnUsedAdornments(this.DataCount); for (int i = 0; i < this.DataCount; i++) { if (i < this.DataCount) { if (this.AdornmentsInfo.AdornmentsPosition == AdornmentsPosition.Top) { AddColumnAdornments(xValues[i], YValues[i], x1Values[i], y1Values[i], i, sbsInfo.Delta / 2); } else if (this.AdornmentsInfo.AdornmentsPosition == AdornmentsPosition.Bottom) { AddColumnAdornments(xValues[i], YValues[i], x1Values[i], y2Values[i], i, sbsInfo.Delta / 2); } else { AddColumnAdornments(xValues[i], YValues[i], x1Values[i], y1Values[i] + (y2Values[i] - y1Values[i]) / 2, i, sbsInfo.Delta / 2); } } } } } } }
/// <summary> /// creates the segments of StackingColumnSeries3D. /// </summary> public override void CreateSegments() { var sbsInfo = GetSideBySideInfo(this); var origin = ActualXAxis.Origin; if (this.ActualXAxis != null && ActualXAxis.Origin == 0 && ActualYAxis is LogarithmicAxis && (ActualYAxis as LogarithmicAxis).Minimum != null) { origin = (double)(ActualYAxis as LogarithmicAxis).Minimum; } var median = sbsInfo.Delta / 2; var stackingValues = GetCumulativeStackValues(this); if (stackingValues == null) { return; } this.YRangeStartValues = stackingValues.StartValues; this.YRangeEndValues = stackingValues.EndValues; bool isIndexed = ActualXAxis is CategoryAxis3D && !(ActualXAxis as CategoryAxis3D).IsIndexed; var xValues = isIndexed ? GroupedXValuesIndexes : GetXValues(); var zValues = GetZValues(); var isZAxis = zValues != null && zValues.Count > 0; var space = (isZAxis ? Area.ActualDepth : Area.Depth) / 4; var start = space; var end = space * 3; double z1, z2; DoubleRange zsbsInfo = DoubleRange.Empty; if (isZAxis) { zsbsInfo = this.GetZSideBySideInfo(this); } if (this.YRangeStartValues == null) { this.YRangeStartValues = (from val in xValues select origin).ToList(); } if (this.Area.VisibleSeries != null) { var stackingseries = (from series in Area.VisibleSeries where (series is StackingColumnSeries3D || series is StackingColumn100Series3D || series is StackingBarSeries3D || series is StackingBar100Series3D) select series).ToList(); if (stackingseries.Count > 0) { double spacing = (stackingseries[0] as StackingColumnSeries3D).SegmentSpacing; for (int index = 0; index < stackingseries.Count; index++) { double seriesspacing = (stackingseries[index] as StackingColumnSeries3D).SegmentSpacing; if ((spacing <= 0 || spacing > 1) && seriesspacing > spacing) { spacing = seriesspacing; } } for (int index = 0; index < stackingseries.Count; index++) { (stackingseries[index] as StackingColumnSeries3D).SegmentSpacing = spacing; } } } if (xValues == null) { return; } if (isIndexed) { Segments.Clear(); Adornments.Clear(); int segmentCount = 0; for (int i = 0; i < DistinctValuesIndexes.Count; i++) { for (int j = 0; j < DistinctValuesIndexes[i].Count; j++) { var x1 = i + sbsInfo.Start; var x2 = i + sbsInfo.End; var y2 = double.IsNaN(YRangeStartValues[segmentCount]) ? origin : YRangeStartValues[segmentCount]; var y1 = double.IsNaN(YRangeEndValues[segmentCount]) ? origin : YRangeEndValues[segmentCount]; if (isZAxis) { z1 = zValues[i] + zsbsInfo.Start; z2 = zValues[i] + zsbsInfo.End; } else { z1 = start; z2 = end; } Segments.Add(new StackingColumnSegment3D(x1, y1, x2, y2, z1, z2, this) { XData = xValues[segmentCount], YData = GroupedSeriesYValues[0][segmentCount], Item = GroupedActualData[segmentCount] }); if (this.AdornmentsInfo == null) { continue; } var xAdornmentPosition = GetXAdornmentAnglePosition(i, sbsInfo); double zAdornmentPosition = 0d; if (isZAxis) { zAdornmentPosition = this.GetZAdornmentAnglePosition(zValues[i], zsbsInfo); } else { zAdornmentPosition = this.GetZAdornmentAnglePosition(start, end); } switch (AdornmentsInfo.AdornmentsPosition) { case AdornmentsPosition.Top: this.AddColumnAdornments(i, this.GroupedSeriesYValues[0][segmentCount], xAdornmentPosition, y1, segmentCount, median, zAdornmentPosition); break; case AdornmentsPosition.Bottom: this.AddColumnAdornments(i, this.GroupedSeriesYValues[0][segmentCount], xAdornmentPosition, y2, segmentCount, median, zAdornmentPosition); break; default: this.AddColumnAdornments(i, this.GroupedSeriesYValues[0][segmentCount], xAdornmentPosition, y1 + (y2 - y1) / 2, segmentCount, median, zAdornmentPosition); break; } segmentCount++; } } } else { this.ClearUnUsedSegments(this.DataCount); this.ClearUnUsedAdornments(this.DataCount); for (var i = 0; i < this.DataCount; i++) { var x1 = xValues[i] + sbsInfo.Start; var x2 = xValues[i] + sbsInfo.End; var y2 = double.IsNaN(YRangeStartValues[i]) ? origin : YRangeStartValues[i]; var y1 = double.IsNaN(YRangeEndValues[i]) ? origin : YRangeEndValues[i]; z1 = isZAxis ? zValues[i] + zsbsInfo.Start : start; z2 = isZAxis ? zValues[i] + zsbsInfo.End : end; if (i < Segments.Count) { (Segments[i]).SetData(x1, y1, x2, y2, z1, z2); ((StackingColumnSegment3D)Segments[i]).YData = this.ActualSeriesYValues[0][i]; ((StackingColumnSegment3D)Segments[i]).XData = xValues[i]; if (isZAxis) { ((StackingColumnSegment3D)Segments[i]).ZData = zValues[i]; } ((StackingColumnSegment3D)Segments[i]).Item = this.ActualData[i]; } else { Segments.Add(new StackingColumnSegment3D(x1, y1, x2, y2, z1, z2, this) { XData = xValues[i], YData = ActualSeriesYValues[0][i], ZData = isZAxis ? zValues[i] : 0, Item = ActualData[i], }); } if (this.AdornmentsInfo == null) { continue; } var xAdornmentPosition = GetXAdornmentAnglePosition(xValues[i], sbsInfo); double zAdornmentPosition = 0d; if (isZAxis) { zAdornmentPosition = this.GetZAdornmentAnglePosition(zValues[i], zsbsInfo); } else { zAdornmentPosition = this.GetZAdornmentAnglePosition(start, end); } switch (AdornmentsInfo.AdornmentsPosition) { case AdornmentsPosition.Top: this.AddColumnAdornments(xValues[i], this.YValues[i], xAdornmentPosition, y1, i, median, zAdornmentPosition); break; case AdornmentsPosition.Bottom: this.AddColumnAdornments(xValues[i], this.YValues[i], xAdornmentPosition, y2, i, median, zAdornmentPosition); break; default: this.AddColumnAdornments(xValues[i], this.YValues[i], xAdornmentPosition, y1 + (y2 - y1) / 2, i, median, zAdornmentPosition); break; } } } if (this.ShowEmptyPoints) { this.UpdateEmptyPointSegments(xValues, true); } }
/// <summary> /// Creates the segments of StackingAreaSeries /// </summary> public override void CreateSegments() { ClearUnUsedAdornments(this.DataCount); List <double> xValues = new List <double>(); List <double> drawingListXValues = new List <double>(); List <double> drawingListYValues = new List <double>(); double Origin = ActualXAxis != null ? ActualXAxis.Origin : 0d; if (ActualXAxis != null && ActualXAxis.Origin == 0 && ActualYAxis is LogarithmicAxis && (ActualYAxis as LogarithmicAxis).Minimum != null) { Origin = (double)(ActualYAxis as LogarithmicAxis).Minimum; } if (ActualXAxis is CategoryAxis && !(ActualXAxis as CategoryAxis).IsIndexed) { Adornments.Clear(); xValues = GroupedXValuesIndexes; } else { xValues = GetXValues(); } var stackingValues = GetCumulativeStackValues(this); if (stackingValues != null) { YRangeStartValues = stackingValues.StartValues; YRangeEndValues = stackingValues.EndValues; if (YRangeStartValues != null) { drawingListXValues.AddRange(xValues); drawingListYValues.AddRange(YRangeStartValues); } else { drawingListXValues.AddRange(xValues); drawingListYValues = (from val in xValues select Origin).ToList(); } drawingListXValues.AddRange((from val in xValues select val).Reverse().ToList()); drawingListYValues.AddRange((from val in YRangeEndValues select val).Reverse().ToList()); if (Segment == null || Segments.Count == 0) { Segment = new StackingAreaSegment(drawingListXValues, drawingListYValues, this) { Series = this, Item = ActualData }; Segment.SetData(drawingListXValues, drawingListYValues); Segments.Add(Segment); } else { Segment.Item = ActualData; Segment.SetData(drawingListXValues, drawingListYValues); } if (ShowEmptyPoints) { UpdateEmptyPointSegments(drawingListXValues, false); } if (AdornmentsInfo != null) { AddStackingAreaAdornments(YRangeEndValues); } } }
/// <summary> /// Creates the segments of SplineAreaSeries /// </summary> public override void CreateSegments() { int index = -1; double[] yCoef = null; var segmentPoints = new List <ChartPoint>(); double Origin = this.ActualXAxis != null ? this.ActualXAxis.Origin : 0.0; if (ActualXAxis != null && ActualXAxis.Origin == 0 && ActualYAxis is LogarithmicAxis && (ActualYAxis as LogarithmicAxis).Minimum != null) { Origin = (double)(ActualYAxis as LogarithmicAxis).Minimum; } 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 && xValues.Count > 1) { if (isGrouping) { Segments.Clear(); Adornments.Clear(); if (SplineType == SplineType.Monotonic) { GetMonotonicSpline(xValues, GroupedSeriesYValues[0]); } else if (SplineType == SplineType.Cardinal) { GetCardinalSpline(xValues, GroupedSeriesYValues[0]); } else { this.NaturalSpline(xValues, GroupedSeriesYValues[0], out yCoef); } ChartPoint initialPoint = new ChartPoint(xValues[0], Origin); segmentPoints.Add(initialPoint); initialPoint = new ChartPoint(xValues[0], double.IsNaN(GroupedSeriesYValues[0][0]) ? Origin : GroupedSeriesYValues[0][0]); segmentPoints.Add(initialPoint); for (int i = 0; i < xValues.Count; i++) { index = i + 1; if (index < xValues.Count && index < GroupedSeriesYValues[0].Count) { ChartPoint startPoint = new ChartPoint(xValues[i], GroupedSeriesYValues[0][i]); ChartPoint endPoint = new ChartPoint(xValues[index], GroupedSeriesYValues[0][index]); ChartPoint startControlPoint; ChartPoint endControlPoint; // Calculate curve points. if (SplineType == SplineType.Monotonic) { startControlPoint = startControlPoints[index - 1]; endControlPoint = endControlPoints[index - 1]; } else if (SplineType == SplineType.Cardinal) { startControlPoint = startControlPoints[index - 1]; endControlPoint = endControlPoints[index - 1]; } else { GetBezierControlPoints(startPoint, endPoint, yCoef[i], yCoef[index], out startControlPoint, out endControlPoint); } segmentPoints.AddRange(new ChartPoint[] { startControlPoint, endControlPoint, endPoint }); } } if (Segment == null || Segments.Count == 0) { Segment = new SplineAreaSegment(segmentPoints, xValues, GroupedSeriesYValues[0], this); Segments.Add(Segment); } if (AdornmentsInfo != null) { AddAreaAdornments(GroupedSeriesYValues[0]); } } else { ClearUnUsedAdornments(this.DataCount); if (SplineType == SplineType.Monotonic) { GetMonotonicSpline(xValues, YValues); } else if (SplineType == SplineType.Cardinal) { GetCardinalSpline(xValues, YValues); } else { this.NaturalSpline(xValues, YValues, out yCoef); } ChartPoint initialPoint = new ChartPoint(xValues[0], Origin); segmentPoints.Add(initialPoint); initialPoint = new ChartPoint(xValues[0], double.IsNaN(YValues[0]) ? Origin : YValues[0]); segmentPoints.Add(initialPoint); for (int i = 0; i < DataCount; i++) { index = i + 1; if (index < DataCount) { ChartPoint startPoint = new ChartPoint(xValues[i], YValues[i]); ChartPoint endPoint = new ChartPoint(xValues[index], YValues[index]); ChartPoint startControlPoint; ChartPoint endControlPoint; // Calculate curve points. if (SplineType == SplineType.Monotonic) { startControlPoint = startControlPoints[index - 1]; endControlPoint = endControlPoints[index - 1]; } else if (SplineType == SplineType.Cardinal) { startControlPoint = startControlPoints[index - 1]; endControlPoint = endControlPoints[index - 1]; } else { GetBezierControlPoints(startPoint, endPoint, yCoef[i], yCoef[index], out startControlPoint, out endControlPoint); } segmentPoints.AddRange(new ChartPoint[] { startControlPoint, endControlPoint, endPoint }); } } if (Segment == null || Segments.Count == 0) { Segment = new SplineAreaSegment(segmentPoints, xValues, YValues, this); Segments.Add(Segment); } else { Segment.Item = ActualData; (Segment as SplineAreaSegment).SetData(segmentPoints, xValues, YValues); } if (AdornmentsInfo != null) { AddAreaAdornments(YValues); } } } }
/// <summary> /// Creates the segments of ColumnSeries. /// </summary> public override void CreateSegments() { double x1, x2, y1, y2; var isGrouped = ActualXAxis is CategoryAxis && !(ActualXAxis as CategoryAxis).IsIndexed; List <double> xValues = null; if (isGrouped) { xValues = GroupedXValuesIndexes; } else { xValues = GetXValues(); } double median = 0d; double origin = ActualXAxis != null ? ActualXAxis.Origin : 0; if (ActualXAxis != null && ActualXAxis.Origin == 0 && ActualYAxis is LogarithmicAxis && (ActualYAxis as LogarithmicAxis).Minimum != null) { origin = (double)(ActualYAxis as LogarithmicAxis).Minimum; } if (xValues != null) { DoubleRange sbsInfo = this.GetSideBySideInfo(this); median = sbsInfo.Delta / 2; int segmentCount = 0; if (isGrouped) { Segments.Clear(); Adornments.Clear(); GroupedActualData.Clear(); for (int i = 0; i < DistinctValuesIndexes.Count; i++) { var list = (from index in DistinctValuesIndexes[i] where GroupedSeriesYValues[0].Count > index select new List <double> { GroupedSeriesYValues[0][index], index }). OrderByDescending(val => val[0]).ToList(); for (int j = 0; j < list.Count; j++) { var yValue = list[j][0]; x1 = i + sbsInfo.Start; x2 = i + sbsInfo.End; y1 = yValue; y2 = origin; // Setting origin value for column segment GroupedActualData.Add(ActualData[(int)list[j][1]]); Segments.Add(new ColumnSegment(x1, y1, x2, y2, this) { XData = xValues[j], YData = yValue, Item = GroupedActualData[segmentCount] }); if (AdornmentsInfo != null) { if (this.AdornmentsInfo.AdornmentsPosition == AdornmentsPosition.Top) { AddColumnAdornments(i, yValue, x1, y1, segmentCount, median); } else if (this.AdornmentsInfo.AdornmentsPosition == AdornmentsPosition.Bottom) { AddColumnAdornments(i, yValue, x1, y2, segmentCount, median); } else { AddColumnAdornments(i, yValue, x1, y1 + (y2 - y1) / 2, segmentCount, median); } } segmentCount++; } } } else { ClearUnUsedSegments(this.DataCount); ClearUnUsedAdornments(this.DataCount); double start = sbsInfo.Start; double end = sbsInfo.End; List <int> SeriesCount = new List <int>(); foreach (ChartSeriesBase series in Area.Series) { SeriesCount.Add(series.DataCount); } for (int i = 0; i < this.DataCount; i++) { if (i < this.DataCount) { x1 = xValues[i] + start; x2 = xValues[i] + end; y1 = YValues[i]; y2 = origin; // Setting origin value for column segment if (i < Segments.Count) { (Segments[i]).SetData(x1, y1, x2, y2); (Segments[i] as ColumnSegment).XData = xValues[i]; (Segments[i] as ColumnSegment).YData = YValues[i]; (Segments[i] as ColumnSegment).Item = ActualData[i]; if (SegmentColorPath != null && !Segments[i].IsEmptySegmentInterior && ColorValues.Count > 0 && !Segments[i].IsSelectedSegment) { Segments[i].Interior = (Interior != null) ? Interior : ColorValues[i]; } } else { Segments.Add(new ColumnSegment(x1, y1, x2, y2, this) { XData = xValues[i], YData = YValues[i], Item = ActualData[i] }); } if (AdornmentsInfo != null) { if (this.AdornmentsInfo.AdornmentsPosition == AdornmentsPosition.Top) { AddColumnAdornments(xValues[i], YValues[i], x1, y1, i, median); } else if (this.AdornmentsInfo.AdornmentsPosition == AdornmentsPosition.Bottom) { AddColumnAdornments(xValues[i], YValues[i], x1, y2, i, median); } else { AddColumnAdornments(xValues[i], YValues[i], x1, y1 + (y2 - y1) / 2, i, median); } } } } if (ShowEmptyPoints) { UpdateEmptyPointSegments(xValues, true); } } } }
/// <summary> /// creates the segments of StackingColumnSeries. /// </summary> public override void CreateSegments() { List <double> xValues = null; var isGrouped = ActualXAxis is CategoryAxis && !(ActualXAxis as CategoryAxis).IsIndexed; DoubleRange sbsInfo = this.GetSideBySideInfo(this); double x1, x2, y1, y2; double Origin = this.ActualXAxis != null ? this.ActualXAxis.Origin : 0; if (ActualXAxis != null && ActualXAxis.Origin == 0 && ActualYAxis is LogarithmicAxis && (ActualYAxis as LogarithmicAxis).Minimum != null) { Origin = (double)(ActualYAxis as LogarithmicAxis).Minimum; } double median = sbsInfo.Delta / 2; if (isGrouped) { xValues = GroupedXValuesIndexes; } else { xValues = GetXValues(); } var stackingValues = GetCumulativeStackValues(this); if (stackingValues != null) { YRangeStartValues = stackingValues.StartValues; YRangeEndValues = stackingValues.EndValues; #if NETFX_CORE // Designer crashes when rebuild the SfChart bool _isInDesignMode = Windows.ApplicationModel.DesignMode.DesignModeEnabled; if (_isInDesignMode) { if (YRangeStartValues.Count == 0 && YRangeEndValues.Count == 0) { return; } } #endif if (YRangeStartValues == null) { YRangeStartValues = (from val in xValues select Origin).ToList(); } if (xValues != null) { if (isGrouped) { Segments.Clear(); Adornments.Clear(); int segmentCount = 0; for (int i = 0; i < DistinctValuesIndexes.Count; i++) { for (int j = 0; j < DistinctValuesIndexes[i].Count; j++) { int index = DistinctValuesIndexes[i][j]; if (j < xValues.Count) { x1 = i + sbsInfo.Start; x2 = i + sbsInfo.End; y2 = double.IsNaN(YRangeStartValues[segmentCount]) ? Origin : YRangeStartValues[segmentCount]; y1 = double.IsNaN(YRangeEndValues[segmentCount]) ? Origin : YRangeEndValues[segmentCount]; StackingColumnSegment columnSegment = new StackingColumnSegment(x1, y1, x2, y2, this); columnSegment.XData = xValues[segmentCount]; columnSegment.YData = GroupedSeriesYValues[0][index]; columnSegment.Item = GroupedActualData[segmentCount]; Segments.Add(columnSegment); if (AdornmentsInfo != null) { if (this.AdornmentsInfo.AdornmentsPosition == AdornmentsPosition.Top) { AddColumnAdornments(i, GroupedSeriesYValues[0][index], x1, y1, segmentCount, median); } else if (this.AdornmentsInfo.AdornmentsPosition == AdornmentsPosition.Bottom) { AddColumnAdornments(i, GroupedSeriesYValues[0][index], x1, y2, segmentCount, median); } else { AddColumnAdornments(i, GroupedSeriesYValues[0][index], x1, y1 + (y2 - y1) / 2, segmentCount, median); } } segmentCount++; } } } } else { ClearUnUsedSegments(this.DataCount); ClearUnUsedAdornments(this.DataCount); for (int i = 0; i < DataCount; i++) { x1 = xValues[i] + sbsInfo.Start; x2 = xValues[i] + sbsInfo.End; y2 = double.IsNaN(YRangeStartValues[i]) ? Origin : YRangeStartValues[i]; y1 = double.IsNaN(YRangeEndValues[i]) ? Origin : YRangeEndValues[i]; if (i < Segments.Count) { (Segments[i]).Item = ActualData[i]; (Segments[i] as StackingColumnSegment).XData = xValues[i]; (Segments[i] as StackingColumnSegment).YData = YValues[i]; (Segments[i]).SetData(x1, y1, x2, y2); if (SegmentColorPath != null && !Segments[i].IsEmptySegmentInterior && ColorValues.Count > 0 && !Segments[i].IsSelectedSegment) { Segments[i].Interior = (Interior != null) ? Interior : ColorValues[i]; } } else { StackingColumnSegment columnSegment = new StackingColumnSegment(x1, y1, x2, y2, this); columnSegment.XData = xValues[i]; columnSegment.YData = ActualSeriesYValues[0][i]; columnSegment.Item = ActualData[i]; Segments.Add(columnSegment); } if (AdornmentsInfo != null) { if (this.AdornmentsInfo.AdornmentsPosition == AdornmentsPosition.Top) { AddColumnAdornments(xValues[i], YValues[i], x1, y1, i, median); } else if (this.AdornmentsInfo.AdornmentsPosition == AdornmentsPosition.Bottom) { AddColumnAdornments(xValues[i], YValues[i], x1, y2, i, median); } else { AddColumnAdornments(xValues[i], YValues[i], x1, y1 + (y2 - y1) / 2, i, median); } } } } if (ShowEmptyPoints) { if (this is StackingColumn100Series) { var index = EmptyPointIndexes[0]; if (EmptyPointStyle == Charts.EmptyPointStyle.Symbol || EmptyPointStyle == Charts.EmptyPointStyle.SymbolAndInterior) { foreach (var n in index) { this.ActualSeriesYValues[0][n] = double.IsNaN(YRangeEndValues[n]) ? 0 : this.YRangeEndValues[n]; } } UpdateEmptyPointSegments(xValues, true); ReValidateYValues(EmptyPointIndexes); ValidateYValues(); } else { UpdateEmptyPointSegments(xValues, true); } } } } }