PINE LIBRARY
SimpleTable

A library for when you just want to get a table up with the least hassle.
The function `f_drawTableFromColumns()`, is intended to be the simplest possible way to draw a table with the least code in the calling script. Just pass in between one and ten arrays that contain the strings you want to show. Each string array represents one column. That's it. You get a table back.
If you want to style the table you can optionally pass colours, size, and whether the table has a header row that should be displayed differently.
An example usage section demonstrates creating a three-column table.
The function automatically sizes the table based on the number of non-na arrays and the maximum column length.
Optional styling parameters cover table position, text size, text alignment, text colour, cell background, header background, header text, and border width. If you don't supply any of these arguments, the table uses some sensible default values.
The table is created and updated on the last bar only, with caching to avoid unnecessary redraws.
Column shrink detection clears the table only when required, preventing stale cell content.
This is not a full-fledged table management library; there are already lots of those published. It is (I believe and hope) the easiest library to use. For example, you don't need to supply a matrix, or a user-defined type full of settings. The library wraps the input arrays into a map, and uses a user-defined type, but internally, so you don't need to worry about it. Just supply one or more arrays with some text.
f_drawTableFromColumnArrays(_a_col1, _a_col2, _a_col3, _a_col4, _a_col5, _a_col6, _a_col7, _a_col8, _a_col9, _a_col10, _position, _textSize, _textAlign, _textColor, _cellBgColor, _headerBgColor, _headerTextColor, _hasHeaderRow, _borderWidth)
Renders a table using up to ten string arrays. The table size is derived from the number of non-na arrays and the maximum length across the supplied arrays.
Parameters:
_a_col1 (array<string>): (array<string>) Column 1 values. Supply na to omit.
_a_col2 (array<string>): (array<string>) Column 2 values. Supply na to omit.
_a_col3 (array<string>): (array<string>) Column 3 values. Supply na to omit.
_a_col4 (array<string>): (array<string>) Column 4 values. Supply na to omit.
_a_col5 (array<string>): (array<string>) Column 5 values. Supply na to omit.
_a_col6 (array<string>): (array<string>) Column 6 values. Supply na to omit.
_a_col7 (array<string>): (array<string>) Column 7 values. Supply na to omit.
_a_col8 (array<string>): (array<string>) Column 8 values. Supply na to omit.
_a_col9 (array<string>): (array<string>) Column 9 values. Supply na to omit.
_a_col10 (array<string>): (array<string>) Column 10 values. Supply na to omit.
_position (string): (TablePosition) Table position on the chart. Default is top right.
_textSize (string): (TableTextSize) Text size for all cells. Default is normal.
_textAlign (string): (TableTextAlign) Horizontal alignment for all cells. Default is left.
_textColor (color): (color) Text colour for all cells. Default is chart foreground color.
_cellBgColor (color): (color) Background colour for all cells. Uses a default if na. Default is gray 90%.
_headerBgColor (color): (color) Background colour for the header row. Uses a default if na. Default is gray 75%.
_headerTextColor (color): (color) Text colour for the header row. Uses a default if na.
_hasHeaderRow (bool): (bool) If true, row 0 is treated as a header. Default is true.
_borderWidth (int): (int) Table border width. Must be non-negative. Default is 1.
Returns: The table object, so the caller can store the table ID if required.
The function `f_drawTableFromColumns()`, is intended to be the simplest possible way to draw a table with the least code in the calling script. Just pass in between one and ten arrays that contain the strings you want to show. Each string array represents one column. That's it. You get a table back.
If you want to style the table you can optionally pass colours, size, and whether the table has a header row that should be displayed differently.
An example usage section demonstrates creating a three-column table.
The function automatically sizes the table based on the number of non-na arrays and the maximum column length.
Optional styling parameters cover table position, text size, text alignment, text colour, cell background, header background, header text, and border width. If you don't supply any of these arguments, the table uses some sensible default values.
The table is created and updated on the last bar only, with caching to avoid unnecessary redraws.
Column shrink detection clears the table only when required, preventing stale cell content.
This is not a full-fledged table management library; there are already lots of those published. It is (I believe and hope) the easiest library to use. For example, you don't need to supply a matrix, or a user-defined type full of settings. The library wraps the input arrays into a map, and uses a user-defined type, but internally, so you don't need to worry about it. Just supply one or more arrays with some text.
f_drawTableFromColumnArrays(_a_col1, _a_col2, _a_col3, _a_col4, _a_col5, _a_col6, _a_col7, _a_col8, _a_col9, _a_col10, _position, _textSize, _textAlign, _textColor, _cellBgColor, _headerBgColor, _headerTextColor, _hasHeaderRow, _borderWidth)
Renders a table using up to ten string arrays. The table size is derived from the number of non-na arrays and the maximum length across the supplied arrays.
Parameters:
_a_col1 (array<string>): (array<string>) Column 1 values. Supply na to omit.
_a_col2 (array<string>): (array<string>) Column 2 values. Supply na to omit.
_a_col3 (array<string>): (array<string>) Column 3 values. Supply na to omit.
_a_col4 (array<string>): (array<string>) Column 4 values. Supply na to omit.
_a_col5 (array<string>): (array<string>) Column 5 values. Supply na to omit.
_a_col6 (array<string>): (array<string>) Column 6 values. Supply na to omit.
_a_col7 (array<string>): (array<string>) Column 7 values. Supply na to omit.
_a_col8 (array<string>): (array<string>) Column 8 values. Supply na to omit.
_a_col9 (array<string>): (array<string>) Column 9 values. Supply na to omit.
_a_col10 (array<string>): (array<string>) Column 10 values. Supply na to omit.
_position (string): (TablePosition) Table position on the chart. Default is top right.
_textSize (string): (TableTextSize) Text size for all cells. Default is normal.
_textAlign (string): (TableTextAlign) Horizontal alignment for all cells. Default is left.
_textColor (color): (color) Text colour for all cells. Default is chart foreground color.
_cellBgColor (color): (color) Background colour for all cells. Uses a default if na. Default is gray 90%.
_headerBgColor (color): (color) Background colour for the header row. Uses a default if na. Default is gray 75%.
_headerTextColor (color): (color) Text colour for the header row. Uses a default if na.
_hasHeaderRow (bool): (bool) If true, row 0 is treated as a header. Default is true.
_borderWidth (int): (int) Table border width. Must be non-negative. Default is 1.
Returns: The table object, so the caller can store the table ID if required.
Pine library
In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in publications is governed by House Rules.
🆓 All my free scripts: is.gd/simplefree
🔥 Beyond Market Structure Paid Space is now live! is.gd/beyondMS
💰 Trade with me: is.gd/simpletradewithme
🔥 Beyond Market Structure Paid Space is now live! is.gd/beyondMS
💰 Trade with me: is.gd/simpletradewithme
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Pine library
In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in publications is governed by House Rules.
🆓 All my free scripts: is.gd/simplefree
🔥 Beyond Market Structure Paid Space is now live! is.gd/beyondMS
💰 Trade with me: is.gd/simpletradewithme
🔥 Beyond Market Structure Paid Space is now live! is.gd/beyondMS
💰 Trade with me: is.gd/simpletradewithme
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.