///=================================================================================================
        /// <summary>   清空控件所有的图型. </summary>
        ///
        /// <remarks>   lyy, 2017:6:9_10:35:33. </remarks>
        ///
        /// <param name="cs">   The create struct. </param>
        ///-------------------------------------------------------------------------------------------------

        public void ClearLines(ChartStylePolar cs)
        {
            List <int> ListLineRemove = new List <int>();

            for (int i = 0; i < cs.ChartCanvas.Children.Count; i++)
            {
                if (cs.ChartCanvas.Children[i].GetType() == typeof(Polyline))
                {
                    ListLineRemove.Add(i);
                }
            }
            for (int j = ListLineRemove.Count - 1; j >= 0; j--)
            {
                cs.ChartCanvas.Children.RemoveAt(j);
            }
            //foreach (var item in cs.ChartCanvas.Children)
            //{
            //    if (item.GetType() == typeof(Polyline))
            //    {
            //        ListLineRemove.Add((Polyline)item);
            //    }
            //}
            //foreach (var item in ListLineRemove)
            //{
            //    cs.ChartCanvas.Children.Remove(item);
            //}
            //cs.ChartCanvas.UpdateLayout();
        }
Esempio n. 2
0
        private void AddChart()
        {
            cs             = new ChartStylePolar();
            dc             = new DataCollectionPolar();
            cs.ChartCanvas = chartCanvas;

            cs.Rmax           = 0.5;
            cs.Rmin           = 0;
            cs.NTicks         = 8;
            cs.AngleStep      = 30;
            cs.AngleDirection = ChartStylePolar.AngleDirectionEnum.CounterClockWise;
            cs.LinePattern    = ChartStylePolar.LinePatternEnum.Dot;
            cs.LineColor      = Brushes.Black;
            cs.SetPolarAxes();

            dc.DataList.Clear();
            ds           = new DataSeries();
            ds.LineColor = Brushes.Red;
            for (int i = 0; i < 360; i++)
            {
                double theta = 1.0 * i;
                double r     = Math.Abs(Math.Cos(2.0 * theta * Math.PI / 180) * Math.Sin(2.0 * theta * Math.PI / 180));
                ds.LineSeries.Points.Add(new Point(theta, r));
            }
            dc.DataList.Add(ds);
            dc.AddPolar(cs);
        }
        public void AddPolar(ChartStylePolar csp)
        {
            double xc = csp.ChartCanvas.Width / 2;
            double yc = csp.ChartCanvas.Height / 2;

            int j = 0;

            foreach (DataSeries ds in DataList)
            {
                if (ds.SeriesName == "Default Name")
                {
                    ds.SeriesName = "DataSeries" + j.ToString();
                }
                ds.AddLinePattern();
                for (int i = 0; i < ds.LineSeries.Points.Count; i++)
                {
                    double r     = ds.LineSeries.Points[i].Y;
                    double theta = ds.LineSeries.Points[i].X * Math.PI / 180;
                    if (csp.AngleDirection == ChartStylePolar.AngleDirectionEnum.CounterClockWise)
                    {
                        theta = -theta;
                    }

                    double x = xc + csp.RNormalize(r) * Math.Cos(theta);
                    double y = yc + csp.RNormalize(r) * Math.Sin(theta);
                    ds.LineSeries.Points[i] = new Point(x, y);
                    ds.Symbols.AddSymbol(csp.ChartCanvas, ds.LineSeries.Points[i]);
                }
                csp.ChartCanvas.Children.Add(ds.LineSeries);
                j++;
            }
        }
Esempio n. 4
0
        private void AddChart1()
        {
            cs             = new ChartStylePolar();
            dc             = new DataCollectionPolar();
            cs.ChartCanvas = chartCanvas;

            cs.Rmax           = 0;
            cs.Rmin           = -7;
            cs.NTicks         = 8;
            cs.AngleStep      = 30;
            cs.AngleDirection = ChartStylePolar.AngleDirectionEnum.CounterClockWise;
            cs.LinePattern    = ChartStylePolar.LinePatternEnum.Dot;
            cs.LineColor      = Brushes.Black;
            cs.SetPolarAxes();

            dc.DataList.Clear();
            ds           = new DataSeries();
            ds.LineColor = Brushes.Red;
            ds.Symbols   = new Symbols {
                SymbolType = Symbols.SymbolTypeEnum.Square, BorderThickness = 1, SymbolSize = 10, BorderColor = Brushes.Black, FillColor = Brushes.Chocolate
            };
            for (int i = 0; i < 360; i++)
            {
                double theta = 1.0 * i;
                double r     = Math.Log(1.001 + Math.Sin(2 * theta * Math.PI / 180));
                ds.LineSeries.Points.Add(new Point(theta, r));
            }
            dc.DataList.Add(ds);

            ds           = new DataSeries();
            ds.LineColor = Brushes.Blue;
            ds.Symbols   = new Symbols {
                SymbolType = Symbols.SymbolTypeEnum.Square, BorderThickness = 1, SymbolSize = 10, BorderColor = Brushes.Black, FillColor = Brushes.Blue
            };
            for (int i = 0; i < 360; i++)
            {
                double theta = 1.0 * i;
                double r     = Math.Log(1.001 + Math.Cos(2 * theta * Math.PI / 180));
                ds.LineSeries.Points.Add(new Point(theta, r));
            }
            dc.DataList.Add(ds);

            dc.AddPolar(cs);
        }