@mathstack/viz 2.2.1 → 2.2.2

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.
@@ -2093,6 +2093,9 @@ function xAxisMixin(Base) {
2093
2093
  getBaselineTranslate() {
2094
2094
  if (!this.otherAxisHasPosAndNegValues('x'))
2095
2095
  return null;
2096
+ const yDomain = this.scales.y.domain();
2097
+ if (yDomain[0] > 0 || yDomain[1] < 0)
2098
+ return null;
2096
2099
  const rangeIndexForSide = this.config.side === 'top' ? 1 : 0;
2097
2100
  const translateDistance = this.scales.y(0) - this.scales.y.range()[rangeIndexForSide];
2098
2101
  return `translate(0, ${translateDistance})`;
@@ -2356,6 +2359,9 @@ function yAxisMixin(Base) {
2356
2359
  getBaselineTranslate() {
2357
2360
  if (!this.otherAxisHasPosAndNegValues('y'))
2358
2361
  return null;
2362
+ const xDomain = this.scales.x.domain();
2363
+ if (xDomain[0] > 0 || xDomain[1] < 0)
2364
+ return null;
2359
2365
  const rangeIndexForSide = this.config.side === 'left' ? 0 : 1;
2360
2366
  const translateDistance = this.scales.x(0) - this.scales.x.range()[rangeIndexForSide];
2361
2367
  return `translate(${translateDistance}, 0)`;
@@ -3065,13 +3071,14 @@ class BarsComponent extends VicXyPrimaryMarks {
3065
3071
  const origin = this.getBarQuantitativeOrigin();
3066
3072
  return this.scales.x(origin);
3067
3073
  }
3068
- else if (this.config.hasNegativeValues) {
3069
- if (d.quantitative < 0) {
3074
+ else if (d.quantitative < 0) {
3075
+ if (this.config.quantitative.domainIncludesZero) {
3070
3076
  return this.scales.x(d.quantitative);
3071
3077
  }
3072
- return this.scales.x(0);
3078
+ return this.scales.x(this.getQuantitativeDomainFromScale()[1]);
3073
3079
  }
3074
- return this.scales.x(this.getQuantitativeDomainFromScale()[0]);
3080
+ const origin = this.getBarQuantitativeOrigin();
3081
+ return this.scales.x(origin);
3075
3082
  }
3076
3083
  getBarY(d) {
3077
3084
  if (this.config.dimensions.y === 'ordinal') {