Example #1
0
        internal virtual object Clone()
        {
            PlotElement clone = new PlotElement();

            CloneAttributes(clone);
            return(clone);
        }
Example #2
0
        double GetMaxSymbolWidth()
        {
            double num = 0.0;

            foreach (DataSeries series in base.Series)
            {
                if (series is IMeasureSymbolWidth)
                {
                    DataTemplate symbol = series.Symbol as DataTemplate;
                    if (symbol == null)
                    {
                        symbol = base.Symbol as DataTemplate;
                    }
                    if (symbol != null)
                    {
                        PlotElement element = symbol.LoadContent() as PlotElement;
                        if (element != null)
                        {
                            num = Math.Max(num, element.Size.Width);
                        }
                    }
                    else if (base.Symbol is PlotElement)
                    {
                        num = Math.Max(num, ((PlotElement)base.Symbol).Size.Width);
                    }
                }
            }
            return(num);
        }
Example #3
0
        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);
        }
Example #4
0
        internal void Start(PlotElement pe)
        {
            int length = ((IDataSeriesInfo)pe.DataPoint.Series).GetValues().GetLength(1);

            if (SymbolStyle != null)
            {
                pe.Style = SymbolStyle;
            }
            if (Storyboard != null)
            {
                Windows.UI.Xaml.Media.Animation.Storyboard storyboard = Storyboard.DeepClone <Windows.UI.Xaml.Media.Animation.Storyboard>();
                if (storyboard != null)
                {
                    foreach (Timeline timeline in Storyboard.Children)
                    {
                        Timeline element        = timeline.DeepClone <Timeline>();
                        string   targetProperty = Windows.UI.Xaml.Media.Animation.Storyboard.GetTargetProperty(timeline);
                        Windows.UI.Xaml.Media.Animation.Storyboard.SetTargetProperty(element, targetProperty);
                        double indexDelay = GetIndexDelay(timeline);
                        if (indexDelay != 0.0)
                        {
                            double num3 = ((pe.DataPoint.PointIndex * indexDelay) * element.Duration.TimeSpan.TotalSeconds) / ((double)length);
                            element.BeginTime = new TimeSpan?(TimeSpan.FromSeconds(num3));
                        }
                        storyboard.Children.Add(element);
                    }
                    Windows.UI.Xaml.Media.Animation.Storyboard.SetTarget(storyboard, pe);
                    storyboard.Begin();
                }
            }
        }
Example #5
0
 protected void AttachTooltip(DataSeries ds, PlotElement ple)
 {
     if ((ple != null) && (ToolTipService.GetToolTip(ple) == null))
     {
         ToolTip tooltip = null;
         if (ds.PointTooltipTemplate != null)
         {
             object obj2 = ds.PointTooltipTemplate.LoadContent();
             if (obj2 is ToolTip)
             {
                 tooltip = (ToolTip)obj2;
             }
             else
             {
                 ToolTip tip = new ToolTip();
                 tip.Content = obj2;
                 tooltip     = tip;
             }
             ToolTipService.SetToolTip(ple, tooltip);
             tooltip.PlacementTarget = ple;
             tooltip.Opened         += (sender, e) =>
             {
                 tooltip.DataContext = ple.DataPoint;
             };
         }
     }
 }
Example #6
0
        internal IPlotElement CreateElement(object element, Style style)
        {
            IPlotElement element2 = null;
            DataTemplate template = element as DataTemplate;

            if (template != null)
            {
                return(template.LoadContent() as IPlotElement);
            }
            PlotElement element3 = element as PlotElement;

            if (element3 != null)
            {
                element2 = element3.Clone() as IPlotElement;
            }
            return(element2);
        }
Example #7
0
 protected void CloneAttributes(PlotElement clone)
 {
     if (base.Fill != null)
     {
         clone.Fill = Utils.Clone(base.Fill);
     }
     if (base.Stroke != null)
     {
         clone.Stroke = Utils.Clone(base.Stroke);
     }
     clone.StrokeThickness      = base.StrokeThickness;
     clone.Size                 = Size;
     clone.IsHitTestVisible     = base.IsHitTestVisible;
     clone.Style                = base.Style;
     clone.Loaded              += new RoutedEventHandler(FireLoaded);
     clone.MouseEnter          += new PointerEventHandler(FireMouseEnter);
     clone.MouseLeave          += new PointerEventHandler(FireMouseLeave);
     clone.MouseLeftButtonDown += new PointerEventHandler(FireMouseLeftButtonDown);
     clone.MouseLeftButtonUp   += new PointerEventHandler(FireMouseLeftButtonUp);
     if (Created != null)
     {
         Created(clone, EventArgs.Empty);
     }
 }
Example #8
0
        internal static void UpdateLabelPosition(PlotElement pe, FrameworkElement lbl)
        {
            if ((pe != null) && (lbl != null))
            {
                Size   labelSize = Utils.GetSize(lbl);
                Rect   labelRect = pe.LabelRect;
                double left      = Canvas.GetLeft(pe);
                double top       = Canvas.GetTop(pe);
                if (!double.IsNaN(left))
                {
                    labelRect.X += left;
                }
                if (!double.IsNaN(top))
                {
                    labelRect.Y += top;
                }
                double         naN            = double.NaN;
                double         length         = double.NaN;
                LabelAlignment labelAlignment = GetLabelAlignment(lbl);
                Point          labelOffset    = GetLabelOffset(lbl);
                Point          hot            = new Point();
                if (labelAlignment == LabelAlignment.Auto)
                {
                    labelAlignment = pe.AutoPosition(ref hot, ref labelOffset);
                }
                switch (labelAlignment)
                {
                case LabelAlignment.BottomCenter:
                    naN    = (labelRect.X + (labelRect.Width * 0.5)) - (labelSize.Width * 0.5);
                    length = labelRect.Bottom;
                    hot    = new Point(labelRect.X + (labelRect.Width * 0.5), labelRect.Bottom);
                    break;

                case LabelAlignment.BottomLeft:
                    naN    = labelRect.X - labelSize.Width;
                    length = labelRect.Bottom;
                    hot    = new Point(labelRect.Left, labelRect.Bottom);
                    break;

                case LabelAlignment.BottomRight:
                    naN    = labelRect.Right;
                    length = labelRect.Bottom;
                    hot    = new Point(labelRect.Right, labelRect.Bottom);
                    break;

                case LabelAlignment.MiddleCenter:
                    naN    = (labelRect.X + (labelRect.Width * 0.5)) - (labelSize.Width * 0.5);
                    length = (labelRect.Y + (labelRect.Height * 0.5)) - (labelSize.Height * 0.5);
                    hot    = new Point(labelRect.X + (labelRect.Width * 0.5), labelRect.Y + (labelRect.Height * 0.5));
                    break;

                case LabelAlignment.MiddleLeft:
                    naN    = labelRect.X - labelSize.Width;
                    length = (labelRect.Y + (labelRect.Height * 0.5)) - (labelSize.Height * 0.5);
                    hot    = new Point(labelRect.X, labelRect.Y + (labelRect.Height * 0.5));
                    break;

                case LabelAlignment.MiddleRight:
                    naN    = labelRect.Right;
                    length = (labelRect.Y + (labelRect.Height * 0.5)) - (labelSize.Height * 0.5);
                    hot    = new Point(labelRect.Right, labelRect.Y + (labelRect.Height * 0.5));
                    break;

                case LabelAlignment.TopCenter:
                    naN    = (labelRect.X + (labelRect.Width * 0.5)) - (labelSize.Width * 0.5);
                    length = labelRect.Top - labelSize.Height;
                    hot    = new Point(labelRect.X + (labelRect.Width * 0.5), labelRect.Top);
                    break;

                case LabelAlignment.TopLeft:
                    naN    = labelRect.X - labelSize.Width;
                    length = labelRect.Top - labelSize.Height;
                    hot    = new Point(labelRect.Left, labelRect.Top);
                    break;

                case LabelAlignment.TopRight:
                    naN    = labelRect.Right;
                    length = labelRect.Top - labelSize.Height;
                    hot    = new Point(labelRect.Right, labelRect.Top);
                    break;
                }
                if ((labelOffset.X != 0.0) || (labelOffset.Y != 0.0))
                {
                    Line labelLine = GetLabelLine(lbl);
                    if (labelLine != null)
                    {
                        labelLine.X1 = hot.X;
                        labelLine.Y1 = hot.Y;
                    }
                    naN    += labelOffset.X;
                    length += labelOffset.Y;
                    if (labelLine != null)
                    {
                        labelLine.X2 = hot.X + labelOffset.X;
                        labelLine.Y2 = hot.Y + labelOffset.Y;
                    }
                }
                Canvas.SetLeft(lbl, naN);
                Canvas.SetTop(lbl, length);
            }
        }
Example #9
0
        UIElement[] IView2DRenderer.Generate()
        {
            int nser = _dataInfo.nser;
            int npts = _dataInfo.npts;

            if ((nser == 0) || (npts == 0))
            {
                return(null);
            }

            List <UIElement> objects    = new List <UIElement>();
            Rect             dataBounds = CoordConverter.DataBounds;
            bool             isStacked  = base.IsStacked;
            StackedSum       sum        = null;
            StackedSum       sum2       = null;
            StackedSum       sum3       = null;
            int nsg = 1;

            if (isStacked)
            {
                nsg  = base.NStackGroups();
                sum  = new StackedSum(nsg);
                sum2 = new StackedSum(nsg);
                sum3 = new StackedSum(nsg);
            }

            double       num4  = GetClusterWidth() * _dataInfo.DeltaX;
            IPlotElement defel = null;

            if (base.Symbol is PlotElement)
            {
                defel = ((PlotElement)base.Symbol).Clone() as IPlotElement;
            }

            bool defval   = (defel != null) ? defel.IsClustered : false;
            bool inverted = base.Inverted;
            int  num5     = 0;

            int[] numArray  = null;
            int[] numArray2 = null;
            if (isStacked)
            {
                num5 = base.NStackGroups();
            }
            else
            {
                numArray  = NClustered(defval);
                numArray2 = new int[numArray.Length];
                num5      = numArray[0];
            }

            double d             = 0.0;
            double origin        = 0.0;
            double seriesOverlap = 0.0;
            Chart  visual        = Chart;
            string xformat       = null;
            string yformat       = null;
            bool   flag4         = false;
            bool   flag5         = false;

            if (visual != null)
            {
                origin        = BarColumnOptions.GetOrigin(visual);
                xformat       = visual.View.AxisX.AnnoFormatInternal;
                yformat       = visual.View.AxisY.AnnoFormatInternal;
                flag4         = !double.IsNaN(visual.View.AxisX.LogBase);
                flag5         = !double.IsNaN(visual.View.AxisY.LogBase);
                seriesOverlap = BarColumnOptions.GetSeriesOverlap(visual);
                if (seriesOverlap > 1.0)
                {
                    seriesOverlap = 1.0;
                }
                else if (seriesOverlap < -1.0)
                {
                    seriesOverlap = -1.0;
                }
            }

            int si    = 0;
            int num10 = 0;

            while (si < nser)
            {
                IDataSeriesInfo ds     = base.Series[si];
                DataSeries      series = (DataSeries)base.Series[si];
                series.Children.Clear();
                objects.Add(series);
                series.SetDefaultFormat(xformat, yformat);
                int stackGroup = 0;
                if (isStacked)
                {
                    stackGroup = BarColumnOptions.GetStackGroup(series);
                }
                if (series.SymbolShape == null)
                {
                    series.SymbolShape = base.StyleGen.Next();
                }
                ShapeStyle symbolShape = series.SymbolShape;
                bool?      nullable    = null;
                double[,] values = ds.GetValues();
                if (values != null)
                {
                    int           length = values.GetLength(1);
                    int           num13  = values.GetLength(0);
                    RenderContext rc     = new RenderContext(this, ds, length)
                    {
                        Bounds = CoordConverter.ViewBounds
                    };
                    Rect clipBounds = rc.ClipBounds;
                    clipBounds = new Rect(clipBounds.X - 1.0, clipBounds.Y - 1.0, clipBounds.Width + 2.0, clipBounds.Height + 2.0);
                    double naN = double.NaN;
                    if ((rc.OptimizationRadiusScope & OptimizationRadiusScope.Symbols) > ((OptimizationRadiusScope)0))
                    {
                        naN = rc.OptimizationRadius;
                    }
                    bool isClustered = defval;
                    bool flag7       = series.IsStacked;
                    int  num15       = 0;
                    int  num16       = length;
                    if (_dataInfo.incX && !inverted)
                    {
                        Rect rect2 = CoordConverter.DataBounds2D;
                        for (int j = 0; j < length; j++)
                        {
                            double num18 = (num13 >= 2) ? values[1, j] : ((double)j);
                            if (num18 >= rect2.Left)
                            {
                                num15 = Math.Max(0, j - 2);
                                break;
                            }
                        }
                        for (int k = num15; k < length; k++)
                        {
                            double num20 = (num13 >= 2) ? values[1, k] : ((double)k);
                            if (num20 > rect2.Right)
                            {
                                num16 = k;
                                break;
                            }
                        }
                        num16 = Math.Min(length, num16 + 2);
                    }
                    Point point = new Point();
                    for (int i = num15; i < num16; i++)
                    {
                        double       num22     = values[0, i];
                        double       x         = (num13 >= 2) ? values[1, i] : ((double)i);
                        double       y         = x;
                        Style        style     = null;
                        IPlotElement pe        = null;
                        bool?        nullable2 = nullable;
                        if (!nullable2.GetValueOrDefault() || !nullable2.HasValue)
                        {
                            if (base.ColorScheme == ColorScheme.Point)
                            {
                                symbolShape = base.StyleGen.GetStyle(i);
                            }
                            style = base.GetStyle(series, si, i);
                            pe    = base.CreateElement(series.Symbol, style);
                            if (pe == null)
                            {
                                pe = PlotElement.SymbolFromMarker(series.SymbolMarker);
                                if ((pe != null) && (style != null))
                                {
                                    pe.Style = style;
                                }
                            }
                            if ((pe == null) && series.ChartType.HasValue)
                            {
                                ChartSubtype subtype = ChartTypes.GetSubtype(series.ChartType.ToString());
                                if (subtype != null)
                                {
                                    pe = base.CreateElement(subtype.Symbol, style);
                                }
                            }
                            else if (pe == null)
                            {
                                if (series.IsDefaultSymbol && (defel != null))
                                {
                                    pe       = defel;
                                    pe.Style = style;
                                    defel    = ((PlotElement)base.Symbol).Clone() as IPlotElement;
                                }
                            }
                            else
                            {
                                isClustered = pe.IsClustered;
                            }
                            if (pe == null)
                            {
                                isClustered = false;
                                if ((series.PointLabelTemplate != null) || (series.PointTooltipTemplate != null))
                                {
                                    DotSymbol symbol = new DotSymbol();
                                    symbol.Fill   = TransparentBrush;
                                    symbol.Size   = new Size(5.0, 5.0);
                                    symbol.Stroke = TransparentBrush;
                                    pe            = symbol;
                                }
                                else
                                {
                                    nullable = true;
                                }
                            }
                            else
                            {
                                isClustered = pe.IsClustered;
                            }
                        }
                        bool flag8 = (flag4 && inverted) || (flag5 && !inverted);
                        if (!flag8)
                        {
                            if (nsg > 1)
                            {
                                if (flag7)
                                {
                                    x += ((-0.5 * num4) + ((0.5 * num4) / ((double)num5))) + ((stackGroup * num4) / ((double)num5));
                                }
                            }
                            else if (isClustered)
                            {
                                int clusterPlotAreaIndex = rc.ClusterPlotAreaIndex;
                                if (clusterPlotAreaIndex == 0)
                                {
                                    if (num5 > 1)
                                    {
                                        x += ((-0.5 * num4) + ((0.5 * num4) / ((double)num5))) + ((num10 * num4) / ((double)num5));
                                    }
                                }
                                else if (numArray[clusterPlotAreaIndex] > 1)
                                {
                                    x += ((-0.5 * num4) + ((0.5 * num4) / ((double)numArray[clusterPlotAreaIndex]))) + ((numArray2[clusterPlotAreaIndex] * num4) / ((double)numArray[clusterPlotAreaIndex]));
                                }
                            }
                        }
                        if (isStacked && flag7)
                        {
                            if (double.IsNaN(num22))
                            {
                                num22 = 0.0;
                            }
                            if (base.IsStacked100)
                            {
                                if (_dataInfo.Stacked[stackGroup, x] != 0.0)
                                {
                                    num22 = ((num22 * 100.0) / _dataInfo.Stacked[stackGroup, x]) + sum[stackGroup, x];
                                }
                            }
                            else
                            {
                                num22 += sum[stackGroup, x];
                            }
                        }
                        double num26 = x;
                        if (inverted)
                        {
                            double num27 = x;
                            x     = num22;
                            num22 = num27;
                        }
                        double num28 = rc.ConvertX(x);
                        double num29 = rc.ConvertY(num22);
                        if (((isStacked && flag7) && (si > 0)) && ((inverted && !double.IsNaN(num29)) || (!inverted && !double.IsNaN(num28))))
                        {
                            rc.SetPrevious(sum[stackGroup, num26]);
                        }
                        nullable2 = nullable;
                        if (!nullable2.GetValueOrDefault() || !nullable2.HasValue)
                        {
                            if (isClustered)
                            {
                                int num30 = num5;
                                if (rc.ClusterPlotAreaIndex > 0)
                                {
                                    num30 = numArray[rc.ClusterPlotAreaIndex];
                                }
                                if (num30 > 0)
                                {
                                    if (inverted)
                                    {
                                        d = Math.Abs((double)(CoordConverter.ConvertY((num4 / ((double)num30)) + num22) - CoordConverter.ConvertY(num22)));
                                    }
                                    else
                                    {
                                        d = Math.Abs((double)(CoordConverter.ConvertX((num4 / ((double)num30)) + x) - CoordConverter.ConvertX(x)));
                                    }
                                }
                            }
                            else if (inverted)
                            {
                                d = Math.Abs((double)(CoordConverter.ConvertY(num4 + num22) - CoordConverter.ConvertY(num22)));
                            }
                            else
                            {
                                d = Math.Abs((double)(CoordConverter.ConvertX(num4 + x) - CoordConverter.ConvertX(x)));
                            }
                            if (double.IsNaN(d))
                            {
                                d = inverted ? (base.SizeY * 20.0) : (base.SizeX * 20.0);
                            }
                        }
                        if (flag8)
                        {
                            double num31 = 0.0;
                            double num32 = d * num5;
                            if (nsg > 1)
                            {
                                if (flag7)
                                {
                                    num31 = ((-0.5 * num32) + ((0.5 * num32) / ((double)num5))) + ((stackGroup * num32) / ((double)num5));
                                }
                            }
                            else if ((num5 > 1) && isClustered)
                            {
                                num31 = ((-0.5 * num32) + ((0.5 * num32) / ((double)num5))) + ((num10 * num32) / ((double)num5));
                            }
                            if (num31 != 0.0)
                            {
                                if (inverted)
                                {
                                    num29 += num31;
                                }
                                else
                                {
                                    num28 += num31;
                                }
                            }
                        }
                        if (isStacked && flag7)
                        {
                            StackedSum sum4;
                            int        num63;
                            double     num64;
                            double     num33 = values[0, i];
                            if (double.IsNaN(num33))
                            {
                                num33 = 0.0;
                            }
                            double num34 = (num33 >= 0.0) ? sum2[stackGroup, num26] : sum3[stackGroup, num26];
                            double num35 = (num33 >= 0.0) ? (sum2[stackGroup, num26] + num33) : (sum3[stackGroup, num26] + num33);
                            if (base.IsStacked100)
                            {
                                num34 = (num34 * 100.0) / _dataInfo.Stacked[stackGroup, num26];
                                num35 = (num35 * 100.0) / _dataInfo.Stacked[stackGroup, num26];
                            }
                            if (inverted)
                            {
                                double num36;
                                double num37;
                                double num38;
                                if (flag4)
                                {
                                    double minX = rc.GetMinX(CoordConverter.DataBounds2D);
                                    num36 = CoordConverter.ConvertX(Math.Max(num35, minX));
                                    num37 = CoordConverter.ConvertX(Math.Max(num34, minX));
                                }
                                else
                                {
                                    num36 = CoordConverter.ConvertX(num35);
                                    num37 = CoordConverter.ConvertX(num34);
                                }
                                if (flag5)
                                {
                                    num38 = base.SizeY * 20.0;
                                }
                                else
                                {
                                    num38 = Math.Abs((double)(CoordConverter.ConvertY(num4 / ((double)nsg)) - CoordConverter.ConvertY(0.0)));
                                }
                                double width = Math.Abs((double)(num37 - num36));
                                rc.Rect = new Rect(Math.Min(num36, num37), num29 - (0.5 * num38), width, num38);
                                sum[stackGroup, num26] = x;
                            }
                            else
                            {
                                double num41;
                                double num42;
                                double num43;
                                if (flag5)
                                {
                                    double minY = rc.GetMinY(CoordConverter.DataBounds2D);
                                    num41 = CoordConverter.ConvertY(Math.Max(num35, minY));
                                    num42 = CoordConverter.ConvertY(Math.Max(num34, minY));
                                }
                                else
                                {
                                    num41 = CoordConverter.ConvertY(num35);
                                    num42 = CoordConverter.ConvertY(num34);
                                }
                                if (flag4)
                                {
                                    num43 = base.SizeX * 20.0;
                                }
                                else
                                {
                                    num43 = Math.Abs((double)(CoordConverter.ConvertX(num4 / ((double)nsg)) - CoordConverter.ConvertX(0.0)));
                                }
                                double height = Math.Abs((double)(num42 - num41));
                                rc.Rect = new Rect(num28 - (0.5 * num43), Math.Min(num41, num42), num43, height);
                                sum[stackGroup, num26] = num22;
                            }
                            if (num33 >= 0.0)
                            {
                                (sum4 = sum2)[num63 = stackGroup, num64 = num26] = sum4[num63, num64] + num33;
                            }
                            else
                            {
                                (sum4 = sum3)[num63 = stackGroup, num64 = num26] = sum4[num63, num64] + num33;
                            }
                        }
                        else
                        {
                            nullable2 = nullable;
                            if (!nullable2.GetValueOrDefault() || !nullable2.HasValue)
                            {
                                double num46 = origin;
                                if (inverted)
                                {
                                    double num47 = rc.GetMinX(CoordConverter.DataBounds2D);
                                    double maxX  = rc.GetMaxX(CoordConverter.DataBounds2D);
                                    if (num46 < num47)
                                    {
                                        num46 = num47;
                                    }
                                    else if (num46 > maxX)
                                    {
                                        num46 = maxX;
                                    }
                                    double num49 = rc.ConvertX(num46);
                                    double num50 = d;
                                    double num51 = Math.Abs((double)(num49 - num28));
                                    if (seriesOverlap != 0.0)
                                    {
                                        double num52 = rc.ConvertY(y);
                                        double num53 = d * num5;
                                        if (seriesOverlap > 0.0)
                                        {
                                            num50 = num53 / ((num5 - (num5 * seriesOverlap)) + seriesOverlap);
                                        }
                                        else
                                        {
                                            num50 *= 1.0 + seriesOverlap;
                                        }
                                        double num54 = (num53 - num50) / ((double)(num5 - 1));
                                        rc.Rect = new Rect(Math.Min(num28, num49), (num52 - (0.5 * num53)) + (((num5 - num10) - 1) * num54), num51, num50);
                                    }
                                    else
                                    {
                                        rc.Rect = new Rect(Math.Min(num28, num49), num29 - (0.5 * num50), num51, num50);
                                    }
                                }
                                else
                                {
                                    double num55 = rc.GetMinY(CoordConverter.DataBounds2D);
                                    double maxY  = rc.GetMaxY(CoordConverter.DataBounds2D);
                                    if (num46 < num55)
                                    {
                                        num46 = num55;
                                    }
                                    else if (num46 > maxY)
                                    {
                                        num46 = maxY;
                                    }
                                    double num57 = rc.ConvertY(num46);
                                    double num58 = d;
                                    double num59 = Math.Abs((double)(num57 - num29));
                                    if (seriesOverlap != 0.0)
                                    {
                                        double num60 = rc.ConvertX(y);
                                        double num61 = d * num5;
                                        if (seriesOverlap > 0.0)
                                        {
                                            num58 = num61 / ((num5 - (num5 * seriesOverlap)) + seriesOverlap);
                                        }
                                        else
                                        {
                                            num58 *= 1.0 + seriesOverlap;
                                        }
                                        double num62 = (num61 - num58) / ((double)(num5 - 1));
                                        rc.Rect = new Rect((num60 - (0.5 * num61)) + (num10 * num62), Math.Min(num29, num57), num58, num59);
                                    }
                                    else
                                    {
                                        rc.Rect = new Rect(num28 - (0.5 * num58), Math.Min(num29, num57), num58, num59);
                                    }
                                }
                            }
                        }
                        rc.SetPoint(i, num28, num29);
                        if (pe != null)
                        {
                            Point point2 = new Point(num28, num29);
                            if ((pe is ICustomClipping) || clipBounds.Contains(point2))
                            {
                                if (double.IsNaN(naN))
                                {
                                    DataPoint dp = series.CreateDataPoint(si, i);
                                    base.RenderElement(objects, pe, series, rc, symbolShape, dp);
                                }
                                else if (((i == 0) || (Math.Abs((double)(point2.X - point.X)) > naN)) || ((Math.Abs((double)(point2.Y - point.Y)) > naN) || (i == (num16 - 1))))
                                {
                                    DataPoint point4 = series.CreateDataPoint(si, i);
                                    base.RenderElement(objects, pe, series, rc, symbolShape, point4);
                                    point = point2;
                                }
                            }
                        }
                    }

                    PlotElement element3 = base.RenderConnection(series, rc, si);
                    if (element3 != null)
                    {
                        series.Children.Insert(0, element3);
                    }

                    if (isClustered)
                    {
                        if (rc.ClusterPlotAreaIndex == 0)
                        {
                            num10++;
                        }
                        else
                        {
                            numArray2[rc.ClusterPlotAreaIndex]++;
                        }
                    }
                }
                si++;
            }
            return(objects.ToArray());
        }
Example #10
0
        void CreateDataObjects()
        {
            if (_startDataIdx >= 0)
            {
                int num = InternalChildren.Count - _startDataIdx;
                for (int j = 0; j < num; j++)
                {
                    PlotElement sender = InternalChildren[_startDataIdx] as PlotElement;
                    InternalChildren.RemoveAt(_startDataIdx);
                    if (((sender != null) && (sender.DataPoint != null)) && (sender.DataPoint.Series != null))
                    {
                        sender.DataPoint.Series.FirePlotElementUnloaded(sender, EventArgs.Empty);
                    }
                }
            }

            Shape plotShape = _view.PlotShape;

            if ((plotShape != null) && !InternalChildren.Contains(plotShape))
            {
                InternalChildren.Insert(0, plotShape);
            }
            _startDataIdx = InternalChildren.Count;

            IView2DRenderer renderer = _view.Renderer as IView2DRenderer;

            if (renderer != null)
            {
                renderer.CoordConverter = this;
                UIElement[] elementArray = renderer.Generate();

                if (_view.Renderer is BaseRenderer br)
                {
                    br.FireRendered(this, EventArgs.Empty);
                }

                if (elementArray == null)
                {
                    while (Children.Count > 1)
                    {
                        Children.RemoveAt(Children.Count - 1);
                    }
                }
                else
                {
                    int length = elementArray.Length;
                    for (int k = 0; k < length; k++)
                    {
                        var elem = elementArray[k];
                        if (elem == null || InternalChildren.Contains(elem))
                        {
                            continue;
                        }

                        if (elem is FrameworkElement fe && fe.Parent is Panel pnl)
                        {
                            pnl.Children.Remove(elem);
                        }
                        InternalChildren.Add(elem);
                    }

                    while (Children.Count > 1)
                    {
                        Children.RemoveAt(Children.Count - 1);
                    }
                }
            }

            int num5 = _view.Layers.Count;

            for (int i = 0; i < num5; i++)
            {
                FrameworkElement element = _view.Layers[i] as FrameworkElement;
                if (element != null)
                {
                    Canvas.SetLeft(element, PlotRect.X);
                    Canvas.SetTop(element, PlotRect.Y);
                    element.Width  = PlotRect.Width;
                    element.Height = PlotRect.Height;
                    Children.Add(element);
                }
            }

            foreach (UIElement element5 in _view.Children)
            {
                if (!Children.Contains(element5))
                {
                    Children.Add(element5);
                }
            }
        }
Example #11
0
        protected UIElement RenderElement(List <UIElement> objects, IPlotElement pe, DataSeries ds, RenderContext rc, ShapeStyle shapeStyle, DataPoint dp)
        {
            DataTemplate pointLabelTemplate = ds.PointLabelTemplate;
            PlotElement  element            = pe as PlotElement;

            if (((ItemNames != null) && (dp.PointIndex < ItemNames.Length)) && (ItemNames[dp.PointIndex] != null))
            {
                dp.Name = ItemNames[dp.PointIndex].ToString();
            }
            FrameworkElement lbl  = null;
            Line             line = null;

            if (pointLabelTemplate != null)
            {
                lbl             = pointLabelTemplate.LoadContent() as FrameworkElement;
                lbl.DataContext = dp;
                if (Canvas.GetZIndex(lbl) == 0)
                {
                    Canvas.SetZIndex(lbl, 1);
                }
                if (pe != null)
                {
                    pe.Label = lbl;
                }
                else
                {
                    PlotElement.UpdateLabelPosition(element, lbl);
                }
                line = PlotElement.GetLabelLine(lbl);
            }
            if (pe == null)
            {
                return(null);
            }
            Size size = ds.GetSymbolSize(dp.PointIndex, _dataInfo, rc.Chart);

            if (!size.IsEmpty && (element != null))
            {
                element.Size = size;
            }
            if (!pe.Render(rc))
            {
                return(null);
            }
            if (lbl != null)
            {
                objects.Add(lbl);
                if (line != null)
                {
                    lbl.Loaded += (sender, e) =>
                    {
                        Canvas parent = (Canvas)lbl.Parent;
                        if (parent != null)
                        {
                            parent.Children.Add(line);
                        }
                    };
                }
            }
            if ((element.Center.X == 0.0) && (element.Center.Y == 0.0))
            {
                element.Center = rc.Current;
            }
            element.PlotRect = rc.Bounds;
            PlotElement.UpdateLabelPosition(element, pe.Label as FrameworkElement);
            if (element.DataContext == null)
            {
                element.DataContext = dp;
            }
            element.DataPoint = dp;
            AttachTooltip(ds, element);
            pe.SetShape(shapeStyle);
            ds.Children.Add((UIElement)pe);
            return((UIElement)pe);
        }
Example #12
0
        UIElement[] IView2DRenderer.Generate()
        {
            int nser = _dataInfo.nser;
            int npts = _dataInfo.npts;

            if ((nser == 0) || (npts == 0))
            {
                return(null);
            }
            IPlotElement element = null;

            if (base.Symbol is PlotElement)
            {
                element = ((PlotElement)base.Symbol).Clone() as IPlotElement;
            }
            List <UIElement> objects = new List <UIElement>();

            for (int i = 0; i < nser; i++)
            {
                DataSeries ds = (DataSeries)base.Series[i];
                ds.Children.Clear();
                objects.Add(ds);
                if (ds.SymbolShape == null)
                {
                    ds.SymbolShape = base.StyleGen.Next();
                }
                ShapeStyle symbolShape = ds.SymbolShape;
                double[,] values = ds.GetValues();
                if (values != null)
                {
                    int           length = values.GetLength(1);
                    int           num5   = values.GetLength(0);
                    RenderContext rc     = new RenderContext(this, ds, length)
                    {
                        Bounds = CoordConverter.ViewBounds
                    };
                    for (int j = 0; j < length; j++)
                    {
                        if (base.ColorScheme == ColorScheme.Point)
                        {
                            symbolShape = base.StyleGen.GetStyle(j);
                        }
                        double       y     = values[0, j];
                        double       x     = (num5 >= 2) ? values[1, j] : ((double)j);
                        bool         flag  = false;
                        Style        style = base.GetStyle(ds, i, j);
                        IPlotElement pe    = base.CreateElement(ds.Symbol, style);
                        if (pe == null)
                        {
                            pe = PlotElement.SymbolFromMarker(ds.SymbolMarker);
                            if ((pe != null) && (style != null))
                            {
                                pe.Style = style;
                            }
                        }
                        if ((pe == null) && ds.ChartType.HasValue)
                        {
                            ChartSubtype subtype = ChartTypes.GetSubtype(ds.ChartType.ToString());
                            if (subtype != null)
                            {
                                pe = base.CreateElement(subtype.Symbol, style);
                            }
                        }
                        else if (((pe == null) && ds.IsDefaultSymbol) && (element != null))
                        {
                            pe       = element;
                            pe.Style = style;
                            element  = ((PlotElement)base.Symbol).Clone() as IPlotElement;
                        }
                        if ((pe == null) && ((ds.PointLabelTemplate != null) || (ds.PointTooltipTemplate != null)))
                        {
                            DotSymbol symbol = new DotSymbol();
                            symbol.Fill   = TransparentBrush;
                            symbol.Size   = new Size(5.0, 5.0);
                            symbol.Stroke = TransparentBrush;
                            pe            = symbol;
                            flag          = true;
                        }
                        Point point   = CoordConverter.ConvertPoint(new Point(x, y));
                        Axis  auxAxis = GetAuxAxis(j);
                        if (auxAxis != null)
                        {
                            ChartViewport2D coordConverter = CoordConverter as ChartViewport2D;
                            if (coordConverter != null)
                            {
                                point = coordConverter.ConvertPoint(new Point(x, y), base.Chart.View.AxisX, auxAxis);
                            }
                        }
                        rc.SetPoint(j, point.X, point.Y);
                        if (!double.IsNaN(point.X) && !double.IsNaN(point.Y))
                        {
                            DataPoint dp       = ds.CreateDataPoint(i, j);
                            UIElement element3 = base.RenderElement(objects, pe, ds, rc, symbolShape, dp);
                            if ((element3 != null) && flag)
                            {
                                Canvas.SetZIndex(element3, 2);
                            }
                        }
                    }
                    PlotElement element4 = base.RenderConnection(ds, rc, i);
                    if (element4 != null)
                    {
                        element4.DataPoint = ds.CreateDataPoint(i, -1);
                        ds.Children.Insert(0, element4);
                    }
                }
            }
            return(objects.ToArray());
        }