2011-02-17 100 views
17

我正在使用MS asp.net圖表控件。我使用雷達圖來繪製一些數值,但由於某種原因,X軸的線條在中間並不真正相遇。醜陋的MS asp.net雷達圖表

我已經設置了LineWidth = 1,但該線仍然需要2像素,一些標記完全關閉,或者它可能是完全關閉的線。 也許我的文字也有點偏差,所以請看照片,希望你能理解我的問題。生成該圖表=)

enter image description here

代碼:

// Populate series data 
Chart chart1 = new Chart(); 
chart1.ChartAreas.Add(new ChartArea("ChartArea1")); 

chart1.Height = new Unit(380); 
chart1.Width = new Unit(880); 
//chart1.AntiAliasing = AntiAliasingStyles.Graphics; 
//chart1.BackColor = Color.Transparent; 
chart1.Customize += new EventHandler(Chart_Customize); 

// Show as 3D 
chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = false; 
chart1.ChartAreas["ChartArea1"].AxisY.IntervalAutoMode 
    = IntervalAutoMode.FixedCount; 
chart1.ChartAreas["ChartArea1"].AxisY.Interval = 10; 
chart1.ChartAreas["ChartArea1"].AxisY.Maximum = 100; 

chart1.ChartAreas["ChartArea1"].AxisY.IsReversed = true; 

chart1.ChartAreas[0].AxisY.LineWidth = 1; 
chart1.ChartAreas[0].AxisY.MajorGrid.LineColor = Color.Gray; 
chart1.ChartAreas[0].AxisY.LineColor = Color.Gray; 
chart1.ChartAreas[0].AxisY.MajorTickMark.Enabled = false; 

List<string> names = new List<string>(); 
int namecounter = 1; 
foreach (var p in Model.Participants) 
{ 
    if (SessionHandle.ShowNamesInDiagrams) 
    names.Add(p.Person.Name); 
    else 
    names.Add(namecounter.ToString()); 
    namecounter++; 
} 

#region firstresult 
if (SessionHandle.ShowFirstResult) 
{ 
    chart1.Series.Add(new Series("FirstResult")); 
    List<double> firstresult = new List<double>(); 
    foreach (var p in Model.Participants) 
    { 
    var resultSummary = from r in Model.ResultSummary 
         where r.userID == p.ParentID && Model 
          .Modules 
          .Where(x => x.hasResult) 
          .ToList() 
          .Exists(x => x.ID == r.moduleID) 
         select r; 
    firstresult.Add(resultSummary.Sum(x => x.scorePercent) 
        /Model.Modules.Where(x => x.hasResult).Count()); 
    } 

    chart1.Series["FirstResult"].Points.DataBindXY(names, firstresult); 
    // Set radar chart type 
    chart1.Series["FirstResult"].ChartType = SeriesChartType.Radar; 

    // Set radar chart style (Area, Line or Marker) 
    chart1.Series["FirstResult"]["RadarDrawingStyle"] = "Marker"; 
    chart1.Series["FirstResult"].Color = Color.DarkBlue; 
    chart1.Series["FirstResult"].MarkerImage 
     = Url.Content("~/Content/Images/firstresult.png"); 

    // Set circular area drawing style (Circle or Polygon) 
    chart1.Series["FirstResult"]["AreaDrawingStyle"] = "Circle"; 

    // Set labels style (Auto, Horizontal, Circular or Radial) 
    chart1.Series["FirstResult"]["CircularLabelsStyle"] = "Horizontal"; 
} 
#endregion 
+2

你能後生成的代碼圖表和圖表定義? – 2011-02-17 14:45:52

回答

2

WPF座標指的是像素,而不是角部的中心,所以儘量添加0.5到你的所有座標。爲了說明這種情況考慮下面的XAML代碼:

<Canvas> 
<Line X1="50" Y1="50" X2="100" Y2="50" Stroke="Black" StrokeThickness="1" /> 
<Line X1="50" Y1="50" X2="50" Y2="100" Stroke="Black" StrokeThickness="1" /> 
<Line X1="50" Y1="50" X2="100" Y2="100" Stroke="Black" StrokeThickness="1" /> 
</Canvas> 

這是正常,然後呈現一個0.5像素偏移應用於每個座標:

Xaml lines