向区域图添加垂直线

时间:2011-03-14 19:38:03

标签: asp.net asp.net-charts

首次使用ASP.NET图表和任何帮助将不胜感激!我正在尝试将一条垂直线添加到区域图中,如下所示......

enter image description here

<asp:Chart id="chtTriage" Width="545" BackColor="#f2f2f2" runat="server">
            <Series>
                <asp:Series Name="srs" ChartType="Area" Color="LightGray">
                    <Points>
                        <asp:DataPoint XValue="0" YValues="1000" />
                        <asp:DataPoint XValue="5" YValues="2500" />
                        <asp:DataPoint XValue="10" YValues="6000" />
                        <asp:DataPoint XValue="15" YValues="4000" />
                        <asp:DataPoint XValue="20" YValues="2500" />
                        <asp:DataPoint XValue="25" YValues="2000" />
                        <asp:DataPoint XValue="30" YValues="1500" />
                        <asp:DataPoint XValue="35" YValues="1200" />
                        <asp:DataPoint XValue="40" YValues="1000" />
                        <asp:DataPoint XValue="45" YValues="500" />
                        <asp:DataPoint XValue="50" YValues="0" />
                    </Points>
                </asp:Series>
            </Series>
            <ChartAreas>
                <asp:ChartArea Name="chaTriage" BackColor="#f2f2f2">
                    <AxisY Title="Number of Dogs" Interval="1000" IntervalType="Number" IsMarginVisible="false">
                        <LabelStyle Font="Aerial, 8.25pt" />
                        <MajorGrid Enabled="false" />
                    </AxisY>
                    <AxisX Title="Triage Points" Interval="10" IntervalType="Number" IsStartedFromZero="true" Minimum="0" IsMarginVisible="false">
                        <LabelStyle Font="Aerial, 8.25pt" />
                        <MajorGrid Enabled="false" />
                    </AxisX>
                </asp:ChartArea>
            </ChartAreas>
        </asp:Chart>

以前有没有人碰过这个?

谢谢!

2 个答案:

答案 0 :(得分:3)

我设法用折线图完成它的方式是这样的:

var dateLine = new VerticalLineAnnotation();
dateLine.AxisX = AttendGraph.ChartAreas[0].AxisX;
dateLine.AxisY = AttendGraph.ChartAreas[0].AxisY;
dateLine.LineColor = Color.DarkBlue;
dateLine.LineWidth = 2;
dateLine.LineDashStyle = ChartDashStyle.Dot;
dateLine.AnchorX = eventInfo.StartDate.AddDays(1).Date.ToOADate();
dateLine.AnchorY = 0;
dateLine.ClipToChartArea = "ChartArea1";
dateLine.IsInfinitive = true;           

AttendGraph.Annotations.Add(dateLine);

我的x轴是我用anchorX设置的日期。 AttendGraph是图表控件。

答案 1 :(得分:0)

结束添加另一系列类型列。

<asp:Series Name="line" ChartType="Column" Color="#D33729">
    <Points>
        <asp:DataPoint XValue="12" YValues="6000" />
     </Points>
</asp:Series>