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): 48392/ 52

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

User Comments

Title: o   
Name: o
Date: 2012-12-03 3:54:11 AM
Comment:
o
Title: complaint   
Name: salman
Date: 2012-10-05 1:32:49 AM
Comment:
not goog
Title: Test   
Name: Test
Date: 2012-09-07 6:11:24 AM
Comment:
Test
Title: Nothing   
Name: Sean
Date: 2011-11-13 10:30:55 PM
Comment:
There's no article to read......
Title: it doesn't work   
Name: EnriqueAguilar
Date: 2010-12-23 1:35:26 PM
Comment:
Copy the complete example and does not work, shipping the example copied and error
Error executing child request for ChartImg.axd.
You can say what'S wrong?
code: can not send
Title: Good One   
Name: B.Raj
Date: 2010-11-17 2:19:44 AM
Comment:
Good article
Title: brainy   
Name: gayathri
Date: 2010-09-23 2:25:18 AM
Comment:
great article
thank you so much
Title: Great article   
Name: Kedar Periyapatna
Date: 2009-10-09 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: 2009-08-29 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: 2009-03-30 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-2024 ASPAlliance.com  |  Page Processed at 2024-04-26 8:36:38 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search