@@ -23,32 +23,43 @@ class TableRow {
2323 * @param {String|Number } value The value to be stored
2424 *
2525 * @example
26- * <div class="norender"><code>
27- * // Given the CSV file "mammals.csv" in the project's "assets" folder:
28- * //
29- * // id,species,name
30- * // 0,Capra hircus,Goat
31- * // 1,Panthera pardus,Leopard
32- * // 2,Equus zebra,Zebra
33- *
26+ * <div>
27+ * <code>
3428 * let table;
3529 *
3630 * async function setup() {
37- * // The table is comma separated value "csv"
38- * // and has a header specifying the columns labels.
39- * table = await loadTable('assets/mammals.csv', 'csv', 'header' );
31+ * // Create a 200x200 canvas and set a white background
32+ * createCanvas(200, 200);
33+ * background(255 );
4034 *
41- * let rows = table.getRows();
35+ * // Load the CSV file with a header row
36+ * table = await loadTable('assets/mammals.csv', ',', 'header');
37+ *
38+ * // Set every row's "name" to "Unicorn"
39+ * let rows = table.getRows();
4240 * for (let r = 0; r < rows.length; r++) {
4341 * rows[r].set('name', 'Unicorn');
4442 * }
4543 *
46- * //print the results
47- * print(table.getArray());
44+ * // Convert the table to an array
45+ * let tableArray = table.getArray();
46+ *
47+ * // Set text properties
48+ * fill(0); // Set text color to black
49+ * textSize(12); // Set text size
50+ *
51+ * // Display each row of the table on the canvas
52+ * let y = 20; // Starting y position
53+ * for (let i = 0; i < tableArray.length; i++) {
54+ * let rowText = tableArray[i].join(', ');
55+ * text(rowText, 10, y * 2.5);
56+ * y += 20; // Increment y position for the next row
57+ * }
4858 *
4959 * describe('no image displayed');
5060 * }
51- * </code></div>
61+ * </code>
62+ * </div>
5263 */
5364 set ( column , value ) {
5465 // if typeof column is string, use .obj
@@ -82,31 +93,44 @@ class TableRow {
8293 * @param {Number|String } value The value to be stored
8394 * as a Float
8495 * @example
85- * <div class="norender"><code>
86- * // Given the CSV file "mammals.csv" in the project's "assets" folder:
87- * //
88- * // id,species,name
89- * // 0,Capra hircus,Goat
90- * // 1,Panthera pardus,Leopard
91- * // 2,Equus zebra,Zebra
92- *
96+ * <div>
97+ * <code>
9398 * let table;
9499 *
95100 * async function setup() {
96- * // The table is comma separated value "csv"
97- * // and has a header specifying the columns labels.
98- * table = await loadTable('assets/mammals.csv', 'csv', 'header' );
101+ * // Create a 200x200 canvas and set a white background
102+ * createCanvas(200, 200);
103+ * background(255 );
99104 *
105+ * // Load the CSV file with a header row
106+ * table = await loadTable('assets/mammals.csv', ',', 'header');
107+ *
108+ * // Update each row's "id" to (row index + 10)
100109 * let rows = table.getRows();
101110 * for (let r = 0; r < rows.length; r++) {
102111 * rows[r].setNum('id', r + 10);
103112 * }
104113 *
105- * print(table.getArray());
114+ * // Convert the table to a 2D array for display
115+ * let tableArray = table.getArray();
116+ *
117+ * // Set text properties
118+ * fill(0); // Text color: black
119+ * textSize(12); // Adjust text size as needed
120+ *
121+ * // Display each row of the table on the canvas
122+ * let y = 20; // Starting y position
123+ * for (let i = 0; i < tableArray.length; i++) {
124+ * // Join each row's values with a comma separator
125+ * let rowText = tableArray[i].join(', ');
126+ * text(rowText, 10, y * 2.5);
127+ * y += 20; // Increment y for the next row
128+ * }
106129 *
107130 * describe('no image displayed');
108131 * }
109- * </code></div>
132+ * </code>
133+ * </div>
110134 */
111135 setNum ( column , value ) {
112136 const floatVal = parseFloat ( value ) ;
@@ -123,32 +147,43 @@ class TableRow {
123147 * @param {String|Number|Boolean|Object } value The value to be stored
124148 * as a String
125149 * @example
126- * <div class="norender"><code>
127- * // Given the CSV file "mammals.csv" in the project's "assets" folder:
128- * //
129- * // id,species,name
130- * // 0,Capra hircus,Goat
131- * // 1,Panthera pardus,Leopard
132- * // 2,Equus zebra,Zebra
133- *
150+ * <div>
151+ * <code>
134152 * let table;
135153 *
136154 * async function setup() {
137- * // The table is comma separated value "csv"
138- * // and has a header specifying the columns labels.
139- * table = await loadTable('assets/mammals.csv', 'csv', 'header');
155+ * // Create a 300x200 canvas and set a white background
156+ * createCanvas(300, 200);
157+ * background(255);
158+ *
159+ * // Load the CSV file with a header row
160+ * table = await loadTable('assets/mammals.csv', ',', 'header');
140161 *
162+ * // Update each row's "name" field
141163 * let rows = table.getRows();
142164 * for (let r = 0; r < rows.length; r++) {
143165 * let name = rows[r].getString('name');
144166 * rows[r].setString('name', 'A ' + name + ' named George');
145167 * }
146168 *
147- * print(table.getArray());
169+ * // Convert the table to a 2D array for display
170+ * let tableArray = table.getArray();
148171 *
149- * describe('no image displayed');
172+ * // Set text properties
173+ * fill(0); // Text color: black
174+ * textSize(12); // Adjust text size as needed
175+ *
176+ * // Display each row of the table on the canvas
177+ * let y = 20; // Starting y position
178+ * for (let i = 0; i < tableArray.length; i++) {
179+ * let rowText = tableArray[i].join(', ');
180+ * text(rowText, 10, y * 2.5);
181+ * y += 20; // Increment y for the next row
182+ * }
183+ *
184+ * // describe('no image displayed');
150185 * }
151- * </code></div>
186+ * </code>
152187 */
153188 setString ( column , value ) {
154189 const stringVal = value . toString ( ) ;
@@ -165,32 +200,37 @@ class TableRow {
165200 * @return {String|Number }
166201 *
167202 * @example
168- * <div class="norender"><code>
169- * // Given the CSV file "mammals.csv" in the project's "assets" folder:
170- * //
171- * // id,species,name
172- * // 0,Capra hircus,Goat
173- * // 1,Panthera pardus,Leopard
174- * // 2,Equus zebra,Zebra
175- *
203+ * <div>
204+ * <code>
176205 * let table;
177206 *
178207 * async function setup() {
179- * // The table is comma separated value "csv"
180- * // and has a header specifying the columns labels.
181- * table = await loadTable('assets/mammals.csv', 'csv', 'header' );
208+ * // Create a 200x100 canvas and set a white background
209+ * createCanvas(200, 100);
210+ * background(255 );
182211 *
212+ * // Load the CSV file with a header row
213+ * table = await loadTable('assets/mammals.csv', ',', 'header');
214+ *
215+ * // Extract the names from each row and store them in an array
183216 * let names = [];
184217 * let rows = table.getRows();
185218 * for (let r = 0; r < rows.length; r++) {
186219 * names.push(rows[r].get('name'));
187220 * }
188221 *
189- * print(names);
222+ * // Set text properties and display the names on the canvas
223+ * fill(0); // Set text color to black
224+ * textSize(12); // Set text size
225+ *
226+ * // Join names into a single string separated by commas
227+ * let namesText = names.join(', ');
228+ * text(namesText, 35, 50);
190229 *
191230 * describe('no image displayed');
192231 * }
193- * </code></div>
232+ * </code>
233+ * </div>
194234 */
195235 get ( column ) {
196236 if ( typeof column === 'string' ) {
@@ -210,33 +250,39 @@ class TableRow {
210250 * ID (number)
211251 * @return {Number } Float Floating point number
212252 * @example
213- * <div class="norender"><code>
214- * // Given the CSV file "mammals.csv" in the project's "assets" folder:
215- * //
216- * // id,species,name
217- * // 0,Capra hircus,Goat
218- * // 1,Panthera pardus,Leopard
219- * // 2,Equus zebra,Zebra
220- *
253+ * <div>
254+ * <code>
221255 * let table;
222256 *
223257 * async function setup() {
224- * // The table is comma separated value "csv"
225- * // and has a header specifying the columns labels.
226- * table = await loadTable('assets/mammals.csv', 'csv', 'header');
258+ * // Create a 200x100 canvas and set a white background
259+ * createCanvas(200, 100);
260+ * background(255);
261+ *
262+ * // Load the CSV file with a header row
263+ * table = await loadTable('assets/mammals.csv', ',', 'header');
227264 *
228265 * let rows = table.getRows();
229266 * let minId = Infinity;
230267 * let maxId = -Infinity;
268+ *
231269 * for (let r = 0; r < rows.length; r++) {
232270 * let id = rows[r].getNum('id');
233271 * minId = min(minId, id);
234- * maxId = min(maxId, id);
235- * }
236- * print('minimum id = ' + minId + ', maximum id = ' + maxId);
272+ * maxId = max(maxId, id);
273+ * }
274+ *
275+ * let result = 'minimum id = ' + minId + ', maximum id = ' + maxId;
276+ *
277+ * // Set text properties and display the result on the canvas
278+ * fill(0); // Set text color to black
279+ * textSize(12); // Set text size
280+ * text(result, 10, 50);
281+ *
237282 * describe('no image displayed');
238283 * }
239- * </code></div>
284+ * </code>
285+ * </div>
240286 */
241287 getNum ( column ) {
242288 let ret ;
@@ -263,35 +309,38 @@ class TableRow {
263309 * ID (number)
264310 * @return {String } String
265311 * @example
266- * <div class="norender"><code>
267- * // Given the CSV file "mammals.csv" in the project's "assets" folder:
268- * //
269- * // id,species,name
270- * // 0,Capra hircus,Goat
271- * // 1,Panthera pardus,Leopard
272- * // 2,Equus zebra,Zebra
273- *
312+ * <div>
313+ * <code>
274314 * let table;
275315 *
276316 * async function setup() {
277- * // The table is comma separated value "csv"
278- * // and has a header specifying the columns labels.
279- * table = await loadTable('assets/mammals.csv', 'csv', 'header');
317+ * // Create a 200x100 canvas and set a white background
318+ * createCanvas(200, 100);
319+ * background(255);
320+ *
321+ * // Load the CSV file with a header row
322+ * table = await loadTable('assets/mammals.csv', ',', 'header');
280323 *
281324 * let rows = table.getRows();
282325 * let longest = '';
283326 * for (let r = 0; r < rows.length; r++) {
284- * let species = rows[r].getString('species');
285- * if (longest.length < species.length) {
327+ * let species = rows[r].getString('species');
328+ * if (longest.length < species.length) {
286329 * longest = species;
287330 * }
288331 * }
289332 *
290- * print('longest: ' + longest);
333+ * let result = 'longest: ' + longest;
334+ *
335+ * // Set text properties and display the result on the canvas
336+ * fill(0); // Set text color to black
337+ * textSize(12); // Set text size
338+ * text(result, 30, 50);
291339 *
292340 * describe('no image displayed');
293341 * }
294- * </code></div>
342+ * </code>
343+ * </div>
295344 */
296345 getString ( column ) {
297346 if ( typeof column === 'string' ) {
0 commit comments