Telerik UI for ASP.NET AJAX

Caution

RadChart has been replaced by RadHtmlChart, Telerik's client-side charting component. If you are considering RadChart for new development, examine the RadHtmlChart documentation and online demos first to see if it will fit your development needs. If you are already using RadChart in your projects, you can migrate to RadHtmlChart by following these articles: Migrating Series, Migrating Axes, Migrating Date Axes, Migrating Databinding, Feature parity. Support for RadChart is discontinued as of Q3 2014, but the control will remain in the assembly so it can still be used. We encourage you to use RadHtmlChart for new development.

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.

  1. 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.

  2. Next construct the RadChart itself. To the RadChart instance, assign the chart title using the ChartTitle.TextBlock.Text property.

  3. 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".

  4. Finally, add the ChartSeries to the RadChart Seriescollection and add the RadChart to the page.

  5. The finished chart in the running project should look like this example:

 
Programmatically Created Chart at Runtime

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.

See Also