Document stub.png This article is a stub. It may be incomplete, unfinished, or have missing parts/sections. If the article can be expanded, please do so! There may be suggestions on its talk page. (November 2019)
A list rendered using the script.

Elements of a list of numbers can be plotted as a line graph using a script.

Scripts

To get how wide each section of the list should be, one must take the width of the stage, 480 pixels, and divide it by the length of the list:

((480) / (length of [list v]))

To calculate the x position of the pen given a list index, one can multiply this value by the number of iterations, which is (i::variables) in this case, and subtract the half width of the stage, to align with the left edge:

((((480) / (length of [list v])) * (i)) - (240))

The following custom block (render) should have run without screen refresh ticked on:

define Render
set [i v] to (1)
erase all // Clear rest of stage
pen up
repeat (length of [list v])
    go to x: ((((480) / (length of [list v])) * (i)) - (240)) y: ((item (i) of [list v]) * (scale))
    pen down
    change [i v] by (1)
end

See Also