Talking about ASP. NET report Control

Source: Internet
Author: User
Tags polyline

The project has graphical requirements for the report, and began looking for third-party chart controls on the Web. Due to the time constraints, large to determine a few candidates: one, office with the OWC control; second, ComponentOne; third, Web Chart. This article explains the ASP. NET report control.

AD:2014WOT Global Software Technology Summit Beijing Station course video release

OWC seems to be the majority of users, but saw a netizen in the post complained about OWC in the use of the need for a license, so it will be excluded, I do not want boss in the report when the pop-up "no License Certificate" window.

Then found the componentone of the Web chart made of various, very good results. I was fascinated, the decision is it, so nonstop under the latest version of more than 100 m installation files, and spent a morning to find a registration code can be used, and then find a tutorial, ok ready, hing hurriedly began to write code. Demand is not complex, draw a number of lines on a page, according to past experience, this large-scale business sharing software on the official site to see two example at most one hour absolutely can handle. But the results made me very annoyed, the official example simple it does not provide, what Ajax, a lot of code to achieve the auxiliary effect, you want to find the core of the three or four lines to kill also can not find, as if afraid you suddenly put its example see understand. Always hated this kind of software. Then uninstall, delete ... After all, a day has passed.

Fortunately, I found the Web Chart later. The code is super concise, the effect is also good, write some simple ASP. NET report control examples for your reference:

Asp. NET report control one, line chart

  1. Reference namespaces
  2. Using WebChart;
  3. Defines an array of colors to fill with different colors for different records when looping
  4. Private string[] MyColor = new string[]
  5. {
  6. "Tomato",//tomatoes
  7. "Black",
  8. "Gold",
  9. "Blue",
  10. "Green",
  11. "Orange",
  12. "Pink",//Pink
  13. "Violet",//Violet
  14. "Orchid",//Light Purple
  15. "Lime",//Bright green
  16. "Tan",//Tan
  17. "Red",
  18. "Navy"//Orange
  19. };
  20. A static example of the simplest polyline that draws a two-point line. The actual project is then recycled.
  21. private void DoIt ()
  22. {
  23. Create a Polyline Object
  24. Linechart mychart = new Linechart ();
  25. Fill a polyline with color
  26. MyChart.Line.Color = Color.fromname (mycolor[0]);
  27. MyChart.Fill.Color = Color.fromname (mycolor[0]);
  28. Mychart.linemarker = new Diamondlinemarker (8, Color.fromname (Mycolor[0]), Color.fromname (mycolor[0]));
  29. Legend Description
  30. mychart.legend = "Polyline One";
  31. Add the first point, the parameter is the name on the x-coordinate, and the parameter is the value on the y-coordinate.
  32. MYCHART.DATA.ADD (New Chartpoint ("One", float. Parse ("100"));
  33. Add a second point
  34. MYCHART.DATA.ADD (New Chartpoint ("Two", float. Parse ("200"));
  35. Chart is the control ID
  36. THIS.CHART.CHARTS.ADD (MyChart);
  37. This.chart.RedrawChart ();
  38. }

Asp. NET report control two, bar chart

  1. Color array
  2. Private string[] MyColor = new string[]
  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. Call this method to generate a bar chart
  21. private void Bindchart ()
  22. {
  23. Get a DataTable, specific function slightly ...
  24. DataTable dt = this.getdt ();
  25. if (dt! = NULL)
  26. {
  27. if (dt. Rows.Count > 0)
  28. {
  29. Traverse a DataTable to generate a bar for each record
  30. for (int i = 0; I < dt. Rows.Count; i++)
  31. {
  32. Creating objects
  33. Columnchart mychart = new Columnchart ();
  34. Set column width
  35. MyChart.  Maxcolumnwidth = 48;
  36. Color
  37. MyChart.  Fill.color = Color.fromname (This.mycolor[i]);
  38. Show the number on the pillar
  39. MyChart.  Datalabels.visible = true;
  40. Number of fonts
  41. MyChart.  Datalabels.font = New Font ("Verdana", 14);
  42. Add to
  43. MyChart. Data.add (New Chartpoint ("", float. Parse (dt. rows[i]["Num"]. ToString ()));
  44. Note
  45. MyChart. Legend = dt. rows[i]["Name"].  ToString ();
  46. THIS.CHART.CHARTS.ADD (MyChart);
  47. }
  48. Auxiliary settings
  49. Background color
  50. Chart.  Background.color = Color.FromArgb (165, 0, 16);
  51. Chart.  Yaxisfont.forecolor = Color.FromArgb (165, 0, 16);
  52. Chart.  Xaxisfont.forecolor = Color.FromArgb (165, 0, 16);
  53. Internal lines
  54. Chart.  Border.color = Color.FromArgb (200, 200, 200);
  55. Border Style
  56. Chart.  BorderStyle = BorderStyle.None;
  57. Y Maximum Value
  58. Double max = Double. Parse (Dt.compute ("MAX (num)", "").  ToString ());
  59. Increment value
  60. int Intv = 2;
  61. Cases with a quantity less than 16
  62. if (max < + )
  63. {
  64. max = 16;
  65. }
  66. Cases greater than 16
  67. Else
  68. {
  69. intintv = Int. Parse (Math.ceiling (MAX/8).  ToString ());
  70. Max + = Intv;
  71. }
  72. Set the y-axis end value
  73. Chart. ycustomend = Int. Parse (max.  ToString ());
  74. Y increment value
  75. Chart.  Yvaluesinterval = Intv;
  76. Generated
  77. This.chart.RedrawChart ();
  78. }
  79. }
  80. }

Web chart for free ASP. NET report control, need friends to go to the official address download: http://www.carlosag.net/Tools/WebChart/Default.aspx, there are many effects and code examples.

(go) About ASP. NET report Control

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.