RadControls for ASP.NET AJAX
The steps below show how to create a minimal RadChart programmatically.
See the "create a more complex chart programmatically" topic to see how multiple series are created and how appearance can be tailored at run-time.
See the topic "Multiple Chart Types in a Single Chart" to see how multiple series area created programmatically and given different ChartSeriesTypes.
Once the chart is created, the critical steps are creating the ChartSeries and ChartSeriesItem collections. There are two approaches to creating chart series objects. One is to use the default ChartSeries constructor and assign its properties. A second route is to use the RadChart CreateSeries() method to set a number of important properties at once and return the constructed chart series.
First add the namespaces that support the objects to be referenced. The Telerik.WebWinControls.UI namespace supports the RadChart declaration and the Telerik.Charting namespace supports the other RadChart objects, e.g. ChartSeries and ChartSeriesItem.
Next construct the RadChart itself. To the RadChart instance, assign the chart title using the ChartTitle.TextBlock.Text property.
Construct a new ChartSeries object. Assign a name to the ChartSeries. Set the ChartSeries.Type to be Bar. Using the ChartSeries.AddItem() method, add a series of ChartSeriesItem objects to the series Items collection. AddItem() takes as parameters a double "Value" and a string "Label".
Finally, add the ChartSeries to the RadChart Seriescollection and add the RadChart to the page.
The finished chart in the running project should look like this example:
The alternative to using the ChartSeries object constructor and assigning properties is to use the RadChart CreateSeries() method that lets you pass several properties in the call, including Name, MainColor, SecondColor and ChartSeriesType.