Page 1 of 1

How to MELT 2 Series on the Bottom Axes?

Posted: Wed Jul 30, 2014 4:56 pm
by 16467044
HI,

I have a Chart with 2 Series.
Both series have the same bottom axis, which is a date.
One series is of the Type CandleSeries and the other one LineSeries.


this WORKS:
To add my points I use:

Code: Select all

for i ... to .... 
begin
SeriesCandle.AddCandle(date,...)
Series_Line.AddXY(date,..)
end;
This works fine.
To my mind, this is due to the fact, that the date values come in SORTED.


DOES NOT WORK;
The moment I use 2 loops:

Code: Select all

for i...to... 
begin
SeriesCandle.AddCandle(date,...)
end;
and:

Code: Select all

for i...to... 
begin
SeriesLine.Addxy(date,...)
end;
It does not work any more as intended.
To my mind, this is due to the fact, that the date series comes in sorted, but in 2 CLUSTERS.
The candle data has e.g. the date from the 1st of April to the 1st of October.
Then the line series starts again by the 1st of April.
This is not the case, if I have ONE loop.

How can I make these 2 series to MELT on the bottom-date axis?
Only the y-values shall differ and have 2 axis.
The x-value shall be the same and show my 2 values at the same day if it occurs to have a common day.


In other words:
The Series.AddXY(date...)
shall do for me:
- search, if there is the date at the bottom axis already
--- if yes, draw the y-value above this very x-value
--- if no, draw a new x-value on the appropriate place and the y-value above it.


I attach you a screenshot, how it shall NOT look alike.

Thanks in advance,
Cheryll

Re: How to MELT 2 Series on the Bottom Axes?

Posted: Thu Jul 31, 2014 11:57 am
by 10050769
Hello Cheryll,

Many thanks for your information. Could you please send us a your project, because we can reproduce the problem you are experiencing here and try to find a solution for it?

Thanks in advance,

Re: How to MELT 2 Series on the Bottom Axes?

Posted: Thu Jul 31, 2014 2:49 pm
by 16467044
Hi Sandra,

I wrote all information you need.
Just add 2 series in a way, that you send 2 clusters of date-data there by 2 loops.
Any data.

Thanks,
Cheryll

Re: How to MELT 2 Series on the Bottom Axes?

Posted: Mon Aug 04, 2014 3:46 pm
by 10050769
Hello Cheryll,
To have same DateTime in the both loops is necessary reset the DateTime before add data to second series. Using the simple code below the problem you experiencing doesn’t appear for us here.

Code: Select all

uses System.DateUtils, TeCanvas;
var date: TDateTime;
procedure TForm2.FormCreate(Sender: TObject);
var i:Integer;
tmpOpen,tmpClose: Double;
begin
Chart1.View3D := false;
    //Date
    date := Now;
    tmpOpen := Random(1000);
    Series2.XValues.DateTime := true;
    for i := 0 to 30 do
    begin
      tmpOpen :=tmpOpen+(Random(100)-50);
      tmpClose:=tmpOpen-(Random(100)-50);
      Series1.AddCandle( date, tmpOpen, tmpOpen+Random(10), tmpClose-Random(10), tmpClose );
      date := IncDay(date,5);
    end;
    //Reset Date to Now.
    date := Now;
    for i := 0 to 30 do
    begin
     Series2.AddXY(date,Random(100));
      date := IncDay(date,5);
    end;
end;
Could you please check the code and tell us if it works in your end?

Thanks in advance,

Re: How to MELT 2 Series on the Bottom Axes?

Posted: Wed Aug 06, 2014 1:53 pm
by 16467044
Hi,

thank you very much for the answer.
The good new: It works!

The strange news: I did nothing.
To work on with my software in the meanwhile, I deactivated the "critical series".
On displaying it again - suddenly the thing was fixed.
I did not touch the 2 functions, which add my 2 series!
Since yesterday I tried to get the misfunction again to report you-, but no, it works now.

However I had this 2-series-problem douzends of time in the last years and used ugly work-arounds.
So I will keep the solution saved and trust, it saves me the rainy day, when I see it again. Thanks!


Regards,
Cheryll