Checking count of items in series after zoom

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
guzial
Newbie
Newbie
Posts: 7
Joined: Mon Mar 12, 2007 12:00 am

Checking count of items in series after zoom

Post by guzial » Wed Apr 23, 2008 8:28 am

Hello

i have problem
i would like to show marks but in special conditions.
When chart is in 100% zoom i would like automatically hide marks because there is to much points and showing marks is not useful. So my problem is to check number of showing points in series and if it less than X i would like to set marks to visible. Is there any way to do it?

thanks in advance

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Apr 23, 2008 9:40 am

Hi guzial,

You can do something like this:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  Series1.FillSampleValues(1000);
end;

procedure TForm1.Chart1Zoom(Sender: TObject);
begin
  SetMarksVisible(Series1);
end;

procedure TForm1.Chart1UndoZoom(Sender: TObject);
begin
  SetMarksVisible(Series1);
end;

procedure TForm1.SetMarksVisible(Series: TChartSeries);
begin
  Chart1.Draw;
  Series.Marks.Visible:=not (Series.VisibleCount>20);
end;
Best Regards,
Narcís Calvet / 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

guzial
Newbie
Newbie
Posts: 7
Joined: Mon Mar 12, 2007 12:00 am

Post by guzial » Thu Apr 24, 2008 6:55 am

what about TGanttSeries ?

Yeray
Site Admin
Site Admin
Posts: 9540
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Mon Apr 28, 2008 9:06 am

Hi guzial,

Yes, there seems to be a bug for Gantt series because VisibleCount doesn't seem to return the correct value. I've added it to the wish list to be fixed in further releases (TV52013013). But here you have a workaround that works fine for me here:

Code: Select all

procedure TForm1.Chart1Zoom(Sender: TObject);
begin
  SetMarksVisible(Series1);
end;

procedure TForm1.Chart1UndoZoom(Sender: TObject);
begin
  SetMarksVisible(Series1);
end;

procedure TForm1.SetMarksVisible(Series: TChartSeries);
var i, nInRange: Integer;
begin
  Chart1.Draw;
  nInRange := 0;
  for i:=0 to Series.Count-1 do
  begin
    if (Series.YValue[i] > Chart1.Axes.Left.Minimum) and (Series.YValue[i] < Chart1.Axes.Left.Maximum) then
      nInRange := nInRange+1;
  end;

  Series.Marks.Visible := not (nInRange > 10);
  Series.Marks.Clip := true;
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply