本文介绍了MS海图雷达轴频率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在WinForms应用中使用MS Chart控件绘制雷达图.

I'd like to draw a radar chart using MS Chart control in a WinForms app.

此图表包含1天的数据,每秒钟都有我的数据,所以我有86 400个x-y值对. X轴包含日期,y表示我的int值.

This chart contains data for 1 day, I have data for every seconds, so I have 86 400 x-y value pairs. X axis contains dates, y my int values.

我的测试代码如下:

var fromDate =  new DateTime(DateTime.Now.Year,
                                         DateTime.Now.Month,
                                         DateTime.Now.Day,
                                         0,
                                         0,
                                         0);

            var toDate = new DateTime(DateTime.Now.Year,
                                      DateTime.Now.Month,
                                      DateTime.Now.Day,
                                      23,
                                      59,
                                      59);

            List<DateTime> xValues = new List<DateTime>();
            List<double> yValues = new List<double>();

            var iterDate = fromDate;
            var i = 0;

            while (iterDate <= toDate)
            {
                xValues.Add(iterDate);
                yValues.Add(i);

                iterDate = iterDate.AddSeconds(1);
                i++;
            }

            chart1.Series["Default"].Points.DataBindXY(xValues, yValues);

            var dateLabelStyle = new LabelStyle();
            dateLabelStyle.Format = "HH:mm:ss";
            chart1.ChartAreas["Default"].AxisX.LabelStyle = dateLabelStyle;

            chart1.ChartAreas["Default"].AxisX.Minimum = fromDate.ToOADate();
            chart1.ChartAreas["Default"].AxisX.Maximum = toDate.ToOADate();

            chart1.Series["Default"].IsXValueIndexed = true;
            chart1.Series["Default"].ChartType = SeriesChartType.Radar;
            chart1.Series["Default"]["RadarDrawingStyle"] = "Line";
            chart1.Series["Default"]["AreaDrawingStyle"] = "Circle";
            chart1.Series["Default"]["CircularLabelsStyle"] = "Horizontal";
            chart1.ChartAreas["Default"].Area3DStyle.Enable3D = false;

结果视图如下:

我认为黑圈效应"的原因是它每86400点绘制y轴.如何设置它仅每隔几个小时绘制一次这些轴?

I think the reason of the 'black circle effect' is that it draws y axis for every 86 400 points. How can I set it to draw these axes only at every hours?

x轴的标签(我设定的日期)没有出现.我怎么给他们看?

Labels (dates as I set) for x axes do not appear. How can I show them?

提前谢谢!

.net4/c#/winforms/vs2010

.net4/c#/winforms/vs2010

推荐答案

您可能想使用极坐标"图而不是雷达".那样的事情会让您更接近您想要的想法:

You probably want to use a "Polar" plot instead of "Radar". Something like that will get you closer to what you want I think:

chart1.Series["Default"].ChartType = SeriesChartType.Polar;
chart1.Series[0]["PolarDrawingStyle"] = "Line";
// setup the X grid
chart1.ChartAreas["Default"].AxisX.MajorGrid.Enabled = true;
chart1.ChartAreas["Default"].AxisX.MajorGrid.IntervalType = DateTimeIntervalType.Hours;
chart1.ChartAreas["Default"].AxisX.MajorGrid.Interval = 1;
chart1.ChartAreas["Default"].AxisX.Crossing = 0;
// setupthe Y grid
chart1.ChartAreas["Default"].AxisY.MajorGrid.Enabled = true;

这篇关于MS海图雷达轴频率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 07:55