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

Conclusion

The free .NET chart control available from Microsoft contains a subset of components originally created by Dundas.  This component is a full-fledged charting component rendering bar, line, pie, or statistical charts in a windows or web UI.  The chart component has many features available to the user, so many that it's often hard to tell what each feature does.

The chart control uses Series and DataPoints to render a chart within a chart region defined by the ChartArea object.  Charts can be 2D or 3D depending on the settings, and the developer has control over colors, borders, fonts, lines, rendering region, and other styling of the chart.

The final result of the markup above, with some added styles, produces the following chart.

The final charting markup looks like the following.

<asp:Chart ID="chSalesData" runat="server" BackGradientStyle="DiagonalLeft" 
    BackColor="LightBlue">
  <Titles>
    <asp:Title Visible="false" />
   </Titles>
   <Legends>
    <asp:Legend Name="DefaultLegend" Docking="Top" />
   </Legends>
   <ChartAreas>
     <asp:ChartArea Name="MainChart">
       <InnerPlotPosition X="10" Y="10" Height="80" Width="80" />
       <AxisX>
         <LabelStyle Enabled="true" />
         <MajorGrid LineWidth="1" />
         <MajorTickMark Enabled="false" />
         <CustomLabels>
           <asp:CustomLabel FromPosition="2004.5" ToPosition="2005.5"
            Text="Store Opening" />
           <asp:CustomLabel FromPosition="2005.5" ToPosition="2006.5" 
            Text="2006" />
           <asp:CustomLabel FromPosition="2006.5" ToPosition="2007.5" 
            Text="2007" />
           <asp:CustomLabel FromPosition="2007.5" ToPosition="2008.5" 
            Text="2008" />
           <asp:CustomLabel FromPosition="2008.5" ToPosition="2009.5" 
            Text="Current Year" />
         </CustomLabels>
       </AxisX>
       <AxisY>
         <LabelStyle Enabled="true" />
         <MajorGrid LineWidth="1" />
         <MajorTickMark Enabled="false" />
       </AxisY>
     </asp:ChartArea>
   </ChartAreas>
   <Series>
     <asp:Series Name="Bicycles" ChartArea="MainChart" ChartType="Line" 
       BackGradientStyle="TopBottom" BackSecondaryColor="LightYellow">
       <Points>
         <asp:DataPoint XValue="2009" Yvalues="5,350.16" />
         <asp:DataPoint XValue="2008" Yvalues="23,551.97" />
         <asp:DataPoint XValue="2007" Yvalues="29,337.62" />
         <asp:DataPoint XValue="2006" Yvalues="16,098.52" />
         <asp:DataPoint XValue="2005" Yvalues="15,929.23" />
       </Points>
     </asp:Series>
   </Series>
 </asp:Chart>

View Entire Article

Article Feedback

Title:  
Name:  
Url: ( Optional )
Comment:  
Please add 3 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-2010 ASPAlliance.com  |  Page Processed at 3/12/2010 4:47:13 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search