Page 1 of 1
TContourplot hang when all YValues =0
Posted: Sun Aug 09, 2009 12:25 pm
by 10546313
Hi,
I use the last TChart V8.05 / D2007 ( but the same is with V8.03, V8.04).
If I fill the Tcontourplot with YValues all the same values ( for example 0 or 0.2) the program hangs.
Can you please help me, I have to deliver the program next week !!
A test program is attached.
Please press the load button and select the DADMIX.01Z file. Oberve that the program hangs if you switch to contour via the tabsheet.
with best regards
Werner
Re: TContourplot hang when all YValues =0
Posted: Mon Aug 10, 2009 7:59 am
by yeray
Hi Werner,
Considering what is explained at teechart help for this series:
TContourSeries help wrote:Description
Calculates and displays "isolines" from a custom array of XYZ points.
The number of contour levels can be specified from 1 to 250.
To see a visual representation of this Series type, go to the TeeChart User Guide.
The Surface's
UseColorRange
and
UsePalette
properties also apply to contour series.
Each contour Level can be coloured using a range (ie: from blue to white) or a "Palette", which can be customized for specific value intervals (ie: red from 100 to 200, green from 201 to 400 ). Same as with
TSurfaceSeries
.
Contour points can be assigned to a Surface and vice-versa:
Each Level can be colored using a different color by doing:
Code: Select all
ContourSeries1.ColorEachPoint := True;
Levels can be displayed at custom "Y" vertical positions:
Each Level can display at it's own Level "Y" position by setting this property:
Code: Select all
ContourSeries1.YPositionLevel := True;
The ContourSeries, by default, shows at the Legend one item for each corresponding Contour "Level". The Contour Series has an event
OnGetLevel
which can be used to override each automatic Level
Value
and
Color
:
Code: Select all
procedure TForm1.Series1GetLevel(Sender: TContourSeries;
LevelIndex: Integer; var Value: Double; var Color: TColor);
begin
Value:=LevelIndex*100.0;
if Value<500 then Color:=clBlue
else Color:=clRed;
end;
The
LevelIndex
parameter specifies each contour level, from
0
to
NumLevels-1
.
*
Note
ContourSeries1.MaxYValue
and
MinYValue
refer to Contour Y values.
Since version 5, this depends on the 2D / 3D setting.
When the Chart is in 2D mode (
Chart1.View3D:=False
) then Contour
MaxYValue
and
MinYValue
methods return the Z values minimum and maximum values.
In 3D mode, the behaviour is the same as in version 4 (they refer to Contour Y values).
To remain independent on the above issue, you should use
Contour.YValues.MaxValue
and
Contour.YValues.MinValue
properties.
And also looking at
this explanation from Narcis, I cant' see the sense of having a contour series with the same value for all the Y values. The contour series seems to need different YValues to define the levels.
Re: TContourplot hang when all YValues =0
Posted: Mon Aug 10, 2009 3:26 pm
by 10546313
Dear Yeray,
sorry , but I disagree completely. The data are sampled from a detector machine and therefore it could be happen, that all y-values have the same value. So you can't say to the user 'I cant' see the sense of having a contour series with the same value for all the Y values'. The program hangs, that is the fact.
Indeed, the problem is the calculation of the levels and your software guys have to have a look to the bounds of ranges that could be happen. If all y-values are the same value the following line in the teesurfa.pas (
Procedure TContourSeries.CreateAutoLevels;
) get the result of tmp= '0'
Code: Select all
tmp:=MandatoryValueList.Range/Max(1,NumLevels-1);
This value gets a problem in the following algorithm.
I have give you enough information, even a sample project (spendig my weekend to do this) to fix this bug, so please do it !
best regards
Werner
Re: TContourplot hang when all YValues =0
Posted: Tue Aug 11, 2009 9:08 am
by yeray
Hi Werner,
My apologies if I looked immovable. The problem is that I'm still not able to understand how would you expect TeeChart to draw that situation. Maybe I'll understand better the expected result if you could attach also a picture showing it.
Re: TContourplot hang when all YValues =0
Posted: Tue Aug 11, 2009 9:54 am
by 10546313
Hi Yeray,
the major problem is the program hang, if all y-values have the same value. Please compile my sample project, load the file as I described and see what happen.
Meanwhile I have fixed the problem, but I am not sure if it works in any cases, so please have a look at it.
Code: Select all
Procedure TContourSeries.CreateAutoLevels;
......
tmp:=MandatoryValueList.Range/Max(1,NumLevels-1); // v8 changed to include max value
if tmp=0 then tmp:=1; //wdu
tmpMin:=MandatoryValueList.MinValue;
for t:=0 to NumLevels-1 do
begin
tmpUpTo:=tmpMin+tmp*(t+1); //wdu
I have attached the picture showing in the case of all y-values have the same value;
With best regards
Werner
Re: TContourplot hang when all YValues =0
Posted: Tue Aug 11, 2009 2:46 pm
by yeray
Hi Werner,
Excuse me again. For some reason I can't see, the first time I ran your application (and tried for several times) I got always a series without data. Then I guessed that there should be some problem in your loading file and that made me to think that the real problem was the "meaning" of the contour series and not a real hang.
Once retested your application and reproduced the hang, I've reduced the problem into a simpler example:
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
var x, z, index: Integer;
begin
for x := 0 to 39 do
for z := 0 to 39 do
series1.AddXYZ(x,1,z)
end;
Note that the program finishes after about 5~10 seconds and there are only 1600 points. And I also could see that your patch seems to solve this really bad performance issue.
Finally, I'd like you to know that I've added this to the wish list to be fixed as soon as possible (TV52014344).