@visactor/vchart 1.8.2 → 1.8.3-alpha.0

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.
package/build/index.js CHANGED
@@ -2315,12 +2315,18 @@
2315
2315
  } catch (e) {
2316
2316
  getComputedStyle = () => ({});
2317
2317
  }
2318
- const style = getComputedStyle(el),
2319
- computedWidth = parseFloat(style.width) - parseFloat(style.paddingLeft) - parseFloat(style.paddingRight) || el.clientWidth - 1,
2320
- computedHeight = parseFloat(style.height) - parseFloat(style.paddingTop) - parseFloat(style.paddingBottom) || el.clientHeight - 1;
2318
+ const style = getComputedStyle(el);
2319
+ if (/^(\d*\.?\d+)(px)$/.exec(style.width)) {
2320
+ const computedWidth = parseFloat(style.width) - parseFloat(style.paddingLeft) - parseFloat(style.paddingRight) || el.clientWidth - 1,
2321
+ computedHeight = parseFloat(style.height) - parseFloat(style.paddingTop) - parseFloat(style.paddingBottom) || el.clientHeight - 1;
2322
+ return {
2323
+ width: computedWidth <= 0 ? defaultWidth : computedWidth,
2324
+ height: computedHeight <= 0 ? defaultHeight : computedHeight
2325
+ };
2326
+ }
2321
2327
  return {
2322
- width: computedWidth <= 0 ? defaultWidth : computedWidth,
2323
- height: computedHeight <= 0 ? defaultHeight : computedHeight
2328
+ width: defaultWidth,
2329
+ height: defaultHeight
2324
2330
  };
2325
2331
  }
2326
2332
  function getElementAbsolutePosition(element) {
@@ -7514,9 +7520,17 @@
7514
7520
  function reflect(f) {
7515
7521
  return x => -f(-x);
7516
7522
  }
7523
+ function limitPositiveZero() {
7524
+ let min = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1e-12;
7525
+ return x => Math.max(x, min);
7526
+ }
7527
+ function limitNegativeZero() {
7528
+ let min = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1e-12;
7529
+ return x => Math.min(x, -min);
7530
+ }
7517
7531
  class LogScale extends ContinuousScale {
7518
7532
  constructor() {
7519
- super(logp(10), powp(10)), this.type = ScaleEnum.Log, this._logs = this.transformer, this._pows = this.untransformer, this._domain = [1, 10], this._base = 10;
7533
+ super(logp(10), powp(10)), this.type = ScaleEnum.Log, this._limit = limitPositiveZero(), this._logs = this.transformer, this._pows = this.untransformer, this._domain = [1, 10], this._base = 10;
7520
7534
  }
7521
7535
  clone() {
7522
7536
  return new LogScale().domain(this._domain, !0).range(this._range, !0).unknown(this._unknown).clamp(this.clamp(), null, !0).interpolate(this._interpolate, !0).base(this._base);
@@ -7527,7 +7541,14 @@
7527
7541
  super.rescale();
7528
7542
  const logs = logp(this._base),
7529
7543
  pows = powp(this._base);
7530
- return (null !== (_a = this._niceDomain) && void 0 !== _a ? _a : this._domain)[0] < 0 ? (this._logs = reflect(logs), this._pows = reflect(pows), this.transformer = logNegative, this.untransformer = expNegative) : (this._logs = logs, this._pows = pows, this.transformer = logs, this.untransformer = pows), this;
7544
+ return (null !== (_a = this._niceDomain) && void 0 !== _a ? _a : this._domain)[0] < 0 ? (this._logs = reflect(logs), this._pows = reflect(pows), this._limit = limitNegativeZero(), this.transformer = logNegative, this.untransformer = expNegative) : (this._logs = logs, this._pows = pows, this._limit = limitPositiveZero(), this.transformer = this._logs, this.untransformer = pows), this;
7545
+ }
7546
+ scale(x) {
7547
+ var _a;
7548
+ if (x = Number(x), Number.isNaN(x) || this._domainValidator && !this._domainValidator(x)) return this._unknown;
7549
+ this._output || (this._output = this._piecewise((null !== (_a = this._niceDomain) && void 0 !== _a ? _a : this._domain).map(this._limit).map(this.transformer), this._calculateWholeRange(this._range), this._interpolate));
7550
+ const output = this._output(this.transformer(this._limit(this._clamp(x))));
7551
+ return this._fishEyeTransform ? this._fishEyeTransform(output) : output;
7531
7552
  }
7532
7553
  base(_, slience) {
7533
7554
  return arguments.length ? (this._base = _, this.rescale(slience)) : this._base;
@@ -7564,7 +7585,7 @@
7564
7585
  ticks() {
7565
7586
  let count = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;
7566
7587
  const d = this.calculateVisibleDomain(this._range);
7567
- return ticksBaseTransform(d[0], d[d.length - 1], count, this._base, this.transformer, this.untransformer);
7588
+ return ticksBaseTransform(this._limit(d[0]), this._limit(d[d.length - 1]), count, this._base, this.transformer, this.untransformer);
7568
7589
  }
7569
7590
  forceTicks() {
7570
7591
  let count = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;
@@ -7573,7 +7594,7 @@
7573
7594
  }
7574
7595
  stepTicks(step) {
7575
7596
  const d = this.calculateVisibleDomain(this._range);
7576
- return forceTicksBaseTransform(d[0], d[d.length - 1], step, this.transformer, this.untransformer);
7597
+ return forceTicksBaseTransform(this._limit(d[0]), this._limit(d[d.length - 1]), step, this.transformer, this.untransformer);
7577
7598
  }
7578
7599
  nice() {
7579
7600
  let option = arguments.length > 1 ? arguments[1] : undefined;
@@ -57635,7 +57656,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
57635
57656
  registerChartPlugin(MediaQuery);
57636
57657
  };
57637
57658
 
57638
- const version = "1.8.2";
57659
+ const version = "1.8.3-alpha.0";
57639
57660
 
57640
57661
  var ChartTypeEnum;
57641
57662
  (function (ChartTypeEnum) {
@@ -80829,7 +80850,7 @@ C0.3-1.4,0.3-1.4,0.3-1.4z;`;
80829
80850
  return this.valueToPosition(values[0]);
80830
80851
  }
80831
80852
  valueToPosition(value) {
80832
- if (this._spec.type === 'log' && (value === 0 || value[0] === 0)) {
80853
+ if (this._spec.type === 'log' && !isNil$1(value) && (value === 0 || value[0] === 0)) {
80833
80854
  return this._scale.range()[0];
80834
80855
  }
80835
80856
  return this._scale.scale(value);