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;
And it shows up as this:
2 main questions:
- Why is it jagged?
- Why does it start and end around the 12:44:24 grid marker if I set my crossing to 0?
Update:
If I change the line:
DateTime now = new DateTime(2012, 3, 20, 11, 24, 24);
to
DateTime now = new DateTime();
the chart shows as desired:
I don't understand this drastic of a change based on the start date.