skip to main content
Programmer's documentation > Developing with the JViews Gantt SDK > Resource Data charts > Synchronizing Schedule charts and Resource Data charts
 
Synchronizing Schedule charts and Resource Data charts
Describes resource selection and display modes, internal chart data rendering and the relationship between time scales, x-grids and time scrolling.
*Overview
*Explains where to find an example that illustrates Gantt data model synchronization.
*Selecting resources for display
*Explains resource selection and display modes.
*Computing resource data
*Explains how to compute multiple IlvDataValue instances using a IlvReservationLoadData object which is then assigned to your Resource Data chart.
*Rendering resource data
*Describes how internal chart data is rendered.
*The x-axis
*Explains how time scales, x-grids and time scrolling are related.
Overview
If your application also includes a Schedule chart, you have the option to synchronize the Gantt data models of both charts. Once the Schedule chart and the Resource Data chart are synchronized, changing the Gantt data model set on one chart will change the Gantt data model set on the other chart. For an example of this, you can look at the Resource Load chart sample, located in <installdir>/jviews-gantt/samples/resourceLoadChart.
The following table shows the APIs to synchronize the data model of a Resource Data chart to that of a Schedule chart.
Property
Methods
Synchronizing the Data Model to a Schedule chart
void syncGanttModel(IlvScheduleChart scheduleChart)
void syncGanttModel(IlvScheduleChart scheduleChart, int resourceDisplayMode)
void unsyncGanttModel()
Selecting resources for display
By default, when you bind a data model to IlvResourceDataChart, the data for all leaf resources in the model are displayed. This binding is dynamic. So, if a leaf resource is added to the data model or if a parent resource becomes a leaf because all of its children are deleted, the resource will be added to the chart display. There are also several alternate modes that can be used to determine which resources from the Gantt data model are displayed in the chart.
The following table shows the APIs to control resources displayed in a chart.
Property
Methods
Resource Display Mode
int getResourceDisplayMode()
void setResourceDisplayMode(int mode)
Manual Resource Display
void clearAllDisplayedResources()
void displayResource(IlvResource resource, boolean displayed)
Accessing the Displayed Resources
Iterator displayedResourcesIterator()
boolean isDisplayed(IlvResource resource)
Resource display modes - Schedule chart not synchronized
In the default case, when the Resource Data chart is not synchronized to a Schedule chart, you have a choice of three resource display modes:
*IlvResourceDataChart.AUTO_RESOURCE_DISPLAY_DISABLED: In this mode, resources in the data model are not automatically displayed by the Resource Data chart. In this mode, you must manually select resources to display by calling the displayResource method.
*IlvResourceDataChart.DISPLAY_ALL_RESOURCES: In this mode, all resources in the data model are automatically displayed by the Resource Data chart.
*IlvResourceDataChart.DISPLAY_ALL_LEAVES: This is the default resource display mode. In this mode, all leaf resources in the data model are automatically displayed by the Resource Data chart.
Resource display modes - Schedule chart synchronized
If you have synchronized the data model of the Resource Data chart to a Schedule chart by calling the syncGanttModel method, then you have a choice of three additional resource display modes.
These additional modes allow you to automatically display data in the Resource Data chart for resources that are selected in the Schedule chart:
*IlvResourceDataChart.DISPLAY_SELECTED_RESOURCES: In this mode, all resources that are selected in the Schedule chart are displayed in the Resource Data chart.
*IlvResourceDataChart.DISPLAY_SELECTED_SUBTREES: In this mode, the same as DISPLAY_SELECTED_RESOURCES mode, all resources that are selected in the Schedule chart are displayed in the Resource Data chart. In addition, when a parent resource is selected in the Schedule chart, all of its descendant resources are also displayed in the Resource Data chart.
*IlvResourceDataChart.DISPLAY_SELECTED_LEAVES: In this mode, all leaf resource that are selected in the Schedule chart are displayed in the Resource Data chart. For parent resources selected in the Schedule chart, their descendant leaf resources are displayed in the Resource Data chart. The selected parent resource itself is not displayed.
For an example of automatically displaying the resources selected in a Schedule chart, you can look at the Resource Load chart sample, located in:
<installdir>/jviews-gantt/samples/resourceLoadChart
Computing resource data
Each resource that is selected for display is represented by a data series of numerical values along the y-axis, plotted against time along the x-axis.
The data series is computed by:
1. A list of IlvDataValues, computed for each reservation assigned to the resource.
2. The lists of data values for the reservations of the resource, which are summed along the y-axis and merged along the x-axis to form the data series.
An instance of IlvDataValue represents a single numerical value at a specific date and time. Implementations of the IlvReservationDataPolicy interface are responsible for computing the list of data values for a single reservation. The default data policy is an instance of the IlvReservationLoadData class. This class performs a simple computation of the number of activities assigned to a resource versus time for a single reservation. Because a reservation represents the assignment of a single activity, IlvReservationLoadData computes a list of only two data values. The first is a value of 1 at the activity's start time, and the second is a value of 0 at the activity's end time. You can extend or create your own IlvReservationDataPolicy implementation that computes more complex data values from the reservations assigned to a resource.
The following table shows the APIs to set the policy on a Resource Data chart once you have created an IlvReservationDataPolicy object.
Property
Methods
Reservation Data Policy
IlvReservationDataPolicy getReservationDataPolicy()
void setReservationDataPolicy(IlvReservationDataPolicy dataPolicy)
The Resource Data chart internally creates instances of IlvResourceDataSet that represent the data series of each resource. This class is responsible for summing the y-values of the data value lists computed by the reservation data policy and for merging the time values along the x-axis. The chart adds the resource data sets to its internal data source, thereby displaying the resource data.
Rendering resource data
The Resource Data chart uses a single IlvChartRenderer implementation to render the internal data source of the chart. This internal data source is automatically populated with a data set for each resource that is displayed by the chart. Therefore, the chart renderer should be a simple composite renderer, a subclass of IlvSimpleCompositeChartRenderer. Simple composite renderers handle a one-to-one relation between their child renderers and their data sets (that is, one child renderer per data set). The default renderer of the Resource Data chart is an instance of the IlvStairChartRenderer class.
The following table shows the APIs to set the renderer of an IlvResourceDataChart.
Property
Methods
Chart Renderer
IlvChartRenderer getRenderer()
 
void setRenderer(IlvChartRenderer renderer)
See Handling chart renderers in Developing with the JViews Charts SDK for details on the supplied chart renderer implementations and their graphical presentation.
The x-axis
The time scale
The Resource Data chart uses an IlvTimeScale to render the x-axis. The default time scale is an instance of IlvGanttTimeScale. You can follow the instructions in Using the time scale to customize or extend the time scale.
The following table shows the APIs to change the time scale of a Resource Data chart.
Property
Methods
Time Scale
IlvTimeScale getTimeScale()
void setTimeScale(IlvTimeScale timeScale)
NOTE The time scale is used as a renderer by the Resource Data chart. It is not added as a true subcomponent of the chart, as in the Gantt and Schedule charts. Therefore, the standard IlvDefaultScaleMouseInteractor does not work in the context of the Resource Data chart.
The x-grid
Like the Gantt and Schedule charts, the Resource Data chart uses an IlvGanttGridRenderer object to render the vertical grid of the x-axis. The default x-axis grid is an instance of IlvWeekendGrid.
The following table shows the APIs to Change the X-axis Grid of a Resource Data Chart.
Property
Methods
X Grid
IlvGanttGridRenderer getXGrid()
void setXGrid(IlvGanttGridRenderer grid)
Time scrolling
The Resource Data chart provides methods to control scrolling that are similar to those of the Gantt and Schedule charts. However, the IlvResourceDataChart does not implement the IlvTimeScrollable interface.
The following table shows the methods to modify the time interval displayed by the chart.
Property
Methods
Time Scrolling
Date getVisibleTime()
void setVisibleTime(Date time)
IlvDuration getVisibleDuration()
void setVisibleDuration(IlvDuration duration)
IlvTimeInterval getVisibleInterval()
void setVisibleInterval(Date time, IlvDuration duration)
Date getMinVisibleTime()
void setMinVisibleTime(Date min)
Date getMaxVisibleTime()
void setMaxVisibleTime(Date max)
IlvDuration getMinVisibleDuration()
void setMinVisibleDuration(IlvDuration duration)
For example, you can scroll a chart horizontally so that it displays from one week before the start of an activity until one week after the activity ends:
IlvActivity activity = ...
IlvTimeInterval interval = activity.getTimeInterval();
Date start = IlvTimeUtil.subtract(interval.getStart(),
                                  IlvDuration.ONE_WEEK))
IlvDuration duration = interval.getDuration();
Duration = duration.add(IlvDuration.ONE_WEEK.multiply(2));
myChart.setVisibleInterval(start, duration);

Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.