Welcome to Golden Software Support

Legend entries: automatic update

Comments

2 comments

  • Avatar
    Sabrina Pearson

    Hi Stephan,

    Grapher 12 adds an option to the legend properties in the Property Manager. When checked, only the visible plots are displayed in the legend. Checking/unchecking plots in the Object Manager force the legend to automatically update when this option is checked. I recommend upgrading to get this feature.

    Thanks,

    Sabrina

    0
    Comment actions Permalink
  • Avatar
    Sabrina Pearson

    Hi Stephan,

    We have not yet added an option that will keep the legend updated based on the visibility of the plots. I have added your request for this to our suggestion list. You could do this with a script. One of our technical support people created the script below. You can use this script to turn on visibility. To run the script:

    1. Save the text below to a BAS file on your computer.
    2. Open the graph that you want to update.
    3. Click the Developer | Recorder | Run command, select the script, and wait a few seconds while the script runs.

    After it completes, the legend should only show the visible objects. Anytime the visibility of the plots change and you want the legend to update, you would need to re-run the script.

    Sub Main

    'Create Grapher as an Object
    Dim Grapher As Object

    Set Grapher = CreateObject("Grapher.Application")
    Grapher.Visible = True

    'Use the active plot window
    Set plot = Grapher.Documents.Active

    Set objects = plot.Shapes

    'Go through all of the objects
    For i = 1 To objects.Count

    'If a graph is found, do this
    If (objects.Item(i).Type = grfShapeGraph ) Then

    'found graph
    'clear legend entries, assumes there is just one legend present for the graph
    While ( objects.Item(i).Legends.Item(1).EntryCount > 0 )

    objects.Item(i).Legends.Item(1).DeleteEntry(objects.Item(i).Legends.Item(1).EntryCount)

    Wend

    For k = 1 To objects.Item(i).Plots.Count

    'go through plots
    If objects.Item(i).Plots.Item(k).Visible Then

    'if plot is visible, add it to the legend entries
    objects.Item(i).Legends.Item(1).AddEntry(objects.Item(i).Plots.Item(k).Name)

    End If

    Next

    End If

    Next

    End Sub

    Thanks,

    Sabrina

    0
    Comment actions Permalink

Please sign in to leave a comment.