@vizzly/dashboard 0.15.0-dev-4815d6f8b96f6aef5270f29e0b642f190891df6b → 0.15.0-dev-7fc1f00d183f9b2ca9704405e39d6c5e03b100bb

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.
@@ -43610,62 +43610,33 @@ var Legend$1 = function Legend(_ref) {
43610
43610
  });
43611
43611
  };
43612
43612
 
43613
- var ASSUMED_AVERAGE_CHAR_WIDTH = 7.1;
43613
+ var ASSUMED_AVERAGE_CHAR_WIDTH = 4;
43614
43614
  function calculateWordWidth(word, avgCharWidth) {
43615
43615
  return word.length * avgCharWidth;
43616
43616
  }
43617
- function getTicksIntervals(numElements) {
43618
- var divisors = [];
43619
- for (var i = 1; i <= Math.sqrt(numElements - 1); i++) {
43620
- if ((numElements - 1) % i !== 0) {
43621
- continue;
43622
- }
43623
- divisors.push(i);
43624
- var divisor = (numElements - 1) / i;
43625
- if (i === divisor) {
43626
- continue;
43627
- }
43628
- divisors.push(divisor);
43629
- }
43630
- divisors.sort(function (a, b) {
43631
- return b - a;
43632
- });
43633
- return divisors;
43634
- }
43635
- function isTickIntervalValid(interval, maxWidth, wordWidths) {
43636
- var totalWidth = 0;
43637
- for (var i = 0; i < wordWidths.length; i += interval) {
43638
- totalWidth += wordWidths[i];
43639
- }
43640
- return totalWidth <= maxWidth;
43641
- }
43617
+
43618
+ /** Reduce width proportionally to simulate spacing / padding between ticks. */
43619
+ var widthWithSpacing = function widthWithSpacing(width) {
43620
+ var THIRTY_PERCENT = 0.3;
43621
+ return width - width * THIRTY_PERCENT;
43622
+ };
43642
43623
  function howManyTicksFitInWidth(ticks, maxWidth, avgCharWidth) {
43643
43624
  if (avgCharWidth === void 0) {
43644
43625
  avgCharWidth = ASSUMED_AVERAGE_CHAR_WIDTH;
43645
43626
  }
43646
- var ticksIntervals = getTicksIntervals(ticks.length);
43647
- var ticksWidths = ticks.map(function (tick) {
43648
- var _tick$formattedValue;
43649
- return calculateWordWidth((_tick$formattedValue = tick == null ? void 0 : tick.formattedValue) != null ? _tick$formattedValue : '', avgCharWidth);
43650
- });
43651
- var optimalInterval = ticksIntervals[ticksIntervals.length - 1]; // Default to showing only first and last marks if none fit
43652
- var left = 0;
43653
- var right = ticksIntervals.length - 1;
43654
-
43655
- // Binary search for the largest step that fits all elements
43656
- while (left <= right) {
43657
- var mid = Math.floor((left + right) / 2);
43658
- var step = ticksIntervals[mid];
43659
- if (isTickIntervalValid(step, maxWidth, ticksWidths)) {
43660
- optimalInterval = step; // Found a valid step, try to find a larger one
43661
- left = mid + 1;
43627
+ var fittedTicks = [];
43628
+ var currentWidth = 0;
43629
+ for (var _iterator = _createForOfIteratorHelperLoose(ticks), _step; !(_step = _iterator()).done;) {
43630
+ var tick = _step.value;
43631
+ var word = (tick == null ? void 0 : tick.formattedValue) || '';
43632
+ var wordWidth = calculateWordWidth(word, avgCharWidth);
43633
+ if (currentWidth + wordWidth <= widthWithSpacing(maxWidth)) {
43634
+ fittedTicks.push(tick);
43635
+ currentWidth += wordWidth + avgCharWidth; // Add space between words
43662
43636
  } else {
43663
- right = mid - 1;
43637
+ break; // Stop if adding the word exceeds maxWidth
43664
43638
  }
43665
43639
  }
43666
- var fittedTicks = ticks.filter(function (_, index) {
43667
- return index % optimalInterval === 0;
43668
- });
43669
43640
  return fittedTicks.length;
43670
43641
  }
43671
43642
  function determineYTicks(ticks, height) {
@@ -43702,14 +43673,16 @@ function pickEquallySpaced(arr, numPicks) {
43702
43673
  return result;
43703
43674
  }
43704
43675
  function adjustTicks(representation, width, height, xKeyField) {
43705
- var _representation$x$tic, _representation$y$tic;
43706
43676
  representation = _.cloneDeep(representation);
43707
43677
 
43708
43678
  // TODO; take this from the theme override...
43709
43679
  var averageCharacterWidth = ASSUMED_AVERAGE_CHAR_WIDTH;
43710
- var numberOfXTicksFittingIntoSpace = howManyTicksFitInWidth((_representation$x$tic = representation.x.ticks) != null ? _representation$x$tic : [], width, averageCharacterWidth);
43680
+ var numberOfXTicksFittingIntoSpace = howManyTicksFitInWidth(representation.x.ticks || [], width, averageCharacterWidth);
43681
+
43682
+ // @ts-ignore
43711
43683
  representation.x.ticks = getEvenlySpacedTicks(representation.x.ticks, numberOfXTicksFittingIntoSpace, xKeyField);
43712
- representation.y.ticks = determineYTicks((_representation$y$tic = representation.y.ticks) != null ? _representation$y$tic : [], height);
43684
+ // @ts-ignore
43685
+ representation.y.ticks = determineYTicks(representation.y.ticks || [], height);
43713
43686
  return representation;
43714
43687
  }
43715
43688
  function toNumeric(value) {
@@ -43742,9 +43715,9 @@ function getEvenlySpacedNumericTicks(sorted, count) {
43742
43715
  var _toNumeric3;
43743
43716
  var closest = sorted[0];
43744
43717
  var minDiff = Math.abs(((_toNumeric3 = toNumeric(sorted[0].scaleValue)) != null ? _toNumeric3 : 0) - target);
43745
- for (var _iterator = _createForOfIteratorHelperLoose(sorted), _step; !(_step = _iterator()).done;) {
43718
+ for (var _iterator2 = _createForOfIteratorHelperLoose(sorted), _step2; !(_step2 = _iterator2()).done;) {
43746
43719
  var _toNumeric4;
43747
- var tick = _step.value;
43720
+ var tick = _step2.value;
43748
43721
  var numericVal = (_toNumeric4 = toNumeric(tick.scaleValue)) != null ? _toNumeric4 : 0;
43749
43722
  var diff = Math.abs(numericVal - target);
43750
43723
  if (diff < minDiff) {
@@ -43766,9 +43739,16 @@ function getEvenlySpacedStringTicks(ticks, count) {
43766
43739
  return result;
43767
43740
  }
43768
43741
  function getEvenlySpacedTicks(ticks, count, xKeyField) {
43742
+ if (count === void 0) {
43743
+ count = 4;
43744
+ }
43769
43745
  if (ticks.length === 0) return [];
43770
43746
  if ((xKeyField == null ? void 0 : xKeyField.dataType) === 'number' || (xKeyField == null ? void 0 : xKeyField.dataType) === 'date_time') {
43771
- return getEvenlySpacedNumericTicks(ticks, count);
43747
+ var sorted = [].concat(ticks).sort(function (a, b) {
43748
+ var _toNumeric5, _toNumeric6;
43749
+ return ((_toNumeric5 = toNumeric(a.scaleValue)) != null ? _toNumeric5 : 0) - ((_toNumeric6 = toNumeric(b.scaleValue)) != null ? _toNumeric6 : 0);
43750
+ });
43751
+ return getEvenlySpacedNumericTicks(sorted, count);
43772
43752
  } else {
43773
43753
  return getEvenlySpacedStringTicks(ticks, count);
43774
43754
  }
@@ -49229,8 +49209,8 @@ var ComboChartViewV2 = function ComboChartViewV2(props) {
49229
49209
  overflowX: 'hidden'
49230
49210
  },
49231
49211
  children: function children(parent) {
49232
- var _comboChartRepresenta, _props$attributes$sta2;
49233
- var numberOfXTicksFittingIntoSpace = howManyTicksFitInWidth((_comboChartRepresenta = comboChartRepresentation.x.ticks) != null ? _comboChartRepresenta : [], parent.width);
49212
+ var _props$attributes$sta2;
49213
+ var numberOfXTicksFittingIntoSpace = howManyTicksFitInWidth(comboChartRepresentation.x.ticks || [], parent.width);
49234
49214
  return jsxRuntime.jsx(ComboChart$4, {
49235
49215
  width: parent.width,
49236
49216
  height: parent.height,
@@ -53301,7 +53281,7 @@ function calculateWordWidth$1(word, avgCharWidth) {
53301
53281
  }
53302
53282
 
53303
53283
  /** Reduce width proportionally to simulate spacing / padding between ticks. */
53304
- var widthWithSpacing = function widthWithSpacing(width) {
53284
+ var widthWithSpacing$1 = function widthWithSpacing(width) {
53305
53285
  var THIRTY_PERCENT = 0.3;
53306
53286
  return width - width * THIRTY_PERCENT;
53307
53287
  };
@@ -53315,7 +53295,7 @@ function howManyTicksFitInWidth$1(ticks, maxWidth, avgCharWidth) {
53315
53295
  var tick = _step.value;
53316
53296
  var word = (tick == null ? void 0 : tick.formattedValue) || '';
53317
53297
  var wordWidth = calculateWordWidth$1(word, avgCharWidth);
53318
- if (currentWidth + wordWidth <= widthWithSpacing(maxWidth)) {
53298
+ if (currentWidth + wordWidth <= widthWithSpacing$1(maxWidth)) {
53319
53299
  fittedTicks.push(tick);
53320
53300
  currentWidth += wordWidth + avgCharWidth; // Add space between words
53321
53301
  } else {