logitude-dashboard-library 3.2.55 → 3.2.56
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/index.js
CHANGED
|
@@ -2542,6 +2542,7 @@ var quarters = ["Q", "Q1", "Q2", "Q3", "Q4"];
|
|
|
2542
2542
|
function getCategoriesBasedDataSource(chartInfo, seriesMeasures, widget) {
|
|
2543
2543
|
if (seriesMeasuresIsEmpty(seriesMeasures)) return null;
|
|
2544
2544
|
handelNullLabels(seriesMeasures);
|
|
2545
|
+
setSafeYAxisMaxValue(chartInfo, seriesMeasures, widget);
|
|
2545
2546
|
return {
|
|
2546
2547
|
chart: chartInfo,
|
|
2547
2548
|
categories: buildCategories(seriesMeasures, widget),
|
|
@@ -2551,6 +2552,7 @@ function getCategoriesBasedDataSource(chartInfo, seriesMeasures, widget) {
|
|
|
2551
2552
|
function getStackedDataSource(chartInfo, seriesMeasures, widget) {
|
|
2552
2553
|
if (seriesMeasuresIsEmpty(seriesMeasures)) return null;
|
|
2553
2554
|
handelNullLabels(seriesMeasures);
|
|
2555
|
+
setSafeYAxisMaxValue(chartInfo, seriesMeasures, widget);
|
|
2554
2556
|
return {
|
|
2555
2557
|
chart: chartInfo,
|
|
2556
2558
|
categories: buildStackedCategories(seriesMeasures, widget),
|
|
@@ -2583,6 +2585,68 @@ function seriesMeasuresIsEmpty(seriesMeasures) {
|
|
|
2583
2585
|
return !hasValue;
|
|
2584
2586
|
}
|
|
2585
2587
|
|
|
2588
|
+
function setSafeYAxisMaxValue(chartInfo, seriesMeasures, widget) {
|
|
2589
|
+
if (!isColumnOrBarChart(widget)) return;
|
|
2590
|
+
var maxMeasureValue = getMaxMeasureValue(seriesMeasures, widget);
|
|
2591
|
+
if (maxMeasureValue === null) return;
|
|
2592
|
+
var safeYAxisMaxValue = Math.max(1, Math.ceil(maxMeasureValue * 1.2));
|
|
2593
|
+
chartInfo.yAxisMaxValue = safeYAxisMaxValue.toString();
|
|
2594
|
+
}
|
|
2595
|
+
|
|
2596
|
+
function getMaxMeasureValue(seriesMeasures, widget) {
|
|
2597
|
+
if (!seriesMeasures || seriesMeasures.length === 0) return null;
|
|
2598
|
+
|
|
2599
|
+
if (widget !== null && widget !== void 0 && widget.IsStacked) {
|
|
2600
|
+
var stackedTotalsByGroupId = new Map();
|
|
2601
|
+
seriesMeasures.forEach(function (seriesMeasure) {
|
|
2602
|
+
var _seriesMeasure$Values;
|
|
2603
|
+
|
|
2604
|
+
seriesMeasure === null || seriesMeasure === void 0 ? void 0 : (_seriesMeasure$Values = seriesMeasure.Values) === null || _seriesMeasure$Values === void 0 ? void 0 : _seriesMeasure$Values.forEach(function (valueItem) {
|
|
2605
|
+
var _stackedTotalsByGroup;
|
|
2606
|
+
|
|
2607
|
+
var numericValue = toNumericValue(valueItem === null || valueItem === void 0 ? void 0 : valueItem.Value);
|
|
2608
|
+
if (numericValue === null) return;
|
|
2609
|
+
var groupId = valueItem === null || valueItem === void 0 ? void 0 : valueItem.GroupById;
|
|
2610
|
+
var currentTotal = (_stackedTotalsByGroup = stackedTotalsByGroupId.get(groupId)) != null ? _stackedTotalsByGroup : 0;
|
|
2611
|
+
stackedTotalsByGroupId.set(groupId, currentTotal + numericValue);
|
|
2612
|
+
});
|
|
2613
|
+
});
|
|
2614
|
+
var maxStackedTotal = null;
|
|
2615
|
+
stackedTotalsByGroupId.forEach(function (total) {
|
|
2616
|
+
if (maxStackedTotal === null || total > maxStackedTotal) {
|
|
2617
|
+
maxStackedTotal = total;
|
|
2618
|
+
}
|
|
2619
|
+
});
|
|
2620
|
+
return maxStackedTotal;
|
|
2621
|
+
}
|
|
2622
|
+
|
|
2623
|
+
var maxValue = null;
|
|
2624
|
+
seriesMeasures.forEach(function (seriesMeasure) {
|
|
2625
|
+
var _seriesMeasure$Values2;
|
|
2626
|
+
|
|
2627
|
+
seriesMeasure === null || seriesMeasure === void 0 ? void 0 : (_seriesMeasure$Values2 = seriesMeasure.Values) === null || _seriesMeasure$Values2 === void 0 ? void 0 : _seriesMeasure$Values2.forEach(function (valueItem) {
|
|
2628
|
+
var numericValue = toNumericValue(valueItem === null || valueItem === void 0 ? void 0 : valueItem.Value);
|
|
2629
|
+
if (numericValue === null) return;
|
|
2630
|
+
|
|
2631
|
+
if (maxValue === null || numericValue > maxValue) {
|
|
2632
|
+
maxValue = numericValue;
|
|
2633
|
+
}
|
|
2634
|
+
});
|
|
2635
|
+
});
|
|
2636
|
+
return maxValue;
|
|
2637
|
+
}
|
|
2638
|
+
|
|
2639
|
+
function toNumericValue(value) {
|
|
2640
|
+
if (value === null || value === undefined || value === "") return null;
|
|
2641
|
+
var numericValue = typeof value === "number" ? value : Number(value);
|
|
2642
|
+
if (!Number.isFinite(numericValue)) return null;
|
|
2643
|
+
return numericValue;
|
|
2644
|
+
}
|
|
2645
|
+
|
|
2646
|
+
function isColumnOrBarChart(widget) {
|
|
2647
|
+
return (widget === null || widget === void 0 ? void 0 : widget.TypeCode) === "column" || (widget === null || widget === void 0 ? void 0 : widget.TypeCode) === "bar";
|
|
2648
|
+
}
|
|
2649
|
+
|
|
2586
2650
|
function buildDataSource(values, widget) {
|
|
2587
2651
|
var data = [];
|
|
2588
2652
|
if (!values || !values[0]) return data;
|
|
@@ -3052,11 +3116,15 @@ function getDefaultChartInfo(widget) {
|
|
|
3052
3116
|
chart.valuePosition = widget.ShowValue && widget.ValuePosition ? widget.ValuePosition : 'Outside';
|
|
3053
3117
|
var isValuePositionInside = widget.ShowValue && widget.ValuePosition && widget.ValuePosition.toLowerCase() == 'inside';
|
|
3054
3118
|
|
|
3055
|
-
if (
|
|
3119
|
+
if (isColumnOrBarChart$1(widget)) {
|
|
3120
|
+
chart.canvasTopPadding = "40";
|
|
3121
|
+
}
|
|
3122
|
+
|
|
3123
|
+
if (widget.ShowValue && widget.ValuePosition && isColumnOrBarChart$1(widget)) {
|
|
3056
3124
|
chart.placeValuesInside = widget.ValuePosition.toLowerCase() == 'inside' ? "1" : "0";
|
|
3057
3125
|
}
|
|
3058
3126
|
|
|
3059
|
-
if (widget.IsStacked && isValuePositionInside && isColumnOrBarChart(widget)) {
|
|
3127
|
+
if (widget.IsStacked && isValuePositionInside && isColumnOrBarChart$1(widget)) {
|
|
3060
3128
|
chart.minPlotHeightForValue = "15";
|
|
3061
3129
|
}
|
|
3062
3130
|
|
|
@@ -3124,7 +3192,7 @@ function getWidgetLegendPosition(widget) {
|
|
|
3124
3192
|
return widget.TypeCode == 'pie' || widget.TypeCode == 'donut' ? "right" : "bottom";
|
|
3125
3193
|
}
|
|
3126
3194
|
|
|
3127
|
-
function isColumnOrBarChart(widget) {
|
|
3195
|
+
function isColumnOrBarChart$1(widget) {
|
|
3128
3196
|
if (!widget) return false;
|
|
3129
3197
|
return widget.TypeCode == 'column' || widget.TypeCode == 'bar';
|
|
3130
3198
|
}
|