MS chart radar axis frequency
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,
Date开发者_如何学PythonTime.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:
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
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;
精彩评论