AddXY behaviour

TeeChart for ActiveX, COM and ASP
Post Reply
Jesús Lucas
Newbie
Newbie
Posts: 6
Joined: Tue Feb 10, 2004 5:00 am
Location: Barcelona (Spain)
Contact:

AddXY behaviour

Post by Jesús Lucas » Tue Aug 31, 2004 2:20 pm

Hello,

We have a problem with AddXY, we upgraded teechart from v5 to v6 some time ago, and we had discovered recently that the AddXY function behaves differently between these versions.

Before, we used the AddXY function to put data the same way for horizontal and vertical bar charts, but now, with version 6, we need to change the X and Y values of the horizontal bar charts to show the data properly.

Is this the desired behaviour or is it a bug?

Thanks for your help.
Best Regards:
Jesús Lucas

Tango/04 Computing Group
http://www.tango04.com
IBM ALL STAR Partner
Teléfono: +34 93 274 00 51 Fax: +34 93 345 13 29
Avenida Meridiana 358, 5 A-B
08027 Barcelona

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Wed Sep 01, 2004 7:19 am

Hi Jesus,

I can create the same Chart using the following code :

Code: Select all

Private Sub Form_Load()
With TChart1
    .AddSeries scHorizLine
    .Series(0).AddXY 0, 10, "", clTeeColor
    .Series(0).AddXY 1, 4, "", clTeeColor
    .Series(0).AddXY 2, 12, "", clTeeColor
    .Series(0).AddXY 3, 7, "", clTeeColor
    .Series(0).AddXY 4, 17, "", clTeeColor
    .Series(0).AddXY 5, 11, "", clTeeColor
    .Axis.Bottom.Increment = 1
End With
End Sub
How can I reproduce the problem you're referencing ?

Jesús Lucas
Newbie
Newbie
Posts: 6
Joined: Tue Feb 10, 2004 5:00 am
Location: Barcelona (Spain)
Contact:

Post by Jesús Lucas » Wed Sep 01, 2004 9:31 am

If I have two charts and a button with this code

Code: Select all

Private Sub Command1_Click()
    TChart2.ChangeSeriesType 0, scHorizBar
End Sub

Private Sub Form_Load()
    With TChart1
        .AddSeries scHorizBar
        .Series(0).AddXY 0, 10, "", clTeeColor
        .Series(0).AddXY 1, 4, "", clTeeColor
        .Series(0).AddXY 2, 12, "", clTeeColor
        .Series(0).AddXY 3, 7, "", clTeeColor
        .Series(0).AddXY 4, 17, "", clTeeColor
        .Series(0).AddXY 5, 11, "", clTeeColor
        .Axis.Bottom.Increment = 1
    End With
    With TChart2
        .AddSeries scBar
        .Series(0).AddXY 0, 10, "", clTeeColor
        .Series(0).AddXY 1, 4, "", clTeeColor
        .Series(0).AddXY 2, 12, "", clTeeColor
        .Series(0).AddXY 3, 7, "", clTeeColor
        .Series(0).AddXY 4, 17, "", clTeeColor
        .Series(0).AddXY 5, 11, "", clTeeColor
        .Axis.Bottom.Increment = 1
    End With

End Sub
When I press the command button to change the series type of the second chart to match the first one, the charts are different, but the data used to generate both charts are the same.

If I want both charts to be the same, I have to change the X and Y values on one of them.

I hope this explanation will be more useful to you.

Thanks for your effort.

By the way, I think this forum had also a bug: the author of every thread always change to match the author of the last reply.
Best Regards:
Jesús Lucas

Tango/04 Computing Group
http://www.tango04.com
IBM ALL STAR Partner
Teléfono: +34 93 274 00 51 Fax: +34 93 345 13 29
Avenida Meridiana 358, 5 A-B
08027 Barcelona

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Wed Sep 01, 2004 2:38 pm

Hi Jesus,

the problem here is that you must add the data to the first Chart inverted, the Help file says :
Warning:

The most important concept in HorizBarSeries is that point values are INVERTED. That means Y values are the bar order position while X values are the bars values.

The AddBar method does the conversion automatically and is the recommended method to add points. When using the AddXY method you should calculate the correct Y position.

Example:

Example [Visual Basic]:

{ This code adds 10 horizontal bars.
The loop counter is used as the Y bar value (the bar order) }

With TChart1
.AddSeries scHorizBar
For i = 1 To 10
.Series(0).AddXY MyValues(i), i, MyLabels(i), MyColor(i)
Next i
End With
By the way, I think this forum had also a bug: the author of every thread always change to match the author of the last reply.
Yes, you're correct, I'll take a look. Thanks for the advise.

Jesús Lucas
Newbie
Newbie
Posts: 6
Joined: Tue Feb 10, 2004 5:00 am
Location: Barcelona (Spain)
Contact:

Post by Jesús Lucas » Wed Sep 01, 2004 2:56 pm

Thanks for the advise, but I need to know if any other series type has the X and Y values changed. I navigated throug the help but I didn't find any more warning. This request is because I don't know in advance the series types of the chart and I thought that using AddXY would work for every type the same way, but now I know that there is at least one exception.

Sorry for the trouble :oops: .
Best Regards:
Jesús Lucas

Tango/04 Computing Group
http://www.tango04.com
IBM ALL STAR Partner
Teléfono: +34 93 274 00 51 Fax: +34 93 345 13 29
Avenida Meridiana 358, 5 A-B
08027 Barcelona

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Thu Sep 02, 2004 12:03 am

Hi Jesus,

this is for all the Horizontal Series like :
HorizArea, HorizBar,HorizLine.

Post Reply