问题描述
我建立一个柱形图与 System.Web.UI.DataVisualization.Charting
和希望显示虚线重新present的平均水平。 StripeLine 似乎正是我要找的只是它位于下/列的后面(见例)。
I'm building a Column chart with System.Web.UI.DataVisualization.Charting
and would like to show a dotted line to represent an average. StripeLine seems to be exactly what I'm looking for except it sits under/behind the columns (see example).
有没有办法来调整Z-指数的 StripeLine
,使其在前面显示/之上的系列
?
Is there a way to adjust the "Z-Index" of a StripeLine
so that it is shown in front of/on top of the Series
?
我没有看到这个属性,并改变我添加系列
和 StripeLine
没有按'订单ŧ有所作为。
I don't see a property for this and changing the order I add the Series
and StripeLine
doesn't make a difference.
推荐答案
您可以使用注释
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);
HTML code
HTML Code
<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>
code为文本批注
Code for Text Annotation
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);
您可以在这里获得更多的信息。
You can get more information here
这篇关于将StripeLine在顶级系列(调整Z-指数/ Z顺序)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!