Why AddGantt or AddGanttColor returns the same ind

2019-09-02 07:44发布

问题:

For some reason for certain cases when adding gantts to a TGanttSeries instance using method AddGanttColor or AddGantt the same index is returned for two different calls.

For example, the following snippet illustrates the case where the last two calls both return index of value 1.

Series.AddGanttColor(0, 100, 0, 'WA #234', clGreen);   // returns value 0
Series.AddGanttColor(100, 200, 1, 'WA #235', clGreen); // returns value 1 
Series.AddGanttColor(50, 200, 2, 'WA #237', clGreen);  // returns value 1!

However, all three gantts are displayed. So, it seems that the third line added gantt as the second in the list, and moved the gantt added on the second line to be the last one (third, and having index 2).

Could anyone please explain how could this be remedied to ensure that returned indexes stay associated with gantts as per AddGanttColor calls. In the above example, I would expect index values 0, 1, and 2 to be associated with the first, second and third added gantt respectively.


Have just confirmed that this situation holds true for TeeChart versions 5 and 8 running under Delphi 5.

回答1:

Well... after some research the cause of the problem was narrowed down to the value of property Series.XValues.Order. This property should be set to loNone in order to preserve association between index values returned from AddGantt and corresponding gantts.

IMO this is an API deficiency.