2011-11-15 29 views
3

我有一個Chart控件,有一些列和GridLines。我想在Chart上的特定位置添加一個紅色的StripLine,以表明這是可接受的級別(或其他)。ASP.NET Chart StripLine通過GridLine

問題是帶狀線沒有顯示,因爲網格線隱藏它!帶狀線和網格線一樣只有1點寬度。

有沒有一種方法可以繪製帶狀線在網格線上而不是在它下面?

由於

+0

這是使用tablix控件嗎?如果是這樣,我最近發佈了一個類似的問題,在這裏:http://stackoverflow.com/questions/8147492/ssrs2008-how-do-i-draw-a-stripline-over-the-top-of-chart-data – Codingo

回答

7

添加follwing代碼在y軸上5-9.5位置,以查看帶狀線。我相信它會工作

// Instantiate new strip line 
    StripLine stripLine1 = new StripLine(); 
    stripLine1.StripWidth = 0; 
    stripLine1.BorderColor = System.Drawing.Color.RoyalBlue; 
    stripLine1.BorderWidth = 3; 
    stripLine1.Interval = 5; 

    // Consider adding transparency so that the strip lines are lighter 
    stripLine1.BackColor = System.Drawing.Color.RosyBrown; 

    stripLine1.BackSecondaryColor = System.Drawing.Color.Purple; 
    stripLine1.BackGradientStyle = GradientStyle.LeftRight; 

    // Add the strip line to the chart 
    Chartname.ChartAreas[0].AxisY.StripLines.Add(stripLine1); 

    StripLine stripLine2 = new StripLine(); 
    stripLine2.StripWidth = 0; 
    stripLine2.BorderColor = System.Drawing.Color.RoyalBlue; 
    stripLine2.BorderWidth = 3; 
    stripLine2.Interval = 9.5; 

    // Consider adding transparency so that the strip lines are lighter 
    stripLine2.BackColor = System.Drawing.Color.RosyBrown; 

    stripLine2.BackSecondaryColor = System.Drawing.Color.Purple; 
    stripLine2.BackGradientStyle = GradientStyle.LeftRight; 

    // Add the strip line to the chart 
    Chartname.ChartAreas[0].AxisY.StripLines.Add(stripLine2);