Need some help for a simple task!!!

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
johnnix
Advanced
Posts: 192
Joined: Tue Jul 10, 2007 12:00 am

Need some help for a simple task!!!

Post by johnnix » Tue Nov 13, 2012 8:37 am

Hello all,

I am completely stack with this so I need a fresh look from someone else!!! I created this chart, works as I want to but it looks like I cannot hide one name group, for example I need the user to be able to show/hide Name1 or Name2 etc. Any help please !!!!
Attachments
Untitled-1.gif
Untitled-1.gif (5.53 KiB) Viewed 8311 times

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

Re: Need some help for a simple task!!!

Post by Yeray » Tue Nov 13, 2012 3:24 pm

Hi Johnnix,

Could you please clarify if you want to hide just the "Name2" text, or also the bars above it?
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

johnnix
Advanced
Posts: 192
Joined: Tue Jul 10, 2007 12:00 am

Re: Need some help for a simple task!!!

Post by johnnix » Wed Nov 14, 2012 7:36 am

Hello,

I need to hide both label and bars :)

Regards

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

Re: Need some help for a simple task!!!

Post by Yeray » Wed Nov 14, 2012 8:44 am

Hi Johnnix,

Then, I'd work with null points. Known the ValueIndex to hide, you can loop all your series and set as null:

Code: Select all

  for i:=0 to Chart1.SeriesCount-1 do
    Chart1[i].SetNull(ValueIndex);
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

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

Re: Need some help for a simple task!!!

Post by Yeray » Wed Nov 14, 2012 9:03 am

Hi again,

In addition to the above, when I tried the following code, where I have 5 TBarSeries with 5 values each and I want to hide the ValueIndex=2:

Code: Select all

uses Series;

procedure TForm1.FormCreate(Sender: TObject);
var i, j, ValueIndex: Integer;
begin
  Chart1.View3D:=false;

  for i:=0 to 4 do
  begin
    with Chart1.AddSeries(TBarSeries) do
    begin
      FillSampleValues(5);
      Marks.Visible:=false;

      for j:=0 to Chart1[i].Count-1 do
        Chart1[i].Labels.Labels[j]:='Name'+IntToStr(j+1);
    end;
  end;

  ValueIndex:=2;  //ValueIndex to hide
  for i:=0 to Chart1.SeriesCount-1 do
    Chart1[i].SetNull(ValueIndex);
end;
I've seen the bars with ValueIndex=2 are correctly hidden, but not the bottom axis label.
However, you can always hide those labels in the bottom axis with no visible value associated:

Code: Select all

procedure TForm1.Chart1GetAxisLabel(Sender: TChartAxis;
  Series: TChartSeries; ValueIndex: Integer; var LabelText: String);
var i: Integer;
begin
  if (Sender=Chart1.Axes.Bottom) and (ValueIndex>-1) then
    for i:=0 to Chart1.SeriesCount-1 do
      if Chart1[i].IsNull(ValueIndex) then
      begin
        if i=Chart1.SeriesCount-1 then
          LabelText:='';
      end
      else
        exit;
end;
And the above seems to work fine for me here.
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

johnnix
Advanced
Posts: 192
Joined: Tue Jul 10, 2007 12:00 am

Re: Need some help for a simple task!!!

Post by johnnix » Thu Nov 15, 2012 7:41 am

Hello Yeray,

Thank you very much for the prompt reply, I will give it a try !!!

Kindest regards

Post Reply