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.

This tutorial shows how to display list data in graphs or charts.

Line Chart

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 is the complete script. The custom block should have run without screen refresh enabled.

define render line chart
erase all
set [i v] to [1] // counter
repeat (length of [list v])
    go to x: ((((480) / (length of [list v])) * (i)) - (240)) y: ((item (i) of [list v]) * (vertical scale))
    pen down
    change [i v] by (1) // increment counter to go to the next list item
end
pen up

See Also