The SDON Cookbook

5/17 Page

Creating Tables with SDON

Tables are a very powerful feature of SDON. They are used to subdivide a shape into multiple cells that have similar properties to a shape: labels, colors, hyperlinks, and more. A cell can also contain another shape. This can be the root shape of a whole "diagram": a tree, a flowchart, a ShapeContainer and even another table.

Defining a Table

A table can be defined for any shape using the Table object.

"Shape": {
    "Table": {}
}

The only required properties of a Table object are one or both of rows and columns. This script creates a table inside a shape with three rows and one column, and three cells.

"Table": {
    "Rows": "3"
}
SDON table with three rows

This creates a table inside a shape with three columns and one row and three cells.

"Table": {
    "Columns": "3"
}
SDON three column table

This creates a table inside a shape with three columns and three rows and nine cells.

"Table": {
"Rows": "3",
"Columns": "3"
}
SDON nine cell table

Joining Rows or Columns

More complex arrangements can be achieved using "Join".

{
    "Shape": {
        "Table": {
            "Rows": "3",
            "Columns": "3",
            "Join": [{
                "Row": "1",
                "Column": "1"
            }]
        },
        "FillColor": "#FFFFFF"
    }
}
SDON join table columns

To join cells, you'll have to define the anchor row and column. By default a Join joins across a row and joins just one cell.

Adding "N":"2" to the Join combines the anchor cell with two more to the right.

You can also Join down a column.

{
    "Shape": {
        "Table": {
            "Rows": "3",
            "Columns": "3",
            "Join": [{
                "Row": "1",
                "Column": "1",
                "N": "2",
                "Down": "1"
            }]
        },
        "FillColor": "#FFFFFF"
    }
}
SDON join rows

You can define multiple joins in an array.

{
    "Shape": {
        "Table": {
            "Rows": "3",
            "Columns": "3",
            "Join": [{
                "Row": "1",
                "Column": "1",
                "N": "2",
                "Down": "True"
            }, {
                "Row": "2",
                "Column": "2",
                "N": "1",
                "Down": "False"
            }]
        },
        "FillColor": "#FFFFFF"
    }
}
SDON table array

Setting the Size of a Table

By default, a table is made to fit inside the shape that hosts it - with the caveats that a row cannot be smaller in height than is required for a line of text in the default font and the width of a column cannot be less than the width of a single character in the default font of the shape. Cells will grow to accommodate the text that they contain based on the TextGrow property of the host shape, but it is sometimes useful to be able to set the minimum width of a column and/or height of row for the whole table. This is done with the "ColumnWidth" and "RowHeight" properties:

{
    "Shape": {
        "Table": {
            "Rows": "3",
            "Columns": "3",
            "RowHeight": "50",
            "ColumnWidth": "100",
            "Join": [{
                "Row": "1",
                "Column": "1",
                "N": "2",
                "Down": "True"
            }]
        },
        "FillColor": "#FFFFFF"
    }
}
SDON larger table

The value "50" for RowHeight sets the minimum height of each row to 50/100 ". Likewise the value of 100 for ColumnWidth sets the minimum width of each column to one inch.

Defining Cells

The intersection of a row and a column defines a cell. A cell has many of the properties of a shape. Cell properties are defined using the "Cells" array.

{
    "Shape": {
        "Table": {
            "Rows": "3",
            "Columns": "3",
            "Join": [{
                "Row": "1",
                "Column": "1",
                "N": "2",
                "Down": "True"
            }],
                          "Cells": [{
                "Row": "1",
                "Column": "1",
                "Label": "Lots of Text in cell 1"
            }, {
                "Row": "2",
                "Column": "2",
                "Label": "Text in cell 2"
            }]
        },
        "FillColor": "#FFFFFF"
    }
}
SDON text heavy cell

For each Cell object, the Row and Column are required to define the cell. Then each cell may have a label, colors, hyperlinks and even an ImageURL.

{
    "Shape": {
        "Table": {
            "Rows": "3",
            "Columns": "3",
            "Join": [{
                "Row": "1",
                "Column": "1",
                "N": "2",
                "Down": "True"
            }],
            "Cells": [{
                "Row": "1",
                "Column": "1",
                "Label": "Lots of Text in cell 1",
                "FillColor": "#00FFFF"
            }, {
                "Row": "2",
                "Column": "2",
                "Image":{"URL": "http://hanabi.autoweek.com/sites/default/files/styles/gen-1200-675/public/2u2a0013_1.jpg?itok=7xbSt67e"}
            }]
        },
        "FillColor": "#FFFFFF"
    }
}
SDON text heavy colored cell

Defining Grid Lines

The border of a cell is defined by the line for the row and column it is in. This is defined with RowProperties and ColumnProperties. Each of these properties is an array of objects.

RowProperties has line properties like color and thickness. LineThick removes the line at the bottom of the first row.

"RowProperties": [{
    "Row": "1",
    "LineThick": "0"
}]
SDON no border line

You can remove all of the grid lines this way.

{
    "Shape": {
        "Table": {
            "Rows": "3",
            "Columns": "3",
            "Join": [{
                "Row": "1",
                "Column": "1",
                "N": "2",
                "Down": "True"
            }],
            "Cells": [{
                "Row": "1",
                "Column": "1",
                "Label": "Lots of Text in cell 1"
            }, {
                "Row": "2",
                "Column": "2",
                "Label": "Text in cell 2"
            }],
            "RowProperties": [{
                "Row": "1",
                "LineThick": "0"
            }, {
                "Row": "2",
                "LineThick": "0"
            }],
            "ColumnProperties": [{
                "Column": "1",
                "LineThick": "0"
            }, {
                "Column": "2",
                "LineThick": "0"
            }]
        },
        "FillColor": "#FFFFFF"
    }
}
SDON table with no borders

You can change the color of the lines too:

{
    "Shape": {
        "Table": {
            "Rows": "3",
            "Columns": "3",
            "Join": [{
                "Row": "1",
                "Column": "1",
                "N": "2",
                "Down": "True"
            }],
            "Cells": [{
                "Row": "1",
                "Column": "1",
                "Label": "Lots of Text in cell 1"
            }, {
                "Row": "2",
                "Column": "2",
                "Label": "Text in cell 2"
            }],
            "RowProperties": [{
                "Row": "1",
                "LineColor": "#FF0000"
            }, {
                "Row": "2",
                "LineColor": "#0000FF"
            }],
            "ColumnProperties": [{
                "Column": "1",
                "LineThick": "5",
                "LineColor": "#00FF00"
            }, {
                "Column": "2",
                "LineThick": "5",
                "LineColor": "#00FF00"
            }]
        },
        "FillColor": "#FFFFFF"
    }
}
SDON table with multi colored lines

Finally you can use RowProperties and ColumnProperties to define the minimum height and width of a row and column. "Height":"75" and "Width:"100" sets the row to 75/100 of an inch tall and width of a column to 1" wide.

{
    "Shape": {
        "Table": {
            "Rows": "3",
            "Columns": "3",
            "Join": [{
                "Row": "1",
                "Column": "1",
                "N": "2",
                "Down": "True"
            }],
            "Cells": [{
                "Row": "1",
                "Column": "1",
                "Label": "Lots of Text in cell 1"
            }, {
                "Row": "2",
                "Column": "2",
                "Label": "Text in cell 2"
            }],
            "RowProperties": [{
                "Row": "1",
                "LineColor": "#FF0000"
            }, {
                "Row": "2",
                "LineColor": "#0000FF",
                "Height": "75"
            }],
            "ColumnProperties": [{
                "Column": "1",
                "LineThick": "5",
                "LineColor": "#00FF00",
                "Width": "100"
            }, {
                "Column": "2",
                "LineThick": "5",
                "LineColor": "#00FF00"
            }]
        },
        "FillColor": "#FFFFFF"
    }
}
SDON table with tall cell

Alternating Row Colors

The "AlternateRows" property of a table makes the rows alternate between two colors:

{
    "Shape": {
        "Table": {
            "Rows": "9",
            "Columns": "3",
            "AlternateRows": {}
        }
    }
}
SDON table with alternating row colors

The default colors are shown above. You can override the defaults:

"AlternateRows": {
    "Color1": "#FF0000",
    "Color2": "#0000FF"
}
SDON change row colors

Putting Shapes in Table Cells

A cell can contain a shape:

"Cells": [{
    "Row": "2",
    "Column": "2",
    "Shape": {}
}]
{
    "Shape": {
        "Table": {
            "Rows": "3",
            "Columns": "3",
            "Cells": [{
                "Row": "1",
                "Column": "1",
                "Label": "Cell 1"
            }, {
                "Row": "2",
                "Column": "2",
                "Shape": {}
            }]
        },
        "FillColor": "#FFFFFF"
    }
}
SDON shape within cell

Note that cell 2,2 grows to accommodate a default-sized shape.

The shape may have all the properties of any shape, including being the root shape for a ShapeContainer, a ShapeConnector or another table:

{
    "Shape": {
        "Table": {
            "Rows": "3",
            "Columns": "3",
            "Cells": [{
                "Row": "1",
                "Column": "1",
                "Label": "Cell 1"
            }, {
                "Row": "2",
                "Column": "2",
                "Shape": {
                    "ShapeContainer": {
                        "Shapes": [{
                            "Label": "Choice A",
                            "FillColor": "#FFFFFF"
                        }, {
                            "Label": "Choice B",
                            "FillColor": "#FFFFFF"
                        }]
                    }
                }
            }]
        },
        "FillColor": "#FFFFFF"
    }
}
SDON two shape table

Note you can "Hide" the parent shape of these two children and get the effect of adding multiple shapes to one cell.

{
    "Shape": {
        "Table": {
            "Rows": "3",
            "Columns": "3",
            "Cells": [{
                "Row": "1",
                "Column": "1",
                "Label": "Cell 1"
            }, {
                "Row": "2",
                "Column": "2",
                "Shape": {
                    "Hide": "True",
                    "ShapeContainer": {
                        "Shapes": [{
                            "Label": "Choice A",
                            "FillColor": "#FFFFFF"
                        }, {
                            "Label": "Choice B",
                            "FillColor": "#FFFFFF"
                        }]
                    }
                }
            }]
        },
        "FillColor": "#FFFFFF"
    }
}
SDON hidden parent table

Any ShapeConnector can be used too.

{
    "Shape": {
        "Table": {
            "Rows": "3",
            "Columns": "3",
            "Cells": [{
                "Row": "1",
                "Column": "1",
                "Label": "Cell 1"
            }, {
                "Row": "2",
                "Column": "2",
                "Shape": {
                    "Label": "Root",
                    "ShapeConnectorType": "Decisiontree",
                    "ShapeConnector": [{
                        "Shapes": [{
                            "Label": "Choice A"
                        }, {
                            "Label": "Choice B"
                        }]
                    }]
                }
            }]
        },
        "FillColor": "#FFFFFF"
    }
}
SDON nine cell table

A shape in a cell can contain another table which may also have a shape in a cell recursively:

{
    "Shape": {
        "Table": {
            "Rows": "3",
            "Columns": "3",
            "Cells": [{
                "Row": "1",
                "Column": "1",
                "Label": "Cell 1"
            }, {
                "Row": "2",
                "Column": "2",
                "Shape": {
                    "Table": {
                        "Rows": "2",
                        "Columns": "2",
                        "Cells": [{
                            "Row": "1",
                            "Column": "1",
                            "Shape": {
                                "FillColor": "#00FFFF",
                                "Label": "New Shape"
                            }
                        }]
                    }
                }
            }]
        },
        "FillColor": "#FFFFFF"
    }
}
SDON colored nested table shape
5/17 Page