将StripeLine放置在系列之上(调整Z-Index/Z-Order)

Gre*_*reg 1 asp.net charts data-visualization mschart asp.net-4.0

我正在构建一个柱形图,System.Web.UI.DataVisualization.Charting并希望显示一条虚线来表示平均值.StripeLine似乎正是我正在寻找的,除了它位于列的下方/后面(参见示例).

有没有办法调整a的"Z-Index" StripeLine,使其显示在?的前面/上方Series

我没有看到这个属性,并改变我添加的顺序Series,StripeLine并没有什么区别.

示例图表

Qua*_*uff 7

您可以使用注释

double avg = Chart1.Series[0].Points.Average(p => p.XValue);
double lineHeight = avg;
HorizontalLineAnnotation ann = new HorizontalLineAnnotation();
ann.AxisX = Chart1.ChartAreas[0].AxisX;
ann.AxisY = Chart1.ChartAreas[0].AxisY;
ann.IsSizeAlwaysRelative = false;
ann.AnchorY = lineHeight;
ann.IsInfinitive = true;
ann.ClipToChartArea = Chart1.ChartAreas[0].Name; ann.LineColor = Color.Red; ann.LineWidth = 3;
Chart1.Annotations.Add(ann);
Run Code Online (Sandbox Code Playgroud)

HTML代码

<asp:Chart runat="server" ID="Chart1"   ImageStorageMode="UseImageLocation"  Width="800px" Height="400px" OnClick="Chart1_Click">
    <ChartAreas  >
    <asp:ChartArea></asp:ChartArea>
    </ChartAreas>
    <series>  
           <asp:Series Name="Students" BorderColor="180, 26, 59, 105">  
            <Points>
                <asp:DataPoint AxisLabel="jon" XValue="5" YValues="4" />
                <asp:DataPoint AxisLabel="kon" XValue="15" YValues="44" />
                <asp:DataPoint AxisLabel="pol" XValue="85" YValues="90" />
            </Points>
           </asp:Series>                        
      </series> 
</asp:Chart>
Run Code Online (Sandbox Code Playgroud)

文本注释代码

TextAnnotation txtAnn = new TextAnnotation();
txtAnn.AxisX = Chart1.ChartAreas[0].AxisX;
txtAnn.AxisY = Chart1.ChartAreas[0].AxisY;
txtAnn.IsSizeAlwaysRelative = false;
txtAnn.AnchorY = lineHeight;
txtAnn.AnchorX = Chart1.Series[0].Points.Last().XValue;
txtAnn.AnchorAlignment = ContentAlignment.BottomLeft;
txtAnn.Text = "DivisionOne(35.5)";
txtAnn.ClipToChartArea = Chart1.ChartAreas[0].Name; txtAnn.ForeColor =  Color.Red; 
Chart1.Annotations.Add(txtAnn);
Run Code Online (Sandbox Code Playgroud)

您可以在此处获取更多信息

有关注释的更多信息

图表图像