Using GraphObject.make with figures in extensions


#1

Hi,

I am new to goJS and I am currently working on upgrading the version from 1.7.25 to 2.0.8. Currently I am importing the Figure.ts to my angular project in which the file calls GraphObject.make is used like

bodyShape = GraphObject.make(Shape, refernceToFigureName, {
object to describe fill and stroke
});

I am not sure what else I need to do besides importing the Figure.ts file to make it compatible here.
Would I need to use the Shape.getFigureGenerator and pass it in the static make function?

Please advise, thanks!


#2

I don’t understand your situation. extensionsTS/Figures.ts does not call GraphObject.make. So your code that calls make must be in your app when you are defining a piece of a template. Is that correct?

So what is refernceToFigureName ? Shouldn’t that just be a string such as “Cloud”?


#3

Hi Walter,

So for the bodyShape = GraphObject.make(Shape, refernceToFigureName , {
object to describe fill and stroke
});
the referenceToFigureName is now Parallelogram1, which is not supported in the goJS core now and have to reference the Figure.ts in the extension, but I am getting error still even after I do import ‘gojs/extensionsTS/Figures’;


So I am wondering if there is anything else that I need to bridge the gap.


#4

What is your code?


#5
function makeCanvasNodeBodyPanel(nodeStyle: NodeStyle, forPalette: boolean): GraphObject {
  const bodyShape = GraphObject.make(Shape, nodeStyle.shape, {
    fill: nodeStyle.color,
    stroke: CanvasDrawingService.colors.nodeBorder
  } as Shape);

  if (!forPalette) {
    bodyShape.bind(new Binding('stroke', 'isSelected', nodeBorderStroke).ofObject());
    bodyShape.bind(new Binding('strokeWidth', 'isSelected', nodeBorderStrokeWidth).ofObject());
  }
}

This is the part that uses the bodyShape whereas nodeStyle.shape is just the string that indicates the figure name like Parallelogram1.


#6

Your code doesn’t return bodyShape. But it otherwise looks OK.

If you evaluate Shape.getFigureGenerators().count, what number do you get?

Have you tried setting a breakpoint in Figures.js to make sure it defines correctly the figures that you use, such as “Parallelogram1”?


#7

Hi walter,

It turns out that it might be some local environment messed up. It is working now.

Thank you so much for your help!!