@vizzly/dashboard 0.15.0-dev-be496789be553817e5a66f91e70d9233188e33b0 → 0.15.0-dev-ec22f31a049b4f844d3ea606a85bd487c4553b03
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,33 +43610,64 @@ var Legend$1 = function Legend(_ref) {
|
|
|
43610
43610
|
});
|
|
43611
43611
|
};
|
|
43612
43612
|
|
|
43613
|
-
var ASSUMED_AVERAGE_CHAR_WIDTH =
|
|
43613
|
+
var ASSUMED_AVERAGE_CHAR_WIDTH = 7.1;
|
|
43614
|
+
|
|
43614
43615
|
function calculateWordWidth(word, avgCharWidth) {
|
|
43615
43616
|
return word.length * avgCharWidth;
|
|
43616
43617
|
}
|
|
43617
|
-
|
|
43618
|
-
|
|
43619
|
-
var
|
|
43620
|
-
|
|
43621
|
-
|
|
43622
|
-
}
|
|
43618
|
+
function getTicksIntervals(numElements) {
|
|
43619
|
+
var divisors = [];
|
|
43620
|
+
for (var i = 1; i <= Math.sqrt(numElements - 1); i++) {
|
|
43621
|
+
if ((numElements - 1) % i !== 0) {
|
|
43622
|
+
continue;
|
|
43623
|
+
}
|
|
43624
|
+
divisors.push(i);
|
|
43625
|
+
var divisor = (numElements - 1) / i;
|
|
43626
|
+
if (i === divisor) {
|
|
43627
|
+
continue;
|
|
43628
|
+
}
|
|
43629
|
+
divisors.push(divisor);
|
|
43630
|
+
}
|
|
43631
|
+
divisors.sort(function (a, b) {
|
|
43632
|
+
return b - a;
|
|
43633
|
+
});
|
|
43634
|
+
return divisors;
|
|
43635
|
+
}
|
|
43636
|
+
function isTickIntervalValid(interval, maxWidth, wordWidths) {
|
|
43637
|
+
var totalWidth = 0;
|
|
43638
|
+
for (var i = 0; i < wordWidths.length; i += interval) {
|
|
43639
|
+
var spacing = i > 0 ? 12 : 0; // Add spacing only after the first tick
|
|
43640
|
+
totalWidth += wordWidths[i] + spacing;
|
|
43641
|
+
}
|
|
43642
|
+
return totalWidth <= maxWidth;
|
|
43643
|
+
}
|
|
43623
43644
|
function howManyTicksFitInWidth(ticks, maxWidth, avgCharWidth) {
|
|
43624
43645
|
if (avgCharWidth === void 0) {
|
|
43625
43646
|
avgCharWidth = ASSUMED_AVERAGE_CHAR_WIDTH;
|
|
43626
43647
|
}
|
|
43627
|
-
var
|
|
43628
|
-
var
|
|
43629
|
-
|
|
43630
|
-
|
|
43631
|
-
|
|
43632
|
-
|
|
43633
|
-
|
|
43634
|
-
|
|
43635
|
-
|
|
43648
|
+
var ticksIntervals = getTicksIntervals(ticks.length);
|
|
43649
|
+
var ticksWidths = ticks.map(function (tick) {
|
|
43650
|
+
var _tick$formattedValue;
|
|
43651
|
+
return calculateWordWidth((_tick$formattedValue = tick == null ? void 0 : tick.formattedValue) != null ? _tick$formattedValue : '', avgCharWidth);
|
|
43652
|
+
});
|
|
43653
|
+
var optimalInterval = ticksIntervals[ticksIntervals.length - 1]; // Default to showing only first and last marks if none fit
|
|
43654
|
+
var left = 0;
|
|
43655
|
+
var right = ticksIntervals.length - 1;
|
|
43656
|
+
|
|
43657
|
+
// Binary search for the largest step that fits all elements
|
|
43658
|
+
while (left <= right) {
|
|
43659
|
+
var mid = Math.floor((left + right) / 2);
|
|
43660
|
+
var step = ticksIntervals[mid];
|
|
43661
|
+
if (isTickIntervalValid(step, maxWidth, ticksWidths)) {
|
|
43662
|
+
optimalInterval = step; // Found a valid step, try to find a larger one
|
|
43663
|
+
left = mid + 1;
|
|
43636
43664
|
} else {
|
|
43637
|
-
|
|
43665
|
+
right = mid - 1;
|
|
43638
43666
|
}
|
|
43639
43667
|
}
|
|
43668
|
+
var fittedTicks = ticks.filter(function (_, index) {
|
|
43669
|
+
return index % optimalInterval === 0;
|
|
43670
|
+
});
|
|
43640
43671
|
return fittedTicks.length;
|
|
43641
43672
|
}
|
|
43642
43673
|
function determineYTicks(ticks, height) {
|
|
@@ -43673,16 +43704,14 @@ function pickEquallySpaced(arr, numPicks) {
|
|
|
43673
43704
|
return result;
|
|
43674
43705
|
}
|
|
43675
43706
|
function adjustTicks(representation, width, height, xKeyField) {
|
|
43707
|
+
var _representation$x$tic, _representation$y$tic;
|
|
43676
43708
|
representation = _.cloneDeep(representation);
|
|
43677
43709
|
|
|
43678
43710
|
// TODO; take this from the theme override...
|
|
43679
43711
|
var averageCharacterWidth = ASSUMED_AVERAGE_CHAR_WIDTH;
|
|
43680
|
-
var numberOfXTicksFittingIntoSpace = howManyTicksFitInWidth(representation.x.ticks
|
|
43681
|
-
|
|
43682
|
-
// @ts-ignore
|
|
43712
|
+
var numberOfXTicksFittingIntoSpace = howManyTicksFitInWidth((_representation$x$tic = representation.x.ticks) != null ? _representation$x$tic : [], width, averageCharacterWidth);
|
|
43683
43713
|
representation.x.ticks = getEvenlySpacedTicks(representation.x.ticks, numberOfXTicksFittingIntoSpace, xKeyField);
|
|
43684
|
-
|
|
43685
|
-
representation.y.ticks = determineYTicks(representation.y.ticks || [], height);
|
|
43714
|
+
representation.y.ticks = determineYTicks((_representation$y$tic = representation.y.ticks) != null ? _representation$y$tic : [], height);
|
|
43686
43715
|
return representation;
|
|
43687
43716
|
}
|
|
43688
43717
|
function toNumeric(value) {
|
|
@@ -43715,9 +43744,9 @@ function getEvenlySpacedNumericTicks(sorted, count) {
|
|
|
43715
43744
|
var _toNumeric3;
|
|
43716
43745
|
var closest = sorted[0];
|
|
43717
43746
|
var minDiff = Math.abs(((_toNumeric3 = toNumeric(sorted[0].scaleValue)) != null ? _toNumeric3 : 0) - target);
|
|
43718
|
-
for (var
|
|
43747
|
+
for (var _iterator = _createForOfIteratorHelperLoose(sorted), _step; !(_step = _iterator()).done;) {
|
|
43719
43748
|
var _toNumeric4;
|
|
43720
|
-
var tick =
|
|
43749
|
+
var tick = _step.value;
|
|
43721
43750
|
var numericVal = (_toNumeric4 = toNumeric(tick.scaleValue)) != null ? _toNumeric4 : 0;
|
|
43722
43751
|
var diff = Math.abs(numericVal - target);
|
|
43723
43752
|
if (diff < minDiff) {
|
|
@@ -43739,16 +43768,9 @@ function getEvenlySpacedStringTicks(ticks, count) {
|
|
|
43739
43768
|
return result;
|
|
43740
43769
|
}
|
|
43741
43770
|
function getEvenlySpacedTicks(ticks, count, xKeyField) {
|
|
43742
|
-
if (count === void 0) {
|
|
43743
|
-
count = 4;
|
|
43744
|
-
}
|
|
43745
43771
|
if (ticks.length === 0) return [];
|
|
43746
43772
|
if ((xKeyField == null ? void 0 : xKeyField.dataType) === 'number' || (xKeyField == null ? void 0 : xKeyField.dataType) === 'date_time') {
|
|
43747
|
-
|
|
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);
|
|
43773
|
+
return getEvenlySpacedNumericTicks(ticks, count);
|
|
43752
43774
|
} else {
|
|
43753
43775
|
return getEvenlySpacedStringTicks(ticks, count);
|
|
43754
43776
|
}
|
|
@@ -53033,8 +53055,10 @@ var SunburstChartView = function SunburstChartView(props) {
|
|
|
53033
53055
|
setTooltipLabel = _useState5[1];
|
|
53034
53056
|
var xScale = d3Scale.scaleLinear().domain(xDomain).range(xRange);
|
|
53035
53057
|
var yScale = d3Scale.scaleSqrt().domain(yDomain).range(yRange);
|
|
53036
|
-
var width = props.width * 3 /
|
|
53037
|
-
var height =
|
|
53058
|
+
var width = props.width * 3 / 6;
|
|
53059
|
+
var height = props.height * 0.9;
|
|
53060
|
+
var minDimension = Math.min(props.width, props.height);
|
|
53061
|
+
var centeredRatio = minDimension / 2.5;
|
|
53038
53062
|
var sunburstChartComponent = getComponentInterface(props.attributes.type);
|
|
53039
53063
|
var headerProps = {
|
|
53040
53064
|
displayTitle: props.attributes.displayTitle,
|
|
@@ -53054,8 +53078,8 @@ var SunburstChartView = function SunburstChartView(props) {
|
|
|
53054
53078
|
order: props.attributes.order
|
|
53055
53079
|
};
|
|
53056
53080
|
React.useEffect(function () {
|
|
53057
|
-
setYRange([yRange[0],
|
|
53058
|
-
}, [
|
|
53081
|
+
setYRange([yRange[0], centeredRatio]);
|
|
53082
|
+
}, [centeredRatio]);
|
|
53059
53083
|
var arc = d3Shape.arc().startAngle(function (d) {
|
|
53060
53084
|
return Math.max(0, Math.min(2 * Math.PI, xScale(d.x0)));
|
|
53061
53085
|
}).endAngle(function (d) {
|
|
@@ -53068,7 +53092,7 @@ var SunburstChartView = function SunburstChartView(props) {
|
|
|
53068
53092
|
var handleClick = function handleClick(d) {
|
|
53069
53093
|
setXDomain([d.x0, d.x1]);
|
|
53070
53094
|
setYDomain([d.y0, 1]);
|
|
53071
|
-
setYRange([d.y0 ? 20 : 0,
|
|
53095
|
+
setYRange([d.y0 ? 20 : 0, centeredRatio]);
|
|
53072
53096
|
};
|
|
53073
53097
|
var handleUpdate = function handleUpdate(t, xd, yd, yr) {
|
|
53074
53098
|
xScale.domain(xd(t));
|
|
@@ -53155,7 +53179,7 @@ var SunburstChartView = function SunburstChartView(props) {
|
|
|
53155
53179
|
height: height,
|
|
53156
53180
|
children: jsxRuntime.jsx(Partition, {
|
|
53157
53181
|
top: 0,
|
|
53158
|
-
left: centerX
|
|
53182
|
+
left: centerX + DEFAULT_MARGINS.left,
|
|
53159
53183
|
root: root,
|
|
53160
53184
|
children: jsxRuntime.jsx(web.Spring, {
|
|
53161
53185
|
reset: true,
|
|
@@ -53281,7 +53305,7 @@ function calculateWordWidth$1(word, avgCharWidth) {
|
|
|
53281
53305
|
}
|
|
53282
53306
|
|
|
53283
53307
|
/** Reduce width proportionally to simulate spacing / padding between ticks. */
|
|
53284
|
-
var widthWithSpacing
|
|
53308
|
+
var widthWithSpacing = function widthWithSpacing(width) {
|
|
53285
53309
|
var THIRTY_PERCENT = 0.3;
|
|
53286
53310
|
return width - width * THIRTY_PERCENT;
|
|
53287
53311
|
};
|
|
@@ -53295,7 +53319,7 @@ function howManyTicksFitInWidth$1(ticks, maxWidth, avgCharWidth) {
|
|
|
53295
53319
|
var tick = _step.value;
|
|
53296
53320
|
var word = (tick == null ? void 0 : tick.formattedValue) || '';
|
|
53297
53321
|
var wordWidth = calculateWordWidth$1(word, avgCharWidth);
|
|
53298
|
-
if (currentWidth + wordWidth <= widthWithSpacing
|
|
53322
|
+
if (currentWidth + wordWidth <= widthWithSpacing(maxWidth)) {
|
|
53299
53323
|
fittedTicks.push(tick);
|
|
53300
53324
|
currentWidth += wordWidth + avgCharWidth; // Add space between words
|
|
53301
53325
|
} else {
|