2012-06-12 30 views
1

我想以不同的顏色(星期一紅色,星期二綠色等)顯示星期中的每一天,並且我無法正確顯示圖表中的數據。
我有系列每一天。但與圖表類型:列該圖顯示每一天都非常醜陋(請參閱圖像:http://i49.tinypic.com/oszeqt.png)。
數據圖表:如何正確地與一天中的顏色來顯示各列:代碼如何在圖表中正確顯示星期幾的顏色列

     DateTime dateValue = new DateTime(2012, 5, int.Parse(tempDay)); 

        switch ((int)dateValue.DayOfWeek) 
        { 
         case 1: 
          chart1.Series["Monday"].Points.AddXY(int.Parse(tempDay), int.Parse(tempTime)); 
          break; 
         case 2: 
          chart1.Series["Tuesday"].Points.AddXY(int.Parse(tempDay), int.Parse(tempTime)); 
          break; 
         case 3: 
          chart1.Series["Wednesday"].Points.AddXY(int.Parse(tempDay), int.Parse(tempTime)); 
          break; 
         case 4: 
          chart1.Series["Thursday"].Points.AddXY(int.Parse(tempDay), int.Parse(tempTime)); 
          break; 
         case 5: 
          chart1.Series["Friday"].Points.AddXY(int.Parse(tempDay), int.Parse(tempTime)); 
          break; 
         case 6: 
          chart1.Series["Saturday"].Points.AddXY(int.Parse(tempDay), int.Parse(tempTime)); 
          break; 
         case 7: 
          chart1.Series["Sunday"].Points.AddXY(int.Parse(tempDay), int.Parse(tempTime)); 
          break; 
        } 

我的問題

01:12000 
02:12500 
03:13000 
04:13500 
05:14029 
06:14509 
07:15000 
08:15500 
09:16000 
10:16500 
11:17000 
12:17125 

位。 (我不需要單獨系列的每一天。)

回答

1

好吧,我終於找到了解決方案!

chart1.Series[0]["DrawSideBySide"] = "false"; 

之後,你必須設置列的寬度,如果太胖

chart1.Series[0]["PointWidth"] = "0.1"; 

這也可以在設計自定義屬性發現,在一系列屬性

0

不能完全確定,如果顏色本身是你的擔心,如果是這樣,我用的是這樣的:

Dim ListOfColors As List(Of String) = Utilities.BuildCustomColorPalette(firstColor) 

..

Public Shared Function BuildCustomColorPalette(colorIN As String) As List(Of String) 
     Dim arrCol() As String = {"DarkOrange", "Green", "Blue", "Yellow", "Purple", "Red", "Aqua", "Fuchsia", "Lime", "DodgerBlue", "Gold"} 
     Dim listOfColors As New List(Of String) 
     listOfColors.Add(colorIN) 
     For idx = 0 To arrCol.Length - 1 
     If listOfColors.Contains(arrCol(idx)) Then 
      'nada 
     Else 
      listOfColors.Add(arrCol(idx)) 
     End If 
     If listOfColors.Count = 10 Then 
      Return listOfColors 
     End If 
     Next 
     Return listOfColors 
    End Function 

.. 像這樣使用:

Chart.Series(Idx).Color = Color.FromName(ListOfColors(Idx)) 
+0

顏色我只是使用chart1 .Series [「Monday」]。Color = System.Drawing.ColorTranslator.FromHtml(「#C2E5EB」);顏色不是我的問題 – miky