Sample 4 - 2 Y Scales, 2 X Scales, Y Stacking, No Scrollbars

' To test this code, the trial or full version of XYChart must be installed on your computer.
' 1. Start a new standard Visual Basic project
' 2. Copy the code below directly into the project
' 3. On the form, place a new XYChart control named XYChart4Ctl1 (default)
' 4. Run the project

Private Sub Form_Load()
    ' Configure XYChart control
    With XYChart4Ctl1
        .NumProfiles = 2

        .NumYScales = 2
        .NumXScales = 2

        ' Y Stacking
        .YStacking = True
        .NumYStacks = 2
        .YStack(1).HeightPercentage = 70
        .YStack(2).HeightPercentage = 30
        .YStack(1).NumYScales = 1
        .YStack(2).NumYScales = 1

         .Toolbar.Visible = True

        ' Format Legend
        .Legend.Visible = True
        .Legend.BorderVisible = False
        .Legend.YScaleVisible = False

        ' Scrollbars
         .ScrollBars.HorizontalVisible = False
        .ScrollBars.VerticalVisible = False

        ' Crosshairs
        .CrossHairs.YCoordInLegend = True
        .CrossHairs.Color = vbYellow
        .CrossHairs.Width = woTwoPoint
        .CrossHairs.HorizontalVisible = False
        .CrossHairs.CoordsBackcolor = vbYellow

        ' Gridlines
        .YGrid(1).LineOption = loCustom
        .YGrid(1).LineColor = RGB(128, 0, 64)
        .XGrid(1).LineOption = loCustom
        .XGrid(1).LineColor = .YGrid(1).LineColor

        .YGrid(2).LineOption = loCustom
        .YGrid(2).LineColor = RGB(0, 0, 64)
        .XGrid(2).LineOption = loCustom
        .XGrid(2).LineColor = .YGrid(2).LineColor

        ' X Scale 1
        .XScale(1).Label = ""
        .XScale(1).TicksFont.Color = RGB(128, 0, 64)
        .XScale(1).LabelFont.Color = .XScale(1).TicksFont.Color
        .XScale(1).TicksFont.Bold = True
        .XScale(1).TicksFont.Size = 14
        .XScale(1).Visible = True

        ' X Scale 2
        .XScale(2).Label = ""
        .XScale(2).TicksFont.Color = RGB(0, 0, 64)
        .XScale(2).LabelFont.Color = .XScale(2).TicksFont.Color
        .XScale(2).TicksFont.Bold = True
        .XScale(2).TicksFont.Size = 10
        .XScale(2).Visible = True

        ' Chart and plot formatting
        .BackColor = RGB(110, 110, 192)
        .Plot.BackColor = .BackColor
        .Plot.Border.LineOption = loNone
        .Plot.Border.LineWidth = woOnePoint
        .Plot.Border.LineColor = RGB(0, 128, 0)

        ' Y Scale 1
        .YScale(1).Label = ""
        .YScale(1).TicksFont.Color = RGB(128, 0, 64)
        .YScale(1).LabelFont.Color = .YScale(1).TicksFont.Color
        .YScale(1).TicksFont.Bold = True
        .YScale(1).TicksFont.Size = 14
        .YScale(1).Visible = True
        .YScale(1).ScaleMode = smManual
        .YScale(1).Min = 0
        .YScale(1).Max = 100

        ' Y Scale 2
        .YScale(2).Label = ""
        .YScale(2).TicksFont.Color = RGB(0, 0, 64)
        .YScale(2).LabelFont.Color = .YScale(2).TicksFont.Color
        .YScale(2).TicksFont.Bold = True
        .YScale(2).TicksFont.Size = 10
        .YScale(2).Visible = True
        .YScale(2).ScaleMode = smManual
        .YScale(2).Min = 0
        .YScale(2).Max = 500

        ' Profile 1
        .Profile(1).YScale = 1
        .Profile(1).XScale = 1
        .Profile(1).LineOption = loCustom
        .Profile(1).LineWidth = woThreePoint
        .Profile(1).LineStyle = soSolid
        .Profile(1).MarkerOption = loNone
        .Profile(1).LineColor = RGB(128, 0, 64)
        .Profile(1).Label = "Profile 1"
        .Profile(1).NumSamples = 30

        ' Profile 2
        .Profile(2).YScale = 2
        .Profile(2).XScale = 2
        .Profile(2).LineOption = loCustom
        .Profile(2).LineWidth = woThreePoint
        .Profile(2).LineStyle = soSolid
        .Profile(2).MarkerOption = loNone
        .Profile(2).LineColor = RGB(0, 0, 64)
        .Profile(2).Label = "Profile 2"
        .Profile(2).NumSamples = 30

        ' Create random chart data
        Dim i As Integer
        Dim ChartData() As Double
        ReDim ChartData(1 To .Profile(1).NumSamples, 1 To 2 * .NumProfiles)
        For i = 1 To .Profile(1).NumSamples
            ' Profile 1
            ChartData(i, 1) = (i - 1) * 1
            ChartData(i, 2) = 70 * Rnd + 20

            ' Profile 2
            ChartData(i, 3) = (i - 1) * 25
            ChartData(i, 4) = 450 * Rnd
        Next i

        .ChartData = ChartData

        
.Refresh

    End With

End Sub


' Resize Event

Private Sub Form_Resize()
    With XYChart4Ctl1
        .Left = 0
        .Top = 0
        .Width = Me.ScaleWidth
        .Height = Me.ScaleHeight
        .Refresh
    End With
End Sub