javascript - integrating angular and joint js -


i trying integrate angular joint js.i have wrapped joint js content within angular directive reasons, code not working.

view contains:

 <joint-diagram graph="graph" width="width" height="height" grid-size="1" /> 

directive:

 app.directive('jointdiagram', [function () {      var directive = {         link: link,         restrict: 'e',         scope: {             height: '=',             width: '=',             gridsize: '=',             graph: '=',         }     };      return directive;      function link(scope, element, attrs) {          var diagram = newdiagram(scope.height, scope.width, scope.gridsize, scope.graph, element[0]);       }      function newdiagram(height, width, gridsize, graph, targetelement) {          var paper = new joint.dia.paper({             el: targetelement,             width: width,             height: height,             gridsize: gridsize,             model: graph,         });          return paper;     }  }]); 

graph,width , height passed via controller.directive rendering paper object without nodes(cells)c passed via graph object.but when print paper object,it contain graph object having nodes.what reason behind this.

i'm not 100% of underlying cause of since you're adding items graph before create paper instance, aren't drawn. can use graph.resetcells() trigger redraw. example, using hello world example provided in jointjs;

// create empty graph instance , assign paper instance var graph = new joint.dia.graph,     paper = new joint.dia.paper({         el: element[0],         width: scope.width,         height: scope.height,         model: graph,         gridsize: scope.gridsize     }),     cells = [];  var rect = new joint.shapes.basic.rect({     position: { x: 100, y: 30 },     size: { width: 100, height: 30 },     attrs: { rect: { fill: 'blue' }, text: { text: 'a box', fill: 'white' } } });  var rect2 = rect.clone(); rect2.translate(300);  var link = new joint.dia.link({     source: { id: rect.id },     target: { id: rect2.id } });  cells.push(rect, rect2, link);  // refresh graph ensure nodes render graph.resetcells(cells) 

Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -