Prabath Yapa
Prabath Yapa

Reputation: 1229

asp.net chart: final series getting cut off when setting .AxisX.Maximum

I'm trying to bind a data table like,

month       value
  5          345
  10         1300
  12         450

to an ASP.NET Chart control. My problem is that the data table only contain months that have values while in the chart i want to show the full month range from 1st to the 12th.

So i used

Chart1.ChartAreas["ChartArea1"].AxisX.Minimum = 1;
Chart1.ChartAreas["ChartArea1"].AxisX.Maximum = 12;

But when i do this, a part of the final series gets cut off in the middle like this.

alt text

I can avoid this issue by making the maximum 13 but that would not be appropriate since i just need to show the months of the year. Please help.

Upvotes: 3

Views: 2270

Answers (2)

atconway
atconway

Reputation: 21304

Yes but look at how the x-axis is measured; it is not just 12, then 13. It is 12.2, 12.4, 12.6, 12.8 and then 13.0. So you see if you make 12.0 the maximum you are not going to get the entire bar for the final month. Also your x-axis shouldn't even be on that interval in the 1st place. It should be in whole numbers only since you are measuring months.

An example of using the "Interval" property on an Axis in a bar chart:

<axisx Title="MyValue" Interval="1" IsMarginVisible="false">

I use ASP.NET charts a lot, and the best site is the one below. I highly recommend downloading the FULL .NET project and look at the samples and code. These types of bar charts are trivial, as you will see after looking at some of the examples in the .aspx sample pages.

Samples Environment for Microsoft Chart Controls:
http://code.msdn.microsoft.com/mschart/Release/ProjectReleases.aspx?ReleaseId=4418

Upvotes: 3

Related Questions