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
Mulitple series from a single recordset
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.
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
Pep Jorge
http://support.steema.com
http://support.steema.com
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?
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
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.
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 |
![]() ![]() ![]() ![]() ![]() ![]() |
Instructions - How to post in this forum |