Konuyu Oyla:
  • Derecelendirme: 5/5 - 1 oy
  • 1
  • 2
  • 3
  • 4
  • 5
[ÇÖZÜLDÜ]canlı trend
#21
Sizin chart'ın tarih alanı bağlı değil görünen.
  DBChart1.SeriesList[0].DataSource := FDQuery1;
  DBChart1.SeriesList[0].XValues.ValueSource  := 'tarih';
 DBChart1.SeriesList[0].XValues.DateTime     := true;
 DBChart1.SeriesList[0].YValues.ValueSource  := 'deger';

 LimitAxis( DBChart1.SeriesList[0] );
Saygılarımla
Muharrem ARMAN

guplouajuixjzfm15eqb.gif
Cevapla
#22
(26-05-2020, Saat: 16:50)mrmarman Adlı Kullanıcıdan Alıntı: Sizin chart'ın tarih alanı bağlı değil görünen.
  DBChart1.SeriesList[0].DataSource := FDQuery1;
  DBChart1.SeriesList[0].XValues.ValueSource  := 'tarih';
 DBChart1.SeriesList[0].XValues.DateTime     := true;
 DBChart1.SeriesList[0].YValues.ValueSource  := 'deger';

 LimitAxis( DBChart1.SeriesList[0] );

@mrmarman  hocam, farkındayım çok uğraştırdım lakin sorunu tesbit edebilsem, çözüm için çabalıcam. Sad
   
Yazılımcı, kahveyi koda çeviren bir organizmadır.
Cevapla
#23
DBChart nesnenizi manuel oluşturarak deneyin. Bir şeyleri deneme yanılma ile yanlış ayarlamış olabilirsiniz.

her eklenen veri için aşağıdaki gibi bir akış olacak.

procedure TForm1.Timer1Timer(Sender: TObject);
var
 aValue : Integer;
begin
 aValue := Random( 200 );
 AddRecord( DBChart1.SeriesList[0], aValue );

 FDQuery1.Refresh;
 FDQuery1.Last;
 DBChart1.RefreshData;
 LimitAxis( DBChart1.SeriesList[0] );
end;

procedure TForm1.ButtonRecordTimerClick(Sender: TObject);
var
i       : Integer;
aValue  : Integer;
begin
// -------------------------------------------------------------------------- //
//  DBChart 1
// -------------------------------------------------------------------------- //
With DBChart1 do
begin
  for i := 0 to SeriesCount -1 do Series[i].Free;
  ClearChart;

  AutoSize                    := False;
  View3D                      := False;
  Legend.Visible              := False;
  Align                       := alNone;
  AxisBehind                  := True; // axis ref.lines must behinde the chart


  With Title do  begin
    Visible       := True;
    Text.Clear;
    Text.Add( 'Örnek Grafik' );
    Text.Add( '' );
    Alignment     := TAlignment.taCenter;
    Font.Style    := [fsBold];
    Font.Size     := 12;
    Font.Name     := 'Tahoma';
    Font.Color    := clMaroon;
    Bevel         := bvRaised;
  end;


  With LeftAxis do begin
    Visible            := True;
    AutomaticMaximum   := False;
    SetMinMax( -5, 250 );
    Increment          :=   1.0;
    Grid.Visible       := False;

    With Title do  begin
      Caption          :='Değerler';
      Alignment        := TAlignment.taCenter;
      Font.Style       := [fsBold];
      Font.Size        := 8;
      Font.Name        := 'Arial';
      Font.Color       := clBlack;
      Bevel            := bvLowered;
      Brush.Color      := clYellow;
      Brush.Style      := bsSolid;
      Transparent      := False;
      Transparency     := 25;
      ClipText         := True;
    end;
  end;

  With BottomAxis do begin
    Visible            := True;
      Texts.Angle      := 90;
      Texts.Size       := 20;
    Ticks.Color        := clRed;
    Automatic          := True;
    MinorTicks.Visible := True;
    MinimumOffset      := 0;
    MaximumOffset      := 0;
  end;
end;

with DBChart1.AddSeries(TFastLineSeries) as TFastLineSeries do  // idx: 0
begin
  Legend.Visible    := False;
  XValues.Order     := loNone;
  TreatNulls        := tnDontPaint;
  SeriesColor       := clBlue;

  Pen.Color         := clBlack;
  Pen.Style         := psSolid;
  Pen.Width         :=  2;

  Marks.Visible     := true;
  Marks.Style       := smsValue;

  VertAxis          := aLeftAxis;
  HorizAxis         := aBottomAxis;
end; // with

DBChart1.SeriesList[0].DataSource := qrygrafik;
DBChart1.SeriesList[0].XValues.ValueSource  := 'tarih';
DBChart1.SeriesList[0].XValues.DateTime     := true;
DBChart1.SeriesList[0].YValues.ValueSource  := 'deger';
LimitAxis( DBChart1.SeriesList[0] );
end;
Saygılarımla
Muharrem ARMAN

guplouajuixjzfm15eqb.gif
Cevapla
#24
(26-05-2020, Saat: 17:10)mrmarman Adlı Kullanıcıdan Alıntı: DBChart nesnenizi manuel oluşturarak deneyin. Bir şeyleri deneme yanılma ile yanlış ayarlamış olabilirsiniz.

her eklenen veri için aşağıdaki gibi bir akış olacak.

procedure TForm1.Timer1Timer(Sender: TObject);
var
 aValue : Integer;
begin
 aValue := Random( 200 );
 AddRecord( DBChart1.SeriesList[0], aValue );

 FDQuery1.Refresh;
 FDQuery1.Last;
 DBChart1.RefreshData;
 LimitAxis( DBChart1.SeriesList[0] );
end;

procedure TForm1.ButtonRecordTimerClick(Sender: TObject);
var
i       : Integer;
aValue  : Integer;
begin
// -------------------------------------------------------------------------- //
//  DBChart 1
// -------------------------------------------------------------------------- //
With DBChart1 do
begin
  for i := 0 to SeriesCount -1 do Series[i].Free;
  ClearChart;

  AutoSize                    := False;
  View3D                      := False;
  Legend.Visible              := False;
  Align                       := alNone;
  AxisBehind                  := True; // axis ref.lines must behinde the chart


  With Title do  begin
    Visible       := True;
    Text.Clear;
    Text.Add( 'Örnek Grafik' );
    Text.Add( '' );
    Alignment     := TAlignment.taCenter;
    Font.Style    := [fsBold];
    Font.Size     := 12;
    Font.Name     := 'Tahoma';
    Font.Color    := clMaroon;
    Bevel         := bvRaised;
  end;


  With LeftAxis do begin
    Visible            := True;
    AutomaticMaximum   := False;
    SetMinMax( -5, 250 );
    Increment          :=   1.0;
    Grid.Visible       := False;

    With Title do  begin
      Caption          :='Değerler';
      Alignment        := TAlignment.taCenter;
      Font.Style       := [fsBold];
      Font.Size        := 8;
      Font.Name        := 'Arial';
      Font.Color       := clBlack;
      Bevel            := bvLowered;
      Brush.Color      := clYellow;
      Brush.Style      := bsSolid;
      Transparent      := False;
      Transparency     := 25;
      ClipText         := True;
    end;
  end;

  With BottomAxis do begin
    Visible            := True;
      Texts.Angle      := 90;
      Texts.Size       := 20;
    Ticks.Color        := clRed;
    Automatic          := True;
    MinorTicks.Visible := True;
    MinimumOffset      := 0;
    MaximumOffset      := 0;
  end;
end;

with DBChart1.AddSeries(TFastLineSeries) as TFastLineSeries do  // idx: 0
begin
  Legend.Visible    := False;
  XValues.Order     := loNone;
  TreatNulls        := tnDontPaint;
  SeriesColor       := clBlue;

  Pen.Color         := clBlack;
  Pen.Style         := psSolid;
  Pen.Width         :=  2;

  Marks.Visible     := true;
  Marks.Style       := smsValue;

  VertAxis          := aLeftAxis;
  HorizAxis         := aBottomAxis;
end; // with

DBChart1.SeriesList[0].DataSource := qrygrafik;
DBChart1.SeriesList[0].XValues.ValueSource  := 'tarih';
DBChart1.SeriesList[0].XValues.DateTime     := true;
DBChart1.SeriesList[0].YValues.ValueSource  := 'deger';
LimitAxis( DBChart1.SeriesList[0] );
end;

@mrmarman  hocam,
son durum bu şekilde. Sad
   
Kodların son durumu da bu :

unit Unit1;

interface

uses
 Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
 Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Data.DB, MemDS, DBAccess,
 Uni, UniProvider, MySQLUniProvider, Vcl.ExtCtrls, Vcl.Grids, Vcl.DBGrids,
 VCLTee.TeEngine, VCLTee.TeeFunci, VCLTee.Series, VCLTee.TeeProcs,
 VCLTee.Chart, VCLTee.DBChart, Math;

type
 TForm1 = class(TForm)
   unicon_mysql: TUniConnection;
   MySQLUniProvider1: TMySQLUniProvider;
   qrygrafik: TUniQuery;
   srcgrafik: TDataSource;
   DBGrid1: TDBGrid;
   DBChart1: TDBChart;
   Button2: TButton;
   Timer1: TTimer;
   Button3: TButton;
   procedure LimitAxis( aChartSeries: TChartSeries );
   procedure DBChart1GetAxisLabel(Sender: TChartAxis; Series: TChartSeries;
     ValueIndex: Integer; var LabelText: string);
   procedure Button2Click(Sender: TObject);
   procedure Timer1Timer(Sender: TObject);
   procedure Button3Click(Sender: TObject);
 private
   { Private declarations }
 public
   { Public declarations }
 end;

var
 Form1: TForm1;

implementation

{$R *.dfm}


procedure TForm1.LimitAxis( aChartSeries: TChartSeries );
const
iVisibleValuesCount = 80;
var
i, iMin, iMax  : Integer;
begin
With aChartSeries do
begin
  iMin := Count - iVisibleValuesCount;
  iMax := pred( Count );

  if iMin < 0 then iMin := 0;
  // Hide old/previous visible marks
  // ( to prevent show marks outside the chart canvas )
  for i := iMin downto iMin - 20 do begin
    if iMin > 0
      then  Marks[ i ].Visible := False;
  end;

  ParentChart.BottomAxis.SetMinMax( aChartSeries.XValues[iMin] , aChartSeries.XValues[iMax]); // this is the magic
end;
end;


procedure TForm1.Timer1Timer(Sender: TObject);
var
aValue : Integer;
begin
aValue := Random( 200 );

   qrygrafik.Insert;
   qrygrafik.FieldByName('deger').value := avalue;
   qrygrafik.FieldByName('tarih').value := date + time;
   qrygrafik.post;

qrygrafik.Refresh;
qrygrafik.Last;
DBChart1.RefreshData;
LimitAxis( DBChart1.SeriesList[0] );
   application.ProcessMessages;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
i       : Integer;
aValue  : Integer;
begin
// -------------------------------------------------------------------------- //
//  DBChart 1
// -------------------------------------------------------------------------- //
With DBChart1 do
begin
  for i := 0 to SeriesCount -1 do Series[i].Free;
  ClearChart;

  AutoSize                    := False;
  View3D                      := False;
  Legend.Visible              := False;
  Align                       := alNone;
  AxisBehind                  := True; // axis ref.lines must behinde the chart


  With Title do  begin
    Visible       := True;
    Text.Clear;
    Text.Add( 'Örnek Grafik' );
    Text.Add( '' );
    Alignment     := TAlignment.taCenter;
    Font.Style    := [fsBold];
    Font.Size     := 12;
    Font.Name     := 'Tahoma';
    Font.Color    := clMaroon;
    Bevel         := bvRaised;
  end;


  With LeftAxis do begin
    Visible            := True;
    AutomaticMaximum   := False;
    SetMinMax( -5, 250 );
    Increment          :=   1.0;
    Grid.Visible       := False;

    With Title do  begin
      Caption          :='Değerler';
 //     Alignment        := TAlignment.taCenter;
      Font.Style       := [fsBold];
      Font.Size        := 8;
      Font.Name        := 'Arial';
      Font.Color       := clBlack;
      Bevel            := bvLowered;
      Brush.Color      := clYellow;
      Brush.Style      := bsSolid;
      Transparent      := False;
      Transparency     := 25;
 //     ClipText         := True;
    end;
  end;

  With BottomAxis do begin
    Visible            := True;
 //     Texts.Angle      := 90;
//       Texts.Size       := 20;
    Ticks.Color        := clRed;
    Automatic          := True;
    MinorTicks.Visible := True;
    MinimumOffset      := 0;
    MaximumOffset      := 0;
  end;
end;

with DBChart1.AddSeries(TFastLineSeries) as TFastLineSeries do  // idx: 0
begin
//  Legend.Visible    := False;
  XValues.Order     := loNone;
  TreatNulls        := tnDontPaint;
  SeriesColor       := clBlue;

  Pen.Color         := clBlack;
  Pen.Style         := psSolid;
  Pen.Width         :=  2;

  Marks.Visible     := true;
  Marks.Style       := smsValue;

  VertAxis          := aLeftAxis;
  HorizAxis         := aBottomAxis;
end; // with

DBChart1.SeriesList[0].DataSource := qrygrafik;
DBChart1.SeriesList[0].XValues.ValueSource  := 'tarih';
DBChart1.SeriesList[0].XValues.DateTime     := true;
DBChart1.SeriesList[0].YValues.ValueSource  := 'deger';

end;

procedure TForm1.Button3Click(Sender: TObject);
begin
timer1.Enabled := true;
end;

procedure TForm1.DBChart1GetAxisLabel(Sender: TChartAxis; Series: TChartSeries;
 ValueIndex: Integer; var LabelText: string);
var
aDate: TDateTime;
begin
if (Sender = DBChart1.Axes.Bottom) then
begin
 aDate     :=  StrToDateTime(LabelText);
 LabelText :=  FormatDateTime('dd.mm.yyyy', aDate);
end;
end;


end.

DBChartı sildim. Sizin kodu ekledim. Yinede ben de kaydırma işlemi yapmıyor bir türlü. Bu kadar uğraşmamıştım hiç. Sad
Yazılımcı, kahveyi koda çeviren bir organizmadır.
Cevapla
#25
80 kayıt sonra kaymaya başlar

80 olan  iVisibleValuesCount = 80;  rakamını 10 yapıp dener misin.
Saygılarımla
Muharrem ARMAN

guplouajuixjzfm15eqb.gif
Cevapla
#26
(26-05-2020, Saat: 18:12)mrmarman Adlı Kullanıcıdan Alıntı: 80 kayıt sonra kaymaya başlar

80 olan  iVisibleValuesCount = 80;  rakamını 10 yapıp dener misin.

@mrmarman hocam

10 olarak düzelttim. Bu sefer de 10. kyıttan itibaren list index hatası verdi.
   

iVisibleValuesCount = 30; yapınca, 30 kayıt insert edildiğinde hata verdi.
Yazılımcı, kahveyi koda çeviren bir organizmadır.
Cevapla
#27
önce 50-100 kadar kayıt ekleyin ondan sonra bir çalıştırın. Bence sorun kayıt sayısında.



Şu şekilde bir eklenti yaptım. Kayıt sayısı belli bir marjın altındaysa da kendisini ona göre ayarlayabiliyor.

procedure TForm1.LimitAxis( aChartSeries: TChartSeries );
const
 iVisibleValuesCount = 20;
var
 i, iMin, iSub, iMax  : Integer;
begin
 With aChartSeries do
 begin
   iMin := Count - iVisibleValuesCount;
   iMax := pred( Count );

   if iMin < 0 then iMin := 0;
   // Hide old/previous visible marks
   // ( to prevent show marks outside the chart canvas )

   iSub := iMin-10;
   if iSub < 0  then iSub := 0;

   for i := iMin downto iSub do begin
     if iMin > 0
       then  Marks[ i ].Visible := False;
   end;

   ParentChart.BottomAxis.SetMinMax( aChartSeries.XValues[iMin] , aChartSeries.XValues[iMax]); // this is the magic
 end;
end;
Saygılarımla
Muharrem ARMAN

guplouajuixjzfm15eqb.gif
Cevapla
#28
(26-05-2020, Saat: 18:20)mrmarman Adlı Kullanıcıdan Alıntı: önce 50-100 kadar kayıt ekleyin ondan sonra bir çalıştırın. Bence sorun kayıt sayısında.

@mrmarman  Hocam,
Hakkınızı helal edin. Çok uğraştırdım sizi. 100 Kayıt ekledikten sonra programı tekrar çalıştırdığımda kayma işlemi başladı. Programı düzenledikten sonra, diğer arkadaşlarımızın da faydalanması için kodları buraya koyacağım. Çok sağolun. Minnettarım.
Yazılımcı, kahveyi koda çeviren bir organizmadır.
Cevapla
#29
Bir önceki mesajda buna ilişkin bir kod ekledim. 1 kayıt  da olsa çalışacak şekilde. iSub isminde bir alt değişken ile marjın altında kalan kayıt sayısını dikkate alıyor.

tebrikler.
Saygılarımla
Muharrem ARMAN

guplouajuixjzfm15eqb.gif
Cevapla
#30
(26-05-2020, Saat: 18:31)mrmarman Adlı Kullanıcıdan Alıntı: Bir önceki mesajda buna ilişkin bir kod ekledim. 1 kayıt  da olsa çalışacak şekilde. iSub isminde bir alt değişken ile marjın altında kalan kayıt sayısını dikkate alıyor.

tebrikler.

@mrmarman 
Aynen hocam dediğiniz gibi kayıt eklemeden yaptım. Çalıştı. Tekrar emeklerinize çok teşekkür ederim.
Yazılımcı, kahveyi koda çeviren bir organizmadır.
Cevapla


Konu ile Alakalı Benzer Konular
Konular Yazar Yorumlar Okunma Son Yorum
  AdoQuery ile ilgili bir sorun. (Çözüldü) Bay_Y 4 111 17-04-2024, Saat: 10:58
Son Yorum: Bay_Y
  Fastreport İçindekiler Sayfası Oluşturma [ÇÖZÜLDÜ] bydelphi 1 237 18-03-2024, Saat: 12:11
Son Yorum: bydelphi
  Çok Satırlı Filtreleme [Çözüldü] bünyamin68 12 1.353 14-02-2024, Saat: 22:42
Son Yorum: mustafaozpinar
  [ÇÖZÜLDÜ] macos işletim sistemine program yazmak shooterman 5 514 02-02-2024, Saat: 09:54
Son Yorum: shooterman
  COZULDU veritabani prg yerine ne kullanabilirim. sadikacar60 8 776 29-01-2024, Saat: 18:41
Son Yorum: sadikacar60



Konuyu Okuyanlar: 1 Ziyaretçi