AnsweredAssumed Answered

Resizing and repositioning symbols on selection

Question asked by msj_ on Jan 14, 2018
Latest reply on Jan 16, 2018 by msj_

Hi all,


I have a number of XYPlots and Trends which have the naming formats:

scatter_cu_1     scatter_pa_1     scatter_pp_1  (the numbers on the end indicate that they are stacked together and need to zoom in/out at same time)

trend_cu_1     trend_pa_1     trend_pp_1


I am currently using the following codes to resize and reposition of them together, using public variables pos_t_top & pos_t_left for trends and pos_s_top & pos_s_left for scatter plots (XYplots)

The problem is that if I zoom in on two different sets of plots, the second zooming script will override the previously saved public variables for positions. How can I move the large symbol back in place before enlarging the selected symbol?


Dim WithEvents sctr_plots As XYPlot

Dim WithEvents trnds As trend

Public pos_s_top As Integer

Public pos_s_left As Integer

Public pos_t_top As Integer

Public pos_t_left As Integer


Private Sub Display_SelectionChange()
    Dim symb As Symbol
    For Each symb In SelectedSymbols
        If symb.Type = pbSymbolXYPlot Then 'for scatter
            Set sctr_plots = symb
        ElseIf symb.Type = pbSymbolTrend Then 'for trends
            Set trnds = symb
        End If
    Next symb

End Sub


Private Sub sctr_plots_Click(ByVal lvarX As Long, ByVal lvarY As Long)

    'Find all 3 scatter plots in the same set to zoom in/out together

    'Zoom in to 1000x1000 if it is 100x100, vice versa

    Dim scatter As Symbol

    Dim j As Integer


    j = VBA.Mid(sctr_plots.Name, 12)

    For Each scatter In Symbols

        With scatter

        If .Type = pbSymbolXYPlot And .Height = 1000 Then

            .Height = 100:     .Width = 100:     .Top = pos_s_top:     .Left = pos_s_left

        ElseIf .Type = pbSymbolXYPlot And VBA.Mid(.Name, 12) = j And .Height = 100 Then

            pos_s_top = .Top 'save current position top

            pos_s_left = .Left 'save current position left

            .Height = 1000:    .Width = 1000:    .Top = 13000:    .Left = -14700

        End If

        End With

    Next scatter

    SelectedSymbols.Remove 1

End Sub


Trend_click is similar to the click event code above, except for width is 200/2000 for zooming in and out.