在DateTime X轴上绘制Polar数据时遇到问题 [英] Having issues with plotting Polar data on a DateTime X Axis

查看:93
本文介绍了在DateTime X轴上绘制Polar数据时遇到问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图在沙盒应用程序中获得一些非常简单的极坐标图,并获得一些非常奇怪的结果.基本上,我正在尝试重新创建此问题的答案(最终它得到了稍微复杂一点,但是如果我能做到这一点,那我应该走了.)

I'm trying to get some pretty simple polar plotting going here in a sandbox app and am getting some very strange results. Basically, I'm trying to recreate the answer to this question (eventually it gets a bit more complicated, but if I can do this, I should be on my way).

这是一些有关我如何设置它的代码.

Here's some code of how I'm setting it up.

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

DateTime now = new DateTime(2012, 3, 20, 11, 24, 24);
DateTime then = now.AddHours(2.0);

var iterDate = now;
var i = 0;

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

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

chart1.Series[0].ChartType = SeriesChartType.Polar;
chart1.Series[0].Points.DataBindXY(xValues, yValues);
chart1.Series[0].XValueType = ChartValueType.DateTime;
chart1.Series[0].IsXValueIndexed = true;

chart1.ChartAreas[0].AxisX.Minimum = now.ToOADate();
chart1.ChartAreas[0].AxisX.Maximum = then.ToOADate();

chart1.ChartAreas[0].AxisX.LabelStyle.Format = "HH:mm:ss";
chart1.Series[0]["PolarDrawingStyle"] = "Line";
// setup the X grid
chart1.ChartAreas[0].AxisX.MajorGrid.Enabled = true;
chart1.ChartAreas[0].AxisX.MajorGrid.IntervalType = DateTimeIntervalType.Minutes;
chart1.ChartAreas[0].AxisX.MajorGrid.Interval = 1;
chart1.ChartAreas[0].AxisX.Crossing = 0;
// setupthe Y grid
chart1.ChartAreas[0].AxisY.MajorGrid.Enabled = true;
chart1.ChartAreas[0].Area3DStyle.Enable3D = false;

它显示如下:

2个主要问题:

  1. 为什么锯齿状?
  2. 如果我将交叉设置为0,为什么它在12:44:24网格标记周围开始和结束?

更新:

如果我更改行:

Update:

If I change the line:

DateTime now = new DateTime(2012, 3, 20, 11, 24, 24);

DateTime now = new DateTime();

该图根据需要显示:

the chart shows as desired:

我不理解这种基于开始日期的剧烈变化.

I don't understand this drastic of a change based on the start date.

推荐答案

将此解决方案发布在MSDN论坛上

Posted this on MSDN Forums here, and received an acceptable answer.

控件显然存在问题.因此,您不必将DateTime用作X值类型,而无需手动设置标签.

There's something wrong with the controls apparently. So you need to not use DateTime as the X Value Type and set the labels manually.

这篇关于在DateTime X轴上绘制Polar数据时遇到问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆