ActiveReports 13
Gantt Charts
ActiveReports 13 > ActiveReports User Guide > Samples and Walkthroughs > Walkthroughs > Page Report/RDL Report Walkthroughs > Chart > Gantt Charts

The Gantt charts are used to represent the schedule of sequence of tasks in a project. To plot Gantt charts, you need to have the start and end times of a task.
The walkthrough is split into the following activities:

Note:

When you complete this walkthrough you get a layout that looks similar to the following at design time and at run time.

Design-Time Layout

Run-Time Layout

To create an ActiveReports project in Visual Studio

  1. Create a new Visual Studio project.
  2. In the New Project dialog that appears, select ActiveReports 13 Page Report Application and in the Name field, rename the file as rptGanttChart.
  3. Click OK to create a new ActiveReports 13 Page Report Application. By default a Page report is added to the project.

    See Adding an ActiveReport to a Project for information on adding different report layouts.

To connect the report to a data source

  1. In the Report Explorer, right-click the Data Sources node and select the Add Data Source option or select Data Source from the Add button.
  2. In the Report Data Source Dialog that appears, select the General page and in the Name field, enter a name like ChartData.
  3. On this page, create a connection to the Schedule database. See Connect to a Data Source for information on connecting to a data source.

To add a dataset

  1. In the Report Explorer, right-click the ChartData data source node and select the Add Data Set option or select Data Set from the Add button.
  2. In the DataSet Dialog that appears, select the General page and enter the name of the dataset as ScheduleData.
  3. On the Query page of this dialog, in the Query field enter the following SQL query.
    SQL Query
    Copy Code
    SELECT Top 5 * from ScheduleOfTime
    
  4. Click the Validate DataSet icon  at the top right hand corner above the Query box to validate the query. 
  5. To obtain end time of the tasks, you need to add a field that calculates end times. Go to Fields tab and add a calculated field EndTime with expression =DateAdd(DateInterval.Hour, [Hours], [StartTime]).
  6. Click OK to close the dialog. Your data set and queried fields appear as child nodes to the data source in the Report Explorer.

To add a chart data region and define plots

  1. From the toolbox, drag a Chart data region onto the design surface of the report.
  2. In the Select a Chart Type wizard that appears and select the chart type as Column.
  3. Right-click on the chart and go to Plot Template > Miscellaneous and select Gantt.

    Note that the chart changes to horizontal bar chart, where horizontal axis (AxisType Y) represents time duration that a task needs to finish and each bar (plotted along Vertical axis (AxisType X)) represents a task.
  4. Select the chart control so that the chart adorners are displayed.
  5. Right-click the Data Fields adorner and click Add. You see that a field is added.
  6. Select the field and click the ellipses next to Subfields property to open Complex Fields Collection Editor.
  7. Set lower value to =Fields!StartTime.Value and upper value to =Fields!EndTime.Value to show Value axis.
  8. Click OK to save and exit the collection editor.
  9. Select the chart control so that the chart adorners are displayed.
  10. Right-click the Category Fields adorner and click Add. You see that category 'Category0' is added.
  11. Select 'Category0' and set its Expression to =Fields!Labels.Value

To configure the appearance of the chart

  1. Select Chart and set Pallet to Office.
  2. Select 'Chart title' on the chart and set Title to 'Schedule'.
  3. Select Category axis (AxisType X) and set Title to 'Topics'.
  4. Select Value axis (AxisType Y) and set Title to 'Timeline'.
  5. Select the Timeline axis and set the label settings as:
    Property Name Property Values
    Labels>LabelAngle -45
    Title>TitleStyle>Font>FontSize
    Specify the template to be displayed for the label.
    10pt
  6. Select the Topics axis and set Title>TitleStyle>Font>FontSize to 10 pt.

To view the report

OR