cx 24.10.6 → 24.10.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.
package/dist/charts.js CHANGED
@@ -5155,7 +5155,10 @@ var TimeScale = /*#__PURE__*/ (function () {
5155
5155
  _proto2.getTimezoneOffset = function getTimezoneOffset(date) {
5156
5156
  return date.getTimezoneOffset() * 60 * 1000;
5157
5157
  };
5158
- _proto2.getScale = function getScale(tickSize, measure) {
5158
+ _proto2.getScale = function getScale(tickSize, measure, minRange) {
5159
+ if (minRange === void 0) {
5160
+ minRange = 1000;
5161
+ }
5159
5162
  var min = this.min,
5160
5163
  max = this.max,
5161
5164
  upperDeadZone = this.upperDeadZone,
@@ -5200,6 +5203,11 @@ var TimeScale = /*#__PURE__*/ (function () {
5200
5203
  if (this.minValue == min) smin = this.minValuePadded;
5201
5204
  if (this.maxValue == max) smax = this.maxValuePadded;
5202
5205
  }
5206
+ if (smax - smin < minRange) {
5207
+ var delta = (minRange - (smax - smin)) / 2;
5208
+ smin -= delta;
5209
+ smax += delta;
5210
+ }
5203
5211
 
5204
5212
  //padding should be activated only if using min/max obtained from the data
5205
5213
  var minPadding = this.minValue === min ? Math.max(0, smin - this.minValuePadded) : 0;
@@ -5253,8 +5261,9 @@ var TimeScale = /*#__PURE__*/ (function () {
5253
5261
  _proto2.findTickSize = function findTickSize(minPxDist) {
5254
5262
  var _this2 = this;
5255
5263
  return this.tickSizes.find(function (_ref) {
5256
- var size = _ref.size;
5257
- return size * Math.abs(_this2.scale.factor) >= minPxDist;
5264
+ var size = _ref.size,
5265
+ noLabels = _ref.noLabels;
5266
+ return !noLabels && size * Math.abs(_this2.scale.factor) >= minPxDist;
5258
5267
  });
5259
5268
  };
5260
5269
  _proto2.getTickSizes = function getTickSizes() {
@@ -5263,6 +5272,7 @@ var TimeScale = /*#__PURE__*/ (function () {
5263
5272
  _proto2.calculateTicks = function calculateTicks() {
5264
5273
  var _this3 = this;
5265
5274
  var minReached = false;
5275
+ var minRange = 1000;
5266
5276
  var _loop = function _loop(unit) {
5267
5277
  if (!minReached) {
5268
5278
  if (unit == _this3.minTickUnit) minReached = true;
@@ -5296,7 +5306,7 @@ var TimeScale = /*#__PURE__*/ (function () {
5296
5306
  var _this3$format, _this3$minLabelDistan;
5297
5307
  //if (useSnapToTicks && d < Math.min(divs.length - 1, this.snapToTicks)) continue;
5298
5308
  var _tickSize2 = _divs[_d] * unitSize;
5299
- var scale = _this3.getScale(null, unit);
5309
+ var scale = _this3.getScale(null, unit, _tickSize2);
5300
5310
  var format = (_this3$format = _this3.format) != null ? _this3$format : _this3.getFormat(unit, scale);
5301
5311
  var minLabelDistance =
5302
5312
  (_this3$minLabelDistan = _this3.minLabelDistanceFormatOverride[format]) != null
@@ -5311,6 +5321,7 @@ var TimeScale = /*#__PURE__*/ (function () {
5311
5321
  bestLabelDistance = labelDistance;
5312
5322
  bestFormat = format;
5313
5323
  bestMinLabelDistance = minLabelDistance;
5324
+ minRange = _tickSize2;
5314
5325
  }
5315
5326
  }
5316
5327
  }
@@ -5372,17 +5383,18 @@ var TimeScale = /*#__PURE__*/ (function () {
5372
5383
  this.tickSizes.unshift({
5373
5384
  size: bestMinorTickSize,
5374
5385
  measure: lowerTickUnit,
5386
+ noLabels: true,
5375
5387
  });
5376
5388
  if (this.tickSizes.length > 1) {
5377
5389
  var labelStep = this.tickSizes[1].size;
5378
- var lowerScale = this.getScale(null, lowerTickUnit);
5390
+ var lowerScale = this.getScale(null, lowerTickUnit, minRange);
5379
5391
  if (lowerScale.max - lowerScale.min >= labelStep) this.scale = lowerScale;
5380
5392
  }
5381
5393
  }
5382
5394
  }
5383
5395
  if (isNumber(this.snapToTicks) && this.snapToTicks >= 0) {
5384
5396
  var _tickSize = this.tickSizes[Math.min(this.tickSizes.length - 1, this.snapToTicks)];
5385
- this.scale = this.getScale(_tickSize.size, _tickSize.measure);
5397
+ this.scale = this.getScale(_tickSize.size, _tickSize.measure, minRange);
5386
5398
  }
5387
5399
  };
5388
5400
  _proto2.getTicks = function getTicks(tickSizes) {
@@ -5469,8 +5481,11 @@ var PointReducer = /*#__PURE__*/ (function (_PureContainer) {
5469
5481
  accumulator = {};
5470
5482
  if (_this.onInitAccumulator) instance.invoke("onInitAccumulator", accumulator, instance);
5471
5483
  };
5484
+ var pointFilter = null;
5485
+ if (this.onCreatePointFilter) pointFilter = instance.invoke("onCreatePointFilter", instance);
5472
5486
  instance.pointReducer = function (x, y, name, data, array, index) {
5473
- onMap(accumulator, x, y, name, data, array, index);
5487
+ if (!pointFilter || pointFilter(x, y, name, data, array, index))
5488
+ onMap(accumulator, x, y, name, data, array, index);
5474
5489
  if (parentPointReducer) parentPointReducer(x, y, name, data, array, index);
5475
5490
  };
5476
5491
  instance.write = function () {