jsxgraph 1.4.0 → 1.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/README.md +1 -1
  2. package/distrib/README.md +1 -1
  3. package/distrib/geogebra.min.js +3 -3
  4. package/distrib/geonext.min.js +3 -3
  5. package/distrib/index.d.ts +5205 -4629
  6. package/distrib/intergeo.min.js +3 -3
  7. package/distrib/jsxgraph.css +10 -15
  8. package/distrib/jsxgraphcore.js +9 -25
  9. package/distrib/jsxgraphsrc.js +4497 -2180
  10. package/distrib/sketch.min.js +3 -3
  11. package/package.json +3 -2
  12. package/src/3d/box3d.js +264 -0
  13. package/src/3d/curve3d.js +97 -0
  14. package/src/3d/linspace3d.js +375 -0
  15. package/src/3d/point3d.js +200 -0
  16. package/src/3d/surface3d.js +81 -0
  17. package/src/3d/threed.js +38 -0
  18. package/src/3d/view3d.js +459 -0
  19. package/src/base/board.js +139 -85
  20. package/src/base/chart.js +1 -1
  21. package/src/base/circle.js +1 -1
  22. package/src/base/composition.js +1 -1
  23. package/src/base/constants.js +15 -14
  24. package/src/base/coords.js +3 -3
  25. package/src/base/coordselement.js +5 -8
  26. package/src/base/curve.js +1 -1
  27. package/src/base/element.js +36 -28
  28. package/src/base/foreignobject.js +12 -2
  29. package/src/base/group.js +1 -1
  30. package/src/base/image.js +1 -1
  31. package/src/base/line.js +2 -2
  32. package/src/base/point.js +8 -18
  33. package/src/base/polygon.js +89 -34
  34. package/src/base/text.js +8 -7
  35. package/src/base/ticks.js +17 -3
  36. package/src/base/transformation.js +1 -1
  37. package/src/base/turtle.js +1 -1
  38. package/src/element/arc.js +1 -1
  39. package/src/element/button.js +1 -1
  40. package/src/element/checkbox.js +1 -1
  41. package/src/element/comb.js +1 -1
  42. package/src/element/composition.js +2 -2
  43. package/src/element/conic.js +3 -3
  44. package/src/element/input.js +1 -1
  45. package/src/element/locus.js +1 -1
  46. package/src/element/measure.js +9 -4
  47. package/src/element/sector.js +5 -5
  48. package/src/element/slider.js +29 -12
  49. package/src/element/slopetriangle.js +1 -1
  50. package/src/jsxgraph.js +9 -3
  51. package/src/jxg.js +3 -3
  52. package/src/loadjsxgraph.js +18 -12
  53. package/src/math/bst.js +1 -1
  54. package/src/math/clip.js +550 -345
  55. package/src/math/complex.js +1 -1
  56. package/src/math/extrapolate.js +1 -1
  57. package/src/math/geometry.js +85 -6
  58. package/src/math/ia.js +69 -69
  59. package/src/math/math.js +10 -1
  60. package/src/math/metapost.js +1 -1
  61. package/src/math/nlp.js +4 -4
  62. package/src/math/numerics.js +2 -1
  63. package/src/math/plot.js +4 -4
  64. package/src/math/poly.js +1 -1
  65. package/src/math/probfuncs.js +2 -1
  66. package/src/math/qdt.js +11 -11
  67. package/src/math/statistics.js +10 -10
  68. package/src/math/symbolic.js +1 -1
  69. package/src/options.js +96 -40
  70. package/src/options3d.js +123 -0
  71. package/src/parser/ca.js +1297 -1291
  72. package/src/parser/datasource.js +1 -1
  73. package/src/parser/geonext.js +6 -6
  74. package/src/parser/jessiecode.js +369 -73
  75. package/src/parser/jessiescript.js +1 -1
  76. package/src/reader/cinderella.js +1 -1
  77. package/src/reader/file.js +1 -1
  78. package/src/reader/geogebra.js +1 -1
  79. package/src/reader/geonext.js +1 -1
  80. package/src/reader/graph.js +1 -1
  81. package/src/reader/intergeo.js +1 -1
  82. package/src/reader/sketch.js +7 -7
  83. package/src/renderer/abstract.js +8 -2
  84. package/src/renderer/canvas.js +9 -5
  85. package/src/renderer/no.js +2 -1
  86. package/src/renderer/svg.js +10 -13
  87. package/src/renderer/vml.js +1 -1
  88. package/src/server/server.js +1 -1
  89. package/src/utils/base64.js +2 -2
  90. package/src/utils/color.js +8 -9
  91. package/src/utils/dump.js +20 -5
  92. package/src/utils/env.js +13 -54
  93. package/src/utils/event.js +1 -1
  94. package/src/utils/expect.js +1 -1
  95. package/src/utils/type.js +12 -10
  96. package/src/utils/xml.js +1 -1
  97. package/src/utils/zip.js +1 -1
  98. package/CHANGELOG.md +0 -1366
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2008-2021
2
+ Copyright 2008-2022
3
3
  Matthias Ehmann,
4
4
  Michael Gerhaeuser,
5
5
  Carsten Miller,
@@ -198,8 +198,6 @@ define([
198
198
  * @private
199
199
  */
200
200
  updateCoords: function (fromParent) {
201
- var i;
202
-
203
201
  if (!this.needsUpdate) {
204
202
  return this;
205
203
  }
@@ -260,7 +258,7 @@ define([
260
258
  ev_sw,
261
259
  slide = this.slideObject,
262
260
  res, cu,
263
- slides = [],
261
+ slides = [],
264
262
  isTransformed;
265
263
 
266
264
  this.needsUpdateFromParent = false;
@@ -326,7 +324,6 @@ define([
326
324
  doRound = true;
327
325
  newPos = 0.0;
328
326
  } else {
329
- //this.coords.setCoordinates(Const.COORDS_BY_USER, Geometry.projectPointToLine(this, slide, this.board).usrCoords, false);
330
327
  newCoords = Geometry.projectPointToLine(this, slide, this.board);
331
328
  p1c = p1c.usrCoords.slice(0);
332
329
  p2c = p2c.usrCoords.slice(0);
@@ -1098,8 +1095,8 @@ define([
1098
1095
  slide = slideobj.borders[i];
1099
1096
  }
1100
1097
  }
1101
- slideobj = this.board.select(slide);
1102
- onPolygon = true;
1098
+ slideobj = this.board.select(slide);
1099
+ onPolygon = true;
1103
1100
  }
1104
1101
 
1105
1102
  /* Gliders on Ticks are forbidden */
@@ -1833,7 +1830,7 @@ define([
1833
1830
  if (direction < 0) {
1834
1831
  alpha *= this.intervalCount / stepCount;
1835
1832
  } else {
1836
- alpha *= (stepCount - this.intervalCount);
1833
+ alpha *= (stepCount - this.intervalCount) / stepCount;
1837
1834
  }
1838
1835
  radius = this.slideObject.Radius();
1839
1836
 
package/src/base/curve.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2008-2021
2
+ Copyright 2008-2022
3
3
  Matthias Ehmann,
4
4
  Michael Gerhaeuser,
5
5
  Carsten Miller,
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2008-2021
2
+ Copyright 2008-2022
3
3
  Matthias Ehmann,
4
4
  Michael Gerhaeuser,
5
5
  Carsten Miller,
@@ -224,7 +224,7 @@ define([
224
224
 
225
225
  /**
226
226
  * Inherits contains the subelements, which may have an attribute
227
- * (in partuclar the attribute "visible") having value 'inherit'.
227
+ * (in particular the attribute "visible") having value 'inherit'.
228
228
  * @type Object
229
229
  */
230
230
  this.inherits = [];
@@ -1052,26 +1052,35 @@ define([
1052
1052
  },
1053
1053
 
1054
1054
  /**
1055
- * Resolves property shortcuts like <tt>color</tt> and expands them, e.g. <tt>strokeColor</tt> and <tt>fillColor</tt>.
1056
- * Writes the expanded properties back to the given <tt>properties</tt>.
1057
- * @param {Object} properties
1058
- * @returns {Object} The given parameter with shortcuts expanded.
1055
+ * Resolves attribute shortcuts like <tt>color</tt> and expands them, e.g. <tt>strokeColor</tt> and <tt>fillColor</tt>.
1056
+ * Writes the expanded attributes back to the given <tt>attributes</tt>.
1057
+ * @param {Object} attributes object
1058
+ * @returns {Object} The given attributes object with shortcuts expanded.
1059
+ * @private
1059
1060
  */
1060
- resolveShortcuts: function (properties) {
1061
- var key, i;
1061
+ resolveShortcuts: function (attributes) {
1062
+ var key, i,
1063
+ j,
1064
+ subattr = ['traceattributes', 'traceAttributes'];
1062
1065
 
1063
1066
  for (key in Options.shortcuts) {
1064
1067
  if (Options.shortcuts.hasOwnProperty(key)) {
1065
- if (Type.exists(properties[key])) {
1066
- for (i = 0; i < Options.shortcuts[key].length; i++) {
1067
- if (!Type.exists(properties[Options.shortcuts[key][i]])) {
1068
- properties[Options.shortcuts[key][i]] = properties[key];
1068
+
1069
+ if (Type.exists(attributes[key])) {
1070
+ for (i = 0; i < Options.shortcuts[key].length; i++) {
1071
+ if (!Type.exists(attributes[Options.shortcuts[key][i]])) {
1072
+ attributes[Options.shortcuts[key][i]] = attributes[key];
1073
+ }
1074
+ }
1075
+ }
1076
+ for (j = 0; j < subattr.length; j++) {
1077
+ if (Type.isObject(attributes[subattr[j]])) {
1078
+ attributes[subattr[j]] = this.resolveShortcuts(attributes[subattr[j]]);
1079
+ }
1069
1080
  }
1070
1081
  }
1071
- }
1072
- }
1073
1082
  }
1074
- return properties;
1083
+ return attributes;
1075
1084
  },
1076
1085
 
1077
1086
  /**
@@ -1927,10 +1936,9 @@ define([
1927
1936
  */
1928
1937
  removeAllTicks: function () {
1929
1938
  var t;
1930
-
1931
1939
  if (Type.exists(this.ticks)) {
1932
- for (t = this.ticks.length; t > 0; t--) {
1933
- this.removeTicks(this.ticks[t - 1]);
1940
+ for (t = this.ticks.length - 1; t >= 0; t--) {
1941
+ this.removeTicks(this.ticks[t]);
1934
1942
  }
1935
1943
  this.ticks = [];
1936
1944
  this.board.update();
@@ -1949,19 +1957,19 @@ define([
1949
1957
  }
1950
1958
 
1951
1959
  if (Type.exists(this.ticks)) {
1952
- for (t = this.ticks.length; t > 0; t--) {
1953
- if (this.ticks[t - 1] === tick) {
1954
- this.board.removeObject(this.ticks[t - 1]);
1955
-
1956
- if (this.ticks[t - 1].ticks) {
1957
- for (j = 0; j < this.ticks[t - 1].ticks.length; j++) {
1958
- if (Type.exists(this.ticks[t - 1].labels[j])) {
1959
- this.board.removeObject(this.ticks[t - 1].labels[j]);
1960
+ for (t = this.ticks.length - 1; t >= 0; t--) {
1961
+ if (this.ticks[t] === tick) {
1962
+ this.board.removeObject(this.ticks[t]);
1963
+
1964
+ if (this.ticks[t].ticks) {
1965
+ for (j = 0; j < this.ticks[t].ticks.length; j++) {
1966
+ if (Type.exists(this.ticks[t].labels[j])) {
1967
+ this.board.removeObject(this.ticks[t].labels[j]);
1960
1968
  }
1961
1969
  }
1962
1970
  }
1963
1971
 
1964
- delete this.ticks[t - 1];
1972
+ delete this.ticks[t];
1965
1973
  break;
1966
1974
  }
1967
1975
  }
@@ -2034,7 +2042,7 @@ define([
2034
2042
  rcoords = new JXG.Coords(Const.COORDS_BY_USER, [rx, ry], this.board);
2035
2043
  if (!attractToGrid ||
2036
2044
  rcoords.distance(
2037
- ev_au == 'screen' ? Const.COORDS_BY_SCREEN : Const.COORDS_BY_USER, this.coords
2045
+ ev_au === 'screen' ? Const.COORDS_BY_SCREEN : Const.COORDS_BY_USER, this.coords
2038
2046
  ) < ev_ad) {
2039
2047
  x = rx;
2040
2048
  y = ry;
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2008-2021
2
+ Copyright 2008-2022
3
3
  Matthias Ehmann,
4
4
  Michael Gerhaeuser,
5
5
  Carsten Miller,
@@ -324,7 +324,13 @@
324
324
  * an SVG foreignObject container.
325
325
  * <p>
326
326
  * Instead of board.create('foreignobject') the shortcut board.create('fo') may be used.
327
- *
327
+ *
328
+ * <p style="background-color:#dddddd; padding:10px"><b>NOTE:</b> In Safari up to version 15, a foreignObject does not obey the layer structure
329
+ * if it contains &lt;video&gt; or &lt;iframe&gt; tags, as well as elements which are
330
+ * positioned with <tt>position:absolute|relative|fixed</tt>. In this case, the foreignobject will be
331
+ * "above" the JSXGraph construction.
332
+ * </p>
333
+ *
328
334
  * @pseudo
329
335
  * @description
330
336
  * @name ForeignObject
@@ -427,6 +433,10 @@
427
433
  *
428
434
  * </script><pre>
429
435
  *
436
+ * Video "24-hour time-lapse in Cascais, Portugal. Produced by Nuno Miguel Duarte" adapted from
437
+ * <a href="https://www.pbslearningmedia.org/resource/buac18-k2-sci-ess-sunposition/changing-position-of-the-sun-in-the-sky/">https://www.pbslearningmedia.org/resource/buac18-k2-sci-ess-sunposition/changing-position-of-the-sun-in-the-sky/</a>,
438
+ * ©2016 Nuno Miguel Duarte.
439
+ *
430
440
  */
431
441
  JXG.createForeignObject = function (board, parents, attributes) {
432
442
  var attr, fo,
package/src/base/group.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2008-2021
2
+ Copyright 2008-2022
3
3
  Matthias Ehmann,
4
4
  Michael Gerhaeuser,
5
5
  Carsten Miller,
package/src/base/image.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2008-2021
2
+ Copyright 2008-2022
3
3
  Matthias Ehmann,
4
4
  Michael Gerhaeuser,
5
5
  Carsten Miller,
package/src/base/line.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2008-2021
2
+ Copyright 2008-2022
3
3
  Matthias Ehmann,
4
4
  Michael Gerhaeuser,
5
5
  Carsten Miller,
@@ -695,7 +695,7 @@ define([
695
695
  if (this.parents.length < 3) { // Line through two points
696
696
  this.point1.handleSnapToGrid(true, true);
697
697
  this.point2.handleSnapToGrid(true, true);
698
- } else if (Type.exists(pos)) { // Free line
698
+ } else if (Type.exists(pos)) { // Free line
699
699
  sX = Type.evaluate(this.visProp.snapsizex);
700
700
  sY = Type.evaluate(this.visProp.snapsizey);
701
701
 
package/src/base/point.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2008-2021
2
+ Copyright 2008-2022
3
3
  Matthias Ehmann,
4
4
  Michael Gerhaeuser,
5
5
  Carsten Miller,
@@ -87,6 +87,7 @@ define([
87
87
  this.board.renderer.drawPoint(this);
88
88
  this.board.finalizeAdding(this);
89
89
 
90
+ this.createGradient();
90
91
  this.createLabel();
91
92
 
92
93
  };
@@ -156,7 +157,7 @@ define([
156
157
  * @returns {JXG.CoordsElement} Reference to this object.
157
158
  */
158
159
  updateTransform: function (fromParent) {
159
- var c, i, invMat;
160
+ var c, i;
160
161
 
161
162
  if (this.transformations.length === 0 || this.baseElement === null) {
162
163
  return this;
@@ -167,17 +168,6 @@ define([
167
168
  c = this.transformations[0].apply(this.baseElement, 'self');
168
169
  this.coords.setCoordinates(Const.COORDS_BY_USER, c);
169
170
  } else {
170
- // Case of board.create('point',[baseElement, transform]);
171
- // if (!fromParent) {
172
- // // The element has been dragged or it is the initial update,
173
- // // now we transform the baseElement
174
- // if (this.draggable() && this.baseElement.draggable()) {
175
- // this.transformations[0].update();
176
- // invMat = Mat.inverse(this.transformations[0].matrix);
177
- // c = Mat.matVecMult(invMat, this.coords.usrCoords);
178
- // this.baseElement.coords.setCoordinates(Const.COORDS_BY_USER, c);
179
- // }
180
- // }
181
171
  c = this.transformations[0].apply(this.baseElement);
182
172
  }
183
173
  this.coords.setCoordinates(Const.COORDS_BY_USER, c);
@@ -352,12 +342,12 @@ define([
352
342
  * var pol = board.create('polygon', [[2,2], [4,2], [4,3]], {strokeColor: 'blue'});
353
343
  *
354
344
  * var point = board.create('point', [-1, 1], {
355
- * attractors: [line, seg, circ, po, curve, pol],
345
+ * attractors: [line, seg, circ, po, curve, pol],
356
346
  * attractorDistance: 0.2
357
347
  * });
358
348
  *
359
349
  * var txt = board.create('text', [-4, 3, function() {
360
- * return 'point on line: ' + point.isOn(line) + '<br>' +
350
+ * return 'point on line: ' + point.isOn(line) + '<br>' +
361
351
  * 'point on seg: ' + point.isOn(seg) + '<br>' +
362
352
  * 'point on circ = ' + point.isOn(circ) + '<br>' +
363
353
  * 'point on point = ' + point.isOn(po) + '<br>' +
@@ -380,14 +370,14 @@ define([
380
370
  } else if (el.elementClass === Const.OBJECT_CLASS_LINE) {
381
371
  if (el.elType === 'segment' && !Type.evaluate(this.visProp.alwaysintersect)) {
382
372
  arr = JXG.Math.Geometry.projectCoordsToSegment(
383
- this.coords.usrCoords,
373
+ this.coords.usrCoords,
384
374
  el.point1.coords.usrCoords,
385
375
  el.point2.coords.usrCoords);
386
376
  if (arr[1] >= 0 && arr[1] <= 1 &&
387
377
  Geometry.distPointLine(this.coords.usrCoords, el.stdform) < tol) {
388
- return true;
378
+ return true;
389
379
  } else {
390
- return false;
380
+ return false;
391
381
  }
392
382
  } else {
393
383
  return Geometry.distPointLine(this.coords.usrCoords, el.stdform) < tol;
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2008-2021
2
+ Copyright 2008-2022
3
3
  Matthias Ehmann,
4
4
  Michael Gerhaeuser,
5
5
  Carsten Miller,
@@ -559,8 +559,35 @@ define([
559
559
 
560
560
  /**
561
561
  * Add more points to the polygon. The new points will be inserted at the end.
562
- * @param {JXG.Point} p Arbitrary number of points
562
+ * The attributes of new border segments are set to the same values
563
+ * as those used when the polygon was created.
564
+ * If new vertices are supplied by coordinates, the default attributes of polygon
565
+ * vertices are taken as their attributes. Therefore, the visual attributes of
566
+ * new vertices and borders may have to be adapted afterwards.
567
+ * @param {JXG.Point} p Arbitrary number of points or coordinate arrays
563
568
  * @returns {JXG.Polygon} Reference to the polygon
569
+ * @example
570
+ * const board = JXG.JSXGraph.initBoard('jxgbox', {axis:true});
571
+ * var pg = board.create('polygon', [[1,2], [3,4], [-3,1]], {hasInnerPoints: true});
572
+ * var newPoint = board.create('point', [-1, -1]);
573
+ * var newPoint2 = board.create('point', [-1, -2]);
574
+ * pg.addPoints(newPoint, newPoint2, [1, -2]);
575
+ *
576
+ * </pre><div id="JXG70eb0fd2-d20f-4ba9-9ab6-0eac92aabfa5" class="jxgbox" style="width: 300px; height: 300px;"></div>
577
+ * <script type="text/javascript">
578
+ * (function() {
579
+ * var board = JXG.JSXGraph.initBoard('JXG70eb0fd2-d20f-4ba9-9ab6-0eac92aabfa5',
580
+ * {boundingbox: [-8, 8, 8,-8], axis: true, showcopyright: false, shownavigation: false});
581
+ * const board = JXG.JSXGraph.initBoard('jxgbox', {axis:true});
582
+ * var pg = board.create('polygon', [[1,2], [3,4], [-3,1]], {hasInnerPoints: true});
583
+ * var newPoint = board.create('point', [-1, -1]);
584
+ * var newPoint2 = board.create('point', [-1, -2]);
585
+ * pg.addPoints(newPoint, newPoint2, [1, -2]);
586
+ *
587
+ * })();
588
+ *
589
+ * </script><pre>
590
+ *
564
591
  */
565
592
  addPoints: function (p) {
566
593
  var args = Array.prototype.slice.call(arguments);
@@ -569,44 +596,72 @@ define([
569
596
  },
570
597
 
571
598
  /**
572
- * Adds more points to the vertex list of the polygon, starting with index <tt><i</tt>
573
- * @param {Number} idx The position where the new vertices are inserted, starting with 0.
574
- * @param {JXG.Point} p Arbitrary number of points to insert.
599
+ * Insert points to the vertex list of the polygon after index <tt><idx</tt>.
600
+ * The attributes of new border segments are set to the same values
601
+ * as those used when the polygon was created.
602
+ * If new vertices are supplied by coordinates, the default attributes of polygon
603
+ * vertices are taken as their attributes. Therefore, the visual attributes of
604
+ * new vertices and borders may have to be adapted afterwards.
605
+ *
606
+ * @param {Number} idx The position after which the new vertices are inserted.
607
+ * Setting idx to -1 inserts the new points at the front, i.e. at position 0.
608
+ * @param {JXG.Point} p Arbitrary number of points or coordinate arrays to insert.
575
609
  * @returns {JXG.Polygon} Reference to the polygon object
610
+ *
611
+ * @example
612
+ * const board = JXG.JSXGraph.initBoard('jxgbox', {axis:true});
613
+ * var pg = board.create('polygon', [[1,2], [3,4], [-3,1]], {hasInnerPoints: true});
614
+ * var newPoint = board.create('point', [-1, -1]);
615
+ * pg.insertPoints(0, newPoint, newPoint, [1, -2]);
616
+ *
617
+ * </pre><div id="JXG17b84b2a-a851-4e3f-824f-7f6a60f166ca" class="jxgbox" style="width: 300px; height: 300px;"></div>
618
+ * <script type="text/javascript">
619
+ * (function() {
620
+ * var board = JXG.JSXGraph.initBoard('JXG17b84b2a-a851-4e3f-824f-7f6a60f166ca',
621
+ * {boundingbox: [-8, 8, 8,-8], axis: true, showcopyright: false, shownavigation: false});
622
+ * const board = JXG.JSXGraph.initBoard('jxgbox', {axis:true});
623
+ * var pg = board.create('polygon', [[1,2], [3,4], [-3,1]], {hasInnerPoints: true});
624
+ * var newPoint = board.create('point', [-1, -1]);
625
+ * pg.insertPoints(0, newPoint, newPoint, [1, -2]);
626
+ *
627
+ * })();
628
+ *
629
+ * </script><pre>
630
+ *
576
631
  */
577
632
  insertPoints: function (idx, p) {
578
- var i, npoints = [], tmp;
633
+ var i, le;
579
634
 
580
635
  if (arguments.length === 0) {
581
636
  return this;
582
637
  }
583
638
 
584
639
 
585
- if (idx < 0 || idx > this.vertices.length - 2) {
640
+ if (idx < -1 || idx > this.vertices.length - 2) {
586
641
  return this;
587
642
  }
588
643
 
589
- for (i = 1; i < arguments.length; i++) {
590
- if (Type.isPoint(arguments[i])) {
591
- npoints.push(arguments[i]);
592
- }
644
+ le = arguments.length - 1;
645
+ for (i = 1; i < le + 1; i++) {
646
+ this.vertices.splice(idx + i, 0,
647
+ Type.providePoints(this.board, [arguments[i]], {}, 'polygon', ['vertices'])[0]
648
+ );
649
+ }
650
+ if (idx === -1) {
651
+ this.vertices[this.vertices.length - 1] = this.vertices[0];
593
652
  }
594
-
595
- tmp = this.vertices.slice(0, idx + 1).concat(npoints);
596
- this.vertices = tmp.concat(this.vertices.slice(idx + 1));
597
-
598
653
  if (this.withLines) {
599
- tmp = this.borders.slice(0, idx);
600
- this.board.removeObject(this.borders[idx]);
601
-
602
- for (i = 0; i < npoints.length; i++) {
603
- tmp.push(this.board.create('segment', [this.vertices[idx + i], this.vertices[idx + i + 1]], this.attr_line));
654
+ if (idx < 0) {
655
+ this.borders[this.borders.length - 1].point2 = this.vertices[this.vertices.length - 1];
656
+ } else {
657
+ this.borders[idx].point2 = this.vertices[idx + 1];
658
+ }
659
+ for (i = idx + 1; i < idx + 1 + le; i++) {
660
+ this.borders.splice(i, 0,
661
+ this.board.create('segment', [this.vertices[i], this.vertices[i + 1]], this.attr_line)
662
+ );
604
663
  }
605
-
606
- tmp.push(this.board.create('segment', [this.vertices[idx + npoints.length], this.vertices[idx + npoints.length + 1]], this.attr_line));
607
- this.borders = tmp.concat(this.borders.slice(idx + 1));
608
664
  }
609
-
610
665
  this.board.update();
611
666
 
612
667
  return this;
@@ -621,7 +676,7 @@ define([
621
676
  var i, j, idx, nvertices = [], nborders = [],
622
677
  nidx = [], partition = [];
623
678
 
624
- // partition:
679
+ // Partition:
625
680
  // in order to keep the borders which could be recycled, we have to partition
626
681
  // the set of removed points. I.e. if the points 1, 2, 5, 6, 7, 10 are removed,
627
682
  // the partitions are
@@ -629,10 +684,10 @@ define([
629
684
  // this gives us the borders, that can be removed and the borders we have to create.
630
685
 
631
686
 
632
- // remove the last vertex which is identical to the first
687
+ // Remove the last vertex which is identical to the first
633
688
  this.vertices = this.vertices.slice(0, this.vertices.length - 1);
634
689
 
635
- // collect all valid parameters as indices in nidx
690
+ // Collect all valid parameters as indices in nidx
636
691
  for (i = 0; i < arguments.length; i++) {
637
692
  idx = arguments[i];
638
693
  if (Type.isPoint(idx)) {
@@ -644,22 +699,22 @@ define([
644
699
  }
645
700
  }
646
701
 
647
- // remove the polygon from each removed point's children
702
+ // Remove the polygon from each removed point's children
648
703
  for (i = 0; i < nidx.length; i++) {
649
704
  this.vertices[nidx[i]].removeChild(this);
650
705
  }
651
706
 
652
- // sort the elements to be eliminated
707
+ // Sort the elements to be eliminated
653
708
  nidx = nidx.sort();
654
709
  nvertices = this.vertices.slice();
655
710
  nborders = this.borders.slice();
656
711
 
657
- // initialize the partition
712
+ // Initialize the partition
658
713
  if (this.withLines) {
659
714
  partition.push([nidx[nidx.length - 1]]);
660
715
  }
661
716
 
662
- // run through all existing vertices and copy all remaining ones to nvertices
717
+ // Run through all existing vertices and copy all remaining ones to nvertices,
663
718
  // compute the partition
664
719
  for (i = nidx.length - 1; i > -1; i--) {
665
720
  nvertices[nidx[i]] = -1;
@@ -670,12 +725,12 @@ define([
670
725
  }
671
726
  }
672
727
 
673
- // finalize the partition computation
728
+ // Finalize the partition computation
674
729
  if (this.withLines) {
675
730
  partition[partition.length - 1][1] = nidx[0];
676
731
  }
677
732
 
678
- // update vertices
733
+ // Update vertices
679
734
  this.vertices = [];
680
735
  for (i = 0; i < nvertices.length; i++) {
681
736
  if (Type.isPoint(nvertices[i])) {
@@ -686,7 +741,7 @@ define([
686
741
  this.vertices.push(this.vertices[0]);
687
742
  }
688
743
 
689
- // delete obsolete and create missing borders
744
+ // Delete obsolete and create missing borders
690
745
  if (this.withLines) {
691
746
  for (i = 0; i < partition.length; i++) {
692
747
  for (j = partition[i][1] - 1; j < partition[i][0] + 1; j++) {
package/src/base/text.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2008-2021
2
+ Copyright 2008-2022
3
3
  Matthias Ehmann,
4
4
  Michael Gerhaeuser,
5
5
  Carsten Miller,
@@ -308,7 +308,7 @@ define([
308
308
  * @return {[type]} [description]
309
309
  */
310
310
  updateSize: function () {
311
- var tmp, s, that, node,
311
+ var tmp, that, node,
312
312
  ev_d = Type.evaluate(this.visProp.display);
313
313
 
314
314
  if (!Env.isBrowser || this.board.renderer.type === 'no') {
@@ -576,7 +576,7 @@ define([
576
576
  * @returns {string} expanded String
577
577
  */
578
578
  expandShortMath: function (expr) {
579
- var re = /([\)0-9\.])\s*([\(a-zA-Z_])/g;
579
+ var re = /([)0-9.])\s*([(a-zA-Z_])/g;
580
580
  return expr.replace(re, '$1*$2');
581
581
  },
582
582
 
@@ -746,7 +746,7 @@ define([
746
746
  content = content.replace(/&lt;\/value&gt;/g, '</value>');
747
747
 
748
748
  do {
749
- search = /<value>([\w\s\*\/\^\-\+\(\)\[\],<>=!]+)<\/value>/;
749
+ search = /<value>([\w\s*/^\-+()[\],<>=!]+)<\/value>/;
750
750
  res = search.exec(content);
751
751
 
752
752
  if (res !== null) {
@@ -874,7 +874,8 @@ define([
874
874
  */
875
875
  setAutoPosition: function () {
876
876
  var x, y, cx, cy,
877
- anchorCoords, anchorX, anchorY,
877
+ anchorCoords,
878
+ // anchorX, anchorY,
878
879
  w = this.size[0],
879
880
  h = this.size[1],
880
881
  start_angle, angle,
@@ -896,8 +897,8 @@ define([
896
897
  return this;
897
898
  }
898
899
 
899
- anchorX = Type.evaluate(this.visProp.anchorx);
900
- anchorY = Type.evaluate(this.visProp.anchory);
900
+ // anchorX = Type.evaluate(this.visProp.anchorx);
901
+ // anchorY = Type.evaluate(this.visProp.anchory);
901
902
  offset = Type.evaluate(this.visProp.offset);
902
903
  anchorCoords = this.element.getLabelAnchor();
903
904
  cx = anchorCoords.scrCoords[1];
package/src/base/ticks.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2008-2021
2
+ Copyright 2008-2022
3
3
  Matthias Ehmann,
4
4
  Michael Gerhaeuser,
5
5
  Carsten Miller,
@@ -1016,14 +1016,24 @@ define([
1016
1016
  * @private
1017
1017
  */
1018
1018
  formatLabelText: function(value) {
1019
- var labelText = value.toString(),
1019
+ var labelText,
1020
+ digits,
1020
1021
  ev_s = Type.evaluate(this.visProp.scalesymbol);
1021
1022
 
1022
1023
  // if value is Number
1023
1024
  if (Type.isNumber(value)) {
1025
+ labelText = (Math.round(value * 1.e13) / 1.e13).toString();
1024
1026
  if (labelText.length > Type.evaluate(this.visProp.maxlabellength) ||
1025
1027
  labelText.indexOf('e') !== -1) {
1026
- labelText = value.toPrecision(Type.evaluate(this.visProp.precision)).toString();
1028
+
1029
+ digits = Type.evaluate(this.visProp.digits);
1030
+ if (Type.evaluate(this.visProp.precision) !== 3 && digits === 3) {
1031
+ // Use the deprecated attribute "precision"
1032
+ digits = Type.evaluate(this.visProp.precision);
1033
+ }
1034
+
1035
+ //labelText = value.toPrecision(digits).toString();
1036
+ labelText = value.toExponential(digits).toString();
1027
1037
  }
1028
1038
 
1029
1039
  if (Type.evaluate(this.visProp.beautifulscientificticklabels)) {
@@ -1036,6 +1046,8 @@ define([
1036
1046
  // trim trailing .
1037
1047
  labelText = labelText.replace(/\.$/, '');
1038
1048
  }
1049
+ } else {
1050
+ labelText = value.toString();
1039
1051
  }
1040
1052
 
1041
1053
  if (ev_s.length > 0) {
@@ -1255,6 +1267,8 @@ define([
1255
1267
  attr.id = this.id + ld.i + 'Label' + this.labelCounter;
1256
1268
 
1257
1269
  label = Text.createText(this.board, [ld.x, ld.y, ld.t], attr);
1270
+ this.addChild(label);
1271
+ label.setParents(this);
1258
1272
  label.isDraggable = false;
1259
1273
  label.dump = false;
1260
1274
  this.labels.push(label);
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2008-2021
2
+ Copyright 2008-2022
3
3
  Matthias Ehmann,
4
4
  Michael Gerhaeuser,
5
5
  Carsten Miller,
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2008-2021
2
+ Copyright 2008-2022
3
3
  Matthias Ehmann,
4
4
  Michael Gerhaeuser,
5
5
  Carsten Miller,
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2008-2021
2
+ Copyright 2008-2022
3
3
  Matthias Ehmann,
4
4
  Michael Gerhaeuser,
5
5
  Carsten Miller,
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2008-2021
2
+ Copyright 2008-2022
3
3
  Matthias Ehmann,
4
4
  Michael Gerhaeuser,
5
5
  Carsten Miller,