TAChart - add, but "inside" the other series lazarus / 55-TAChart ---------------------------------------------------------------------- Nicole · 2022-09-30 13:26 We have a TAChart, which's series are added at runtime by Series.AddXY(xx,yy); Series.AddXY(date,o,h,l,c) etc. Those series have all in common: The x-axes, which contains the date. Now I ADD one more series after the others are added already. It is added nicely, - on the right side of the existing series, with a double populated x-aches. How can I say, "add some y values to the existing(!) x-axes date"? ---------------------------------------------------------------------- wp · 2022-09-30 14:06 Show your code. ---------------------------------------------------------------------- Nicole · 2022-09-30 14:38 What the code does (many bugs and typos to do, pls do not tell me, I know it): Pls mind the fk1 or fk2 or fk3. fk for "foreign key" are the keys to SQL-series. The first query takes 3 SQL-series in one request. In the second query takes only 1 SQL-seried for fk1 and shall draw the candlestick-chart-series. The second series ("inside") is added after the German comment, which reads Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i "  // zweite Query wird gestaltet, die den Kontrakt 1 ins Chart zeichnet" Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TFrame_oi.Zeichne_oi(fk1, fk2, fk3: integer);Var s: string;    openinterest, volumen: integer;    Baranzahl: integer;//    kontrak1, kontrak2, kontrakt3: TEinKontrakt;    dat, dat_alt, dat2, dat1: TDateTime;    d: double; begin  Baranzahl:=StrToInt(LabeledEdit_oiBaranzahl.Caption);  dat2:=DB_Kontrakte.ReadSQL_tbKontrakteLetztesDatum(now); // dat2 ist das letzte verfügbare Datum  dat1:=IncDay(dat2, - Baranzahl);   // 20 Tage sind ca 1 Monat, dat 1 = erstes einzulesendes Datum  dat_alt:=dat1;    if fk1 <> -1 then     s:= DB_Kontrakte.ReadSQL_tbKontrakteElementZuID(fk1, 'NAME_');  Chart_oi.Title.Text.Text:='Liquidität der Kontrkate um ' + s + ' // Volumen ► blau, oi ► rot, ratio ► fett (linke Skala)';  // fett ging nicht mit ratio  if fk3 = -1   // mit den anderen beiden müsste ich die Ware abfragen  then showMessage('Frame_oi.Zeichne_oi damit habe ich noch wenig Erfahrung, hier fehlt jedenfalls der 3. Fremdschüssel');   s:='Select FK_JDATUM, VOLUME, openinterest From TBKURSZEILEN A ' +      'where FK_JDATUM > :datum '+      'and (FK_KONTRAKT = :fk1 or FK_KONTRAKT = :fk2 or FK_KONTRAKT = :fk3) ' +     'order by fk_JDatum ';  // wenn eines davon -1 wäre Abbruch  IBQuery_oi.SQL.Text:=s;            // die id der 3 Kontrakte und das Datum  IBQuery_oi.ParamByName('datum').AsDate:=dat1;  IBQuery_oi.ParamByName('fk1').AsInteger:=fk1;  IBQuery_oi.ParamByName('fk2').AsInteger:=fk2;  IBQuery_oi.ParamByName('fk3').AsInteger:=fk3;   IBQuery_oi.Active:=true;   Chart_oiLineSeries_oi.Clear;  Chart_oiLineSeries_vol.Clear;  Chart_oiLineSeries_ratio.Clear;  openinterest:=0;  volumen:=0;  while not IBQuery_oi.EOF do begin // openinterest und volumen werden aus allen 3 Kontrakten addiert     dat:=IBQuery_oi.FieldByName('FK_JDATUM').AsDateTime;    if dat=dat_alt then begin        openinterest:=openinterest + IBQuery_oi.FieldByName('openinterest').AsInteger;        volumen:=volumen + IBQuery_oi.FieldByName('VOLUME').AsInteger;    end    else begin        //  die vorigen Werte werden gezeichnet        if volumen <> 0 then begin          Chart_oiLineSeries_oi.AddXY(dat, openinterest);          Chart_oiLineSeries_vol.AddXY(dat, volumen);  //      Chart_oi_Candles.AddXOHLC(date,o,h,l,c);          d:=openinterest / volumen;          Chart_oiLineSeries_ratio.AddXY(dat, d);        end;         dat_alt:=dat;  // es wird neu gerechnet und neu zugewiesen        openinterest:=IBQuery_oi.FieldByName('openinterest').AsInteger;      volumen:=IBQuery_oi.FieldByName('VOLUME').AsInteger;    end;     IBQuery_oi.Next;  end;   // zweite Query wird gestaltet, die den Kontrakt 1 ins Chart zeichnet  IBQuery_oiEinKontrakt.SQL.Text:='Select first 50 ID_KURSZEILEN, FK_JDATUM, FK_KONTRAKT, '+     'O, H, L, C From TBKURSZEILEN where FK_KONTRAKT = :fk order by FK_JDATUM asc';  IBQuery_oiEinKontrakt.ParamByName('fk').AsInteger:=fk1;  IBQuery_oiEinKontrakt.Active:=true;   while not IBQuery_oiEinKontrakt.EOF do begin       Chart_oi_Candles.AddXOHLC(       IBQuery_oiEinKontrakt.FieldByName('FK_JDATUM').AsDateTime,       IBQuery_oiEinKontrakt.FieldByName('O').AsFloat,         IBQuery_oiEinKontrakt.FieldByName('H').AsFloat,         IBQuery_oiEinKontrakt.FieldByName('L').AsFloat,         IBQuery_oiEinKontrakt.FieldByName('C').AsFloat         );   IBQuery_oiEinKontrakt.Next;   end; end;                    If you ask yourself, why I do it this way and not simpler: Those SQL-series have different length. Where fk1 has data, fk3 has none. We do not know, which day exists for which foreign key. ---------------------------------------------------------------------- wp · 2022-09-30 15:32 I am attaching a test project showing that there is no bug in TAChart: A lineseries and an ohlc series with common date values for x are populated by random y values one after each other, but they are displayed correctly on the same axis. So, I don't know what's wrong in your case. The one thing that I noticed is that you do not clear the Chart_oi_Candles series unlike the others before adding the new data (but this would not append the newly added data to the x axis). ---------------------------------------------------------------------- Nicole · 2022-09-30 16:22 "clear" was a very useful hint and I added it. Nevertheless it did not cause the problem. I am afraid, TAChart may have drawn., -  what I keyed in. Those query may have reached too far into the past. So the problem is solved by SQL in that way select.... from... where ... datum > dat1