Display a vertical line in a JViews Gantt Chart to mark the current time

Article ID: 2213
Last updated: 29 May, 2018
Article ID: 2213
Last updated: 29 May, 2018
Revision: 3
Views: 1044
Posted: 28 Mar, 2007
by Dean J.
Updated: 29 May, 2018
by Gargani A.

Question

How can I display a vertical line in a JViews Gantt Chart to mark the current time?

Answer

The Gantt Sheet is actually an instance of IlvManagerView, the viewclass in the Graphics Framework. You can easily add static JViews graphic objects to a Gantt chart or Schedule chart. In this case, we add a vertical line. The following source code is from a class definition that extends the JViews class IlvLine:

  IlvGanttSheet sheet = _chart.getGanttSheet();
  IlvTimeConverter timeConverter = sheet.getTimeConverter();
  // First get the x position of the current date in manager coordinates.
  final float x = (float)timeConverter.getUnits(new Date());
  // ...
  sheet.getManager().addObject(this, _layer, true);

When displaying such a line, two other issues must be handled. You must make the line long enough to cover all of the visible range of the chart, even when new rows are added, and you must refresh the position of the line periodically in case the user has zoomed in far enough to see time passing.

Vertical line in a JViews Gantt

The complete source is provided in this file: timenow.zip.

The code defines a class that displays a vertical line at the current time in a Gantt or Schedule chart. The line moves as time passes. The refresh rate of the line, as well as its appearance, are customizable.

Download and extract the file. Then read the html file it contains, timenow.html.

Note: Starting from JViews Gantt 8.0, Time Indicators are supported by the IlvTimeIndicator abstract base class and its two concrete implementations: IlvFixedTimeIndicator and IlvCurrentTimeIndicator.

For more information about this feature, refer to the following section:
    Developing with the SDK > Gantt Charts > Using the Gantt Sheet > Time Indicators

The associated code sample can be found in the Code Examples section of the Documentation and is located here:

<JVIEWS_GANTT_HOME>/codefragments/application/timeIndicator

This article was:   Helpful | Not helpful
Report an issue
Article ID: 2213
Last updated: 29 May, 2018
Revision: 3
Views: 1044
Posted: 28 Mar, 2007 by Dean J.
Updated: 29 May, 2018 by Gargani A.
Also listed in


Others in this category