NetLogo / NetLogo/NetLogo

Enhancement(s): Generalized Plot hook procedures in code

Open
#1,783 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

editor infrastructure
Dominant language
Scala
Stars
1.2k
Forks
272
PR merge metrics
No merged PRs in 30d

Description

I'm finding that I have to copy/paste a lot of duplicate code into plots, specifically the Plot Update Commands section. It's mostly visual sugar that I'm copy/pasting, but I'd rather have access to a global hook for shared update steps between plots.

IRL example: Scrolling x-axis window for that last 100 ticks.

if ticks > 100 [
  set-plot-x-range (ticks - 100) ticks
]

Rather than pasting this snippet into EVERY plot (about a dozen), something in code would be easier/scalable.

Proposed example: In Code Tab:

to NETLOGO-HOOK-update-plot-commands
  if ticks > display.plot-x-range [
    set-plot-x-range (ticks - display.plot-x-range) ticks
  ]
end

This function would run first before the individual update hook was run for each plot. Alternatively, 2 hook functions could be used, one PRE hook and one POST hook to run commands before and then after the Update Plot Commands section of the plots.

There'd be no reason that similar hooks couldn't be added for any other code chunks entered into interface elements.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the implementation of plot update commands and the Code tab or interface-element execution paths. Determine how a shared hook would be represented and ordered relative to each plot's existing update commands; done means the proposed global behavior is defined and works consistently across plots without duplicated snippets.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
data-visualization
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.