Page 1 of 1

Vertical bar series question

Posted: Thu Jun 22, 2006 12:06 pm
by 9241653
Hello,

I have a chart with 2 vertical bar series. The series are not stacked.

The first serie's datasource has the values:

A, 100
B, 80
C, 50
D, 70

The second serie's datasource has the values:

C, 20
D, 30

Now when I display the chart, the values from the second serie are displayed over A and B but I want them to be displayed over C and D.

Is this possible?

Thanks,
Vasile

Posted: Thu Jun 22, 2006 1:03 pm
by narcis
Hi Vasile,

Yes, this is possible. To achieve that you should add XValues for the series too. Actually they are automatically added: 0, 1, 2, 3 for the first series and 0, 1 for the second series. So that the series are displayed as you want you should add 0, 1, 2, 3 for the first series and 2, 3 for the second series.

Posted: Thu Jun 22, 2006 2:21 pm
by 9241653
Unfortunately I get those values from a database so I can't get 0,1,2,3,etc.
I only can get some ids in ascending order but they are not sequential (100,101,104,120 for example).

If I add :

100, A, 100
101, B, 80
104, C, 50
120, D, 70

and

104, C, 50
120, D, 70

it still doesn't work...

Posted: Thu Jun 22, 2006 3:11 pm
by narcis
Hi vasile,

It works fine for me here using:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  With Series1 do
  begin
    AddXY(100,100,'A',clTeeColor);
    AddXY(101,80,'B',clTeeColor);
    AddXY(104,50,'C',clTeeColor);
    AddXY(120,70,'D',clTeeColor);
    BarWidthPercent:=20;
    OffsetPercent:=-50;
  end;

  With Series2 do
  begin
    AddXY(104,50,'C',clTeeColor);
    AddXY(120,70,'D',clTeeColor);
    BarWidthPercent:=20;
    OffsetPercent:=50;
  end;
end;
So you should try to set up your datasource to populate the series like this.

Posted: Thu Jun 22, 2006 3:52 pm
by 9241653
Thanks for the example.
It works fine now except one small thing: there is a gap between C and D bars - because of the ids (104 and 120), is it possible to display the bars at the same distance one from another?

I could have ids like 101,102,120, 1200, 5000, etc.

Thanks,
Vasile

Posted: Fri Jun 23, 2006 10:14 am
by narcis
Hi Vasile,

I'm afraid this is not possible. You should manually read your database values and manually populate the chart ignoring the indexes. This way x values will be automatically added.

To avoid the first problem you reported here you should check if each series has a value for each index or not and populate series accordingly.

Posted: Fri Jun 23, 2006 10:17 am
by 9241653
OK, thank you.