Mulitple series from a single recordset

TeeChart for ActiveX, COM and ASP
Post Reply
kebojax
Newbie
Newbie
Posts: 2
Joined: Tue Jul 22, 2003 4:00 am

Mulitple series from a single recordset

Post by kebojax » Fri Nov 03, 2006 1:18 pm

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

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

Post by Pep » Tue Nov 07, 2006 5:39 pm

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

kebojax
Newbie
Newbie
Posts: 2
Joined: Tue Jul 22, 2003 4:00 am

Post by kebojax » Wed Nov 08, 2006 12:25 pm

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?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Nov 08, 2006 4:33 pm

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply