Syncfusion AI Assistant

How can I help you?

Static Functions

16 Mar 202624 minutes to read

Root static functions of Diagram Component

bindVisioConnectors

Converts Visio connector data to Syncfusion connector format.
Applies styling, constraints, decorators, and annotations.

Parameter Type Description
connectorData VisioConnector The Visio connector to convert
context ParsingContext Parsing context for warnings and settings

Returns any

getCellValue

Extracts a cell value from cell array, handling both single and array formats.

Parameter Type Description
cell OneOrMany A single cell object or array of cell objects
name string Name of the cell to find

Returns string | undefined

getConnectorShape

Determines the connector shape type based on master name and keywords.
Identifies special connector types like BPMN flow shapes and UML connectors.

Parameter Type Description
attributes Attributes Shape attributes containing the name
shapes VisioShapeNode The connector shape object
Node (optional) VisioConnector Optional node/connector reference for shape lookup
context (optional) ParsingContext Parsing context with master data

Returns any

isConnectorShape

Determines if a shape is a connector based on its cells and master reference.
Checks for connector-specific cells (BeginX, BeginY, EndX, EndY) and valid master.

Parameter Type Description
shape VisioShapeNode The Visio shape object to check
context ParsingContext Parsing context with master data

Returns boolean

applyParentTransformToCellMap

Applies a parent group’s transform to a child cell map.
Handles flips, rotation, and pivot translation to convert
child pin coordinates into page coordinates.

Parameter Type Description
mergedMap Map Original cell map of the child shape
parentTx GroupTransform Parent group transform details

Returns Map

calculateShadowProperties

Calculates shadow properties from offset and scale.
Converts Visio shadow offset values to distance and angle for CSS shadow properties.

Parameter Type Description
visioOffsetX number The horizontal shadow offset from Visio
visioOffsetY number The vertical shadow offset from Visio
scalingFactor number The factor used to scale the offsets

Returns Object

createCellMap

Creates a map from an array of cells for efficient O(1) lookup access.
Maps cell names to their values, significantly improving performance for
repeated cell value lookups compared to linear search through arrays.
Special handling for LocPinX and LocPinY cells:

  • If a formula is available (F attribute), the formula is used as the value
  • Otherwise, the evaluated value (V attribute) is used
Parameter Type Description
cells VisioCell[] Array of Visio cells to map

Returns Map

createPathFromGeometry

Creates an SVG path string from Visio geometry data.
Converts Visio geometry rows (MoveTo, LineTo, ArcTo, etc.) to SVG path commands.
The function applies coordinate transformations to convert from Visio’s local
coordinate system to either local or global normalized coordinates.

Returns string

createPathFromGeometrySections

Creates a combined SVG path from one or more Visio Geometry sections.
Each Visio <Section N='Geometry'> block is converted to an SVG subpath
(via createPathFromGeometry) and appended to form a single path string.
Subpaths that begin with a relative ‘m’ are converted to absolute ‘M’
to prevent path drift between sections. If a Geometry section is filled
(NoFill cell is 0 or absent) the resulting subpath is closed with a
trailing ‘Z’ to ensure correct fill rendering; sections explicitly
marked NoFill will remain open.

Parameter Type Description
geometrySections VisioSection[] One or more Visio Geometry sections to convert
nodeOptions PathOptions Node sizing options used to provide width/height when building temporary geometry objects
cfg (optional) PathConfig Optional configuration forwarded to createPathFromGeometry

Returns string

ensureArray

Ensures a value is wrapped in an array for consistent processing.
Handles undefined, single values, and arrays uniformly.
This utility is essential for handling Visio XML where properties can be
either single elements or arrays of elements, providing a unified interface.

Parameter Type Description
value T | T[] | undefined | null The value to ensure is an array

Returns T[]

extractGradientStops

Extracts gradient stops from a FillGradient or LineGradient section.
Converts Visio gradient data into standard objects with color, opacity, and offset.
Gradient stops define the color and transparency at specific positions along
a gradient. This function normalizes Visio’s representation to standard format.

Stop object structure:

  • color: hex color string (e.g., ‘#FF0000’)
  • opacity: 0-1 range (1 = fully opaque, calculated as 1 - transparency)
  • offset: 0-1 range (normalized position along gradient)
Parameter Type Description
fillGradientSection VisioSection | null | undefined The Visio FillGradient or LineGradient section to extract gradient stops from

Returns GradientStop[]

findCellValue

Finds a cell by name in an array and returns its evaluated value.
Linear search through cell array to locate and extract a specific cell value.
This is useful for one-time cell lookups where creating a full map is unnecessary.
For multiple lookups, use createCellMap instead for better performance.

Parameter Type Description
cells VisioCell[] Array of cells to search
name string Cell name to find

Returns string | undefined

formatCoordinate

Formats a coordinate value to a specified number of decimal places.
Rounds values to improve readability and reduces floating-point precision issues.
This is commonly used for SVG path data and coordinate output where excessive
decimal places are unnecessary and increase file size.

Parameter Type Description
value number | null | undefined Coordinate value to format
precision number Number of decimal places (default: 2)

Returns number | undefined

formatPathData

Formats an SVG path string by normalizing whitespace and commas.
Cleans up path data while preserving SVG validity and openness.
The formatter:

  • Adds spaces around SVG command letters
  • Converts commas to spaces
  • Normalizes multiple spaces to single spaces
  • Does NOT add closing ‘Z’ command (keeps path open)
Parameter Type Description
path string The raw SVG path data string to format

Returns string

generatePathCommand

Generates an SVG path command from a Visio geometry row.
Handles various row types (MoveTo, LineTo, ArcTo, Bezier, etc.)
and converts their parameters to SVG path syntax.

Parameter Type Description
rowType string | undefined Row kind identifier (e.g., ‘MoveTo’, ‘LineTo’, ‘ArcTo’)
coords GeometryRowCoordinates Coordinate values used by the row
scaleFunctions ScalingFunctions Functions to scale X and Y values
lastCoords PathCoordinates The previous path coordinates for continuity
flipY boolean Whether to invert the Y-axis during conversion

Returns string

getAttrString

Safely retrieves a string attribute from an attributes object.
Returns an empty string if the key is missing or value is null/undefined.

Parameter Type Description
attrs Record Attributes object
key string Attribute key to retrieve

Returns string

getCellMap

Builds a cell map from a Visio shape node.
Converts the shape’s Cell elements into a key-value map for easier lookup.

Parameter Type Description
node VisioShapeNode Shape node containing Cell elements

Returns Map

getCellMapBooleanValue

Gets a boolean value from a cell map with optional default.
Safely extracts boolean values from the cell lookup map.
Recognizes Visio’s ‘1’ for true and ‘0’ for false conventions.

Parameter Type Description
cellMap Map Map of cell names to values
key string Cell name to retrieve
defaultValue boolean Default boolean value if key not found (default: false)

Returns boolean

getCellMapNumericValue

Gets a numeric value from a cell map with optional default.
Safely extracts and parses numeric values from the cell lookup map.

Parameter Type Description
cellMap Map Map of cell names to values
key string Cell name to retrieve
defaultValue number Default numeric value if key not found (default: 0)

Returns number

getCellMapStringValue

Gets a string value from a cell map with optional default.
Safely extracts string values from the cell lookup map.

Parameter Type Description
cellMap Map Map of cell names to values
key string Cell name to retrieve
defaultValue string Default string value if key not found (default: ‘’)

Returns string

getDecoratorDimensions

Returns decorator dimensions by size code and shape name.
Maps decorator size codes to width and height values.
Process:

  1. Normalize shape name to lowercase
  2. Check if shape matches known arrow-like shapes
  3. Use appropriate size table (arrow shapes share same progression)
  4. Parse numeric size index from Visio (0-6)
  5. Clamp to available sizes
  6. Return dimensions or fallback to default
Parameter Type Description
sizeType string The size code/index string from Visio (expects ‘0’..’6’)
arrowShape string The decorator shape name to lookup dimensions for

Returns Object

getDecoratorShape

Gets decorator shape name from Visio arrow type ID.
Handles special cases where multiple IDs map to the same shape.
Uses the centralized DECORATOR_SHAPE_MAP for mapping, with special handling
for common arrow types that share shape properties.

Parameter Type Description
arrowType number The Visio arrow type ID number

Returns string

getGradientVectorByAngle

Computes a gradient vector from an angle in degrees using CSS-like semantics.
Returns endpoints for a linear gradient in normalized [0..100] space.
CSS angle convention:

  • 0 degrees: to the right (→)
  • 90 degrees: upward (↑)
  • 180 degrees: to the left (←)
  • 270 degrees: downward (↓)

The function computes a line through the center (50, 50) at the given angle,
then clamps the endpoints to the [0..100] square range.

Parameter Type Description
angleDeg number The angle in degrees for gradient direction

Returns GradientVector

getNumberFromCellMap

Retrieves a numeric value from a map with a fallback.
Safely converts the stored value to a number or returns the fallback.

Parameter Type Description
map Map Map containing key-value pairs
key string Key to look up in the map
fallback number Value to return if lookup fails or is not numeric

Returns number

getRadialGradient

Represents a radial gradient by direction code.
Maps Visio’s direction codes to radial gradient parameters.
Radial gradients emanate from a focal point (fx, fy) and expand to a circle
with center (cx, cy) and radius r.

Parameter Type Description
gradientDir string | undefined The gradient direction code string

Returns RadialGradientConfig

getRouting

Gets routing style flag from a shape’s cell map.
Determines if a connector uses automatic line routing (Bezier or orthogonal).
Specific routing style values indicate automatic routing should be enabled.
These values are defined in Visio’s ShapeRouteStyle cell.

Parameter Type Description
cellMap Map The cell map containing shape properties

Returns boolean

getTooltip

Gets tooltip/comment text from a shape’s cell map.
Extracts the comment cell which stores tooltip text displayed on hover.

Parameter Type Description
cellMap Map The cell map containing shape properties

Returns string

getTrimmedOrEmpty

Trims a string value and returns it, or empty string if falsy.
Ensures no null/undefined values propagate.

Parameter Type Description
value string Input string to trim

Returns string

getVisibility

Gets shape visibility status from its geometry section.
Checks for a ‘NoShow’ cell with value ‘1’ which indicates hidden shapes.
Visibility is stored in the Geometry section of shapes, and this function
searches both direct cells and row cells for the visibility flag.

Parameter Type Description
sections VisioSection | VisioSection[] | undefined The Visio section(s) to check for visibility settings

Returns boolean

hasKey

Runtime type guard: checks if an object has an own property key.
Combines object check with property ownership verification.
Uses Object.prototype.hasOwnProperty for accurate property detection,
avoiding issues with inherited properties.

Parameter Type Description
obj unknown The object to check
key string The property key to look for

Returns obj

inchToPoint

Converts inches to points (72 pt per inch).
Uses SCREEN_DPI as a single source of truth with point scaling factor.
Points are used in typography (72 points = 1 inch).
This conversion is useful for font sizes and other typography-related measurements.

Parameter Type Description
val number The value in inches to convert

Returns number

inchToPx

Converts inches to pixels based on configured screen DPI.
Uses SCREEN_DPI constant (96) as the standard conversion rate.
Visio uses inches as its primary unit, while the diagram component uses pixels.
This conversion is fundamental to translating all Visio coordinates.

Parameter Type Description
val number The value in inches to convert

Returns number

isGroupShape

Checks if a shape is a group shape based on its Type attribute.
Group shapes contain other shapes and have special handling for positioning
and sizing calculations.

Parameter Type Description
shape unknown The shape node to check

Returns boolean

isObject

Runtime type guard: checks if a value is a non-null object.
Useful for narrowing types in conditional branches.

Parameter Type Description
x unknown The value to check

Returns x

mapCellValues

Safely converts a value that may be a single cell or an array of cells
into a lookup map for convenient access.
This is a wrapper around createCellMap that normalizes the input to always be
an array before creating the map, simplifying client code.

Parameter Type Description
cells VisioCell | VisioCell[] A single cell or array of cells to map

Returns Map

mergeCellMaps

Merges two cell maps, overlaying instance values on top of master defaults.
Ensures that page-level overrides take precedence over master definitions.

Parameter Type Description
masterMap Map Cell map from master shape
instMap Map Cell map from instance shape

Returns Map

parseNumberCell

Safely parses a numeric cell value with fallback to a default value.
Handles undefined, null, non-numeric strings, and NaN values gracefully.
This utility prevents parsing errors and ensures a numeric value is always returned,
making it safe to use in calculations without additional null/undefined checks.

Parameter Type Description
value string | undefined The string value to parse as a number
defaultValue number The value to return if parsing fails (default: 0)

Returns number

radiansToDegrees

Converts radians to degrees using centralized constants.
Uses the RADIANS_TO_DEGREES constant from visio-constants for consistency.

Parameter Type Description
radians number The angle value in radians to convert

Returns number

roundTo2Decimals

Rounds a value to exactly 2 decimal places.
Commonly used for coordinate rounding in projections and calculations.

Parameter Type Description
value number The value to round

Returns number

roundToPrecision

Rounds a value to a specified decimal precision.
Uses the LAYOUT_METRICS precision as default for path data consistency.

Parameter Type Description
value number The value to round
precision number Number of decimal places (default: LAYOUT_METRICS.PATH_PRECISION)

Returns number

safeNumber

Safely converts a value to a number with fallback.
Handles NaN and Infinity cases, returning default value if conversion fails.

Parameter Type Description
value unknown The value to convert to number
defaultValue number The fallback if conversion fails (default: 0)

Returns number

toBoolean

Converts a value to boolean with flexible input handling.
Recognizes multiple false representations and validates Visio’s boolean cell format.
Visio represents booleans in cells as:

  • ‘1’ or true for true values
  • ‘0’ or false for false values

This function handles all these cases plus common JavaScript boolean conversions.

Parameter Type Description
value string | undefined The value to convert to boolean
defaultValue boolean The fallback if value is null/undefined (default: false)

Returns boolean

toCamelCase

Converts a string from kebab-case or snake_case to lowerCamelCase.
Used extensively for converting Visio property names (e.g., ‘Lock-Move-X’)
to JavaScript naming conventions (e.g., ‘lockMoveX’).
This function:

  • Splits on hyphens (-) and underscores (_)
  • Keeps first part lowercase
  • Capitalizes first letter of subsequent parts
  • Joins without separators
Parameter Type Description
key string Property name to convert

Returns string

loadVisioDataIntoDiagram

Loads a parsed and clean VisioDiagramData model into a Syncfusion Diagram instance.
This is the final step in the import pipeline, converting data structures to diagram elements.

Parameter Type Description
diagram Diagram The Syncfusion diagram instance to populate.
diagramData VisioDiagramData The clean, parsed Visio diagram data model.
context ParsingContext Reference to the ParsingContext for utility methods and logging.

Returns Promise

parseVisioData

Main entry point to parse a raw Visio JavaScript object into a structured data model.
Orchestrates the entire parsing process, converting XML into typed data structures.

Parameter Type Description
visioObj VisioDocumentStructure The raw JavaScript object derived from XML conversion.
context ParsingContext The context instance used for configuration and logging.

Returns Promise

parserVisioShape

Parses Visio shape elements into EJ2 diagram shapes.
Iterates through shape nodes, delegates parsing to parserVisioShapeNode,
and collects the resulting VisioShape objects.

Parameter Type Description
shapeObj Object Input object containing shape nodes
context ParsingContext Parsing context with master index

Returns VisioShape[]

allGeometrySectionsNoFill

Checks if all geometry sections explicitly have NoFill=1.
Returns true only if every geometry section has the NoFill cell set to 1,
indicating that all geometry sections should not be filled.

Parameter Type Description
sections VisioSection[] Array of Visio geometry sections to check

Returns boolean

allGeometrySectionsNoLine

Checks if all geometry sections explicitly have NoLine=1.
Returns true only if every geometry section has the NoLine cell set to 1,
indicating that all geometry sections should not have a border line.

Parameter Type Description
sections VisioSection[] Array of Visio geometry sections to check

Returns boolean

areAllGeometrySectionsHidden

Returns true only if every Geometry section in the array
is hidden (NoShow = 1). Empty or invalid input returns false
(do not hide the whole shape by default).

Parameter Type Description
sections VisioSection[] Geometry sections collection.

Returns boolean

determineDefaultNodeShape

Determines the default EJ2 node shape for a Visio shape.
Resolves semantic name, attempts mapping to supported EJ2 types,
and falls back to geometry-based path if no supported type is found.

Returns DetermineShapeResult

isGeometryRowHidden

Determines if a Geometry row is hidden by checking a row-level
NoShow cell (1 = hidden). If the row lacks NoShow, the row is
considered visible.

Parameter Type Description
row VisioRow The Geometry row to evaluate.

Returns boolean

isGeometrySectionHidden

Determines if a Geometry section is hidden by checking the section-level
NoShow cell (1 = hidden). Falls back to visible if the cell is not present.

Parameter Type Description
section VisioSection The Geometry section to evaluate.

Returns boolean

mergeGeometrySectionsByIndex

Merges geometry sections from master and instance nodes.
Keeps master sections intact and supplements with instance-only sections,
without overriding master rows with page rows.

Parameter Type Description
masterNode VisioShapeNode Master shape node
instNode VisioShapeNode Instance shape node

Returns VisioSection[]

resolveMasterSourceForNode

Resolves the master source node for a given page shape.
Looks up the appropriate master or master-shape reference
from the parsing context and returns the corresponding node.

Returns VisioShapeNode | null

resolveShapeNameForMapping

Resolves the semantic shape name for mapping to EJ2 diagram nodes.
Checks instance attributes, master source attributes, and master index
definitions to determine the most appropriate shape name.

Returns string

tryDetermineSemanticGroupShape

Attempts to determine a semantic group shape for a Visio group node.
Resolves the group’s name, runs the shape type mapper, and only collapses
into semantic families (BPMN, UML, Image) to avoid losing visuals for generic groups.

Returns DetermineShapeResult | null

bezierPoints

Get the intermediate bezier curve for point over connector

Returns PointModel

getBezierBounds

Get the bezier curve bounds.

Returns Rect

getBezierPoints

Get the bezier points if control points are not given.

Returns PointModel

getDirection

Get the direction of the control points while the bezier is connected to the node

Returns string

getConnectorArrowType

To Get connector style based on the arrow type

Parameter Type Description
data FlowChartData provide the flow chart data.

Returns Object | Object | Object