Changing precision of points in model

Dear all,
Any update, I just need to use my point structure
“points” :[{“x” : 382.57772043949024}, { “x” : 315}]
not “points” : [135.2847602000331, 115.81426167116703, , , ]

Thanks in advance.

Sorry, but that kind of structure is definitely not supported. We need “y” values alternating with the “x” values.

walter , thanks for your reply ,
making my self clear …
At this example State Chart
with this data:

{ "class": "go.GraphLinksModel",
  "nodeKeyProperty": "id",
  "nodeDataArray": [ 
{"id":0, "loc":"120 120", "text":"Initial"},
{"id":1, "loc":"330 120", "text":"First down"},
{"id":2, "loc":"244.00000000000008 38", "text":"First up"},
{"id":3, "loc":"60 276", "text":"Second down"},
{"id":4, "loc":"226 226", "text":"Wait"}
  "linkDataArray": [ 
{"from":0, "to":0, "text":"up or timer", "curviness":-20, "points":[139.41512791725412,120.06698729810777,114.4151279172541,76.76571710888586,186.67626207597763,76.76571710888584,161.67626207597763,120.06698729810777]},
{"from":0, "to":1, "text":"down", "curviness":20, "points":[180.76948747715568,131.80688808153928,230.72759332882114,119.34569499661586,280.3637966644106,119.34569499661586,330.9080797978817,129.64174426680844]},
{"from":1, "to":0, "text":"up (moved)\nPOST", "curviness":20, "points":[330.9080797978817,149.0496457264233,280.3637966644106,159.34569499661586,230.72759332882117,159.34569499661586,180.76948747715573,146.88450191169244]},
{"from":1, "to":1, "text":"down", "curviness":-20, "points":[367.4151279172541,120.06698729810777,342.4151279172541,76.76571710888586,414.6762620759776,76.76571710888584,389.6762620759776,120.06698729810777]},
{"from":1, "to":2, "text":"up (no move)", "points":[371.80027824761413,120.02795061011684,362.95675836652924,93.522151028028,345.40890049974734,76.47963699705613,319.52841577535326,68.60838869745171]},
{"from":1, "to":4, "text":"timer", "points":[364.48435506749837,158.59514113173364,338.60333011725146,194.02529204286978,311.03138209371673,217.31315252489907,277.97104807731443,233.2958072771315]},
{"from":2, "to":0, "text":"timer\nPOST", "points":[244.52284732121024,65.62591662434437,211.10066062047963,73.03300304794113,184.05731237286176,91.07212045196252,163.72119405158958,120.08733364233396]},
{"from":2, "to":3, "text":"down", "points":[265.51181340834955,76.56558208910013,219.7248847037368,128.97790306925668,175.56610235296435,192.26788339572664,129.54441693909882,276.06085822473505]},
{"from":3, "to":0, "text":"up\nPOST\n(dblclick\nif no move)", "points":[117.82683663867506,276.00098953578543,115.16367938106525,233.73357395899052,123.06078279054985,194.62410945487628,140.9528437513677,158.63910233936275]},
{"from":3, "to":3, "text":"down or timer", "curviness":20, "points":[130.17626207597763,314.624402695124,155.17626207597763,357.92567288434594,82.91512791725414,357.92567288434594,107.91512791725412,314.624402695124]},
{"from":4, "to":0, "text":"up\nPOST", "points":[229.43085590520485,231.51484946697732,201.72141372197794,215.28585832013306,179.59122253774768,192.4000020710754,161.10321345572174,158.6299660597074]},
{"from":4, "to":4, "text":"down", "points":[264.17626207597766,264.62440269512393,285.17626207597766,300.99746965407035,220.91512791725412,300.99746965407035,241.91512791725412,264.62440269512393]}

Need to pass “point” array as following:
“points” :[{“anytitle” : 264.17626207597766}, { “anytitle” : 285.17626207597766} …]

+when save need to remove decimal values (.17626207597766)
Already done on the level of digram,

“positionComputation”:function (diagram, pt) {
return new go.Point(Math.floor(pt.x), Math.floor(pt.y)); }

Need to implement it on the node’s level.

It does not make any sense to me to want to save link route points in the structures that you have suggested.

But your last paragraph makes some sense. Is the requirement merely that all point values in a link route are rounded off to the nearest integer?

  function GriddedLink() {;
  go.Diagram.inherit(GriddedLink, go.Link);

  GriddedLink.prototype.computePoints = function() {
    var ret =;
    if (ret) {
      var list = this.points;
      for (var i = 0; i < list.length; i++) {
        var p = list.elt(i);
        list.setElt(i, new go.Point(Math.round(p.x), Math.round(p.y)));
    return ret;

Then in your Link template(s), use GriddedLink instead of go.Link.

This will ensure that all regular routing computations will result in Points whose x and y values are integers. However, other manipulations of the route (such as the LinkReshapingTool) might not go through this mechanism. You might then want to adapt those tools to follow your desired conventions.

Dear walter,
Thanks for your reply,
regarding “route points” the source data come from a machine and passed back to another machine.

This format is a must.

Please let me know if it possible or not.

It is not possible to have points that only have one component. Your points must have both an X and Y value.

You can take the data you are getting from some other machine and convert it into an acceptable format for GoJS and convert back when passing back to that machine.

I am talking about this:
what to change it to
“points” :[{“anytitle” : 264.17626207597766}, { “anytitle” : 264.62440269512393} …]


Ok, that’s fine, as long as you know that those numbers correspond to x/y pairs.

You have two options.

  1. In your model, continue using the simple structure, “points”:[264.17626207597766,264.62440269512393…].
    When communicating with your other machine, you can use a function that will convert to and from this format to your desired format.
  2. In your two-way data binding, use conversion functions that will take your format and change back and forth with the expected points format, which is a simple array. GoJS Data Binding -- Northwoods Software

This is something you’ll need to program as it is specific to your app.

For Integer issue , simpley change :

new go.Binding(“location”, “loc”, go.Point.parse).makeTwoWay(go.Point.stringify ),


new go.Binding(“location”, “loc”, go.Point.parse).makeTwoWay(ConvertitToInt ),

and add this function:

function ConvertitToInt(a){ return Math.round(a.x).toString()+" "+Math.round(a.y).toString();}