@amcharts/amcharts5 5.3.6 → 5.3.8

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 (219) hide show
  1. package/.internal/charts/hierarchy/ForceDirected.d.ts.map +1 -1
  2. package/.internal/charts/hierarchy/ForceDirected.js +3 -3
  3. package/.internal/charts/hierarchy/ForceDirected.js.map +1 -1
  4. package/.internal/charts/map/MapChartDefaultTheme.d.ts.map +1 -1
  5. package/.internal/charts/map/MapChartDefaultTheme.js +4 -0
  6. package/.internal/charts/map/MapChartDefaultTheme.js.map +1 -1
  7. package/.internal/charts/map/ZoomControl.js +1 -0
  8. package/.internal/charts/map/ZoomControl.js.map +1 -1
  9. package/.internal/charts/stock/StockChart.d.ts +14 -1
  10. package/.internal/charts/stock/StockChart.d.ts.map +1 -1
  11. package/.internal/charts/stock/StockChart.js +44 -0
  12. package/.internal/charts/stock/StockChart.js.map +1 -1
  13. package/.internal/charts/stock/StockChartDefaultTheme.d.ts.map +1 -1
  14. package/.internal/charts/stock/StockChartDefaultTheme.js +3 -1
  15. package/.internal/charts/stock/StockChartDefaultTheme.js.map +1 -1
  16. package/.internal/charts/stock/drawing/DrawingSeries.d.ts +1 -0
  17. package/.internal/charts/stock/drawing/DrawingSeries.d.ts.map +1 -1
  18. package/.internal/charts/stock/drawing/DrawingSeries.js +15 -0
  19. package/.internal/charts/stock/drawing/DrawingSeries.js.map +1 -1
  20. package/.internal/charts/stock/toolbar/DateRangeSelector.d.ts +21 -0
  21. package/.internal/charts/stock/toolbar/DateRangeSelector.d.ts.map +1 -1
  22. package/.internal/charts/stock/toolbar/DateRangeSelector.js +49 -6
  23. package/.internal/charts/stock/toolbar/DateRangeSelector.js.map +1 -1
  24. package/.internal/charts/stock/toolbar/DrawingControl.d.ts.map +1 -1
  25. package/.internal/charts/stock/toolbar/DrawingControl.js +40 -30
  26. package/.internal/charts/stock/toolbar/DrawingControl.js.map +1 -1
  27. package/.internal/charts/xy/axes/Axis.d.ts +7 -2
  28. package/.internal/charts/xy/axes/Axis.d.ts.map +1 -1
  29. package/.internal/charts/xy/axes/Axis.js.map +1 -1
  30. package/.internal/charts/xy/axes/AxisRendererX.d.ts.map +1 -1
  31. package/.internal/charts/xy/axes/AxisRendererX.js +1 -0
  32. package/.internal/charts/xy/axes/AxisRendererX.js.map +1 -1
  33. package/.internal/charts/xy/axes/AxisRendererY.d.ts.map +1 -1
  34. package/.internal/charts/xy/axes/AxisRendererY.js +1 -0
  35. package/.internal/charts/xy/axes/AxisRendererY.js.map +1 -1
  36. package/.internal/charts/xy/axes/GaplessDateAxis.d.ts.map +1 -1
  37. package/.internal/charts/xy/axes/GaplessDateAxis.js +5 -0
  38. package/.internal/charts/xy/axes/GaplessDateAxis.js.map +1 -1
  39. package/.internal/charts/xy/axes/ValueAxis.d.ts +1 -1
  40. package/.internal/charts/xy/axes/ValueAxis.js.map +1 -1
  41. package/.internal/charts/xy/series/XYSeries.d.ts.map +1 -1
  42. package/.internal/charts/xy/series/XYSeries.js +20 -1
  43. package/.internal/charts/xy/series/XYSeries.js.map +1 -1
  44. package/.internal/core/Registry.js +1 -1
  45. package/.internal/core/Registry.js.map +1 -1
  46. package/.internal/core/Root.d.ts +15 -1
  47. package/.internal/core/Root.d.ts.map +1 -1
  48. package/.internal/core/Root.js +82 -24
  49. package/.internal/core/Root.js.map +1 -1
  50. package/.internal/core/render/Component.d.ts.map +1 -1
  51. package/.internal/core/render/Component.js +3 -0
  52. package/.internal/core/render/Component.js.map +1 -1
  53. package/.internal/core/render/Container.d.ts.map +1 -1
  54. package/.internal/core/render/Container.js +8 -2
  55. package/.internal/core/render/Container.js.map +1 -1
  56. package/.internal/core/render/Graphics.d.ts.map +1 -1
  57. package/.internal/core/render/Graphics.js +3 -0
  58. package/.internal/core/render/Graphics.js.map +1 -1
  59. package/.internal/core/render/Sprite.d.ts.map +1 -1
  60. package/.internal/core/render/Sprite.js +13 -3
  61. package/.internal/core/render/Sprite.js.map +1 -1
  62. package/.internal/core/render/Tooltip.d.ts +2 -1
  63. package/.internal/core/render/Tooltip.d.ts.map +1 -1
  64. package/.internal/core/render/Tooltip.js +19 -1
  65. package/.internal/core/render/Tooltip.js.map +1 -1
  66. package/.internal/core/render/backend/CanvasRenderer.d.ts +8 -8
  67. package/.internal/core/render/backend/CanvasRenderer.d.ts.map +1 -1
  68. package/.internal/core/render/backend/CanvasRenderer.js +93 -65
  69. package/.internal/core/render/backend/CanvasRenderer.js.map +1 -1
  70. package/.internal/core/render/backend/Renderer.d.ts +2 -1
  71. package/.internal/core/render/backend/Renderer.d.ts.map +1 -1
  72. package/.internal/core/render/backend/Renderer.js.map +1 -1
  73. package/.internal/core/util/Template.d.ts +4 -0
  74. package/.internal/core/util/Template.d.ts.map +1 -1
  75. package/.internal/core/util/Template.js +6 -0
  76. package/.internal/core/util/Template.js.map +1 -1
  77. package/.internal/plugins/exporting/Exporting.d.ts.map +1 -1
  78. package/.internal/plugins/exporting/Exporting.js +4 -4
  79. package/.internal/plugins/exporting/Exporting.js.map +1 -1
  80. package/CHANGELOG.md +34 -0
  81. package/examples/javascript/flow-chord/package.json +1 -1
  82. package/examples/javascript/flow-chord-directed/package.json +1 -1
  83. package/examples/javascript/flow-chord-non-ribbon/package.json +1 -1
  84. package/examples/javascript/flow-sankey/package.json +1 -1
  85. package/examples/javascript/gauge/package.json +1 -1
  86. package/examples/javascript/gauge-bands/package.json +1 -1
  87. package/examples/javascript/hierarchy-force-directed/package.json +1 -1
  88. package/examples/javascript/hierarchy-pack/package.json +1 -1
  89. package/examples/javascript/hierarchy-partition/package.json +1 -1
  90. package/examples/javascript/hierarchy-sunburst/package.json +1 -1
  91. package/examples/javascript/hierarchy-tree/package.json +1 -1
  92. package/examples/javascript/hierarchy-treemap/package.json +1 -1
  93. package/examples/javascript/jest/package.json +1 -1
  94. package/examples/javascript/json-pie/package.json +1 -1
  95. package/examples/javascript/json-xy/package.json +1 -1
  96. package/examples/javascript/map-animating-along-lines/package.json +1 -1
  97. package/examples/javascript/map-day-and-night/package.json +1 -1
  98. package/examples/javascript/map-globe-rotate-to-country/package.json +1 -1
  99. package/examples/javascript/map-globe-with-projected-circles/package.json +1 -1
  100. package/examples/javascript/map-with-bubbles/package.json +1 -1
  101. package/examples/javascript/map-zoom-to-country/package.json +1 -1
  102. package/examples/javascript/misc-40-charts/package.json +1 -1
  103. package/examples/javascript/misc-microchart-grid/package.json +1 -1
  104. package/examples/javascript/pie-chart/package.json +1 -1
  105. package/examples/javascript/pie-donut-chart/package.json +1 -1
  106. package/examples/javascript/pie-variable-radius/package.json +1 -1
  107. package/examples/javascript/radar-column-iwatch-style/package.json +1 -1
  108. package/examples/javascript/radar-heat-map/package.json +1 -1
  109. package/examples/javascript/radar-line/package.json +1 -1
  110. package/examples/javascript/radar-time-line/package.json +1 -1
  111. package/examples/javascript/sliced-funnel/package.json +1 -1
  112. package/examples/javascript/sliced-pictorial-stacked/package.json +1 -1
  113. package/examples/javascript/sliced-pyramid/package.json +1 -1
  114. package/examples/javascript/stock-chart/package.json +1 -1
  115. package/examples/javascript/stock-chart-comparing-stocks/package.json +1 -1
  116. package/examples/javascript/stock-chart-data-granularity/package.json +1 -1
  117. package/examples/javascript/stock-chart-data-grouping/package.json +1 -1
  118. package/examples/javascript/stock-chart-intraday/package.json +1 -1
  119. package/examples/javascript/stock-chart-live/package.json +1 -1
  120. package/examples/javascript/stock-chart-volume-separate-panel/package.json +1 -1
  121. package/examples/javascript/venn-diagram/package.json +1 -1
  122. package/examples/javascript/wordcloud-with-data/package.json +1 -1
  123. package/examples/javascript/wordcloud-with-text/package.json +1 -1
  124. package/examples/javascript/xy-100-percent-stacked-column/package.json +1 -1
  125. package/examples/javascript/xy-animated-bullet-at-the-end-of-the-series/package.json +1 -1
  126. package/examples/javascript/xy-bubble/package.json +1 -1
  127. package/examples/javascript/xy-candlestick/package.json +1 -1
  128. package/examples/javascript/xy-clustered-column/package.json +1 -1
  129. package/examples/javascript/xy-column/package.json +1 -1
  130. package/examples/javascript/xy-comparing-series-google-analytics-style/package.json +1 -1
  131. package/examples/javascript/xy-data-grouping/package.json +1 -1
  132. package/examples/javascript/xy-draggable-range/package.json +1 -1
  133. package/examples/javascript/xy-drawing-series-with-mouse-or-touch/package.json +1 -1
  134. package/examples/javascript/xy-dumbbell plot/package.json +1 -1
  135. package/examples/javascript/xy-evenly-spaced-date-axis/package.json +1 -1
  136. package/examples/javascript/xy-line/package.json +1 -1
  137. package/examples/javascript/xy-line-highlight-on-legend-hover/package.json +1 -1
  138. package/examples/javascript/xy-live-data/package.json +1 -1
  139. package/examples/javascript/xy-multiple-synced-value-axes/package.json +1 -1
  140. package/examples/javascript/xy-ohlc/package.json +1 -1
  141. package/examples/javascript/xy-real-time-data-sorting/package.json +1 -1
  142. package/examples/javascript/xy-smoothed-line/package.json +1 -1
  143. package/examples/javascript/xy-stacked-and-clustered-column/package.json +1 -1
  144. package/examples/javascript/xy-stacked-column/package.json +1 -1
  145. package/examples/javascript/xy-stacked-step/package.json +1 -1
  146. package/examples/javascript/xy-stock/package.json +1 -1
  147. package/examples/javascript/xy-stock-comparing/package.json +1 -1
  148. package/examples/typescript/flow-chord/package.json +1 -1
  149. package/examples/typescript/flow-chord-directed/package.json +1 -1
  150. package/examples/typescript/flow-chord-non-ribbon/package.json +1 -1
  151. package/examples/typescript/flow-sankey/package.json +1 -1
  152. package/examples/typescript/gauge/package.json +1 -1
  153. package/examples/typescript/gauge-bands/package.json +1 -1
  154. package/examples/typescript/hierarchy-force-directed/package.json +1 -1
  155. package/examples/typescript/hierarchy-pack/package.json +1 -1
  156. package/examples/typescript/hierarchy-partition/package.json +1 -1
  157. package/examples/typescript/hierarchy-sunburst/package.json +1 -1
  158. package/examples/typescript/hierarchy-tree/package.json +1 -1
  159. package/examples/typescript/hierarchy-treemap/package.json +1 -1
  160. package/examples/typescript/jest/package.json +1 -1
  161. package/examples/typescript/json-pie/package.json +1 -1
  162. package/examples/typescript/json-xy/package.json +1 -1
  163. package/examples/typescript/map-animating-along-lines/package.json +1 -1
  164. package/examples/typescript/map-day-and-night/package.json +1 -1
  165. package/examples/typescript/map-globe-rotate-to-country/package.json +1 -1
  166. package/examples/typescript/map-globe-with-projected-circles/package.json +1 -1
  167. package/examples/typescript/map-with-bubbles/package.json +1 -1
  168. package/examples/typescript/map-zoom-to-country/package.json +1 -1
  169. package/examples/typescript/misc-40-charts/package.json +1 -1
  170. package/examples/typescript/misc-microchart-grid/package.json +1 -1
  171. package/examples/typescript/pie-chart/package.json +1 -1
  172. package/examples/typescript/pie-donut-chart/package.json +1 -1
  173. package/examples/typescript/pie-variable-radius/package.json +1 -1
  174. package/examples/typescript/radar-column-iwatch-style/package.json +1 -1
  175. package/examples/typescript/radar-heat-map/package.json +1 -1
  176. package/examples/typescript/radar-line/package.json +1 -1
  177. package/examples/typescript/radar-time-line/package.json +1 -1
  178. package/examples/typescript/sliced-funnel/package.json +1 -1
  179. package/examples/typescript/sliced-pictorial-stacked/package.json +1 -1
  180. package/examples/typescript/sliced-pyramid/package.json +1 -1
  181. package/examples/typescript/stock-chart/package.json +1 -1
  182. package/examples/typescript/stock-chart-comparing-stocks/package.json +1 -1
  183. package/examples/typescript/stock-chart-data-granularity/package.json +1 -1
  184. package/examples/typescript/stock-chart-data-grouping/package.json +1 -1
  185. package/examples/typescript/stock-chart-intraday/package.json +1 -1
  186. package/examples/typescript/stock-chart-live/package.json +1 -1
  187. package/examples/typescript/stock-chart-volume-separate-panel/package.json +1 -1
  188. package/examples/typescript/venn-diagram/package.json +1 -1
  189. package/examples/typescript/wordcloud-with-data/package.json +1 -1
  190. package/examples/typescript/wordcloud-with-text/package.json +1 -1
  191. package/examples/typescript/xy-100-percent-stacked-column/package.json +1 -1
  192. package/examples/typescript/xy-animated-bullet-at-the-end-of-the-series/package.json +1 -1
  193. package/examples/typescript/xy-bubble/package.json +1 -1
  194. package/examples/typescript/xy-candlestick/package.json +1 -1
  195. package/examples/typescript/xy-clustered-column/package.json +1 -1
  196. package/examples/typescript/xy-column/package.json +1 -1
  197. package/examples/typescript/xy-comparing-series-google-analytics-style/package.json +1 -1
  198. package/examples/typescript/xy-data-grouping/package.json +1 -1
  199. package/examples/typescript/xy-draggable-range/package.json +1 -1
  200. package/examples/typescript/xy-drawing-series-with-mouse-or-touch/package.json +1 -1
  201. package/examples/typescript/xy-dumbbell plot/package.json +1 -1
  202. package/examples/typescript/xy-evenly-spaced-date-axis/package.json +1 -1
  203. package/examples/typescript/xy-line/package.json +1 -1
  204. package/examples/typescript/xy-line-highlight-on-legend-hover/package.json +1 -1
  205. package/examples/typescript/xy-live-data/package.json +1 -1
  206. package/examples/typescript/xy-multiple-synced-value-axes/package.json +1 -1
  207. package/examples/typescript/xy-ohlc/package.json +1 -1
  208. package/examples/typescript/xy-real-time-data-sorting/package.json +1 -1
  209. package/examples/typescript/xy-smoothed-line/package.json +1 -1
  210. package/examples/typescript/xy-stacked-and-clustered-column/package.json +1 -1
  211. package/examples/typescript/xy-stacked-column/package.json +1 -1
  212. package/examples/typescript/xy-stacked-step/package.json +1 -1
  213. package/examples/typescript/xy-stock/package.json +1 -1
  214. package/examples/typescript/xy-stock-comparing/package.json +1 -1
  215. package/map.d.ts +1 -1
  216. package/map.d.ts.map +1 -1
  217. package/map.js +1 -1
  218. package/map.js.map +1 -1
  219. package/package.json +1 -1
@@ -447,6 +447,7 @@ export class CanvasDisplayObject extends DisposerClass {
447
447
  if (this._parent) {
448
448
  this._parent.registerChildLayer(this._layer);
449
449
  }
450
+ this._layer.dirty = true;
450
451
  this._renderer.resizeLayer(this._layer);
451
452
  this._renderer.resizeGhost();
452
453
  }
@@ -1819,17 +1820,17 @@ export class CanvasText extends CanvasDisplayObject {
1819
1820
  writable: true,
1820
1821
  value: 1
1821
1822
  });
1822
- Object.defineProperty(this, "_textInfo", {
1823
+ Object.defineProperty(this, "textVisible", {
1823
1824
  enumerable: true,
1824
1825
  configurable: true,
1825
1826
  writable: true,
1826
- value: void 0
1827
+ value: true
1827
1828
  });
1828
- Object.defineProperty(this, "_textVisible", {
1829
+ Object.defineProperty(this, "_textInfo", {
1829
1830
  enumerable: true,
1830
1831
  configurable: true,
1831
1832
  writable: true,
1832
- value: true
1833
+ value: void 0
1833
1834
  });
1834
1835
  Object.defineProperty(this, "_originalScale", {
1835
1836
  enumerable: true,
@@ -1946,7 +1947,7 @@ export class CanvasText extends CanvasDisplayObject {
1946
1947
  if (!this._textInfo) {
1947
1948
  this._measure(layer);
1948
1949
  }
1949
- if (this._textVisible) {
1950
+ if (this.textVisible) {
1950
1951
  const interactive = this._isInteractive();
1951
1952
  const context = layer.context;
1952
1953
  const layerDirty = layer.dirty;
@@ -2205,7 +2206,7 @@ export class CanvasText extends CanvasDisplayObject {
2205
2206
  const tmpText = this._truncateText(context, chunk.text, excessWidth, false, (firstTextChunk && this.style.oversizedBehavior != "wrap-no-break"));
2206
2207
  if (tmpText == "") {
2207
2208
  // Unable to fit a single letter - hide the whole label
2208
- this._textVisible = true;
2209
+ this.textVisible = true;
2209
2210
  return false;
2210
2211
  }
2211
2212
  //skipFurtherText = true;
@@ -2339,18 +2340,26 @@ export class CanvasText extends CanvasDisplayObject {
2339
2340
  if (ratio < 1) {
2340
2341
  if (oversizedBehavior == "fit") {
2341
2342
  if ($type.isNumber(this.style.minScale) && (ratio < this.style.minScale)) {
2342
- this._textVisible = false;
2343
+ this.textVisible = false;
2344
+ bounds.left = 0;
2345
+ bounds.top = 0;
2346
+ bounds.right = 0;
2347
+ bounds.bottom = 0;
2343
2348
  }
2344
2349
  else {
2345
2350
  if (!this._originalScale || this._originalScale == 1) {
2346
2351
  this._originalScale = this.scale;
2347
2352
  }
2348
2353
  this.scale = ratio;
2349
- this._textVisible = true;
2354
+ this.textVisible = true;
2350
2355
  }
2351
2356
  }
2352
2357
  else if (oversizedBehavior == "hide") {
2353
- this._textVisible = false;
2358
+ this.textVisible = false;
2359
+ bounds.left = 0;
2360
+ bounds.top = 0;
2361
+ bounds.right = 0;
2362
+ bounds.bottom = 0;
2354
2363
  }
2355
2364
  else {
2356
2365
  switch (this.style.textAlign) {
@@ -2369,13 +2378,13 @@ export class CanvasText extends CanvasDisplayObject {
2369
2378
  }
2370
2379
  this.scale = this._originalScale || 1;
2371
2380
  this._originalScale = undefined;
2372
- this._textVisible = true;
2381
+ this.textVisible = true;
2373
2382
  }
2374
2383
  }
2375
2384
  else {
2376
2385
  this.scale = this._originalScale || 1;
2377
2386
  this._originalScale = undefined;
2378
- this._textVisible = true;
2387
+ this.textVisible = true;
2379
2388
  }
2380
2389
  }
2381
2390
  context.restore();
@@ -2698,7 +2707,7 @@ export class CanvasRadialText extends CanvasText {
2698
2707
  }
2699
2708
  }
2700
2709
  _renderCircular(parentLayer) {
2701
- if (this._textVisible) {
2710
+ if (this.textVisible) {
2702
2711
  const layer = this._layer || parentLayer;
2703
2712
  this._prerender(layer);
2704
2713
  const interactive = this._isInteractive();
@@ -2888,7 +2897,7 @@ export class CanvasRadialText extends CanvasText {
2888
2897
  let ellipsisMetrics;
2889
2898
  //const wrap = $type.isNumber(maxWidth) && (oversizedBehavior == "wrap" || oversizedBehavior == "wrap-no-break");
2890
2899
  // Reset text info
2891
- this._textVisible = true;
2900
+ this.textVisible = true;
2892
2901
  this._textInfo = [];
2893
2902
  this._textReversed = false;
2894
2903
  // Pre-render
@@ -3000,7 +3009,7 @@ export class CanvasRadialText extends CanvasText {
3000
3009
  totalWidth += ellipsisWidth;
3001
3010
  if ((totalWidth + ellipsisWidth) > maxWidth) {
3002
3011
  if (lineInfo.textChunks.length == 1) {
3003
- this._textVisible = false;
3012
+ this.textVisible = false;
3004
3013
  }
3005
3014
  else {
3006
3015
  lineInfo.width += ellipsisWidth;
@@ -3044,7 +3053,7 @@ export class CanvasRadialText extends CanvasText {
3044
3053
  ghostContext.restore();
3045
3054
  }
3046
3055
  if (oversizedBehavior == "hide" && (totalWidth > maxWidth)) {
3047
- this._textVisible = false;
3056
+ this.textVisible = false;
3048
3057
  }
3049
3058
  // Adjust chunk internal offsets
3050
3059
  $array.each(this._textInfo, (lineInfo) => {
@@ -3331,25 +3340,25 @@ export class CanvasRenderer extends ArrayDisposer {
3331
3340
  writable: true,
3332
3341
  value: this._patternCanvas.getContext("2d")
3333
3342
  });
3334
- Object.defineProperty(this, "_width", {
3343
+ Object.defineProperty(this, "_domWidth", {
3335
3344
  enumerable: true,
3336
3345
  configurable: true,
3337
3346
  writable: true,
3338
3347
  value: 0
3339
3348
  });
3340
- Object.defineProperty(this, "_height", {
3349
+ Object.defineProperty(this, "_domHeight", {
3341
3350
  enumerable: true,
3342
3351
  configurable: true,
3343
3352
  writable: true,
3344
3353
  value: 0
3345
3354
  });
3346
- Object.defineProperty(this, "_clientWidth", {
3355
+ Object.defineProperty(this, "_canvasWidth", {
3347
3356
  enumerable: true,
3348
3357
  configurable: true,
3349
3358
  writable: true,
3350
3359
  value: 0
3351
3360
  });
3352
- Object.defineProperty(this, "_clientHeight", {
3361
+ Object.defineProperty(this, "_canvasHeight", {
3353
3362
  enumerable: true,
3354
3363
  configurable: true,
3355
3364
  writable: true,
@@ -3620,25 +3629,25 @@ export class CanvasRenderer extends ArrayDisposer {
3620
3629
  return new CanvasImage(this, image);
3621
3630
  }
3622
3631
  resizeLayer(layer) {
3623
- layer.dirty = true;
3624
- layer.resize(this._clientWidth, this._clientHeight, this.resolution);
3632
+ layer.resize(this._canvasWidth, this._canvasHeight, this._domWidth, this._domHeight, this.resolution);
3625
3633
  }
3626
3634
  resizeGhost() {
3627
- this._ghostLayer.resize(this._clientWidth, this._clientHeight, this.resolution);
3635
+ this._ghostLayer.resize(this._canvasWidth, this._canvasHeight, this._domWidth, this._domHeight, this.resolution);
3628
3636
  }
3629
- resize(width, height) {
3630
- this._clientWidth = width;
3631
- this._clientHeight = height;
3632
- this._width = Math.floor(width * this.resolution);
3633
- this._height = Math.floor(height * this.resolution);
3637
+ resize(canvasWidth, canvasHeight, domWidth, domHeight) {
3638
+ this._canvasWidth = canvasWidth;
3639
+ this._canvasHeight = canvasHeight;
3640
+ this._domWidth = domWidth;
3641
+ this._domHeight = domHeight;
3634
3642
  $array.each(this.layers, (layer) => {
3635
3643
  if (layer) {
3644
+ layer.dirty = true;
3636
3645
  this.resizeLayer(layer);
3637
3646
  }
3638
3647
  });
3639
3648
  this.resizeGhost();
3640
- this.view.style.width = width + "px";
3641
- this.view.style.height = height + "px";
3649
+ this.view.style.width = domWidth + "px";
3650
+ this.view.style.height = domHeight + "px";
3642
3651
  }
3643
3652
  createDetachedLayer(willReadFrequently = false) {
3644
3653
  const view = document.createElement("canvas");
@@ -3667,11 +3676,8 @@ export class CanvasRenderer extends ArrayDisposer {
3667
3676
  const layer = this.createDetachedLayer(order == 99);
3668
3677
  layer.order = order;
3669
3678
  layer.visible = visible;
3670
- if (layer.visible && this._width) {
3671
- layer.view.width = this._width;
3672
- layer.view.style.width = this._clientWidth + "px";
3673
- layer.view.height = this._height;
3674
- layer.view.style.height = this._clientHeight + "px";
3679
+ if (layer.visible) {
3680
+ this.resizeLayer(layer);
3675
3681
  }
3676
3682
  const layers = this.layers;
3677
3683
  layers.push(layer);
@@ -4160,27 +4166,29 @@ export class CanvasRenderer extends ArrayDisposer {
4160
4166
  options = {};
4161
4167
  }
4162
4168
  let scale = this.resolution;
4169
+ let canvasWidth = Math.floor(this._canvasWidth * this.resolution);
4170
+ let canvasHeight = Math.floor(this._canvasHeight * this.resolution);
4163
4171
  // Check if we need to scale
4164
- if (options.minWidth && (options.minWidth > this._width)) {
4165
- let minScale = options.minWidth / this._width;
4172
+ if (options.minWidth && (options.minWidth > canvasWidth)) {
4173
+ let minScale = options.minWidth / canvasWidth;
4166
4174
  if (minScale > scale) {
4167
4175
  scale = minScale * this.resolution;
4168
4176
  }
4169
4177
  }
4170
- if (options.minHeight && (options.minHeight > this._height)) {
4171
- let minScale = options.minHeight / this._height;
4178
+ if (options.minHeight && (options.minHeight > canvasHeight)) {
4179
+ let minScale = options.minHeight / canvasHeight;
4172
4180
  if (minScale > scale) {
4173
4181
  scale = minScale * this.resolution;
4174
4182
  }
4175
4183
  }
4176
- if (options.maxWidth && (options.maxWidth < this._width)) {
4177
- let maxScale = options.maxWidth / this._width;
4184
+ if (options.maxWidth && (options.maxWidth < canvasWidth)) {
4185
+ let maxScale = options.maxWidth / canvasWidth;
4178
4186
  if (maxScale < scale) {
4179
4187
  scale = maxScale * this.resolution;
4180
4188
  }
4181
4189
  }
4182
- if (options.maxHeight && (options.maxHeight > this._height)) {
4183
- let maxScale = options.maxHeight / this._height;
4190
+ if (options.maxHeight && (options.maxHeight > canvasHeight)) {
4191
+ let maxScale = options.maxHeight / canvasHeight;
4184
4192
  if (maxScale < scale) {
4185
4193
  scale = maxScale * this.resolution;
4186
4194
  }
@@ -4193,13 +4201,11 @@ export class CanvasRenderer extends ArrayDisposer {
4193
4201
  const canvases = [];
4194
4202
  // Set up new canvas for export
4195
4203
  let forceRender = false;
4196
- let canvasWidth = this._width;
4197
- let canvasHeight = this._height;
4198
4204
  const canvas = document.createElement("canvas");
4199
4205
  if (scale != this.resolution) {
4200
4206
  forceRender = true;
4201
- canvasWidth = this._width * scale / this.resolution;
4202
- canvasHeight = this._height * scale / this.resolution;
4207
+ canvasWidth = canvasWidth * scale / this.resolution;
4208
+ canvasHeight = canvasHeight * scale / this.resolution;
4203
4209
  }
4204
4210
  canvas.width = canvasWidth;
4205
4211
  canvas.height = canvasHeight;
@@ -4225,8 +4231,14 @@ export class CanvasRenderer extends ArrayDisposer {
4225
4231
  layer.view.style.top = "-10000px";
4226
4232
  this.view.appendChild(layer.view);
4227
4233
  canvases.push(layer.view);
4228
- layer.view.width = canvasWidth;
4229
- layer.view.height = canvasHeight;
4234
+ let extraX = 0;
4235
+ let extraY = 0;
4236
+ if (layer.margin) {
4237
+ extraX += layer.margin.left || 0 + layer.margin.right || 0;
4238
+ extraY += layer.margin.top || 0 + layer.margin.bottom || 0;
4239
+ }
4240
+ layer.view.width = canvasWidth + extraX;
4241
+ layer.view.height = canvasHeight + extraY;
4230
4242
  layer.context = layer.view.getContext("2d");
4231
4243
  layer.dirty = true;
4232
4244
  layer.scale = scale;
@@ -4241,7 +4253,13 @@ export class CanvasRenderer extends ArrayDisposer {
4241
4253
  $array.each(this.layers, (layer) => {
4242
4254
  if (layer && layer.visible) {
4243
4255
  // Layer is fine. Just plop it into our target canvas
4244
- context.drawImage(layer.view, 0, 0);
4256
+ let x = 0;
4257
+ let y = 0;
4258
+ if (layer.margin) {
4259
+ x = -(layer.margin.left || 0) * this.resolution;
4260
+ y = -(layer.margin.top || 0) * this.resolution;
4261
+ }
4262
+ context.drawImage(layer.view, x, y);
4245
4263
  // Restore layer original canvas
4246
4264
  if (layer.exportableView) {
4247
4265
  layer.view = layer.exportableView;
@@ -4314,17 +4332,20 @@ class GhostLayer {
4314
4332
  this.view.style.top = "0px";
4315
4333
  this.view.style.left = "0px";
4316
4334
  }
4317
- resize(width, height, resolution) {
4318
- width += (this.margin.left + this.margin.right);
4319
- height += (this.margin.top + this.margin.bottom);
4335
+ resize(canvasWidth, canvasHeight, domWidth, domHeight, resolution) {
4336
+ canvasWidth += (this.margin.left + this.margin.right);
4337
+ canvasHeight += (this.margin.top + this.margin.bottom);
4338
+ // TODO this should take into account calculateSize
4339
+ domWidth += (this.margin.left + this.margin.right);
4340
+ domHeight += (this.margin.top + this.margin.bottom);
4320
4341
  this.view.style.left = -this.margin.left + "px";
4321
4342
  this.view.style.top = -this.margin.top + "px";
4322
- this._width = Math.floor(width * resolution);
4323
- this._height = Math.floor(height * resolution);
4343
+ this._width = Math.floor(canvasWidth * resolution);
4344
+ this._height = Math.floor(canvasHeight * resolution);
4324
4345
  this.view.width = this._width;
4325
- this.view.style.width = width + "px";
4346
+ this.view.style.width = domWidth + "px";
4326
4347
  this.view.height = this._height;
4327
- this.view.style.height = height + "px";
4348
+ this.view.style.height = domHeight + "px";
4328
4349
  }
4329
4350
  getImageData(point, bbox) {
4330
4351
  return this.context.getImageData(
@@ -4443,16 +4464,23 @@ export class CanvasLayer {
4443
4464
  this.view = view;
4444
4465
  this.context = context;
4445
4466
  }
4446
- resize(width, height, resolution) {
4467
+ resize(canvasWidth, canvasHeight, domWidth, domHeight, resolution) {
4468
+ // TODO should this take into account calculateSize ?
4447
4469
  if (this.width != null) {
4448
- width = this.width;
4470
+ canvasWidth = this.width;
4471
+ domWidth = this.width;
4449
4472
  }
4473
+ // TODO should this take into account calculateSize ?
4450
4474
  if (this.height != null) {
4451
- height = this.height;
4475
+ canvasHeight = this.height;
4476
+ domHeight = this.height;
4452
4477
  }
4453
4478
  if (this.margin) {
4454
- width += (this.margin.left + this.margin.right);
4455
- height += (this.margin.top + this.margin.bottom);
4479
+ canvasWidth += (this.margin.left + this.margin.right);
4480
+ canvasHeight += (this.margin.top + this.margin.bottom);
4481
+ // TODO this should take into account calculateSize
4482
+ domWidth += (this.margin.left + this.margin.right);
4483
+ domHeight += (this.margin.top + this.margin.bottom);
4456
4484
  this.view.style.left = -this.margin.left + "px";
4457
4485
  this.view.style.top = -this.margin.top + "px";
4458
4486
  }
@@ -4460,12 +4488,12 @@ export class CanvasLayer {
4460
4488
  this.view.style.left = "0px";
4461
4489
  this.view.style.top = "0px";
4462
4490
  }
4463
- this._width = Math.floor(width * resolution);
4464
- this._height = Math.floor(height * resolution);
4491
+ this._width = Math.floor(canvasWidth * resolution);
4492
+ this._height = Math.floor(canvasHeight * resolution);
4465
4493
  this.view.width = this._width;
4466
- this.view.style.width = width + "px";
4494
+ this.view.style.width = domWidth + "px";
4467
4495
  this.view.height = this._height;
4468
- this.view.style.height = height + "px";
4496
+ this.view.style.height = domHeight + "px";
4469
4497
  }
4470
4498
  clear() {
4471
4499
  this.context.save();