This topic describes the steps necessary to build a simple ASP.NET application using Xceed Chart for ASP.NET.
1. Make sure that your ASP.NET server is working properly. In the localhost wwwroot directory, create a file called TestAspX.aspx and insert the following line of code:
| HTML | |
|---|---|
<%=Now()%>
| |
now point your browser to: http://localhost/testaspx.aspx the page will display the current time.
2. Open Microsoft Visual Studio .NET.
3. Under File / New Project, select "Visual C# projects" and then select "ASP.NET Web application" from the list on the right side.
4. [Optional] Change the application name from WebApplication[n] to ChartTest.
5. Click OK.
6. Right-click on the Project's References tree item in the Solution Explorer and select "Add Reference". The Add Reference dialog will appear.
7. Select all Xceed Chart for .NET assemblies—with the exception of Xceed.Chart.Server.dll and *.exe—and click Select, then OK.
8. Open the Toolbox. If it is not visible, go to the View\Toolbox menu item or press Ctrl + Alt + X.
9. Open the Components tab, right-click, and select Add/Remove Items.
10. On the .NET Framework Components, click Browse and open Xceed.Chart.Server.dll then click Ok. The ChartServerControl component must appear in the Toolbox components tab.
11. Then simply insert the chart into the aspx form.
12. Open the global.asax file and add the following line to the beginning of the Application_Start method:
| VB.NET | |
|---|---|
Xceed.Chart.Server.Licenser.LicenseKey = ""CHWXX-XXXXX-XXXXX-XXXX" | |
| C# | |
|---|---|
Xceed.Chart.Server.Licenser.LicenseKey = ""CHWXX-XXXXX-XXXXX-XXXX"; | |
14. Configure the temporary directory. For details, see the temporary file and persistent server topics in the Server Configuration book.
15. Start the application. The web page will display an empty chart.
16. Close the browser and then open the source code for WebForm1.aspx. From the Solution Explorer, right-click on WebForm1.aspx and select "View code".
17. Add the following lines at the beginning of the file:
| VB.NET | |
|---|---|
Imports Xceed.Chart.Standard | |
| C# | |
|---|---|
using Xceed.Chart.GraphicsCore; | |
18. In the Page_Load function, insert the following code:
| VB.NET | |
|---|---|
Dim chart As Chart chart = CType( chartServerControl1.Charts( 0 ), Chart ) pie = CType( chart.Series.Add( SeriesType.Pie ), PieSeries ) pie.Legend.Mode = SeriesLegendMode.DataPoints | |
| C# | |
|---|---|
Chart chart; chart = ( Chart )chartServerControl1.Charts[ 0 ]; pie = ( PieSeries )chart.Series.Add( SeriesType.Pie ); pie.Legend.Mode = SeriesLegendMode.DataPoints; | |
19. Now start the application again. The page will display a simple pie chart.
20. That's it! You've created a simple server-side chart using Xceed Chart for ASP.NET!
