Getting Started

Glossary Item Box

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
Imports Xceed.Chart.GraphicsCore
Imports Xceed.Chart
Imports Xceed.Chart.Server
Imports Xceed.Chart.Core
C#  
using Xceed.Chart.GraphicsCore;
using Xceed.Chart.Standard;
using Xceed.Chart;
using Xceed.Chart.Server;
using Xceed.Chart.Core;

18. In the Page_Load function, insert the following code:

VB.NET  
Dim chart As Chart
Dim pie As PieSeries
chart = CType( chartServerControl1.Charts( 0 ), Chart )
chart.Width = 70
chart.Depth = 10
pie = CType( chart.Series.Add( SeriesType.Pie ), PieSeries )


pie.AddPie( 12, 0, "Cars", New FillEffect( Color.Red ), New LineProperties() )
pie.AddPie( 42, 0, "Trains", New FillEffect( Color.Gold ), New LineProperties( )
pie.AddPie( 56, 0, "Airplanes", New FillEffect( Color.Chocolate ), New LineProperties() )
pie.AddPie( 23, 0, "Buses", New FillEffect( Color.Cyan ), New LineProperties() )
pie.Legend.Mode = SeriesLegendMode.DataPoints

pie.Legend.Format = "<label> <percent>"
pie.PieStyle = PieStyle.SmoothEdgePie
pie.LabelMode = PieLabelMode.Spider

pie.Appearance.FillMode = AppearanceFillMode.Predefined
C#  
Chart chart;
PieSeries pie;
chart = ( Chart )chartServerControl1.Charts[ 0 ];
chart.Width = 70;
chart.Depth = 10;
pie = ( PieSeries )chart.Series.Add( SeriesType.Pie );


pie.AddPie( 12, 0, "Cars", new FillEffect( Color.Red ), new LineProperties() );
pie.AddPie( 42, 0, "Trains", new FillEffect( Color.Gold ), new LineProperties() );
pie.AddPie( 56, 0, "Airplanes", new FillEffect( Color.Chocolate ), new LineProperties() );
pie.AddPie( 23, 0, "Buses", new FillEffect( Color.Cyan ), new LineProperties() );
pie.Legend.Mode = SeriesLegendMode.DataPoints;

pie.Legend.Format = "<label> <percent>";
pie.PieStyle = PieStyle.SmoothEdgePie;
pie.LabelMode = PieLabelMode.Spider;

pie.Appearance.FillMode = AppearanceFillMode.Predefined;

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!

See Also

Temporary Files