protected PlotElement RenderConnection(DataSeries ds, RenderContext rc, int i) { PlotElement element = null; if (ds.Connection is PlotElement) { element = ((PlotElement)ds.Connection).Clone() as PlotElement; } if ((element == null) && ds.ChartType.HasValue) { ChartSubtype subtype = ChartTypes.GetSubtype(ds.ChartType.ToString()); if ((subtype != null) && (subtype.Connection is PlotElement)) { element = ((PlotElement)subtype.Connection).Clone() as PlotElement; } } if ((!ds.ChartType.HasValue && ds.IsDefaultConnection) && ((element == null) && (Connection is PlotElement))) { element = ((PlotElement)Connection).Clone() as PlotElement; } if ((element != null) && ((IPlotElement)element).Render(rc)) { element.DataPoint = new DataPoint(ds, i, -1, null); element.PlotRect = rc.Bounds; ds.ConnectionShape = StyleGen.GetStyle2(i); ((IPlotElement)element).SetShape(ds.ConnectionShape); } return(element); }
internal virtual void UpdateLegend(IList <LegendItem> litems) { using (IEnumerator <LegendItem> enumerator = litems.GetEnumerator()) { while (enumerator.MoveNext()) { enumerator.Current.Clear(); } } litems.Clear(); if (ColorScheme == Dt.Charts.ColorScheme.Point) { AnalyzeData(IsStacked); int nser = _dataInfo.nser; int npts = _dataInfo.npts; if (nser > 0) { DataSeries series = Series[0] as DataSeries; for (int i = 0; i < npts; i++) { ShapeStyle shapeStyle = StyleGen.GetStyle(i); string lbl = null; object item = null; if ((ItemNames != null) && (i < ItemNames.Length)) { item = ItemNames[i]; if (item != null) { lbl = item.ToString(); } } else { lbl = "Item " + ((int)i).ToString((IFormatProvider)CultureInfo.CurrentCulture); } Shape sym = CreateSymbolShape(shapeStyle); if (series.ReadLocalValue(DataSeries.SymbolStrokeProperty) != DependencyProperty.UnsetValue) { sym.Stroke = series.SymbolStroke; } if (series.ReadLocalValue(DataSeries.SymbolStrokeThicknessProperty) != DependencyProperty.UnsetValue) { sym.StrokeThickness = Math.Min(2.0, series.SymbolStrokeThickness); } LegendItem item2 = new LegendItem(sym, null, lbl, item); litems.Add(item2); } } } else { int num4 = Series.Count; for (int j = 0; j < num4; j++) { DataSeries series2 = Series[j] as DataSeries; if (series2 != null) { if ((series2.SymbolShape == null) || !_stgen.List.Contains(series2.SymbolShape)) { series2.SymbolShape = _stgen.Next(); } if (series2.ConnectionShape == null) { series2.ConnectionShape = _stgen.List2[_stgen.List.Count - 1]; } if (((byte)(series2.Display & SeriesDisplay.HideLegend)) == 0) { LegendItem item3; object symbol = Symbol; object connection = Connection; if (series2.ChartType.HasValue) { ChartSubtype subtype = ChartTypes.GetSubtype(series2.ChartType.ToString()); symbol = subtype.Symbol; connection = subtype.Connection; } bool flag = (((symbol != null) && series2.IsDefaultSymbol) || (series2.Symbol != null)) || (series2.SymbolMarker != Marker.None); bool flag2 = ((connection != null) && series2.IsDefaultConnection) || (series2.Connection != null); IPlotElement connectionElement = series2.GetConnectionElement(this, clear); if ((!flag && flag2) && (connectionElement is Area)) { item3 = new LegendItem(flag2 ? CreateLineShape(series2) : null, null, series2.Label, series2); } else { item3 = new LegendItem(flag ? CreateSymbolShape(series2) : null, flag2 ? CreateLineShape(series2) : null, series2.Label, series2); } litems.Add(item3); } } } clear = false; } }
UIElement[] IView2DRenderer.Generate() { int nser = _dataInfo.nser; int npts = _dataInfo.npts; if ((nser == 0) || (npts == 0)) { return(null); } List <UIElement> objects = new List <UIElement>(); int num3 = 0; int num4 = 0; double width = _sz.Width; double height = _sz.Height; double num7 = width / ((double)_ncols); double num8 = height / ((double)_nrows); double num9 = 0.5 * Math.Min((double)(width / ((double)_ncols)), (double)(height / ((double)_nrows))); double naN = double.NaN; double startingAngle = 0.0; SweepDirection clockwise = SweepDirection.Clockwise; bool flag = false; Chart chart = base.Chart; double d = 0.0; if (chart != null) { startingAngle = PieOptions.GetStartingAngle(chart); clockwise = PieOptions.GetDirection(chart); flag = base.Chart.ChartType == ChartType.PieStacked; naN = PieOptions.GetOffset(chart); d = PieOptions.GetInnerRadius(chart); } if (double.IsNaN(naN)) { naN = base.Offset; } if (double.IsNaN(d) || (d == 0.0)) { d = base.InnerRadius; } for (int i = 0; i < nser; i++) { Point point = new Point(); double radiusX = num9 * base.Radius; double inner = d; if (flag) { inner = (((double)i) / ((double)nser)) * radiusX; radiusX *= ((double)(i + 1)) / ((double)nser); inner /= radiusX; } point = new Point((num4 - (0.5 * _ncols)) + 0.5, (num3 - (0.5 * _nrows)) + 0.5) { X = (num7 * point.X) + (0.5 * width), Y = (num8 * point.Y) + (0.5 * height) }; IDataSeriesInfo info = Series[i]; DataSeries series = info as DataSeries; series.Children.Clear(); objects.Add(series); double num16 = _dataInfo.SumsAbs[i]; double[,] values = info.GetValues(); if (!string.IsNullOrEmpty(series.Label)) { DataTemplate seriesLabelTemplate = null; if (chart != null) { seriesLabelTemplate = PieOptions.GetSeriesLabelTemplate(chart); } UIElement el = null; if (seriesLabelTemplate != null) { el = seriesLabelTemplate.LoadContent() as UIElement; FrameworkElement element2 = el as FrameworkElement; if (element2 != null) { element2.DataContext = series; } } if (el == null) { TextBlock block = new TextBlock(); block.Text = series.Label; IRenderer renderer = this; Control visual = renderer.Visual as Control; if (visual != null) { block.FontFamily = visual.FontFamily; block.FontSize = visual.FontSize; block.FontStretch = visual.FontStretch; block.FontStyle = visual.FontStyle; block.FontWeight = visual.FontWeight; } el = block; } Size size = Utils.GetSize(el); Canvas.SetLeft(el, point.X - (0.5 * size.Width)); if ((size.Height + radiusX) > (0.5 * num8)) { radiusX = (0.5 * num8) - size.Height; } if (flag) { Canvas.SetTop(el, (point.Y - (radiusX * inner)) - size.Height); } else { Canvas.SetTop(el, (point.Y - radiusX) - size.Height); } objects.Add(el); } double angle = startingAngle; double num18 = 0.0; if (naN > 0.0) { num18 = naN * radiusX; radiusX *= 1.0 - naN; } int num19 = (values != null) ? values.GetLength(1) : 0; for (int j = 0; j < num19; j++) { double num21 = values[0, j]; if (!double.IsNaN(num21) && (num21 != 0.0)) { ShapeStyle shapeStyle = StyleGen.GetStyle(j); double sweep = (Math.Abs(num21) / num16) * 360.0; if (sweep != 0.0) { if (clockwise == SweepDirection.Counterclockwise) { sweep = -sweep; } Point center = point; if ((num18 > 0.0) && (sweep != 360.0)) { double num23 = 0.017453292519943295 * (angle + (0.5 * sweep)); center.X += num18 * Math.Cos(num23); center.Y += num18 * Math.Sin(num23); } PieRenderContext rc = new PieRenderContext(); if (sweep < 0.0) { rc.PieInfo = new PieInfo(center, radiusX, radiusX, inner, angle + sweep, -sweep, 0.0, 0.0); } else { rc.PieInfo = new PieInfo(center, radiusX, radiusX, inner, angle, sweep, 0.0, 0.0); } DataPoint dp = series.CreateDataPoint(i, j); IPlotElement pe = null; if ((series.Symbol is PlotElement) && ((IPlotElement)series.Symbol).IsCompatible(this)) { pe = ((PlotElement)series.Symbol).Clone() as IPlotElement; } if ((pe == null) && (Symbol is PlotElement)) { pe = ((PlotElement)Symbol).Clone() as IPlotElement; } RenderElement(objects, pe, series, rc, shapeStyle, dp); if (series.ReadLocalValue(DataSeries.SymbolStrokeProperty) != DependencyProperty.UnsetValue) { ((PlotElement)pe).Stroke = series.SymbolStroke; } if (series.ReadLocalValue(DataSeries.SymbolStrokeThicknessProperty) != DependencyProperty.UnsetValue) { ((PlotElement)pe).StrokeThickness = series.SymbolStrokeThickness; } angle += sweep; } } } if (!flag) { num4++; if (num4 >= _ncols) { num4 = 0; num3++; } } } return(objects.ToArray()); }