Improved Draw_Table

john's Avatar


03 Mar, 2024 04:34 AM

Attached is an improved version of my draw_table node.

Draw_table converts a data table to a graphical object that you can include in your output. It produces a table that looks somewhat like the data view, but with cleaner column spacing.

Like Nodebox's data view, all columns are left-justified. This can make columns of floating point numbers harder to read. Hence, my new option: "Align numbers".

If you check this option, draw_table will detect which table columns are numeric and align the numbers in those columns to their decimal points. It will automatically handle numbers with dollar and percent signs (placing minus signs in front of dollar signs when needed). For larger numbers it will insert separators (comma or period) every three digits depending on local region.

The attached demo and screenshot show one example. Try clicking the "Align numbers" option on and off to see the difference. The date column is recognized as non-numeric (even though all entries contain nothing but numbers and dashes). The other three columns are recognized as numeric and correctly aligned despite the dollar and percent signs.

Detecting and aligning numeric columns is tricky. I tried to anticipate many possible variations, but some unusual tables may fool my node. So if anyone out there uses this node and finds a case where this new option fails, I would really appreciate you sending me the example.



Note: the demo requires dateformat.clj to quickly generate fake dates, but no external libraries are required by the draw_table node.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Already uploaded files

  • draw_table_screenshot.png 890 KB
  • 15.1 KB

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

16 May, 2024 02:11 AM
16 May, 2024 01:58 AM
14 May, 2024 01:29 AM
13 May, 2024 12:36 AM
12 May, 2024 07:46 PM


05 May, 2024 04:38 PM
03 May, 2024 06:50 AM
03 May, 2024 12:30 AM
03 May, 2024 12:09 AM
19 Apr, 2024 04:41 AM
16 Apr, 2024 06:18 PM