Function with time issue
Function with time issue
Hi everyone.
I got a new issue and i would like to know if i'm getting this issue because i dont use teechart the right way i should. I found a really big issue with the function when i use a datetime for the X axis using psRange. It doesn't seems to calculate it correctly because i have 2 different chart (teeChart and Excel) and when i do check it manually, TeeChart doesnt do it right. When using add function, If i have some series with less data than the others, the fun begins. It seems it doesn nearly the same thing as if it were set to psNumPoint because it doesnt seem to care about my datetime but only the number of points.
I did add a screenshot that show how it goes. The teal series is the total (add function) and you can see easely that the slope doesnt follow the time line of the other series. I hope there is a simple answer to that because otherwise, i will have to do an other add function that work well with a datetime base.
* i forgot to tell you some stuff:
Series.SetFunction(TAddTeeFunction.Create(Chart))
Series.FunctionType.PeriodStyle := psRange
Series.FunctionType.Period := DateTimeStep[dtOneMinute];
Series.DataSources.Clear;
Looping for Series.DataSources.Add(SeriestoBeAdded)
Series.CheckDataSource;
D2010, TeeChart v8.06
I got a new issue and i would like to know if i'm getting this issue because i dont use teechart the right way i should. I found a really big issue with the function when i use a datetime for the X axis using psRange. It doesn't seems to calculate it correctly because i have 2 different chart (teeChart and Excel) and when i do check it manually, TeeChart doesnt do it right. When using add function, If i have some series with less data than the others, the fun begins. It seems it doesn nearly the same thing as if it were set to psNumPoint because it doesnt seem to care about my datetime but only the number of points.
I did add a screenshot that show how it goes. The teal series is the total (add function) and you can see easely that the slope doesnt follow the time line of the other series. I hope there is a simple answer to that because otherwise, i will have to do an other add function that work well with a datetime base.
* i forgot to tell you some stuff:
Series.SetFunction(TAddTeeFunction.Create(Chart))
Series.FunctionType.PeriodStyle := psRange
Series.FunctionType.Period := DateTimeStep[dtOneMinute];
Series.DataSources.Clear;
Looping for Series.DataSources.Add(SeriestoBeAdded)
Series.CheckDataSource;
D2010, TeeChart v8.06
Re: Function with time issue
Hi GoToXY,
I can't reproduce the problem with the following code:
Do you see any important step that I could miss trying to reproduce the problem?
Please, modify the code above so we can run it as-is to reproduce the problem here (or send us a simple example project)
I can't reproduce the problem with the following code:
Code: Select all
uses series, TeeFunci;
procedure TForm1.FormCreate(Sender: TObject);
var i, j: Integer;
tmpdate: TDateTime;
begin
Chart1.View3D:=false;
for i:=0 to 1 do
with Chart1.AddSeries(TFastLineSeries) do
begin
XValues.DateTime:=true;
tmpdate:=Date;
for j:=0 to 20 do
begin
if ((i = 0) and (j mod 10 > 5)) then
AddXY(tmpdate + j, 10)
else
AddXY(tmpdate + j, 20);
end;
end;
with Chart1.AddSeries(TFastLineSeries) do
begin
SetFunction(TAddTeeFunction.Create(self));
FunctionType.PeriodStyle:=psRange;
FunctionType.Period:=DateTimeStep[dtOneMinute];
DataSources.Add(Chart1[0]);
DataSources.Add(Chart1[1]);
end;
end;
Please, modify the code above so we can run it as-is to reproduce the problem here (or send us a simple example project)
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Function with time issue
Hi YEray,
First i think you need more data than what you use otherwise it is hard to see the error.
You used days not minute in your example. adding 1 to a date will add a day, we have to work on minutes to see it (maybe we can see it too in days, be as we are using dtOneMinute, it would appear to be more realistic to use minute)
I will try to make a simple application to show you what i mean.
First i think you need more data than what you use otherwise it is hard to see the error.
You used days not minute in your example. adding 1 to a date will add a day, we have to work on minutes to see it (maybe we can see it too in days, be as we are using dtOneMinute, it would appear to be more realistic to use minute)
I will try to make a simple application to show you what i mean.
Re: Function with time issue
Ok, i found a way to show you the error and im pretty sure you gonna be very surprise with the result.
Here a Screenshot of the sample application As you can see, logically, add those lines would result in a straight Line with no stairs starting from 500. but what we are getting is how it add stuff in the wrong way.
I think we will have this issue with all the function so far, because it seems to be a DateTime baseline issue.
Here a Screenshot of the sample application As you can see, logically, add those lines would result in a straight Line with no stairs starting from 500. but what we are getting is how it add stuff in the wrong way.
I think we will have this issue with all the function so far, because it seems to be a DateTime baseline issue.
- Attachments
-
- AddFunction.zip
- Sample application test
- (7.9 KiB) Downloaded 495 times
Re: Function with time issue
Hi GoToXY,
You are right. I think that the functions don't support sources with different increments in X. I've added it to the defect list to be fixed in future releases (TV52014986).
Thanks for reporting it.
You are right. I think that the functions don't support sources with different increments in X. I've added it to the defect list to be fixed in future releases (TV52014986).
Thanks for reporting it.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Function with time issue
Any date on the next update because that kind of error really put us in a bad position toward our customer.I can't use any of the function in TChart because of that issue and to be honest with you, without that, TChart is becoming very useless for us.Yeray wrote:Hi GoToXY,
You are right. I think that the functions don't support sources with different increments in X. I've added it to the defect list to be fixed in future releases (TV52014986).
Thanks for reporting it.
Thanks again Yeray
Re: Function with time issue
Hi GoToXY,
Investigating this a little bit more, we've seen that this would be the expected result, similar to the discussed here and here.
The problem is that these calculations need their sources to have the same number of X values so they can be done correclty.
Here you have an example similar to yours and the workaround that consists on adding null points where a series hasn't a value but the other has:
Investigating this a little bit more, we've seen that this would be the expected result, similar to the discussed here and here.
The problem is that these calculations need their sources to have the same number of X values so they can be done correclty.
Here you have an example similar to yours and the workaround that consists on adding null points where a series hasn't a value but the other has:
Code: Select all
uses Series, TeeFunci, Math;
procedure TForm1.FormCreate(Sender: TObject);
Var i: Integer;
begin
Chart1.View3D:=false;
For i := 0 To 2 Do
begin
Chart1.AddSeries(TLineSeries);
(Chart1[i] as TLineSeries).Pointer.Visible:=true;
end;
Chart1[2].Color := clRed;
Chart1[2].SetFunction(TAddTeeFunction.Create(Chart1));
For i := 0 To 1 Do
Chart1[2].DataSources.Add(Chart1[i]);
CheckBox1Click(self);
end;
procedure TForm1.CheckBox1Click(Sender: TObject);
Var i,j,MaxCount: Integer;
begin
For i:=0 To 1 Do
Chart1[i].Clear;
if CheckBox1.Checked then
begin
Chart1[0].AddXY(0,5);
Chart1[0].AddXY(2,5);
Chart1[0].AddXY(1,5);
Chart1[1].AddXY(0,10);
Chart1[1].AddXY(5,10);
Chart1[1].AddXY(10,10);
//workaround
i:=0;
while i < Max(Chart1[0].Count, Chart1[1].Count) do
begin
if ((i >= Chart1[0].Count) or (Chart1[0].XValue[i] > Chart1[1].XValue[i])) then
Chart1[0].AddNullXY(Chart1[1].XValue[i],0)
else
if ((i >= Chart1[1].Count) or (Chart1[0].XValue[i] < Chart1[1].XValue[i])) then
Chart1[1].AddNullXY(Chart1[0].XValue[i],0);
i:=i+1;
end;
Chart1[0].XValues.Order:=loAscending;
Chart1[1].XValues.Order:=loAscending;
(Chart1[0] as TLineSeries).TreatNulls:=tnSkip;
(Chart1[1] as TLineSeries).TreatNulls:=tnSkip;
//end workaround
end
else
begin
Chart1[0].Add(5);
Chart1[0].Add(5);
Chart1[0].Add(5);
Chart1[1].Add(10);
Chart1[1].Add(10);
Chart1[1].Add(10);
end;
Chart1[2].CheckDataSource;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Function with time issue
Sorry, i havent seen you had reply on this one. I did try the "workAround" but no, it doesnt work at all. i got lots of points that goes to 1899-12-30 (wierd because the AddNullXY(TheDate,0)
with the copy of the workaround
with the copy of the workaround
- Attachments
-
- addfncbug2.jpg (92.31 KiB) Viewed 11871 times
Re: Function with time issue
Ok, i did managed to solve the null date by doing
This is what i got
As you can see, It is very a theorical workaround and not a practical one. I did others test and the best i could get so far is this
To get that line i had to change the workaround by changing the Y= value 0 in the addNullXY to the nearest old value of the adding series
If you come across a beter idea, please let me know.
Code: Select all
while i < Max(Chart1[0].Count, Chart1[1].Count)-1 do
To get that line i had to change the workaround by changing the Y= value 0 in the addNullXY to the nearest old value of the adding series
Code: Select all
//workaround
i:=0;
while i < Max(Chart1[0].Count, Chart1[1].Count)-1 do
begin
if ((i >= Chart1[0].Count) or (Chart1[0].XValue[i] > Chart1[1].XValue[i])) then
Chart1[0].AddNullXY(Chart1[1].XValue[i],Chart1[0].YValues[i-1])
else
if ((i >= Chart1[1].Count) or (Chart1[0].XValue[i] < Chart1[1].XValue[i])) then
Chart1[1].AddNullXY(Chart1[0].XValue[i],Chart1[1].YValues[i-1]);
i:=i+1;
end;
Chart1[0].XValues.Order:=loAscending;
Chart1[1].XValues.Order:=loAscending;
(Chart1[0] as TLineSeries).TreatNulls:=tnSkip;
(Chart1[1] as TLineSeries).TreatNulls:=tnSkip;
//end workaround
Re: Function with time issue
Hi GoToXY,
That's right, if you want your function to consider the "missing points" to have the value on the line, another option could be calculating the interpolation point instead of using the last YValue.
Take a look at the demo at All features\Welcome!\Chart Styles\Standard\Line (Strip)\Interpolating Line series
That's right, if you want your function to consider the "missing points" to have the value on the line, another option could be calculating the interpolation point instead of using the last YValue.
Take a look at the demo at All features\Welcome!\Chart Styles\Standard\Line (Strip)\Interpolating Line series
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Function with time issue
Yes, i did it 1 hour ago, just havent got the time to paste my code here tho. Oh i didnt know you guys already had done those thing in the demo. Anyway, everything is working fine now.
Thanks again for your support!
Thanks again for your support!