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
- Reference namespaces
- Using WebChart;
- Defines an array of colors to fill with different colors for different records when looping
- Private string[] MyColor = new string[]
- {
- "Tomato",//tomatoes
- "Black",
- "Gold",
- "Blue",
- "Green",
- "Orange",
- "Pink",//Pink
- "Violet",//Violet
- "Orchid",//Light Purple
- "Lime",//Bright green
- "Tan",//Tan
- "Red",
- "Navy"//Orange
- };
- A static example of the simplest polyline that draws a two-point line. The actual project is then recycled.
- private void DoIt ()
- {
- Create a Polyline Object
- Linechart mychart = new Linechart ();
- Fill a polyline with color
- MyChart.Line.Color = Color.fromname (mycolor[0]);
- MyChart.Fill.Color = Color.fromname (mycolor[0]);
- Mychart.linemarker = new Diamondlinemarker (8, Color.fromname (Mycolor[0]), Color.fromname (mycolor[0]));
- Legend Description
- mychart.legend = "Polyline One";
- Add the first point, the parameter is the name on the x-coordinate, and the parameter is the value on the y-coordinate.
- MYCHART.DATA.ADD (New Chartpoint ("One", float. Parse ("100"));
- Add a second point
- MYCHART.DATA.ADD (New Chartpoint ("Two", float. Parse ("200"));
- Chart is the control ID
- THIS.CHART.CHARTS.ADD (MyChart);
- This.chart.RedrawChart ();
- }
Asp. NET report control two, bar chart
- Color array
- Private string[] MyColor = new string[]
- {
- "Fuchsia",
- "Black",
- "Gold",
- "Blue",
- "Hotpink",
- "Orange",
- "Peru",
- "DodgerBlue",
- "Lime",
- "Tan",
- "Red",
- "Greenyellow",
- "Darkgreen",
- "Dimgray",
- "Orchid"
- };
- Call this method to generate a bar chart
- private void Bindchart ()
- {
- Get a DataTable, specific function slightly ...
- DataTable dt = this.getdt ();
- if (dt! = NULL)
- {
- if (dt. Rows.Count > 0)
- {
- Traverse a DataTable to generate a bar for each record
- for (int i = 0; I < dt. Rows.Count; i++)
- {
- Creating objects
- Columnchart mychart = new Columnchart ();
- Set column width
- MyChart. Maxcolumnwidth = 48;
- Color
- MyChart. Fill.color = Color.fromname (This.mycolor[i]);
- Show the number on the pillar
- MyChart. Datalabels.visible = true;
- Number of fonts
- MyChart. Datalabels.font = New Font ("Verdana", 14);
- Add to
- MyChart. Data.add (New Chartpoint ("", float. Parse (dt. rows[i]["Num"]. ToString ()));
- Note
- MyChart. Legend = dt. rows[i]["Name"]. ToString ();
- THIS.CHART.CHARTS.ADD (MyChart);
- }
- Auxiliary settings
- Background color
- Chart. Background.color = Color.FromArgb (165, 0, 16);
- Chart. Yaxisfont.forecolor = Color.FromArgb (165, 0, 16);
- Chart. Xaxisfont.forecolor = Color.FromArgb (165, 0, 16);
- Internal lines
- Chart. Border.color = Color.FromArgb (200, 200, 200);
- Border Style
- Chart. BorderStyle = BorderStyle.None;
- Y Maximum Value
- Double max = Double. Parse (Dt.compute ("MAX (num)", ""). ToString ());
- Increment value
- int Intv = 2;
- Cases with a quantity less than 16
- if (max < + )
- {
- max = 16;
- }
- Cases greater than 16
- Else
- {
- intintv = Int. Parse (Math.ceiling (MAX/8). ToString ());
- Max + = Intv;
- }
- Set the y-axis end value
- Chart. ycustomend = Int. Parse (max. ToString ());
- Y increment value
- Chart. Yvaluesinterval = Intv;
- Generated
- This.chart.RedrawChart ();
- }
- }
- }
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