@estesbubba wrote:
I have a simple path and want to normalize it so it's centered. Here is the code where I create it and normalize it (the React StartIcon isn't used in GoJS).
const paths = ['M6 4l20 12-20 12z']; const StartIcon = props => ( <SvgIcon viewBox="0 0 32 32" {...props}> {paths.map(path => <path d={path} />)} </SvgIcon> ); export default StartIcon; export const startGeometry = go.Geometry.parse(paths.join(' X '), true).normalize();
Here is the part of the template where I'm using it and 'iconSource' is the results of startGeometry.
make( go.Panel, 'Vertical', { margin: 3, cursor: 'move' }, make( 'Panel', 'Viewbox', { name: 'templateIcon', background: 'rgba(255, 255, 255, 0)', alignment: go.Spot.Center, width: cfg.iconSize, height: cfg.iconSize }, make( go.Shape, { background: 'red', width: cfg.pictureSize, height: cfg.pictureSize, stroke: null, fill: '#fff' }, new go.Binding('geometry', 'iconSource') ) ) )
Doing this throws this exception.
go.js:1291 Uncaught TypeError: Cannot read property 'width' of undefined at X../node_modules/gojs/release/go.js.X.Ln (go.js:1291) at yk (go.js:1025) at C../node_modules/gojs/release/go.js.g.Ln (go.js:1172) at yk (go.js:1025) at C../node_modules/gojs/release/go.js.g.Ln (go.js:1147) at yk (go.js:1025) at C../node_modules/gojs/release/go.js.g.Ln (go.js:1155) at yk (go.js:1025) at C../node_modules/gojs/release/go.js.g.Ln (go.js:1159) at yk (go.js:1025) at T../node_modules/gojs/release/go.js.g.Ln (go.js:1159) at yk (go.js:1025) at D../node_modules/gojs/release/go.js.D.RB (go.js:793) at Hi (go.js:792) at Ri (go.js:789) at D../node_modules/gojs/release/go.js.D.maybeUpdate.D.cg (go.js:788) at go.js:788
If I remove the normalize() everything works just fine. Looking at the Geometry in Intro it doesn't use width. Any ideas on what is going on? I'm using GoJS 1.8.14.
I tried this and same problem so my paths.join() isn't causing the problem.
export const startGeometry = go.Geometry.parse('M6 4l20 12-20 12z', true).normalize();
PS - I'm using GoJS with NPM and if there's a way to get the debug build let me know (if that stack trace will help).
Posts: 1
Participants: 1