The diagram does not have a flowElement attribute, only a plane
attribute.
You need to assign it on creation:
var diPlane = bpmnModdle.create('bpmndi:BPMNPlane');
var diDiagram = bpmnModdle.create('bpmndi:BPMNDiagram', {
plane: diPlane
});
or set the plane directly to the element:
diagram.plane = bpmnModdle.create('bpmndi:BPMNPlane')