画雷达图背景

直接糊代码

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);
            }

        }
    }

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值