MS图雷达轴频率

发布于 2024-11-28 12:21:40 字数 2227 浏览 0 评论 0原文

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

该图表包含 1 天的数据,我有每秒的数据,所以我有 86 400 个 xy 值对。 X 轴包含日期,y 轴包含 int 值。

我的测试代码是这样的:

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;

结果视图是这样的: 在此处输入图像描述

我认为“黑圈效应”的原因是它每 86 400 个点绘制 y 轴。我怎样才能设置它只在每小时绘制这些轴?

x 轴的标签(我设置的日期)不会出现。我怎样才能向他们展示?

提前谢谢!

.net4/c#/winforms/vs2010

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

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.

My test code is like this:

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;

Result view is like this:
enter image description here

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?

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

Thx in advance!

.net4/c#/winforms/vs2010

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

离不开的别离 2024-12-05 12:21:40

您可能想使用“极地”图而不是“雷达”。类似的东西会让你更接近你想要的我认为:

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;

极坐标图

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;

Polar plot

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文