New to Telerik Reporting? Download free 30-day trial

How to Create Pie Chart

In this article we will show you how to create a Pie chart using the Graph item.

Pie Chart\Pie Chart

  1. Add a new graph item to the report.

    1. Set the DataSource property to a new SqlDataSource.

    2. Set the connection string to the demo AdventureWorks database.

    3. Set the query to the following one:

      SELECT S.Name AS StoreName, SOH.SubTotal
      FROM Sales.Customer AS CU
      INNER JOIN Sales.SalesOrderHeader AS SOH ON CU.CustomerID = SOH.CustomerID
      INNER JOIN Sales.Store AS S ON CU.CustomerID = S.CustomerID
    4. You can click on Execute Query... just to check if everything is OK with the database connection. Click Finish when you are ready.

  2. Open SeriesGroups collection editor and click Add :

    1. Set the new group Groupings to: =Fields.StoreName

    2. Set the Sortings to: =Sum(Fields.SubTotal)

    3. Set the Filters to: =Sum(Fields.SubTotal) Top N =10

    4. Set the Name to seriesGroup1

  3. Open CategoryGroups collection editor and click Add. By default this will add a new static group (group without grouping).

    1. Set the Name to categoryGroup1
  4. Open CoordinateSystems collection editor and Add a new PolarCoordinateSystem.

    1. Leave the Name to polarCoordinateSystem1.

    2. Set the RadialAxis to New Axis with Category Scale.

    3. Expand RadialAxis node.Expand Scale node.Set SpacingSlotCount to 0.Expand the axis Style node.Set Visible to False.

    4. Set the AngularAxis to New Axis with Numerical Scale.

    5. Expand AngularAxis node.Expand the axis Style node.Set Visible to False.

  5. Open Series collection editor and Add new BarSeries.

    1. Set the CategoryGroup to categoryGroup1.

    2. Set the SeriesGroup to seriesGroup1.

    3. Set the CoordinateSystem to polarCoordinateSystem1.

    4. Set the ArrangeMode to Stacked100.

    5. Set the X value to =Sum(Fields.SubTotal)

    6. Set the DataPointLabel to =Sum(Fields.SubTotal)/1000.0

    7. Set the DataPointLabelFormat to {0:C0}K

  6. Set the color palette, the formatting of the labels, the values of the legend and any other improvements as needed. For more information, see Formatting a Graph.

In this article