LineSeries Getting AXlabels and AddArray

TeeChart for ActiveX, COM and ASP
Post Reply
SS
Newbie
Newbie
Posts: 27
Joined: Thu Nov 27, 2003 5:00 am
Location: Chicago

LineSeries Getting AXlabels and AddArray

Post by SS » Mon Mar 15, 2004 10:32 pm

For our charts we previously used AddXY and set the AXLabels to a value that we later pull out and use for a mouse over for the charts.

We recently switched to using AddArray's for performance improvement on both lineseries and fastline series. I know AddArray does not support setting an XLabel like the AddXY does, but what is the best way to add the Xlabel to the series after I have added the series via AddArray method?

So I would grab data from the database, add it to the chart series via the addarray method, then do something to go back and add Xlabels to each of the points within the series. Each chart has 6-7 series each with 10 and 50,000 points, so performance is a consideration.

Patrick

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

Post by Pep » Tue Mar 16, 2004 8:42 am

Hi^Patrick,

how about adding the labels as an array ? I think this is the best way :
i.e:

Code: Select all

Private Sub Form_Load()
ReDim MyYArray(10)
ReDim MyXArray(10)

For i = 0 To UBound(MyYArray) - 1
    MyXArray(i) = DateValue("2" & i & "/03/02")
    MyYArray(i) = Rnd * 100
Next i
TChart1.AddSeries scFastLine
TChart1.Series(0).XValues.DateTime = True
TChart1.Axis.Bottom.Labels.Angle = 90
TChart1.Series(0).AddArray UBound(MyYArray), MyYArray(), MyXArray()
End Sub

SS
Newbie
Newbie
Posts: 27
Joined: Thu Nov 27, 2003 5:00 am
Location: Chicago

Post by SS » Tue Mar 16, 2004 4:23 pm

When I refer to XLabel I don't mean the label for the X axis, what I mean is the Const ALabel in function AddXY(AX, AY: Double; Const ALabel: WideString; Value: OLE_COLOR): Integer; However in the description it denotes this field as the AXLabel which is the same as the ALabel above. Description: This function inserts a new point in the Series. The new point has X and Y values. The AXLabel parameter is optional (can be empty ''). The function returns the new point position in the Values list.

All your code is doing is adding an array of x and y values to a series. Typically when you do: objChart.Series(0).AddXY p_nSeriesLocation, p_nDataValue, arrSeries_MouseOver, p_sSeries_Color

The thing I'm interested in is the ALabel listed above as the arrSeries_MouseOver. We show the p_nSeriesLocation as one axis and the p_nDataValue as the other axis and set the color. However when you do: objChart.Series(0).AddArray UBound(MyYArray), MyYArray(), MyXArray() you have no option of setting the ALabel (arrSeries_MouseOver).

We use AddArray to add a series to the charts quicker but then I don't have away of setting the MouseOver Value. I thought my options were for each point in the series read the x and y values then delete the point then readd the point with the AddXY which we lose the performance increase from AddArray.

I was hoping I could just loop through the series and do a Set objChart.Series(0).SetALabel(12) = "SomeValue" kind of like the objChart.Series(0).setnull (12) but I could not find a way to accomplish this.

When I do mouse move on a chart we read the x value, y value to display to the user but we also put data in the ALabel for an additional 3rd value.

Hope this makes more sense.

SS
Newbie
Newbie
Posts: 27
Joined: Thu Nov 27, 2003 5:00 am
Location: Chicago

Post by SS » Wed Mar 17, 2004 8:58 pm

Ok I figured it out. I add the arrays using AddArray and then go back and for each point that I want to set a mouse over I call teechart.series(0).pointlabel(p_nLocation) = some_string_value

It achieves what I want it to. But it would be nice when adding arrays if you could specify a third array to add specifically for the point labels.

Post Reply