@swimlane/ngx-charts 17.0.0 → 17.0.1

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.
@@ -1050,6 +1050,11 @@
1050
1050
  this.animations = true;
1051
1051
  this.select = new core.EventEmitter();
1052
1052
  }
1053
+ BaseChartComponent.prototype.ngOnInit = function () {
1054
+ if (common.isPlatformServer(this.platformId)) {
1055
+ this.animations = false;
1056
+ }
1057
+ };
1053
1058
  BaseChartComponent.prototype.ngAfterViewInit = function () {
1054
1059
  this.bindWindowResizeEvent();
1055
1060
  // listen for visibility of the element for hidden by default scenario
@@ -10389,16 +10394,30 @@
10389
10394
  };
10390
10395
 
10391
10396
  var PieLabelComponent = /** @class */ (function () {
10392
- function PieLabelComponent() {
10397
+ function PieLabelComponent(platformId) {
10398
+ this.platformId = platformId;
10393
10399
  this.animations = true;
10394
10400
  this.labelTrim = true;
10395
10401
  this.labelTrimSize = 10;
10396
- this.isIE = /(edge|msie|trident)/i.test(navigator.userAgent);
10397
10402
  this.trimLabel = trimLabel;
10398
10403
  }
10399
10404
  PieLabelComponent.prototype.ngOnChanges = function (changes) {
10405
+ this.setTransforms();
10400
10406
  this.update();
10401
10407
  };
10408
+ PieLabelComponent.prototype.setTransforms = function () {
10409
+ if (common.isPlatformServer(this.platformId)) {
10410
+ this.styleTransform = "translate3d(" + this.textX + "px," + this.textY + "px, 0)";
10411
+ this.attrTransform = "translate(" + this.textX + "," + this.textY + ")";
10412
+ this.textTransition = !this.animations ? null : 'transform 0.75s';
10413
+ }
10414
+ else {
10415
+ var isIE = /(edge|msie|trident)/i.test(navigator.userAgent);
10416
+ this.styleTransform = isIE ? null : "translate3d(" + this.textX + "px," + this.textY + "px, 0)";
10417
+ this.attrTransform = !isIE ? null : "translate(" + this.textX + "," + this.textY + ")";
10418
+ this.textTransition = isIE || !this.animations ? null : 'transform 0.75s';
10419
+ }
10420
+ };
10402
10421
  PieLabelComponent.prototype.update = function () {
10403
10422
  var startRadius = this.radius;
10404
10423
  if (this.explodeSlices) {
@@ -10428,27 +10447,6 @@
10428
10447
  enumerable: false,
10429
10448
  configurable: true
10430
10449
  });
10431
- Object.defineProperty(PieLabelComponent.prototype, "styleTransform", {
10432
- get: function () {
10433
- return this.isIE ? null : "translate3d(" + this.textX + "px," + this.textY + "px, 0)";
10434
- },
10435
- enumerable: false,
10436
- configurable: true
10437
- });
10438
- Object.defineProperty(PieLabelComponent.prototype, "attrTransform", {
10439
- get: function () {
10440
- return !this.isIE ? null : "translate(" + this.textX + "," + this.textY + ")";
10441
- },
10442
- enumerable: false,
10443
- configurable: true
10444
- });
10445
- Object.defineProperty(PieLabelComponent.prototype, "textTransition", {
10446
- get: function () {
10447
- return this.isIE || !this.animations ? null : 'transform 0.75s';
10448
- },
10449
- enumerable: false,
10450
- configurable: true
10451
- });
10452
10450
  PieLabelComponent.prototype.textAnchor = function () {
10453
10451
  return this.midAngle(this.data) < Math.PI ? 'start' : 'end';
10454
10452
  };
@@ -10464,7 +10462,9 @@
10464
10462
  changeDetection: core.ChangeDetectionStrategy.OnPush
10465
10463
  },] }
10466
10464
  ];
10467
- PieLabelComponent.ctorParameters = function () { return []; };
10465
+ PieLabelComponent.ctorParameters = function () { return [
10466
+ { type: undefined, decorators: [{ type: core.Inject, args: [core.PLATFORM_ID,] }] }
10467
+ ]; };
10468
10468
  PieLabelComponent.propDecorators = {
10469
10469
  data: [{ type: core.Input }],
10470
10470
  radius: [{ type: core.Input }],
@@ -11234,10 +11234,108 @@
11234
11234
  },] }
11235
11235
  ];
11236
11236
 
11237
+ function calculateTextWidth(fontFamilyKey, text, defaultWidth) {
11238
+ if (defaultWidth === void 0) { defaultWidth = 8; }
11239
+ return text.split('').reduce(function (acc, curr) {
11240
+ var width = fontFamilyKey[curr] || defaultWidth;
11241
+ return acc + width;
11242
+ }, 0);
11243
+ }
11244
+
11245
+ var VERDANA_FONT_WIDTHS_16_PX = {
11246
+ '0': 10,
11247
+ '1': 10,
11248
+ '2': 10,
11249
+ '3': 10,
11250
+ '4': 10,
11251
+ '5': 10,
11252
+ '6': 10,
11253
+ '7': 10,
11254
+ '8': 10,
11255
+ '9': 10,
11256
+ A: 11,
11257
+ B: 11,
11258
+ C: 11,
11259
+ D: 12,
11260
+ E: 10,
11261
+ F: 9,
11262
+ G: 12,
11263
+ H: 12,
11264
+ I: 7,
11265
+ J: 7,
11266
+ K: 11,
11267
+ L: 9,
11268
+ M: 13,
11269
+ N: 12,
11270
+ O: 13,
11271
+ P: 10,
11272
+ Q: 13,
11273
+ R: 11,
11274
+ S: 11,
11275
+ T: 10,
11276
+ U: 12,
11277
+ V: 11,
11278
+ W: 16,
11279
+ X: 11,
11280
+ Y: 10,
11281
+ Z: 11,
11282
+ a: 10,
11283
+ b: 10,
11284
+ c: 8,
11285
+ d: 10,
11286
+ e: 10,
11287
+ f: 6,
11288
+ g: 10,
11289
+ h: 10,
11290
+ i: 4,
11291
+ j: 6,
11292
+ k: 9,
11293
+ l: 4,
11294
+ m: 16,
11295
+ n: 10,
11296
+ o: 10,
11297
+ p: 10,
11298
+ q: 10,
11299
+ r: 7,
11300
+ s: 8,
11301
+ t: 6,
11302
+ u: 10,
11303
+ v: 9,
11304
+ w: 13,
11305
+ x: 9,
11306
+ y: 9,
11307
+ z: 8,
11308
+ '!': 6,
11309
+ '@': 16,
11310
+ '#': 13,
11311
+ $: 10,
11312
+ '%': 17,
11313
+ '^': 13,
11314
+ '&': 12,
11315
+ '*': 10,
11316
+ '(': 7,
11317
+ ')': 7,
11318
+ _: 10,
11319
+ '-': 7,
11320
+ '+': 13,
11321
+ '=': 13,
11322
+ ',': 6,
11323
+ '.': 6,
11324
+ '/': 7,
11325
+ "'": 4,
11326
+ ':': 7,
11327
+ '|': 7,
11328
+ '?': 9,
11329
+ ';': 7,
11330
+ '<': 13,
11331
+ '>': 13
11332
+ };
11333
+
11237
11334
  var CardComponent = /** @class */ (function () {
11238
- function CardComponent(element, cd, zone) {
11335
+ function CardComponent(element, cd, zone, platformId) {
11239
11336
  this.cd = cd;
11240
11337
  this.zone = zone;
11338
+ this.platformId = platformId;
11241
11339
  this.animations = true;
11242
11340
  this.select = new core.EventEmitter();
11243
11341
  this.value = '';
@@ -11252,8 +11350,15 @@
11252
11350
  CardComponent.prototype.ngOnChanges = function (changes) {
11253
11351
  this.update();
11254
11352
  };
11353
+ CardComponent.prototype.ngOnInit = function () {
11354
+ if (common.isPlatformServer(this.platformId)) {
11355
+ this.scaleTextSSR();
11356
+ }
11357
+ };
11255
11358
  CardComponent.prototype.ngOnDestroy = function () {
11256
- cancelAnimationFrame(this.animationReq);
11359
+ if (common.isPlatformBrowser(this.platformId)) {
11360
+ cancelAnimationFrame(this.animationReq);
11361
+ }
11257
11362
  };
11258
11363
  CardComponent.prototype.update = function () {
11259
11364
  var _this = this;
@@ -11278,7 +11383,9 @@
11278
11383
  _this.setPadding();
11279
11384
  _this.bandPath = roundedRect(0, 0, _this.cardWidth, _this.bandHeight, 3, [false, false, true, true]);
11280
11385
  setTimeout(function () {
11281
- _this.scaleText();
11386
+ if (common.isPlatformBrowser(_this.platformId)) {
11387
+ _this.scaleText();
11388
+ }
11282
11389
  _this.value = value;
11283
11390
  if (hasValue && !_this.initialized) {
11284
11391
  setTimeout(function () { return _this.startCount(); }, 20);
@@ -11331,6 +11438,17 @@
11331
11438
  _this.cd.markForCheck();
11332
11439
  });
11333
11440
  };
11441
+ CardComponent.prototype.scaleTextSSR = function () {
11442
+ var width = calculateTextWidth(VERDANA_FONT_WIDTHS_16_PX, this.value, 10);
11443
+ var height = 18;
11444
+ var textPadding = (this.textPadding[1] = this.textPadding[3] = this.cardWidth / 8);
11445
+ var availableWidth = this.cardWidth - 2 * textPadding;
11446
+ var availableHeight = this.cardHeight / 3;
11447
+ var resizeScale = Math.min(availableWidth / width, availableHeight / height);
11448
+ this.textFontSize = Math.floor(this.textFontSize * resizeScale);
11449
+ this.labelFontSize = Math.min(this.textFontSize, 15);
11450
+ this.setPadding();
11451
+ };
11334
11452
  CardComponent.prototype.setPadding = function () {
11335
11453
  this.textPadding[1] = this.textPadding[3] = this.cardWidth / 8;
11336
11454
  var padding = this.cardHeight / 2;
@@ -11352,7 +11470,8 @@
11352
11470
  CardComponent.ctorParameters = function () { return [
11353
11471
  { type: core.ElementRef },
11354
11472
  { type: core.ChangeDetectorRef },
11355
- { type: core.NgZone }
11473
+ { type: core.NgZone },
11474
+ { type: undefined, decorators: [{ type: core.Inject, args: [core.PLATFORM_ID,] }] }
11356
11475
  ]; };
11357
11476
  CardComponent.propDecorators = {
11358
11477
  color: [{ type: core.Input }],
@@ -11855,10 +11974,12 @@
11855
11974
  LinearGaugeComponent.prototype.ngAfterViewInit = function () {
11856
11975
  var _this = this;
11857
11976
  _super.prototype.ngAfterViewInit.call(this);
11858
- setTimeout(function () {
11859
- _this.scaleText('value');
11860
- _this.scaleText('units');
11861
- });
11977
+ if (common.isPlatformBrowser(this.platformId)) {
11978
+ setTimeout(function () {
11979
+ _this.scaleText('value');
11980
+ _this.scaleText('units');
11981
+ });
11982
+ }
11862
11983
  };
11863
11984
  LinearGaugeComponent.prototype.update = function () {
11864
11985
  var _this = this;
@@ -11885,8 +12006,14 @@
11885
12006
  this.transformLine = "translate(" + (this.margin[3] + this.valueScale(this.previousValue)) + ", " + yOffset + ")";
11886
12007
  this.valueTranslate = "translate(0, -15)";
11887
12008
  this.unitsTranslate = "translate(0, 15)";
11888
- setTimeout(function () { return _this.scaleText('value'); }, 50);
11889
- setTimeout(function () { return _this.scaleText('units'); }, 50);
12009
+ if (common.isPlatformServer(this.platformId)) {
12010
+ this.scaleTextSSR('value');
12011
+ this.scaleTextSSR('units');
12012
+ }
12013
+ else {
12014
+ setTimeout(function () { return _this.scaleText('value'); }, 50);
12015
+ setTimeout(function () { return _this.scaleText('units'); }, 50);
12016
+ }
11890
12017
  };
11891
12018
  LinearGaugeComponent.prototype.getValueDomain = function () {
11892
12019
  return [this.min, this.max];
@@ -11932,13 +12059,33 @@
11932
12059
  this.unitsTextTransform = "scale(" + resizeScale + ", " + resizeScale + ")";
11933
12060
  }
11934
12061
  this.cd.markForCheck();
11935
- if (repeat) {
12062
+ if (repeat && common.isPlatformBrowser(this.platformId)) {
11936
12063
  setTimeout(function () {
11937
12064
  _this.scaleText(element, false);
11938
12065
  }, 50);
11939
12066
  }
11940
12067
  }
11941
12068
  };
12069
+ LinearGaugeComponent.prototype.scaleTextSSR = function (element) {
12070
+ var resizeScale = 1;
12071
+ var value = element === 'value' ? this.displayValue : this.units;
12072
+ var width = calculateTextWidth(VERDANA_FONT_WIDTHS_16_PX, value, 10);
12073
+ var height = 25;
12074
+ var availableWidth = this.dims.width;
12075
+ var availableHeight = Math.max(this.dims.height / 2 - 15, 0);
12076
+ var resizeScaleWidth = Math.floor((availableWidth / (width / resizeScale)) * 100) / 100;
12077
+ var resizeScaleHeight = Math.floor((availableHeight / (height / resizeScale)) * 100) / 100;
12078
+ resizeScale = Math.min(resizeScaleHeight, resizeScaleWidth);
12079
+ if (element === 'value') {
12080
+ this.valueResizeScale = resizeScale;
12081
+ this.valueTextTransform = "scale(" + resizeScale + ", " + resizeScale + ")";
12082
+ }
12083
+ else {
12084
+ this.unitsResizeScale = resizeScale;
12085
+ this.unitsTextTransform = "scale(" + resizeScale + ", " + resizeScale + ")";
12086
+ }
12087
+ this.cd.markForCheck();
12088
+ };
11942
12089
  LinearGaugeComponent.prototype.onClick = function () {
11943
12090
  this.select.emit({
11944
12091
  name: 'Value',