Electrified

TableBuilder

Electrified 업데이트됨   
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:

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.

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.
파인 라이브러리

트레이딩뷰 정신에 따라 오써는 이 파인 코드를 오픈 소스 라이브러리로 퍼블리쉬하여 당사 커뮤니티의 다른 파인 프로그래머들이 쓸 수 있도록 하였습니다. 오써에게 찬사를! 여러분은 이 라이브러리를 프라이빗 또는 오픈 소스 퍼블리케이션에 쓸 수 있지만 퍼블리케이션에 재사용은 하우스룰을 따릅니다.

면책사항

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.

이 라이브러리를 쓰시겠습니까?

텍스트를 클립보드에 카피한 뒤 님의 스크립트에 붙여 넣기.