Page 1 of 1

Mulitple series from a single recordset

Posted: Fri Nov 03, 2006 1:18 pm
by 9078318
I'm fairly new to TeeChart and want to add multiple series to a graph using a single recordset. The data will be:
Type - Hour - Count
Each Type will be a series
Hour will be the bottom axis labels
and Count will be the bar values.
I can create the chart with a single type, but am unsure how to create the multiple series. Any assistance would be appreciated.
If it helps here's the data from one test:
TYPE HOUR COUNT
1 8 4
1 9 11
1 10 11
1 11 7
1 12 13
1 13 5
1 14 5
1 15 15
1 16 7
5 8 3
5 9 3
5 10 3
5 11 3
5 12 7
5 13 3
5 14 3
5 15 5
5 16 2
5 17 3

Posted: Tue Nov 07, 2006 5:39 pm
by Pep
Hi,

if all the data is stored on the same Table you will have to use a "select..." to get the data for each Series, and then you can set the ValueSource for each ValueList, you can use similar code to the following one, modifying the Select and repeating the assignment of ValueSource for each Series.

Code: Select all

Dim Data As New ADODB.Connection
Dim rst As New ADODB.Recordset

Private Sub Form_Load()
Data.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
               & App.Path & "\AccessTestDB.mdb;Persist Security Info=False"
rst.Open "select * from DataTwo", Data, 1, 1
With TChart1
    .Aspect.View3D = False
    .AddSeries scHorizBar
    .Series(0).DataSource = rst
    .Series(0).XValues.ValueSource = rst.Fields(1).Name
    .Series(0).YValues.ValueSource = rst.Fields(2).Name
    .Series(0).YValues.DateTime = True
End With
End Sub

Posted: Wed Nov 08, 2006 12:25 pm
by 9078318
Thanks, that's what I figured. I was just trying to see if there was a way to do it with a single recordset. The query is going against a lot of data and I was trying to avoid having to run it multiple times. Would it be possible to set up an internal array and then loop through the recordset multiple times, the first time assigning the values for record type "A" to the array, add the series. Loop through the recordset again assigning the values for record type "B" to the array, add the series; and so on?

Posted: Wed Nov 08, 2006 4:33 pm
by narcis
Hi kebojax,

Yes, you can use arrays as shown in the features demo examples at All Features\Welcome!\Speed. You'll find the features demo at TeeChart's program group.