Skip to end of metadata
Go to start of metadata

The Basics

Every SDON script has the following structure:

{
“DiagramType”:”<type>”,
“RootShape”:[{<shape properties>}]
}


Where <shape properties> define the properties of a shape. The Reference below specifies all the properties supported but two key ones are:

“Label”:”the text inside the shape”


And

“ShapeList”:[<shape list properties>]


A ShapeList is an automatic connector line plus the shapes connected to it. Flowcharts can have more than one connector per shape, so the ShapeList property is an array of ShapeList objects. A ShapeList object consists of properties that describe the connector line (like "Direction" and "LineColor" plus an array of Shape objects.

"ShapeList":
        [{
            "Direction":"Right",
            "Shapes":     
                         [
                           {<shape properties>},
                           {<shape properties>}.
                           {<shape properties>}
                          ]
        }]


Because Shapes in a ShapeList are the same as any other Shape, they too can have child ShapeLists as one of their properties.

"ShapeList":
        [{
            "Direction":"Right",
            "Shapes":     
                         [
                           {“Label”:”Child Shape”,”ShapeList”:[
{“Shapes”:[
 {<shape properties>},
{<shape properties>}]}
]},
                           {<shape properties>},
                           {<shape properties>}
                          ]
        }]


This structure is recursive and leads to tree-like structures.
Here's an example of a tree (using a DiagramType of OrgChart):

{
    "DiagramType":"Orgchart",
    "RootShape":[{
        "Label":"Top Dog",
        "ShapeList":
        [{
            "Direction":"Right",
            "Shapes":     [
                   {"Label":"Ivanka"},
                   {"Label":"Jared"},
                   {"Label":"Donald Jr","ShapeList":[{"Shapes":[{"Label":"Donald III"}]}]},
                   {"Label":"Melania"},
                   {"Label":"Baron","ShapeList":[{"Shapes":[{"Label":"Flopsy"},{"Label":"Mopsy"}]}]
                   }]
        }]
        }],
    }



Here's a simple flowchart:

{
    "DiagramType":"Flowchart",
    "RootShape":[{
        "Label":"Root",
        "ShapeList":
        [{
            "Direction":"Right",
            "Shapes":     [
                   {"Label":"Shape 1","ShapeList":[{"Direction":"Down","Shapes":
                       [
                               {"Label":"Child 1"},
                               {"Label":"Child 2"}
                       ]}
                   ]},    
                   {"Label":"Shape 2"},
                   {"Label":"Shape 3","ShapeList":[{"Direction":"Down","Shapes":
                       [
                               {"Label":"Down 1"},
                               {"Label":"Down 2"}
                       ]},
                       
                       {"Direction":"Up","Shapes":
                       [
                               {"Label":"Up 1"},
                               {"Label":"Up 2"}
                       ]}
                 ]
                   },
                    {"Label":"Shape 4"},
                    {"Label":"Shape 5"}
            ]
        }]
    }]
}


Note than Shape 3 has two ShapeLists: One down and one up. The shapes to the right are part of the same ShapeList as Shape 1, Shape 2 and Shape 3.

Defaults

Virtually all object properties are optional. Without specific properties individual objects use default properties. Here is the same tree with only the required properties for a three level chart.

{
    "DiagramType":"Orgchart",
    "RootShape":[{
        "ShapeList":
        [{
            "Shapes":     [
             {},   //Equals an empty org chart box
             {},  //Equals an empty org chart box as a peer to box above
             {"ShapeList":[{"Shapes":[{}]}]}, //Equals peer box with one child shape
             {},
             {"ShapeList":[{"Shapes":[{},{}]}] //Equals peer box with two child shapes
         }]
        }]
    }]
}



Note that the default Direction is Down for an Orgchart. The default label for the top position is "Manager". Note also that the positions, color and sizes of the boxes are all defaulted.

Adding Other Lines that Connect Shapes (Returns)

A line that connects two arbitrary shapes is called a Return. (A line that "returns" to a previous step in a flowchart).
Returns are specified by an array of Return objects after the RootShape array.

{
“DiagramType”:”<type>”,
“RootShape”:[{<shape properties>}],
“Returns”:[{<return properties>}]}
Return have the following required properties:
“StartID”:”id number of a shape”
“EndID”:”id number of a shape”

Shapes may have optional ID's. To draw a return line between two shapes they must have an ID property. In the flowchart example above, this return draws a line between "Down 2" and "Shape 2".

"Returns":[{"StartID":"2","EndID":"1"}]


Where these two shapes are defined with these ID's.

{
    "DiagramType":"Flowchart",
    "RootShape":[{
        "Label":"Root",
        "ShapeList":
        [{
            "Direction":"Right",
            "Shapes":     [
                   {"Label":"Shape 1","ShapeList":[{"Direction":"Down","Shapes":
                       [
                               {"Label":"Child 1"},
                               {"Label":"Child 2"}
                       ]}
                   ]},    
                   {"Label":"Shape 2","ID":"1"},
                   {"Label":"Shape 3","ShapeList":[{"Direction":"Down","Shapes":
                       [
                               {"Label":"Down 1"},
                               {"Label":"Down 2","ID":"2"}
                       ]},
                       
                       {"Direction":"Up","Shapes":
                       [
                               {"Label":"Up 1"},
                               {"Label":"Up 2"}
                       ]}
                 ]
                   },
                    {"Label":"Shape 4"},
                    {"Label":"Shape 5"}
            ]
        }]
    }],
  "Returns":[{"StartID":"2","EndID":"1"}]
}


This creates a chart like this with a line connecting "Down 2" to "Shape 2".

You can add return lines to any type of chart. The optional properties for a return line include the side of the shape it touches, its thickness, line pattern and color. These are listed in the reference.

Adding a Title to the Diagram

Any diagram may have a title that appears centered above the whole diagram ½" above it. The title is specified with a Title object specified after the RootShape.

“Title”:{“Label”:”Project Ownership for the Web App Saga”}


The Title object currently supports just a Label property that defines the string used in the title. The text format follows the default for the template except for the point size, which is 14 by default. Eventually all of the normal text formatting properties will be supported.
You can make a multi-line title by inserting a CR as "/n" into the string.

Changing the Appearance of a Shape or Line

The appearance of lines and shapes conform to the default settings of the SmartDraw template unless modified with optional properties.
Shapes may have specific

  • "FillColor":"#FF00FF"
  • "LineColor":"#0000FF"
  • "LineThick":"5" (in 1/100")
  • "ShapeType":"RRect"

Here is one of the shapes from the tree example using some of these attributes:

{"Label":"Melania","ID":"2","FillColor":"#FF00FF","ShapeType":"Oval","LineThick":"5"}


Lines (returns and connectors) may have specific:

  • "LineColor":"#0000FF"
  • "LineThick":"5" (in 1/100")

Changing the Appearance of a Text

Text labels appear with just one size, font, color and style but this can be controlled for each label:

  • "TextBold":"1"
  • "TextItalic":"1"
  • "TextUnderline":"1"
  • "TextSize":"12" (in points)
  • "TextFont":" "Baskerville"
  • "TextColor":"#FFFF00"
  • "TextAlignH":"left" (or center or right)
  • "TextAlignV":"top" (or middle or bottom – note lowercase)

Here is another shape with some of these properties for the label.

{"Label":"Jared","ID":"2","TextSize":"18","TextFont":"Baskerville","TextUnderline":"1","TextAlignH":"left"}


Adding Text to Lines

The automatic connector line segments that touch a shape can have their own text labels. The line label is added to the Shape object in a ShapeList.
Adding "LineLabel":"Yes" to the Down 1 shape in our flowchart creates this:

{"Label":"Down 1",”LineLabel”:”Yes”},



Returns can also have labels. Adding "Label":"Loop Again" to the return definition in our flowchart creates:

"Returns":[{"StartID":"2","EndID":"1","Label":"Loop Again"}]


Making Connectors Collapse

Trees (Org Chart, Mind maps and Decision Trees) have collapsible connectors. The + and – controls collapse and expand the tree attached to a shape. It can be useful to create a tree in a collapsed state so that the diagram is simpler when first viewed. The user can then expand the nodes he wants.
Adding "Collapse":"1" to a ShapeList object puts it into the collapsed state. This SDON file:

{
“DiagramType”:”Mindmap”,
“RootShape”:[{“Label”:”Hello World”,
          ”ShapeList”:
[{“Collapse:”1”,”Shapes”:[{“Label:”:”Child 1”},{“Label”:”Child 2”}]}]
           },
           {}]
} 


Makes this chart:

Clicking on the + opens the connector:

Adding Hyperlinks to Shapes

The shape property:

 "Hyperlink":{"url":"urlstring"}


Adds a hyperlink to a shape. The Hyperlink property is an object and not just a string because in a future version the object will also support a property "Page":"N" where N is a page number. This defines a link between the current page and other page in the same document.

Creating Tables Inside Shapes

A Shape can contain a table. A table is an arrangement of rows and columns in a shape.
At its simplest level a shape can be divided into NxM rows and columns using the Table Shape Property:

 "Table":{"Rows":"5","Columns":"2"}


By default the number of rows and columns is 1. Hence

"Table":{"Rows":"5"}


creates a single column table with one column.

"Table":{"Columns":"2"}


Creates a two column table with one row. A 1x1 table is ignored.
This example in our tree creates the following shape:

{"Label":"Donald Jr","Table":{"Rows":"5","Columns":"2"}}



Notice that the label for the shape is placed in the first cell of the table.
You can specify labels (and other properties) for each of the ten cells in the table by including an array of cell objects in the table object:

{"Label":"Donald Jr","Table":{"Rows":"5","Columns":"2","Cell":[
{"Column":"1","Row":"2","Label":"Ivanka"},
{"Column":"1","Row":"3","Label":"Eric"},
{"Column":"1","Row":"4","Label":"Tiffany"},
{"Column":"1","Row":"5","Label":"Barron"}]}}



You can also join cells both vertically and horizontally by adding a "Join" array to the table definition.

{"Label":"Donald's Children","Table":{"Rows":"7","Columns":"2",
"Join":[{"Row":"1","Column":"1","N":"1"}],"Cell":[
{"Column":"1","Row":"3","Label":"Donald Jr."},
{"Column":"1","Row":"4","Label":"Ivanka"},
{"Column":"1","Row":"5","Label":"Eric"},
{"Column":"1","Row":"6","Label":"Tiffany"},
{"Column":"1","Row":"7","Label":"Barron"}]}}




You can also change the colors and other attributes of each cell just like Shapes:

{"Table":{"Rows":"7","Columns":"2",
"Join":[{"Row":"1","Column":"1","N":"1"}],"Cell":[
{"Column":"1","Row":"1","Label":"Donald's Children", "TextSize":"12","FillColor":"#62DDDD"},
{"Column":"1","Row":"2","Label":"Name","TextBold":"1","FillColor":"#FFFF00"},
{"Column":"2","Row":"2","Label":"Mother","TextBold":"1","FillColor":"#FFFF00"},
{"Column":"1","Row":"3","Label":"Donald Jr."},
{"Column":"2","Row":"3","Label":"Ivana"},
{"Column":"1","Row":"4","Label":"Ivanka"},
{"Column":"2","Row":"4","Label":"Ivana"},
{"Column":"1","Row":"5","Label":"Eric"},
{"Column":"2","Row":"5","Label":"Ivana"},
{"Column":"1","Row":"6","Label":"Tiffany"},
{"Column":"2","Row":"6","Label":"Marla"},
{"Column":"1","Row":"7","Label":"Barron"},{"Column":"2","Row":"7","Label":"Melania"}]}}



You can also add hyperlinks to cells with the same Hyperlink property as shapes:

{"Column":"2","Row":"6","Label":"Marla”, ”Hyperlink”:{“url”:”https://www.smartdraw.com”}},
  • No labels