Page 1 of 1

AddXY behaviour

Posted: Tue Aug 31, 2004 2:20 pm
by 9080808
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.

Posted: Wed Sep 01, 2004 7:19 am
by Pep
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 ?

Posted: Wed Sep 01, 2004 9:31 am
by 9080808
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.

Posted: Wed Sep 01, 2004 2:38 pm
by Pep
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.

Posted: Wed Sep 01, 2004 2:56 pm
by 9080808
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: .

Posted: Thu Sep 02, 2004 12:03 am
by Pep
Hi Jesus,

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