How to MELT 2 Series on the Bottom Axes?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Chartist
Newbie
Newbie
Posts: 60
Joined: Wed Sep 18, 2013 12:00 am

How to MELT 2 Series on the Bottom Axes?

Post by Chartist » Wed Jul 30, 2014 4:56 pm

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
Attachments
meltSeries.jpg
meltSeries.jpg (331.04 KiB) Viewed 7600 times
Cheryll

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

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

Post by Sandra » Thu Jul 31, 2014 11:57 am

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,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Chartist
Newbie
Newbie
Posts: 60
Joined: Wed Sep 18, 2013 12:00 am

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

Post by Chartist » Thu Jul 31, 2014 2:49 pm

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
Cheryll

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

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

Post by Sandra » Mon Aug 04, 2014 3:46 pm

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,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Chartist
Newbie
Newbie
Posts: 60
Joined: Wed Sep 18, 2013 12:00 am

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

Post by Chartist » Wed Aug 06, 2014 1:53 pm

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
Cheryll

Post Reply