Using the ASP.NET Chart Control
page 4 of 5
by Brian Mains
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 11265/ 352

Custom Labels

The .NET charting control provides the ability to create custom labels for the X or Y axis.  This means that anyone has full control over the text that renders along the axis line.  For example, take a look at the following example.

<AxisX>
      <CustomLabels>
            <asp:CustomLabel FromPosition="2004.5" ToPosition="2005.5"
                  Text="Store Opening" />
            <asp:CustomLabel FromPosition="2008.5" ToPosition="2009.5"
                  Text="Current Year" />
      </CustomLabels>
</AxisX>

Based upon this list of custom labels, the X axis value for the year 2005 will be transformed to the text "Store Opening", and the current year's axis value will be transformed to "Current Year".

You may be wondering why I use values like 2004.5.  I tend to use half decimal points and search for a range.  The reasoning is that the X and Y values are doubles, and sometimes even though a value is 16, it may really be 15.999999999999999999999 or 16.000000000000001, and thus searching for an exact value may not produce the actual result.  This is one of the many tidbits of knowledge that I learned from reading Steve McConnell's Code Complete.

And so I tend to choose values I'm certain will be a match.  I could have used 2004.9 and 2005.1 to fit within the range, which would have been perfectly fine; I just tend to use .5 for whatever reason that may be.


View Entire Article

Article Feedback

Title:  
Name:  
Url: ( Optional )
Comment:  
Please add 2 and 4 and type the answer here:

User Comments

Title: Great article   
Name: Kedar Periyapatna
Date: 10/9/2009 9:36:46 PM
Comment:
Hey ... i really appreciate your work .. very simple and clear explanation of asp.net Chart ... I do have one question ... as in WPF charts .. can I highlight every point of intersection b/w X and Y point by a thick dot .... thank u again
Title: MS CHART IS VERY GOOD   
Name: MOHAMMAD JAVED
Date: 8/29/2009 12:29:22 AM
Comment:
I USED MS CHART CONTROL ON AN APPLICATION IT HAS ALL FEATURES BUT SOME FEATURES ARE NOT MENTIONED.
BUT ITS IMPLEMENTATION AND USE ARE VERY EASY.
Title: Loving the MS Chart Control   
Name: Duncan
Date: 3/30/2009 10:28:22 PM
Comment:
I used the MSCC to build an application to track my mass(kg), body-fat(%) and body-water(%). It was a little intimidating at first, but by the end of a week I was comfortable with the control. It can be hard to set up on an ISP as it expects installation (not just upload of .dll to your /bin directory) and/or seems to require write permissions (even when set to persist the image to memory), but YMMV -- I'm happy with it. I really appreciated all the examples the author provided, which is also why I appreciate this article! Thanks!

Product Spotlight
Product Spotlight 






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2009 ASPAlliance.com  |  Page Processed at 11/21/2009 8:07:47 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search