SVG and databinding

Depending of my datasource I can receive two kinds of SVG data in my nodearray :

  • A simple SVG path
  • A real SVG file

like :

{ key: '1', icon: 'F M30 15c0 1.6-1.3 2.8-3 2.8H2.8C1.3 17.8 0 16.6 0 15s1.3-2.8 3-2.8h24c1.7 0 3 1.3 3 2.8z' }
{ key: '2', icon: '<xml version="1.0" encoding="utf-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ""><svg ver.... }

The first kind is simple to treat, I can add a shape to my node panel and use the geometryString binded on the icon attribute :

  new go.Binding('geometryString', 'icon'),

The second is a little bit more complicated, I need to use an SVG interpreter (like your example SVG Tiger Drawing in GoJS) to create a panel with multiples shapes (one per path).

But how to add the first shape only if icon contain a SVG path and the panel if the icon contain a SVG file ? Is this possible to use a databinding to add child to my panel…

Ok it was very simple a databinding with target.add(myPanel).