2011-08-08 13 views
5

Me gustaría dibujar un gráfico de radar usando el control MS Chart en una aplicación WinForms.MS chart radar axis frequency

Este cuadro contiene datos para 1 día, tengo datos para cada segundo, así que tengo 86 400 x-y pares de valores. El eje X contiene fechas, y mis valores int.

Mi código de prueba es la siguiente:

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; 

vista de resultados es la siguiente: enter image description here

Creo que la razón del 'efecto de círculo negro' es que llama eje y por cada 86 400 puntos. ¿Cómo puedo configurarlo para dibujar estos ejes solo a cada hora?

Las etiquetas (fechas como las configuré) para x ejes no aparecen. ¿Cómo puedo mostrarlos?

¡Thx por adelantado!

.net4/C#/WinForms/VS2010

Respuesta

3

Es posible que desee utilizar una parcela "polar" en lugar de "Radar". Algo así como que le conseguirá más cerca de lo que usted quiere que pienso:

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

+0

Gracias por su ayuda! – Tom