画雷达图背景

直接糊代码

public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
            
            DrawRadarBackGround(8, 6, 20,new Point(200,300));
        }
       /// <summary>
       /// 画雷达图背景
       /// </summary>
       /// <param name="eclipseCount">圆个数</param>
       /// <param name="lineCount">线个数</param>
       /// <param name="radius">半径</param>
       /// <param name="centerPoint">圆心坐标</param>
        public void DrawRadarBackGround(int eclipseCount,int lineCount,double radius,Point centerPoint)
        {
            //画圆
            for (int i = 1; i < eclipseCount+1; i++)
            {
                Path p = new Path();
                p.Stroke = new SolidColorBrush(Colors.DarkGray);
                p.StrokeThickness = 1.0;
                EllipseGeometry e = new EllipseGeometry();
                //圆心 坐标
                e.Center = centerPoint;
                //半径为50的倍数
                e.RadiusX = i * radius;
                e.RadiusY = i * radius;
                p.Data = e;
                cavMain.Children.Add(p);
            }
            //画线
            for (int i = 0; i < lineCount; i++)
            {
                Path p = new Path();
                p.StrokeThickness = 1;
                p.Stroke = new SolidColorBrush(Colors.DarkGray);
                LineGeometry ge = new LineGeometry();
                //150为圆心 坐标 
                double x1 = centerPoint.X + (radius * eclipseCount * Math.Cos(i * Math.PI / lineCount));
                double y1 = centerPoint.Y - (radius * eclipseCount * Math.Sin((Math.PI * i) / lineCount));

                double x2 = centerPoint.X + (radius * eclipseCount * Math.Cos(Math.PI * i / lineCount + Math.PI));
                double y2 = centerPoint.Y - (radius * eclipseCount * Math.Sin((Math.PI) * i / lineCount + Math.PI));

                ge.StartPoint = new Point(x1, y1);
                ge.EndPoint = new Point(x2, y2);
                p.Data = ge;
                cavMain.Children.Add(p);
            }

        }
    }

 
画雷达图背景
 

你可能感兴趣的:(背景)