Reputation: 378
First time working with ASP.NET charting and any help would be greatly appreciated! I'm trying to add a vertical line to an area chart like the following...
<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>
Has anyone ever run across this before?
Thanks!
Upvotes: 1
Views: 4045
Reputation: 15664
The way I managed to do it with a line graph is like this:
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);
My x-axis is a date which I set with the anchorX. AttendGraph is the chart control.
Upvotes: 3
Reputation: 378
Ended up adding another series of type column.
<asp:Series Name="line" ChartType="Column" Color="#D33729">
<Points>
<asp:DataPoint XValue="12" YValues="6000" />
</Points>
</asp:Series>
Upvotes: 0