PINE LIBRARY

TableBuilder

업데이트됨
TableBuilder is a library designed to make it easier to create tables in PineScript.
It allows you to more flexibly define the structure of a table before actually building it.

Features:
  • Style inheritance: styles are inherited from Table, to Column, to Row, and then Cell.
  • Columns are useful for propagating/reusing style but they are not required.
  • Add rows with different numbers of cells. The resultant number of columns in the table will be determined by the max number of cells vs the number of defined columns.
  • Auto text color: Instead of having to set the font color for every cell, the color is automatically determined by the luminosity of the background color.


See the 'Demo' section of the code for an example.
릴리즈 노트
Improved thumbnail.
릴리즈 노트
v3: More segmentation of functions.

Added:
gridSize(tbl)
  Parameters:
    tbl: The table to get the dimensions of.
  Returns: [columns, rows]

updateStyle(tbl, style)
  Updates the style of a table but not the cells.
  Parameters:
    tbl: The table to update the style of.
    style: The new style to use for the table.

initialize(tbl)
  Initializes a table with the given size and style.
  Parameters:
    tbl: The table to initialize.
  Returns: A tuple containing the initialized table, the number of columns, and the number of rows. [table, columns, rows]

update(pineTable, tbl)
  Updates an existing PineScript table with the data and style from a Table object.
  Parameters:
    pineTable: The existing PineScript table to update.
    tbl: The Table object containing the data and style to update the existing table with.
릴리즈 노트
v4 Heavy revision in order to use more shallow User Defined Types (UDTs).

Added:
createRow(contents, height, tooltip)
  Creates a new row with an array of cells containing the given contents.
  Parameters:
    contents: An array of strings representing the cell contents.
    height: The height of the row.
    tooltip: The tooltip of the row.
  Returns: A new Row object.

updateRow(t, row, cells, tooltip)
  Updates a row of cells in a table with the given cell content.
  Parameters:
    t: The table to update.
    row: The index of the row to update.
    cells: The array of cell content to set in the row.
    tooltip: The optional default tooltip to use if the cell's value is na.

style(t, firstCol, lastCol, firstRow, lastRow, bgColor)
  Styles the cells in the given range of the table with the given background color while automatically chosing a foreground color.
  Parameters:
    t: The table to style.
    firstCol: The index of the first column in the range.
    lastCol: The index of the last column in the range.
    firstRow: The index of the first row in the range.
    lastRow: The index of the last row in the range.
    bgColor: The background color to apply.

styleColumns(t, first, last, bgColor)
  Parameters:
    t
    first
    last
    bgColor

styleColumn(t, col, bgColor)
  Parameters:
    t
    col
    bgColor

styleRows(t, first, last, bgColor)
  Parameters:
    t
    first
    last
    bgColor

styleRow(t, col, bgColor)
  Parameters:
    t
    col
    bgColor

CellAlign
  Fields:
    horizontal
    vertical

CellStyle
  Fields:
    bgColor
    width
    height

TableSize
  Fields:
    columns
    rows

Updated:
addCell(row, contents, format, tooltip)
  Adds a new cell with the given integer contents to the row.
  Parameters:
    row: The row to add the cell to.
    contents: The contents of the new cell, an integer.
    format: The format string for the integer.
    tooltip: The tooltip of the new cell.
  Returns: The new Cell object.

addRow(rows, contents, height, tooltip)
  Adds a new row to the array of rows using the given array of cell contents.
  Parameters:
    rows: An array of rows.
    contents: The array of cell contents to use for the new row.
    height: The height of the new row.
    tooltip: The tooltip of the new row.
  Returns: The new Row object.

updateStyle(t, style)
  Updates a PineScript table with the style properties of the given TableStyle.
  Parameters:
    t: The PineScript table to update.
    style: The TableStyle containing the style properties to apply.

initialize(rows, position, border, frame)
  Initializes a new PineScript table with the given data rows and table style.
  Parameters:
    rows: An array of Rows to populate the table with.
    position: The position of the table within the chart.
    border: The optional border style for the table.
    frame: The optional frame style for the table.
  Returns: The new PineScript table.

Removed:
create(position, style)
  Creates a new table with an optional style.

equals(a, b)
  Determines if two TableStyles are equal.

inherit(child, parent)
  Creates a TableStyle with the same property values as the child but inherits properties from the parent if the child property is na.

getStyleChange(child, parent)
  Creates a TableStyle that only uses property values from the child that differ from the parent.

addColumn(table, style)
  Adds a new column to the given table with optional style.

gridSize(tbl)

update(pineTable, tbl)
  Updates an existing PineScript table with the data and style from a Table object.

build(tbl)
  Builds a table in PineScript based on a given Table object. Any values that are 'na' will simply not be set.

Column
릴리즈 노트
v5 Added function for styling all cells.
릴리즈 노트
v6 Added a styleRows function for updating background color using an array.
릴리즈 노트
v7 Leave na values blank when adding cells.
릴리즈 노트
v8 Fixed row tooltip.
릴리즈 노트
v9 Updated color lib
릴리즈 노트
v10 Fix and demonstrate row tooltips.
릴리즈 노트
v11 Fixed looping issues.
릴리즈 노트
v12 More loop fixes.
릴리즈 노트
v13 Fix out of bounds issue.
릴리즈 노트
v14 Extend types with methods.
CELLcellscolumncolumnsdisplayformattingROWrowstabletables

파인 라이브러리

진정한 TradingView 정신에 따라, 저자는 이 파인 코드를 다른 파인 프로그래머들이 재사용할 수 있도록 오픈 소스 라이브러리로 공개했습니다. 저자에게 박수를 보냅니다! 이 라이브러리는 개인적으로 사용하거나 다른 오픈 소스 출판물에서 사용할 수 있지만, 이 코드를 출판물에서 재사용하는 것은 하우스 룰에 의해 관리됩니다.

면책사항