MS chart - Dynamically setting the height on the basis of the number of records returned.

Hello there,

I have an MS chart control, a range bar chart which displays a set of names on the X axis and Dates on the Y axis. The chart displays the data properly to a certain number of records but when the data retrieved is too large It is not at all possible to read the data because it is too tiny.

Is there a way I can increase the height of the control on the basis of the records retrieved and also, is it possible to fix the height of the series manually.

Thanks,

CPM
virtualmenonAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
EspavoConnect With a Mentor Commented:
Here's some VB as to how I manage the size of my Charts in an app... (This is a Bar Graph)
Espavo

Dim Chart1 As New Chart
Chart1.IsMapEnabled = "False"
Chart1.ImageStorageMode = ImageStorageMode.UseImageLocation
Chart1.ImageLocation = "~/temp/ChartPic_#SEQ(300,10)" 
 

'Calculate the height, based on the number Chart Points (+ Legend)
'cZ is the count of the number of items on the chart
Dim cHeight As Int32 = ((cZ + 1) * 22) + 80
Chart1.Height = Unit.Pixel(cHeight)

Open in new window

0
 
ericathomeCommented:
Here is a reference to properties on the MS Chart Control:
http://msdn.microsoft.com/en-us/library/5xeba95d(VS.71).aspx

You can set the Maximum property if you desire to the MAX(value) of the range of values being placed in the chart. However, assigning a value to Maximum changes the ValueScale property Auto to False. See the web page at the link above (Maximum and ValueScale links) for more details.

Here is a link to an example working with the AxisScale object: http://msdn.microsoft.com/en-us/library/2cz3ktky(v=VS.71).aspx 

Let me know if you need more detail.

Thanks, Eric
0
 
virtualmenonAuthor Commented:
hello eric,

Could you give me a simple example where I can fix the series height to be a certain percentage of the chart height..

thanks,
cpm
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
virtualmenonAuthor Commented:
Can i set the height of the chart area dynamically..??
0
 
ericathomeCommented:
Espavo, thanks for adding a great example.
VirtualMenon, if by dynamically you mean in the code behind, the answer demonstrated above is yes. Espavo provided a good example, let us know if you need anything else to finish the solution.
Eric
 
0
 
virtualmenonAuthor Commented:
Awesome example Espavo. Thanks a lot mate...Worked like a gem.

Thanks,

CPM
0
 
virtualmenonAuthor Commented:
Excellent
0
All Courses

From novice to tech pro — start learning today.