Binding Picture Source to data uri


go.Picture.source can render data uri.
So, I tryed to change source using binding. but it’s not wroking.

How to change picture.source using data uri?


var GO = go.GraphObject.make;
GO(go.Node, ‘Spot’,
selectionAdornmentTemplate: makeSelectionAdornmentTemplate(),
resizeAdornmentTemplate: makeResizeAdornmentTemplate(),
rotateAdornmentTemplate: makeRotateAdornmentTemplate(),
locationSpot: shapeLocationSpot,
locationObjectName: ‘OBJSHAPE’,
selectionAdorned: false,
resizeObjectName: ‘OBJSHAPE’,
resizable: true,
layerName: “Layer1”,
new go.Binding(‘location’, ‘loc’, go.Point.parse).makeTwoWay(go.Point.stringify),
new go.Binding(‘layerName’, ‘layer’).makeTwoWay(),
{ name: ‘OBJSHAPE’,
width: 100, height: 100, margin: 0, background: “white”,
imageStretch: go.GraphObject.UniformToFill,
angle: 0,
source: ‘data:image/png;base64,iVBORw0K…’,
portId: ‘’,
fromLinkable: true, fromLinkableSelfNode: false, fromLinkableDuplicates: true,
toLinkable: true, toLinkableSelfNode: false, toLinkableDuplicates: true
new go.Binding(‘source’),
new go.Binding(‘angle’, ‘angle’).makeTwoWay(),
new go.Binding(‘desiredSize’, ‘size’, go.Size.parse).makeTwoWay(go.Size.stringify)


function changePicure(evt) {
var file =[0];
if (!file.type.match(‘image.*’)) {
var reader = new FileReader();
reader.onloadend = function(encodedFile) {
$.each(myDiagram.selection.toArray(), function(key,data) {
if (‘Picture’ == data.category) {

console messages are below:

GraphLinksModel.setDataProperty is modifying a GraphObject, “Node#21738(Picture)” go.js:17
Is that really your intent?


Actually, the error message gives a good clue: the value of the “data” variable is a Node, not the that one would expect to pass to Model.setDataProperty.

Furthermore, have you examined the value of encodedFile.srcElement.result in the debugger?

Also, why are you using the onloadend event rather than implementing separate onload and onerror events?

As a separate comment, it would be better to write your loop within the transaction as follows:

myDiagram.selection.each(function(part) { if (part.category === "Picture") { myDiagram.model.setDataProperty(, "source", ...); } });