Bubble chart

TeeChart for ActiveX, COM and ASP
Post Reply
TCubs
Newbie
Newbie
Posts: 6
Joined: Fri Jun 04, 2004 4:00 am
Location: NY

Bubble chart

Post by TCubs » Mon Nov 22, 2004 9:50 pm

Hi,

I would really like to use the Bubble series as this is perfect for a project I am working on. I am using TeeChart version 6 of the ASP plug-in. Please can you show me a short code snippet that will generate a simple bubble chart, and also let me know what each option is. I believe it is something like:

Code: Select all

Do Until END_OF_RECORDSET
  With CHARTNAME.Series(1).asBubble 
    .AddBubble OPTION1, OPTION2, OPTION3, i, COLOR
    i = i + 1 
    adoRs.MoveNext 
  End With 
Loop
but I am not sure. Thanks!

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

Post by Pep » Tue Nov 23, 2004 2:56 pm

Hi,

yes, you must use the AddBubble method, from the help :
function AddBubble(AX, AY, ARadius: Double; Const AXLabel: WideString; Value: OLE_COLOR): Integer;

Type Library
TeeChartX

Description
The AddBubble method appends a new Bubble point to the Series Points List. The Bubble point is assigned to be at AX,AY coordinates and have ARadius, Label and Color parameters. The Label parameter is used to draw Axis Labels, Bubble Marks and Legend.

Example

This example randomly creates bubble values.

Example [Visual Basic]:

Dim t As Integer

With TChart1
.Series(0).Clear
For t = 1 To 10
.Series(0).asBubble.AddBubble t, Rnd(2), Rnd(5), "", _
RGB(255 * Rnd, 128 * Rnd, 255 * Rnd)
Next t
End With

TCubs
Newbie
Newbie
Posts: 6
Joined: Fri Jun 04, 2004 4:00 am
Location: NY

Post by TCubs » Tue Nov 23, 2004 8:26 pm

Hi Josep,
Thanks for this. I did get the example to work.

I have a 2D table of values that I'd like to display is a bubble chart, where the size of the bubble is represented by the value in the cell. I would therefore get a chart with 'bubbles' replacing the table 'cells'. Is this possible? The chart would look like columns of bubbles of different sizes, with the table top/left titles becoming the chart axes.

2 3 1 ---> |O 0 o
1 2 3 ---> |o O 0
3 3 2 ---> |0 o O
1 1 2 ---> |o o O
----------> ---------> etc.

Thanks again,
Terry

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 24, 2004 11:38 am

Hi Terry,

To have your chart like a bubble table you can do something like:

Code: Select all

Private Sub Form_Load()

    Dim x, y, FMin, FMax As Integer  
    
    FMin = 1
    FMax = 5
    
    TChart1.Axis.Bottom.SetMinMax FMin - 1, FMax + 1
    TChart1.Axis.Left.SetMinMax FMin - 1, FMax + 1
    
    With TChart1.Series(0)
        For x = FMin To FMax
            For y = FMin To FMax
                .asBubble.AddBubble x, y, Rnd(5), "", clTeeColor
            Next y
        Next x
    End With
    
End Sub
Setting Axis Min. and Max. values you will have a better aproach to a "table-like" appearence, then you will have to add the bubbles with your table source values.
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