Introduction to ASP. NET Report controls

Source: Internet
Author: User

OWC seems to be mostly used by many users, but some netizens complained in the post that OWC needed a License book for use, so they excluded it, I don't want the BOSS to pop up a "no license book" window when reading the report.

Then we found the various types of ComponentOne Web charts, with excellent results. I was so fascinated by it that I decided to keep it. So I immediately went down to the installation file of the latest version of 100 M and found a usable registration code in the morning, and I found another tutorial, OK, everything is ready, and you are eager to start writing code. The requirement is not complex. Just draw multiple line charts on a single page. Based on past experience, this large commercial sharing software can definitely deal with two Example on the official site for at most one hour. However, I am very annoyed by the results. The official Example is simply not provided. What AJAX do you get and a lot of code to implement the auxiliary effect, the three or four lines of the core you are looking for cannot be found, as if you were afraid that you would suddenly understand its Example. I have always hated such software. As a result, a day has passed.

Fortunately, I found the Web Chart. The code is super concise and the effect is good. Write some simple examples of ASP. NET Report controls for your reference:

ASP. NET Report controls 1. line chart

 
 
  1. // Reference the namespace
  2. Using WebChart;
  3.  
  4. // Define a color array to fill different colors for different records during the loop
  5. Private string []MyColor=NewString []
  6. {
  7. "Tomato", // Tomato
  8. "Black ",
  9. "Gold ",
  10. "Blue ",
  11. "Green ",
  12. "Orange ",
  13. "Pink", // Pink
  14. "Violet", // Violet
  15. "Orchid", // lavender
  16. "Lime", // bright green
  17. "Tan", // Brown
  18. "Red ",
  19. "Navy" // orange
  20. };
  21.  
  22. // The static method is used as an example to draw the simplest line of two points. The actual project loops accordingly.
  23. Private void doIt ()
  24. {
  25. // Create a line Object
  26. LineChartMyChart=NewLineChart ();
  27. // Fill the line color
  28. MyChart. Line. Color= Color. FromName (myColor [0]);
  29. MyChart. Fill. Color= Color. FromName (myColor [0]);
  30. MyChart. LineMarker=NewDiamondLineMarker (8, Color. FromName (myColor [0]), Color. FromName (myColor [0]);
  31. // Legend
  32. MyChart. Legend="Line 1";
  33. // Add the first vertex. Parameter 1 is the name of the x coordinate, and parameter 2 is the value of the y coordinate.
  34. MyChart. Data. Add (new ChartPoint ("1", float. Parse ("100 ")));
  35. // Add the second Vertex
  36. MyChart. Data. Add (new ChartPoint ("2", float. Parse ("200 ")));
  37. // Chart is the Control ID.
  38. This. chart. Charts. Add (myChart );
  39. This. chart. RedrawChart ();
  40. }

ASP. NET Report controls 2. Bar Chart

 
 
  1. // Color array
  2. Private string []MyColor=NewString []
  3. {
  4. "Fuchsia ",
  5. "Black ",
  6. "Gold ",
  7. "Blue ",
  8. "HotPink ",
  9. "Orange ",
  10. "Peru ",
  11. "DodgerBlue ",
  12. "Lime ",
  13. "Tan ",
  14. "Red ",
  15. "GreenYellow ",
  16. "DarkGreen ",
  17. "DimGray ",
  18. "Orchid"
  19. };
  20.  
  21. // Call this method to generate a bar chart
  22. Private void bindchart ()
  23. {
  24. // Obtain a DataTable. The specific function is omitted...
  25. DataTableDt=This. Getdt ();
  26. If (dt! = Null)
  27. {
  28. If (dt. Rows. Count>0)
  29. {
  30. // Traverse the DataTable to generate a column for each record
  31. For (intI=0; I< Dt. Rows. Count; I ++)
  32. {
  33. // Create an object
  34. ColumnChartMychart=NewColumnChart ();
  35. // Set the column width
  36. Mychart. MaxColumnWidth=48;
  37. // Color
  38. Mychart. Fill. Color= Color. FromName (this. myColor [I]);
  39. // Display the quantity on the column
  40. Mychart. DataLabels. Visible=True;
  41. // Number of fonts
  42. Mychart. DataLabels. Font=NewFont ("Verdana", 14 );
  43. // Add
  44. Mychart. Data. Add (new ChartPoint ("", float. Parse (dt. Rows [I] ["num"]. ToString ())));
  45. // Remarks
  46. Mychart. Legend=Dt. Rows [I] ["name"]. ToString ();
  47. This. chart. Charts. Add (mychart );
  48. }
  49. // Auxiliary settings
  50. // Background color
  51. Chart. Background. Color= Color. FromArgb (165, 0, 16 );
  52. Chart. YAxisFont. ForeColor= Color. FromArgb (165, 0, 16 );
  53. Chart. XAxisFont. ForeColor= Color. FromArgb (165, 0, 16 );
  54. // Internal line
  55. Chart. Border. Color= Color. FromArgb (200,200,200 );
  56. // Border Style
  57. Chart. BorderStyle= BorderStyle. None;
  58. // Maximum value of y
  59. DoubleMax=Double. Parse (dt. Compute ("MAX (num)", ""). ToString ());
  60. // Increment Value
  61. IntIntv=2;
  62.  
  63. // When the number is less than 16
  64. If (max< 16)
  65. {
  66. Max=16;
  67. }
  68. // Case larger than 16
  69. Else
  70. {
  71. IntIntv= Int. Parse (Math. Ceiling (max/8). ToString ());
  72. Max + = intv;
  73. }
  74.  
  75. // Set the end value of the Y axis
  76. Chart. YCustomEnd=Int. Parse (max. ToString ());
  77. // Y increment Value
  78. Chart. YValuesInterval=Intv;
  79.  
  80. // Generate
  81. This. chart. RedrawChart ();
  82. }
  83. }
  84. }

Web Chart is a free ASP. NET Report control. You can download it from the official address: http://www.carlosag.net/tools/webchart/default.aspx. there are also many effects and code examples.

  1. Shell functions in ASP. NET Environment
  2. Batch insert data to databases in ASP. NET
  3. ASP. NET sends data to webpages in Post Mode
  4. WEB Application Deployment in ASP. NET 2.0
  5. HttpWorkerRequest object in ASP. NET
  6. Eve of the owc component in ASP. NET 2.0

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.