Use Microsoft chart to create charts

Source: Internet
Author: User

---------------------------------- The copyright in this article is owned by willpan. for reprinting, please indicate the source ---------------------------------------------------------------------

ASP. NET provides the ability to use the datavisualization. dll dynamic class library to create charts of various styles. First, we will introduce the data tables and project structures used in this example.

Project Structure:

Database table structure:

Source code:Http://www.cnblogs.com/willpan/admin/Files.aspx

First, let's look at the effect after running:

Daily statistics:

Weekly Statistics:

Source code explanation:

View code

1 <asp: chart id = "chart1" runat = "server" Height = "350px" width = "750px" imagetype = "PNG" borderdashstyle = "solid" backgradientstyle = "topbottom" backsecondarycolor = "White "palette =" brightpastel "bordercolor =" 26, 59,105 "backcolor =" # d3dff0 "borderwidth =" 2 ">
2 <legends>
3 <asp: legend legendstyle = "row" istextautofit = "false" dockedtochartarea = "chartarea1" Docking = "Left" name = "default" backcolor = "Transparent" font = "trebuchet MS, 8.25pt, style = bold "titlefont =" Microsoft sans serif, 8pt, style = bold "> </ASP: Legend>
4 </legends>
5 <borderskin skinstyle = "emboss"> </borderskin>
6 <Series>
7 <asp: series name = "Series1" backgradientstyle = "verticalcenter" isvalueshownaslabel = "false" chartarea = "chartarea1" customproperties = "labelstyle = bottom" bordercolor = "180, 26, 59,105 "labelformat =" # "charttype =" column ">
8 </ASP: Series>
9 </series>
10 <chartareas>
11 <asp: chartarea name = "chartarea1" bordercolor = "64, 64, 64, 64 "backsecondarycolor =" white "backcolor =" oldlace "shadowcolor =" Transparent "backgradientstyle =" topbottom ">
12
13 <area3dstyle rotation = "10" Perspective = "10" Inclination = "15" isrightangleaxes = "false" wallwidth = "0" isclustered = "false"> </area3dstyle>
14 <axisy linecolor = "64, 64, 64, 64" islabelautofit = "false" arrowstyle = "Triangle">
15 <labelstyle font = "trebuchet MS, 8.25pt, style = bold"/>
16 <majorgrid linecolor = "64, 64, 64, 64"/>
17 </axisy>
18 <axisx linecolor = "64, 64, 64, 64" islabelautofit = "false" arrowstyle = "Triangle" Title = "time" interval = "1">
19 <labelstyle font = "trebuchet MS, 8.25pt, style = bold"/>
20 <majorgrid linecolor = "64, 64, 64, 64"/>
21 </axisx>
22 </ASP: chartarea>
23 </chartareas>
24 </ASP: Chart>

You can see the <asp: Chart> </ASP: Chart> label, which is the root label (Chart label ).

Including <legends>, <borderskin>, <Series>, and <chartareas>.

<Legends> defines the description of a chart,

<Borderskin> defines the chart skin, which is an enumeration value. Control by skinstyle = "emboss.

<Series> used to bind data. The attribute charttype = "column" indicates that the chart is a column chart, which is also an enumeration type. Attribute chartarea = "chartarea1" indicates the chart display area

You can bind data in the background as follows: chart1.series ["Series1"]. points. addxy (row ["X"], row ["Y"]. tostring (); determines the point by horizontal and vertical coordinates.

<Chartareas> defines the chart display area. You can add multiple <asp: chartarea> </ASP: chartarea> On the tag side.

You can define horizontal and vertical coordinates in the <asp: chartarea> label. For example, add the vertical coordinates <axisy> </axisy> and horizontal coordinates <axisx> </axisx>.

Linecolor indicates the color of the horizontal and vertical coordinates, arrowstyle indicates the arrow style, title indicates the title of the horizontal and vertical coordinates, and interval indicates the interval. The default value is 0.

All the preceding labels and attributes can be found in the system. Web. datavisualization. xml file.

------------------------------------------------------------ The purpose of the shared communication is to improve -----------------------------------------------------------------------

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.