For the pie series -- this is the correct way. Here is the reason -- there is no way to set the pie slices appearance before they even exist.
For StackedBar and StackedBar100 series -- if you need to provide different color for each individual bar you will need to use the same approach as with the pie series due to the very same reason. However, if you are fine with the default chart behavior -- all the series items use the same color (but you need to customize it) -- you can choose:
- Use ItemDataBound event to set each item's appearance (you have already found this)
- Use DataBound event to set each series appearance, one setting for the entire series
- Use the DataYColumn property of the ChartSeries object and set the appearance for the series. More details about this one:
When databinding RadChart you can let RadChart generate series for you or you can supply your own series. If you simply set the DataSource
property RadChart will create a ChartSeries for each numeric field/column in the datasource. Alternatively, you can create ChartSeries objects and add them to RadChart.Series collection. In this case if you set the ChartSeries.DataYColumn
property to the name of a field or column in the datasource, RadChart will not create series but it will only populate those you have created. This way you can customize the series appearance declaratively.
I have attached a small example showing this.
the Telerik team