Page 1 of 1

Multiple charts per form

Posted: Wed Feb 08, 2006 10:04 pm
by 9529775
Hi all

I'm on TChart v 7.0

I want to develop a dashboard like form with Tee Chart. My page would have a bar chart with 2 pie charts below the bar chart. Does Tee Chart allow multiple chart types per page in a form?

How can I link the pie charts to the bar charts such that the pie charts will change depending on which bar I click on?

Your advice most appreciated. Thanks

Best Regards

Posted: Thu Feb 09, 2006 9:45 am
by narcis
Hi,

Yes, this can be done using the approach shown at the code below. You can also position the charts as shown in the Multiple Pies example at All Features\Welcome!\Chart Styles\Standard\Pie in the TeeChart features demo which can be found at TeeChart's program group.

Code: Select all

Private Sub Form_Load()
    With TChart1.Series(0)
        .Add 12000, "Monitor", vbBlue
        .Add 22000, "Keyboard", vbRed
        .Add 52000, "Mouse", vbGreen
        .Add 8000, "Printer", vbWhite
        .Add 23000, "Webcam", vbYellow
    End With
    
    TChart2.Visible = False
End Sub

Private Sub TChart1_OnClickSeries(ByVal SeriesIndex As Long, ByVal ValueIndex As Long, ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
    TChart2.Visible = True
    
    TChart2.Header.Text.Clear
    TChart2.Header.Text.Add "Monthly " + TChart1.Series(0).ValueMarkText(ValueIndex) + " sales"
    
    Dim NumProds As Long
    NumProds = TChart1.Series(0).YValues.Value(ValueIndex)
    
    Dim Val As Double
    With TChart2.Series(0)
        .Clear
        .Add GenerateValue(NumProds), "January", clTeeColor
        .Add GenerateValue(NumProds), "February", clTeeColor
        .Add GenerateValue(NumProds), "March", clTeeColor
        .Add GenerateValue(NumProds), "April", clTeeColor
        .Add GenerateValue(NumProds), "May", clTeeColor
        .Add GenerateValue(NumProds), "June", clTeeColor
        .Add GenerateValue(NumProds), "July", clTeeColor
        .Add GenerateValue(NumProds), "August", clTeeColor
        .Add GenerateValue(NumProds), "September", clTeeColor
        .Add GenerateValue(NumProds), "October", clTeeColor
        .Add GenerateValue(NumProds), "November", clTeeColor
        .Add NumProds, "December", clTeeColor
    End With
    
    TChart2.Environment.InternalRepaint
    TChart2.Left = TChart1.Left
    TChart2.Top = TChart1.Top
    TChart2.Width = TChart1.Width
    TChart2.Height = TChart1.Height
End Sub

Function GenerateValue(NumProducts) As Double
    GenerateValue = (((NumProducts / 3) - 0 + 1) * Rnd + 0)
    NumProducts = NumProducts - GenerateValue
End Function

Private Sub TChart2_OnClick()
    TChart2.Visible = False
End Sub