This walkthrough shows how to add a simple pie chart to a WPF application.

Prerequisites

This walkthrough doesn't cover installation of amCharts for WPF. Read Installation article for the installation instructions.

Adding pie chart object to a WPF Window

Note:

This procedure assumes that you have already created or opened a WPF application and a Window in it.

  1. Drag PieChart control from your Visual Studio toolbox onto your WPF Designer surface.

  2. Adjust Width and Height properties of the created am:PieChart via XAML editor or properties window. Alternatively you can just delete these property settings to allow the chart to occupy all of the available space.

  3. Add slices to the chart either by creating am:Slice elements inside the am:PieChart tag in XAML editor or via Slices collection editor in properties window.

    The only required property/attribute is Value which denotes the value of the data object represented by this slice. It is adviced to set the Title property too. Title is displayed by default in data labels, balloons and legend.

You have successfully added a simple pie chart to your WPF application

Here's a complete code of the window containing the pie chart:

CopyXAML
<Window x:Class="AmChartsWPFTutorials.SimplePieChart"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:am="http://schemas.amcharts.com/charts/wpf/2009/xaml"
    Title="SimplePieChart" Height="350" Width="600">
    <Grid>
        <am:PieChart Name="pieChart1">
            <am:Slice Title="Slice #1" Value="78" />
            <am:Slice Title="Slice #2" Value="45" />
            <am:Slice Title="Slice #3" Value="146" />
        </am:PieChart>
    </Grid>
</Window>

And when run the application your window should look like this:

See Also