ActiveReports 18 .NET Edition
Report Authors: Designer Components / Report Controls / Page/RDLX Report / Chart / Plots / Column and Bar Charts / Create Clustered Bar Chart
In This Topic
    Create Clustered Bar Chart
    In This Topic

    This walkthrough creates a Clustered Bar Chart. The chart compares the Store, Reseller, Online, and Catalog sales for the different sales categories as shown. The final chart appears like this:

    Clustered Bar Chart

    Create a Report and Bind Report to Data

    In the ActiveReports Designer, create a new RDLX report and follow the New Report wizard to bind the report to data. You can also perform data binding later using the Report Data Source dialog accessed from the Report Explorer.

    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.mescius.io/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. Go to the Fields page to view the available fields and modify the Name of the [SalesAmount] field to [Net Sales].
    4. On the same page, add three calculated fields:
      Name Value
      Net Income =[Net Sales] - [UnitCost] - [DiscountAmount] - [ReturnAmount]
      Product Category =Switch([ProductKey] < 116, "Audio", [ProductKey] >= 116 And [ProductKey] < 338, "TV and Video", [ProductKey] >= 338 And [ProductKey] < 944, "Computers", [ProductKey] >= 944 And [ProductKey] < 1316, "Cameras", [ProductKey] >= 1316, "Cell Phones")
      Sales Channel =Switch([ChannelKey] = 1, "Store", [ChannelKey] = 2, "Online", [ChannelKey] = 3, "Catalog", [ChannelKey] = 4, "Reseller")
    5. Click OK to save the changes.

    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 'Bar'.
    3. Click Next to proceed. Here, you need to specify the bar settings. We will define a data series value to display the net sales values across the horizontal axis. We will later sub-categorize the data series value to form a cluster.
    4. Under Choose Data Values, add a new data value, and set its properties as below.                
      Field Aggregate
      =[Net Sales] Sum
    5. In Choose Data Categories, select  [Product Category] as the Field. We will add more customizations to the category in later steps.
    6. Click Next to preview your chart.
       clustered bar chart at preview time
      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 Categories page. Here, we will sort the product category to display in the order of decreasing total net sales. So fill in the following settings:
      Field Settings
      Sorting field =[Net Sales]
      Sorting direction Descending
      Sorting aggregate Sum
    3. Go to the Encodings page.
    4. On the Detail tab, add a new value, and set its properties as below.
      1. Set Expression to =[Sales Channel] to display sales by store, reseller, online, and catalog.
      2. Under Grouping, set Group to 'Cluster' since we want to display the detail columns (i.e. sales by store, reseller, online, and catalog) in a cluster.
    5. Navigate to the Color tab, add a new value and set Expression to =[Sales Channel] to display the legends based on the detail columns.
    6. Click OK to complete setting up the plot.

    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 Y-axis title in the chart.
    3. Go to the Labels page > General tab and set the following properties.
      • Format: Currency (with 0 decimal points)
      • Angle: 45
    4. Now go to the Appearance tab and set the following properties.
      • Font > Size: 9pt
      • Font > Color: Gray
    5. Go to the Line page and uncheck the Show Line option.
    6. Go to the Major Gridline page, check-on the Show Grid option and set the following properties.
      • Grid Interval: 50000
      • Grid appearance > Show Grid: Check-on
      • Grid appearance > Width: 0.25pt
      • Grid appearance > Color: #cccccc
      • Grid appearance > Style: Dotted
    7. Go to the Scale page and set the following properties.
      • Scale Type: Linear
      • Minimum scale value: 0
      • Maximum scale value: 450000
    8. Click OK to complete setting up the Y-axis.

    X-Axis

    1. To open the smart panel for advanced X-axis settings, right-click 'X-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 X-axis title in the chart.
    3. Go to the Labels page > Appearance tab and set the following properties.
      • Font > Size: 9pt
      • Font > Color: Gray
    4. Go to the Line page and set the following properties.
      • Color: Gray
      • Width: 2pt
    5. Click OK to complete setting up the X-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.
      • #f26324
      • #1fd537
      • #e40010
      • #8fcd37
    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: 9pt
      • Font > Color: DimGray
    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 Title to 'Sales by Category and Channel'.
    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.
         Cluster Bar 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.