The SDON Cookbook

6/17 Page

Adding Text to Shapes in SDON

By default shapes contain no text. Adding "Label":"string value" to the shape object will cause a text label to appear in the shape using the default font, text color and alignment.

{
    "Label": "This is a text label"
}
SDON shape with text

Just as the default values for properties like the FillColor of a shape can be overridden by explicitly defining values for them as part of the object record, so defaults for text properties can be overridden.

Aligning Text in the Shape

The horizontal alignment is specified with the "TextAlignH" property (left, right, center) and the vertical alignment is specified with the "TextAlignV" propriety (top,bottom, middle).

{
    "Label": "This is a text label",
    "TextAlignH": "Left",
    "TextAlignV": "Top"
}
SDON left align label

Changing the Appearance of the Text

TextFont sets the name of the font, TextSize sets the size of the text in points, TextBold, TextItalic and TextUnderline are boolean values that turn on or off bold, italic and underline. TextColor sets the color. These commands all apply to the entire label.

{
    "Label": "Text is Blue",
    "TextColor": "#003399",
    "TextItalic": "true",
    "TextSize": "14"
}
SDON blue text

Controlling the amount of text shown in a shape or table cell with "Truncate"

When the label assigned to a shape or a table cell is derived from data and may be longer than can comfortably fit inside the shape, you can truncate it if the number of characters exceeds a maximum using the Truncate property. If the label in this shape exceeds 20 characters only the first 20 are shown plus ellipses. A tool tip is also created and added to the shape that shows the full text string:

{
    "Truncate": "20"
}
SDON truncated text

Showing Multiple Data Values in a Single Shape

When building a diagram from data, a shape often represents a data record and often data records have multiple fields, each with a different value.

The simplest approach is just to show one value that identifies the record in the shape. For example in a flowchart of a workflow show the name of the step in the shape as a "Label". But what if you want to show two or more field values in a shape? One way to do this is using a table:

Using a Table to Show Multiple Values

Any shape can be subdivided into a table of cells by dividing it into rows and columns.

{
 "Shape":{"Table":{"Rows":3,"Columns":2}}
}
SDON two column table

Each of the six cells in this table can have its own "Label", colors etc, just like a shape.

{
"Shape":{"Table":{"Rows":3,"Cell":[{"Row":1,"Label":"Value1"},{"Row":2,"Label":"Value2"}]}}
}
SDON table labels

Tables are very flexible and making them look the way you want is explained later.

Using Concatenation to Show Multiple Values

A second way to show multiple values in a shape is to concatenate the values on separate lines. The \n in a text string creates a new line.

{
"Shape":{"Label":"Value1\nValue2"}
}
SDON multiple line labels

Using Shape Data to Show Multiple Values

If a shape represents a record with many values it becomes less practical to show them all in the shape itself, even using tables. A third alternative is to show some of the values in a tool tip using Shape Data.

Compare this:

SDON shapes with rows

the same example using shape data:

SDON shape data

Hovering over the small "i" icon on each shape displays a tool tip that shows the additional data:

SDON shape data hover

Read more about shape data with SDON.

Adding a Title

Adding a title to your diagram is accomplished by adding a "Title" object to your SDON Object.

"Title": {
    "Label": "This is a title",
    "TextSize": "18"
}

The Title object contains a Label and the normal text properties. Entering /n in the label text causes a line break.

The title is centered above the diagram.

{
    "Title": {
        "Label": "A Simple Flowchart with a Return",
        "TextSize": "18"
    },
    "Shape": {
        "ShapeConnectorType": "Flowchart",
        "ShapeConnector": [{
            "EndArrow": "1",
            "TextSize": "18",
            "TextColor": "#00FF00",
            "Shapes": [{
                "Label": "Shape A",
                "LineLabel": "label A",
                "ID": "1"
            }, {
                "Label": "Shape B",
                "LineLabel": "label B",
                "ID": "21"
            }]
        }]
    },
    "Returns": [{
        "StartID": "21",
        "EndID": "1",
        "Label": "Repeat"
    }]
}
SDON shape data hover
6/17 Page