ActiveReports 16 .NET Edition
ActiveReports 16 User Guide / Concepts / Page Report/RDL Report Concepts / Toolbox / Chart / Plots / Pie and Doughnut Charts / Create Doughnut Chart
In This Topic
    Create Doughnut Chart
    In This Topic

    This walkthrough creates a Doughnut Chart. The chart shows the contribution of sales channels to the total unit cost, return, and discount. The final chart appears like this:

    Doughnut Chart

    Create a Report

    In the ActiveReports Designer, create a new RDL report.

    Bind Report to Data

    The Report Data Source dialog is invoked when a new report is created if you keep the default check on for the Launch Data Source Wizard option. You can also access this dialog by right-clicking the Data Sources node in the Report Explorer and then selecting the Add Data Source option.

    Connect to a Data Source

    1. In the Report Data Source dialog, select the General page and enter the name of the data source.
    2. Under Type, select 'Json Provider'.
    3. Go to the Content tab under Connection and set the type of JSON data to 'External file or URL'.
    4. In the Select or type the file name or URL field, enter the following URL:
      https://demodata.grapecity.com/contoso/odata/v1/FactSales
      For more information, see the JSON Provider topic.
    5. Go to the Connection String tab and verify the generated connection string by clicking the Validate DataSource Validate Icon icon.
    6. Click OK to save the changes and open the DataSet dialog.

    Add a Dataset   

    1. In the Dataset dialog, select the General page and enter the name of the dataset, 'FactSales'.
    2. Go to the Query page and enter the following query to fetch the required fields:       
      Query
      Copy Code
      $.value[*]
      
    3. Click OK to save the changes.
    4. Go to the Fields page to view the available fields and modify the Name of the [ReturnAmount] and [DiscountAmount] fields to [Returns] and [Discount], respectively.
    5. On the same page, add two calculated fields:
      Name Value
      Net Income =[SalesAmount] - [UnitCost] - [Discount] - [Returns]
      Sales Channel =Switch([ChannelKey] = 1, "Store", [ChannelKey] = 2, "Online", [ChannelKey] = 3, "Catalog", [ChannelKey] = 4, "Reseller")

    Create a Chart

    We will use the Chart Wizard dialog to configure chart data values. The wizard appears by default if you have a dataset added to your report. See the topic on Chart Wizard for more information.

    1. Drag-drop Chart data region onto the design area. The Chart Wizard dialog appears with an option to select the data and the chart type.
    2. Select the Dataset Name as 'FactSales' and the Chart Type as 'Doughnut'.
    3. Click Next to proceed. Here, you need to specify the doughnut settings.
    4. In Choose Data values section, we will define three data series values to display the sales amount, unit cost, and discount for the sales channels.
      Select the following three fields from the drop-down and set the corresponding aggregates:
      Field Aggregate
      =[UnitCost] Sum
      =[Returns] Sum
      =[Discount] Sum
                     
    5. Click Next to preview your chart.
       Doughnut Chart Settings Dialog Box
      You can also modify the chart palette and do other customizations as the last step in the process of chart creation. Or, you can exit the wizard and access these smart panels as explained below.         

    Set Advanced Customization

    Now that the chart is configured with data values, let us do some customizations on the chart elements using the smart panels.

    Plot Settings

    1. To open the smart panel for advanced plot settings, right-click 'Plot-Plot1' on the Report Explorer and choose Property Dialog.
    2. Go to the Encodings page.
    3. On the Detail tab, add a new value, and set its properties as below.
      1. Set Expression to =[Sales Channel] to display sales data for the subcategories i.e. store, reseller, online, and catalog.
      2. Under Grouping, set Group to 'Stack' since we want to display the subcategories (i.e. sales data by store, reseller, online, and catalog) in a stack.
    4. Navigate to the Color page, add a new value, and set the Expression to =[Sales Channel] to display legends based on the subcategories.
    5. Go to the Labels page > General tab and set the following properties:
      • Template: {valueField.name}
      • Text Position: Center
    6. Go to the Appearance tab and set the following properties.
      • Font > Size: 10pt
      • Font > Weight: SemiBold
      • Font > Color: #ffffff
      • Connecting Line > Style: Solid
      • Connecting Line > Color: Gainsboro
    7. Click OK to complete setting up the plot.
    8. With 'Plot-Plot1' selected, go to the Properties pane and set the Inner Radius property for the doughnut to '20%' to reduce the inner size.

    Y-Axis

    1. To open the smart panel for advanced Y-axis settings, right-click 'Y-axis' on the Report Explorer and choose Property Dialog.
    2. Go to the Title page and remove the text from the Title field to hide the axis title in the chart.
    3. Go to the Labels page and uncheck the Show Labels option as we are already displaying the sales channel labels in the chart.
    4. Go to the Line page and set the following properties:
      • Color: Gainsboro
      • Width: 0.25pt
    5. Click OK to complete setting up the Y-axis.

    Chart Palette

    1. To open the smart panel for advanced chart settings, right-click 'Chart' on the Report Explorer and choose Property Dialog.
    2. Go to the Palette page, select Custom from the drop-down and add the following colors.
      • #8fcd37
      • #f26324
      • #e40010
      • #1fd537
    3. Click OK to complete setting up the custom palette.

    Legend - Color

    1. To open the smart panel for the legend, right-click 'Legend - Color' on the Report Explorer, and choose Property Dialog.
    2. Go to the Appearance page and set the following properties:
      • Font > Size: 10pt
      • Font > Color: #3c3c3c
    3. Go to the Layout page and set the following properties:
      • Position: Top
      • Orientation: Horizontal
    4. Click OK to complete setting up the chart legend.

    Chart Header

    1. To open the smart panel for the chart header, right-click 'Header' on the Report Explorer and choose Property Dialog.
    2. Go to the General page and set Text to 'Expenses and Losses'.
    3. Go to the Font page and set the properties as below.
      • Size: 24pt
      • Color: #3da7a8
    4. Click OK to complete setting up the chart header.
      You may want to resize the chart.
         Doughnut Chart at Design Time
      Note: We use stub data at design time and not real data. So to view the actual final chart, you need to view the chart on the preview.
    5. Once you are done with configuring and customizing the chart, press F5 to preview the report.