2013-06-04 20 views
1

我需要一些圖表顯示我們客戶的發展。 因爲今年的數據仍然在變化,所以我也想'突出'當年的區域。用boxobj標記當前年份(zedGraph和C#)

因爲圖片是超過1000個字好:

這是我目前的圖形: enter image description here

,它應該是這樣的: enter image description here

(我知道2012年是不是當前年份,這些只是一些示例數據;))

不幸的是,zedGraph s boxObj真的很煩人,我無法以任何方式讓它工作。

這是迄今爲止我圖形代碼:

 graphControl.GraphPane.CurveList.Clear(); 

     graphControl.GraphPane.Title.Text = "Umsatz-Jahresvergleich von " + kunde.Name; 
     graphControl.GraphPane.XAxis.Title.Text = "Jahr"; 
     graphControl.GraphPane.YAxis.Title.Text = "Umsatz in €"; 

     ArrayList arrYears   = new ArrayList(); 
     List<String> lstYearStrings = new List<string>(); 
     double[] xValue2 = new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; 

     ArrayList arrActYear = new ArrayList(); 
     foreach (KeyValuePair<int, Jahresumsatz> kvp in kunde.Umsaetze.OrderBy(key => key.Key)) 
     { 
      arrYears.Add(kvp.Value.UmsatzNetto); 
      lstYearStrings.Add(kvp.Value.Jahr.ToString()); 
     } 

     graphControl.GraphPane.XAxis.Scale.TextLabels = lstYearStrings.ToArray(); 
     graphControl.GraphPane.XAxis.Type = AxisType.Text; 
     graphControl.GraphPane.XAxis.Scale.FontSpec.Angle = 90; 

     LineItem curve = graphControl.GraphPane.AddCurve("Umsatz im Jahresvergleich", xValue2, (double[])arrYears.ToArray(typeof(double)), Color.Red, SymbolType.Circle); 
     curve.Line.Fill = new Fill(Color.White, Color.FromArgb(160, 230, 145, 205), 90F); 
     curve.Symbol.Fill = new Fill(Color.Red); 


     /* One of my many experiments with BoxObj... it's not working of cause :(
     BoxObj box = new BoxObj(0.5, 0.5, 40, 40, Color.Empty,Color.FromArgb(150, Color.LightGreen)); 
     box.Fill = new Fill(Color.White, Color.FromArgb(200, Color.LightGreen), 45.0F); 
     box.ZOrder = ZOrder.E_BehindCurves; 
     box.IsClippedToChartRect = true; 
     box.Location.CoordinateFrame = CoordType.AxisXYScale;*/ 

     graphControl.GraphPane.GraphObjList.Add(box); 

     graphControl.GraphPane.AxisChange(); 

     graphControl.Refresh(); 

這將是非常酷的,如果有人可以幫助我這一個。

順便說一下,BoxObj需要以某種方式動態化,以便與圖形成比例,如果選定的年份不同,仍然適合。

提前

回答

2

非常感謝我嘗試下面的東西沿着你有什麼,看到透明的綠色矩形的線條:

BoxObj box = new BoxObj(3, 70, 1, 70, Color.Empty,Color.FromArgb(100, Color.LightGreen)); 
box.Fill = new Fill(Color.White, Color.FromArgb(120, Color.LightGreen), 45.0F); 
box.ZOrder = ZOrder.A_InFront; 
box.IsClippedToChartRect = true; 
box.Location.CoordinateFrame = CoordType.AxisXYScale; 
+0

嘿,感謝您的回答。它仍然沒有按預期工作,但你指出了我的正確方向;) – user1567896

相關問題