PsychoDUCK PsychoDUCK - 4 months ago 36
ASP.NET (C#) Question

ASP.NET Chart Column Widths

I have the following ASP.NET dynamic chart below. How do I puta lines going down the chart for each date on the x axis. There are currently 3 lines going down the y axis, Jul 2009, May 2010, and Mar 2011. I want a line for each date, so you can see each point on the line and I also want to display each date that a point is placed on the chart.

Also, there seems to padding at the start and end of the chart and no right border. How do I get rid of the padding and get the right border in place?

chart image

Here is my code:

Front End:

<asp:Chart ID="chtReport" runat="server" Width="650px" Height="400px" ImageType="Jpeg">
<asp:Series Name="TotalLine" YValueType="Double" ChartType="Line" ChartArea="MainChartArea" />
<asp:Series Name="GoalLine" YValueType="Double" ChartType="Line" ChartArea="MainChartArea" />
<asp:Series Name="AverageLine" YValueType="Double" ChartType="Line" ChartArea="MainChartArea" />
<asp:Series Name="TotalPoint" YValueType="Double" ChartType="Point" ChartArea="MainChartArea" />
<asp:Series Name="GoalPoint" YValueType="Double" ChartType="Point" ChartArea="MainChartArea" />
<asp:Series Name="AveragePoint" YValueType="Double" ChartType="Point" ChartArea="MainChartArea" />
<asp:ChartArea Name="MainChartArea">

Back End

protected void Page_Load(object sender, EventArgs e)
for (DateTime date = startDate; date <= ChartDetails.EndDate; date = date.AddMonths(1))

grdChart.DataSource = dates;

chtReport.ChartAreas["MainChartArea"].AxisY.Minimum = 0;
chtReport.ChartAreas["MainChartArea"].AxisY.Maximum = 100;
chtReport.ChartAreas["MainChartArea"].AxisX.Title = "Date Range";
chtReport.ChartAreas["MainChartArea"].AxisY.Title = "Percent";

protected void grdChart_ItemDataBound(object sender, DataGridItemEventArgs e)
// Extra Code above...

chtReport.Series["TotalLine"].Points.AddXY(rowDate.ToString("MMM yyyy"), total);
chtReport.Series["GoalLine"].Points.AddXY(rowDate.ToString("MMM yyyy"), total);
chtReport.Series["AverageLine"].Points.AddXY(rowDate.ToString("MMM yyyy"), total);

chtReport.Series["GoalPoint"].Points.AddXY(rowDate.ToString("MMM yyyy"), total);
chtReport.Series["AveragePoint"].Points.AddXY(rowDate.ToString("MMM yyyy"), total);

Thanks in advance for any help.


I added the following line of code and I now have the grid lines I was looking for.

chtReport.ChartAreas["MainChartArea"].AxisX.Interval = 1;