Telerik blogs

A population pyramid, also called an age structure diagram as defined by Wikipedia is a graphical illustration that shows the distribution of various age groups in a human population (typically that of a country or region of the world). It typically consists of two back-to-back bar graphs, with the population plotted on the X axis and age on the Y axis, one showing the number of males and one showing females in a particular population in five-year age.

Although there are different types of population pyramids this blog post will demonstrate how to create such pyramid using the RadChart’s Horizontal Bar type.

In order to visualize the chart data as a pyramid structure you need to define two Horizontal Bar series - one for Male, and one for Female population for given age range. Note that each Male / Female pair of series items for given age range should be associated with the same XCategory.

The Y axis is formatted using Custom Format Strings so that the "-" sign for negative values is suppressed and 0 remains as start tick for the Bars:

  1. RadChart1.DefaultView.ChartArea.AxisY.DefaultLabelFormat = "#VAL{#0.##;#0.##;0}";

The Bars are set to have 100% overlapping so that each two back-to-back graphs are correctly aligned:

  1. RadChart1.DefaultView.ChartArea.ItemOverlapPercent = 100;

Finally Titles for the axes are added for better readability. The result is shown below:

You may download the sample code from here!

About the Author

Evgenia Milcheva

Front-End Developer
Telerik XAML Team

Related Posts


Comments are disabled in preview mode.