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

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

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 4:16:07 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search