@quillsql/react 2.16.95 → 2.16.97
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.cjs +375 -513
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +375 -513
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -23784,11 +23784,17 @@ function formattedPivotRowsAndColumns(report, dashboardFilters = [], options = {
|
|
|
23784
23784
|
dashboardFilters
|
|
23785
23785
|
);
|
|
23786
23786
|
const pivotValueColumns = columns?.slice(1) ?? [];
|
|
23787
|
-
const yAxisFields = report.pivot && !report.pivot.columnField && pivotValueColumns.length > 0 ? pivotValueColumns.map((col
|
|
23788
|
-
|
|
23789
|
-
|
|
23790
|
-
|
|
23791
|
-
|
|
23787
|
+
const yAxisFields = report.pivot && !report.pivot.columnField && pivotValueColumns.length > 0 ? pivotValueColumns.map((col) => {
|
|
23788
|
+
const saved = report.yAxisFields?.find(
|
|
23789
|
+
(axis) => axis.field === col.field
|
|
23790
|
+
);
|
|
23791
|
+
const savedLabel = String(saved?.label ?? "").trim();
|
|
23792
|
+
return {
|
|
23793
|
+
field: col.field,
|
|
23794
|
+
label: savedLabel || col.label || col.field,
|
|
23795
|
+
format: saved?.format ?? legacyPivotFormat ?? col.format ?? "whole_number"
|
|
23796
|
+
};
|
|
23797
|
+
}) : formattedYAxisFields?.length > 0 ? formattedYAxisFields : pivotValueColumns.map((col) => ({
|
|
23792
23798
|
field: col.field,
|
|
23793
23799
|
label: col.label ?? col.field,
|
|
23794
23800
|
format: legacyPivotFormat ?? col.format ?? "whole_number"
|
|
@@ -41174,7 +41180,7 @@ function D3Gauge({
|
|
|
41174
41180
|
if (!containerRef.current || !select) return;
|
|
41175
41181
|
const container = containerRef.current;
|
|
41176
41182
|
select(container).select("svg").remove();
|
|
41177
|
-
svgRef.current = select(container).append("svg").attr("width", "100%").attr("height", "100%").attr("preserveAspectRatio", "xMidYMid meet");
|
|
41183
|
+
svgRef.current = select(container).append("svg").attr("width", "100%").attr("height", "100%").attr("preserveAspectRatio", "xMidYMid meet").style("display", "block");
|
|
41178
41184
|
gaugeGroupRef.current = svgRef.current.append("g");
|
|
41179
41185
|
for (let i = 0; i < 3; i++) {
|
|
41180
41186
|
gaugeGroupRef.current.append("path").attr("class", `arc-seg seg${i}`);
|
|
@@ -41309,7 +41315,7 @@ function D3Gauge({
|
|
|
41309
41315
|
"div",
|
|
41310
41316
|
{
|
|
41311
41317
|
ref: containerRef,
|
|
41312
|
-
style: { width: "100%", ...containerStyle },
|
|
41318
|
+
style: { width: "100%", height: "100%", ...containerStyle },
|
|
41313
41319
|
className
|
|
41314
41320
|
}
|
|
41315
41321
|
);
|
|
@@ -49472,10 +49478,10 @@ function InternalChart({
|
|
|
49472
49478
|
config: report,
|
|
49473
49479
|
containerStyle: {
|
|
49474
49480
|
minHeight: 300,
|
|
49475
|
-
width: ["US map", "World map"].includes(report.chartType) ? "70%" :
|
|
49476
|
-
height: ["US map", "World map"].includes(report.chartType) ? "fit-content" :
|
|
49477
|
-
marginLeft:
|
|
49478
|
-
marginRight:
|
|
49481
|
+
width: ["US map", "World map"].includes(report.chartType) ? "70%" : "100%",
|
|
49482
|
+
height: ["US map", "World map"].includes(report.chartType) ? "fit-content" : report.chartType === "gauge" ? 300 : void 0,
|
|
49483
|
+
marginLeft: "auto",
|
|
49484
|
+
marginRight: "auto"
|
|
49479
49485
|
},
|
|
49480
49486
|
reportId: report.id,
|
|
49481
49487
|
colors,
|
|
@@ -62800,9 +62806,6 @@ function getPageOptionsFromPageCount(pageCount) {
|
|
|
62800
62806
|
|
|
62801
62807
|
// src/hooks/useForm.tsx
|
|
62802
62808
|
var INTERNAL_PIVOT_ROW_FIELDS = /* @__PURE__ */ new Set(["__quillRawDate"]);
|
|
62803
|
-
var LEGACY_SINGLE_Y_AXIS_COLUMN_PIVOT_REPORT_IDS = /* @__PURE__ */ new Set([
|
|
62804
|
-
"69b63941ac8df4cda178a38a"
|
|
62805
|
-
]);
|
|
62806
62809
|
var AGGREGATION_OPTION_TYPES = [
|
|
62807
62810
|
"sum",
|
|
62808
62811
|
"average",
|
|
@@ -63607,10 +63610,7 @@ function normalizePivotColumnDisplayValue(value) {
|
|
|
63607
63610
|
if (!normalized) return "-";
|
|
63608
63611
|
return ["undefined", "null"].includes(normalized.toLowerCase()) ? "-" : normalized;
|
|
63609
63612
|
}
|
|
63610
|
-
function
|
|
63611
|
-
return aggregation?.aggregationType === "percentage" ? "percentage" : "whole_number";
|
|
63612
|
-
}
|
|
63613
|
-
function getPivotTableSlotReportColumn(reportColumns, aggregations, rowField, pivotTableColumnKey) {
|
|
63613
|
+
function getPivotTableReportColumn(reportColumns, aggregations, rowField, pivotTableColumnKey) {
|
|
63614
63614
|
const cols = reportColumns ?? [];
|
|
63615
63615
|
if (cols.length === 0) return void 0;
|
|
63616
63616
|
const row = String(rowField ?? "").trim();
|
|
@@ -63688,7 +63688,214 @@ function shouldUsePivotRowFieldAsXAxis(chartType, pivotRowField, rowColumnFormat
|
|
|
63688
63688
|
}
|
|
63689
63689
|
return true;
|
|
63690
63690
|
}
|
|
63691
|
-
function
|
|
63691
|
+
function pivotDisplayFieldKeys(chart) {
|
|
63692
|
+
const rowField = String(chart.pivot?.rowField ?? "").trim();
|
|
63693
|
+
const firstPivotRow = (chart.rows ?? []).find(
|
|
63694
|
+
(row) => Object.keys(row).length > 0
|
|
63695
|
+
);
|
|
63696
|
+
if (!firstPivotRow) return [];
|
|
63697
|
+
const keys = Object.keys(firstPivotRow).filter(
|
|
63698
|
+
(field) => !INTERNAL_PIVOT_ROW_FIELDS.has(field)
|
|
63699
|
+
);
|
|
63700
|
+
if (rowField && keys.includes(rowField)) {
|
|
63701
|
+
return [rowField, ...keys.filter((field) => field !== rowField)];
|
|
63702
|
+
}
|
|
63703
|
+
return keys;
|
|
63704
|
+
}
|
|
63705
|
+
function pivotValueFieldKeys(chart) {
|
|
63706
|
+
const rowKey = pivotRowKey(chart);
|
|
63707
|
+
const rowField = String(chart.pivot?.rowField ?? "").trim();
|
|
63708
|
+
return pivotDisplayFieldKeys(chart).filter(
|
|
63709
|
+
(field) => field !== rowKey && field !== rowField
|
|
63710
|
+
);
|
|
63711
|
+
}
|
|
63712
|
+
function pivotFallbackValueKeys(chart) {
|
|
63713
|
+
return (chart.pivotColumns ?? []).slice(1).map((column) => String(column.field ?? "").trim()).filter(Boolean);
|
|
63714
|
+
}
|
|
63715
|
+
function findSavedYAxisField(saved, field) {
|
|
63716
|
+
return saved.find((axis) => String(axis.field ?? "").trim() === field) ?? (saved.length === 1 ? saved[0] : void 0);
|
|
63717
|
+
}
|
|
63718
|
+
function isPlaceholderAxisLabel(label, field) {
|
|
63719
|
+
const trimmed = String(label ?? "").trim();
|
|
63720
|
+
const fieldTrim = String(field ?? "").trim();
|
|
63721
|
+
if (!trimmed) return true;
|
|
63722
|
+
if (trimmed.toLowerCase() === fieldTrim.toLowerCase()) return true;
|
|
63723
|
+
return trimmed === toTitleCaseLabel(fieldTrim);
|
|
63724
|
+
}
|
|
63725
|
+
function resolvedAxisLabel(savedLabel, field, generatedLabel) {
|
|
63726
|
+
return isPlaceholderAxisLabel(savedLabel, field) ? generatedLabel : savedLabel;
|
|
63727
|
+
}
|
|
63728
|
+
function resolveYAxisFormatForField(field, aggregation, saved, fallback) {
|
|
63729
|
+
const formatByField = new Map(
|
|
63730
|
+
saved.map((axis) => [String(axis.field ?? "").trim(), axis.format])
|
|
63731
|
+
);
|
|
63732
|
+
if (aggregation?.aggregationType === "count") {
|
|
63733
|
+
return formatByField.get(field) ?? formatByField.get("count") ?? saved[0]?.format ?? "whole_number";
|
|
63734
|
+
}
|
|
63735
|
+
if (aggregation?.aggregationType === "percentage") {
|
|
63736
|
+
const savedFormat = formatByField.get(field);
|
|
63737
|
+
if (savedFormat === "percent" || savedFormat === "percentage") {
|
|
63738
|
+
return savedFormat;
|
|
63739
|
+
}
|
|
63740
|
+
return "percentage";
|
|
63741
|
+
}
|
|
63742
|
+
const aggType = aggregation?.aggregationType ? String(aggregation.aggregationType) : void 0;
|
|
63743
|
+
return formatByField.get(field) ?? formatByField.get(trimAggregationSuffix(field, aggType)) ?? (aggregation?.valueField ? formatByField.get(aggregation.valueField) : void 0) ?? fallback;
|
|
63744
|
+
}
|
|
63745
|
+
function aggregationIdentityForField(field, aggregations) {
|
|
63746
|
+
return getAggregationIdentityKey(
|
|
63747
|
+
findAggregationForFieldStrict(field, aggregations)
|
|
63748
|
+
);
|
|
63749
|
+
}
|
|
63750
|
+
function indexByAggregationIdentity(axes, aggregations) {
|
|
63751
|
+
const byIdentity = /* @__PURE__ */ new Map();
|
|
63752
|
+
for (const axis of axes) {
|
|
63753
|
+
const identity = aggregationIdentityForField(axis.field, aggregations);
|
|
63754
|
+
if (identity && !byIdentity.has(identity)) {
|
|
63755
|
+
byIdentity.set(identity, axis);
|
|
63756
|
+
}
|
|
63757
|
+
}
|
|
63758
|
+
return byIdentity;
|
|
63759
|
+
}
|
|
63760
|
+
function matchedValueKeyForAggregation(aggregation, valueKeys, canonicalField) {
|
|
63761
|
+
if (valueKeys.includes(canonicalField)) return canonicalField;
|
|
63762
|
+
return valueKeys.find(
|
|
63763
|
+
(key) => findAggregationForFieldStrict(key, [aggregation])
|
|
63764
|
+
);
|
|
63765
|
+
}
|
|
63766
|
+
function composePivotColumnSeriesLabel(field, aggregation, measureLabel, hasMultipleAggregations) {
|
|
63767
|
+
if (!aggregation) return toTitleCaseLabel(String(field ?? ""));
|
|
63768
|
+
const category = normalizePivotColumnDisplayValue(
|
|
63769
|
+
getPivotColumnValueForSeries(field, aggregation, hasMultipleAggregations)
|
|
63770
|
+
);
|
|
63771
|
+
const isMeasureNamedSeries = Boolean(aggregation.valueField) && category === String(aggregation.valueField ?? "").trim();
|
|
63772
|
+
if (isMeasureNamedSeries) return measureLabel;
|
|
63773
|
+
if (!measureLabel || measureLabel === category) return category;
|
|
63774
|
+
return `${category} \xB7 ${measureLabel}`;
|
|
63775
|
+
}
|
|
63776
|
+
function measureFromAggregation(aggregation, chart, saved, fallback, hasMultipleAggregations, resolveTableLabel) {
|
|
63777
|
+
const canonicalField = getAggregationFieldKey(
|
|
63778
|
+
aggregation,
|
|
63779
|
+
hasMultipleAggregations
|
|
63780
|
+
);
|
|
63781
|
+
if (!canonicalField) return null;
|
|
63782
|
+
const previous = findSavedYAxisField(saved, canonicalField);
|
|
63783
|
+
const savedLabel = String(previous?.label ?? "").trim();
|
|
63784
|
+
const generatedLabel = buildAggregationLabel(
|
|
63785
|
+
aggregation,
|
|
63786
|
+
chart,
|
|
63787
|
+
resolveTableLabel
|
|
63788
|
+
);
|
|
63789
|
+
return {
|
|
63790
|
+
field: canonicalField,
|
|
63791
|
+
label: resolvedAxisLabel(savedLabel, canonicalField, generatedLabel),
|
|
63792
|
+
format: resolveYAxisFormatForField(
|
|
63793
|
+
canonicalField,
|
|
63794
|
+
aggregation,
|
|
63795
|
+
saved,
|
|
63796
|
+
fallback
|
|
63797
|
+
)
|
|
63798
|
+
};
|
|
63799
|
+
}
|
|
63800
|
+
function applyYAxisEdits(measures, edits, aggregations) {
|
|
63801
|
+
if (!edits) return measures;
|
|
63802
|
+
const byField = new Map(
|
|
63803
|
+
measures.map((measure) => [String(measure.field ?? "").trim(), measure])
|
|
63804
|
+
);
|
|
63805
|
+
const byIdentity = indexByAggregationIdentity(measures, aggregations);
|
|
63806
|
+
const next = [];
|
|
63807
|
+
for (const edit of edits) {
|
|
63808
|
+
const field = String(edit.field ?? "").trim();
|
|
63809
|
+
if (!field) continue;
|
|
63810
|
+
const identity = aggregationIdentityForField(field, aggregations);
|
|
63811
|
+
const base = (identity ? byIdentity.get(identity) : void 0) ?? byField.get(field);
|
|
63812
|
+
const label = String(edit.label ?? "").trim();
|
|
63813
|
+
if (!base) {
|
|
63814
|
+
next.push({
|
|
63815
|
+
field,
|
|
63816
|
+
label: label || toTitleCaseLabel(field),
|
|
63817
|
+
format: toAxisFormat(edit.format, "string")
|
|
63818
|
+
});
|
|
63819
|
+
continue;
|
|
63820
|
+
}
|
|
63821
|
+
next.push({
|
|
63822
|
+
field: base.field,
|
|
63823
|
+
label: label || base.label,
|
|
63824
|
+
format: toAxisFormat(edit.format, base.format)
|
|
63825
|
+
});
|
|
63826
|
+
}
|
|
63827
|
+
return next.length > 0 ? next : measures;
|
|
63828
|
+
}
|
|
63829
|
+
function resolveReportYAxis(chart, edits, resolveTableLabel) {
|
|
63830
|
+
const saved = chart.yAxisFields ?? [];
|
|
63831
|
+
if (!chart.pivot) {
|
|
63832
|
+
const measures2 = applyYAxisEdits(saved, edits, []);
|
|
63833
|
+
return { measures: measures2, series: measures2 };
|
|
63834
|
+
}
|
|
63835
|
+
const aggregations = getPivotAggregations(chart);
|
|
63836
|
+
const hasMultipleAggregations = aggregations.length > 1;
|
|
63837
|
+
const columnField = String(chart.pivot?.columnField ?? "").trim();
|
|
63838
|
+
const isAggregationOnlyPivot = !String(chart.pivot?.rowField ?? "").trim() && !columnField;
|
|
63839
|
+
const fallback = saved[0]?.format ?? chart.xAxisFormat ?? "whole_number";
|
|
63840
|
+
const valueKeys = pivotValueFieldKeys(chart);
|
|
63841
|
+
const fallbackKeys = pivotFallbackValueKeys(chart);
|
|
63842
|
+
let measures = aggregations.flatMap((aggregation) => {
|
|
63843
|
+
const measure = measureFromAggregation(
|
|
63844
|
+
aggregation,
|
|
63845
|
+
chart,
|
|
63846
|
+
saved,
|
|
63847
|
+
fallback,
|
|
63848
|
+
hasMultipleAggregations,
|
|
63849
|
+
resolveTableLabel
|
|
63850
|
+
);
|
|
63851
|
+
if (!measure) return [];
|
|
63852
|
+
if (columnField) return [measure];
|
|
63853
|
+
if (valueKeys.length === 0) return [measure];
|
|
63854
|
+
const matchedKey = matchedValueKeyForAggregation(
|
|
63855
|
+
aggregation,
|
|
63856
|
+
valueKeys,
|
|
63857
|
+
measure.field
|
|
63858
|
+
);
|
|
63859
|
+
if (matchedKey) return [{ ...measure, field: matchedKey }];
|
|
63860
|
+
return isAggregationOnlyPivot ? [measure] : [];
|
|
63861
|
+
});
|
|
63862
|
+
if (!columnField && measures.length === 0 && saved.length > 0) {
|
|
63863
|
+
measures = saved;
|
|
63864
|
+
}
|
|
63865
|
+
measures = applyYAxisEdits(measures, edits, aggregations);
|
|
63866
|
+
if (!columnField) {
|
|
63867
|
+
return { measures, series: measures };
|
|
63868
|
+
}
|
|
63869
|
+
const keys = valueKeys.length > 0 ? valueKeys : fallbackKeys;
|
|
63870
|
+
const measureByIdentity = indexByAggregationIdentity(measures, aggregations);
|
|
63871
|
+
const selectedIdentities = new Set(measureByIdentity.keys());
|
|
63872
|
+
const series = keys.flatMap((field) => {
|
|
63873
|
+
const aggregation = findAggregationForFieldStrict(field, aggregations);
|
|
63874
|
+
const identity = getAggregationIdentityKey(aggregation);
|
|
63875
|
+
if (selectedIdentities.size > 0 && identity && !selectedIdentities.has(identity)) {
|
|
63876
|
+
return [];
|
|
63877
|
+
}
|
|
63878
|
+
const measure = (identity ? measureByIdentity.get(identity) : void 0) ?? (measures.length === 1 ? measures[0] : void 0);
|
|
63879
|
+
const measureLabel = String(measure?.label ?? "").trim() || (aggregation ? buildAggregationLabel(aggregation, chart, resolveTableLabel) : toTitleCaseLabel(field));
|
|
63880
|
+
return [
|
|
63881
|
+
{
|
|
63882
|
+
field,
|
|
63883
|
+
label: composePivotColumnSeriesLabel(
|
|
63884
|
+
field,
|
|
63885
|
+
aggregation,
|
|
63886
|
+
measureLabel,
|
|
63887
|
+
hasMultipleAggregations
|
|
63888
|
+
),
|
|
63889
|
+
format: measure?.format ?? resolveYAxisFormatForField(field, aggregation, saved, fallback)
|
|
63890
|
+
}
|
|
63891
|
+
];
|
|
63892
|
+
});
|
|
63893
|
+
if (series.length > 0) {
|
|
63894
|
+
return { measures, series };
|
|
63895
|
+
}
|
|
63896
|
+
return { measures, series: measures };
|
|
63897
|
+
}
|
|
63898
|
+
function normalizePivotChartForDisplay(chart) {
|
|
63692
63899
|
const swapPivotRowsForChartRows = Boolean(chart?.pivot) && Array.isArray(chart?.pivotRows) && chart.pivotRows.length > 0;
|
|
63693
63900
|
const syntheticAggregationOnlyRows = chart && !swapPivotRowsForChartRows ? buildSyntheticAggregationOnlyDisplayRows(chart) : null;
|
|
63694
63901
|
const hasExplicitEmptyGroupedPivot = Boolean(
|
|
@@ -63724,136 +63931,13 @@ function normalizePivotChartForDisplay(chart, resolveTableLabel) {
|
|
|
63724
63931
|
String(withResolvedXAxis.chartType ?? "").toLowerCase()
|
|
63725
63932
|
);
|
|
63726
63933
|
const aggregations = getPivotAggregations(withResolvedXAxis);
|
|
63727
|
-
const hasMultipleAggregations = aggregations.length > 1;
|
|
63728
63934
|
const yAxisFallbackFormat = withResolvedXAxis.yAxisFields?.[0]?.format ?? withResolvedXAxis.xAxisFormat ?? "whole_number";
|
|
63729
63935
|
const firstPivotRow = (withResolvedXAxis.rows ?? []).find(
|
|
63730
63936
|
(row) => Object.keys(row).length > 0
|
|
63731
63937
|
);
|
|
63732
|
-
const
|
|
63733
|
-
|
|
63734
|
-
|
|
63735
|
-
const pivotRowFields = firstPivotRow ? (() => {
|
|
63736
|
-
const keys = Object.keys(firstPivotRow).filter(
|
|
63737
|
-
(field) => !INTERNAL_PIVOT_ROW_FIELDS.has(field)
|
|
63738
|
-
);
|
|
63739
|
-
if (pivotRowFieldName && keys.includes(pivotRowFieldName)) {
|
|
63740
|
-
return [
|
|
63741
|
-
pivotRowFieldName,
|
|
63742
|
-
...keys.filter((field) => field !== pivotRowFieldName)
|
|
63743
|
-
];
|
|
63744
|
-
}
|
|
63745
|
-
return keys;
|
|
63746
|
-
})() : [];
|
|
63747
|
-
const pivotValueFields = pivotRowFields.filter(
|
|
63748
|
-
(field) => field !== pivotRowKey(withResolvedXAxis) && field !== withResolvedXAxis.pivot?.rowField
|
|
63749
|
-
);
|
|
63750
|
-
const isAggregationOnlyPivot = !String(withResolvedXAxis.pivot?.rowField ?? "").trim() && !String(withResolvedXAxis.pivot?.columnField ?? "").trim();
|
|
63751
|
-
const yAxisFormatByField = new Map(
|
|
63752
|
-
(withResolvedXAxis.yAxisFields ?? []).map((axis) => [
|
|
63753
|
-
axis.field,
|
|
63754
|
-
axis.format
|
|
63755
|
-
])
|
|
63756
|
-
);
|
|
63757
|
-
const resolveYAxisFormat = (field, aggregation) => {
|
|
63758
|
-
if (aggregation?.aggregationType === "count") {
|
|
63759
|
-
const savedFormat = yAxisFormatByField.get(field) ?? yAxisFormatByField.get("count") ?? withResolvedXAxis.yAxisFields?.find(
|
|
63760
|
-
(axis) => String(axis.field ?? "").trim() === field
|
|
63761
|
-
)?.format ?? withResolvedXAxis.yAxisFields?.[0]?.format;
|
|
63762
|
-
if (savedFormat) return savedFormat;
|
|
63763
|
-
return "whole_number";
|
|
63764
|
-
}
|
|
63765
|
-
if (aggregation?.aggregationType === "percentage") {
|
|
63766
|
-
const savedFormat = yAxisFormatByField.get(field);
|
|
63767
|
-
if (savedFormat === "percent" || savedFormat === "percentage") {
|
|
63768
|
-
return savedFormat;
|
|
63769
|
-
}
|
|
63770
|
-
return "percentage";
|
|
63771
|
-
}
|
|
63772
|
-
const directAxisFormat = yAxisFormatByField.get(field);
|
|
63773
|
-
if (directAxisFormat) return directAxisFormat;
|
|
63774
|
-
const aggType = aggregation?.aggregationType ? String(aggregation.aggregationType) : void 0;
|
|
63775
|
-
const baseField = trimAggregationSuffix(field, aggType);
|
|
63776
|
-
const baseAxisFormat = yAxisFormatByField.get(baseField);
|
|
63777
|
-
if (baseAxisFormat) return baseAxisFormat;
|
|
63778
|
-
if (aggregation?.valueField) {
|
|
63779
|
-
const aggregationValueFieldFormat = yAxisFormatByField.get(
|
|
63780
|
-
aggregation.valueField
|
|
63781
|
-
);
|
|
63782
|
-
if (aggregationValueFieldFormat) return aggregationValueFieldFormat;
|
|
63783
|
-
}
|
|
63784
|
-
return yAxisFallbackFormat;
|
|
63785
|
-
};
|
|
63786
|
-
const resolveAggregationAxisFieldForDisplay = (aggregation, canonicalField) => {
|
|
63787
|
-
if (!canonicalField) return null;
|
|
63788
|
-
if (pivotValueFields.includes(canonicalField)) {
|
|
63789
|
-
return canonicalField;
|
|
63790
|
-
}
|
|
63791
|
-
if (!isAggregationOnlyPivot) {
|
|
63792
|
-
return null;
|
|
63793
|
-
}
|
|
63794
|
-
const matchedPivotKey = pivotValueFields.find(
|
|
63795
|
-
(pf) => findAggregationForFieldStrict(pf, [aggregation])
|
|
63796
|
-
);
|
|
63797
|
-
return matchedPivotKey ?? canonicalField;
|
|
63798
|
-
};
|
|
63799
|
-
const yAxisFromAggregations = !withResolvedXAxis.pivot?.columnField && aggregations.length > 0 ? aggregations.map((aggregation) => {
|
|
63800
|
-
const canonicalField = getAggregationFieldKey(
|
|
63801
|
-
aggregation,
|
|
63802
|
-
hasMultipleAggregations
|
|
63803
|
-
);
|
|
63804
|
-
const field = resolveAggregationAxisFieldForDisplay(
|
|
63805
|
-
aggregation,
|
|
63806
|
-
canonicalField
|
|
63807
|
-
);
|
|
63808
|
-
if (!field) return null;
|
|
63809
|
-
return {
|
|
63810
|
-
field,
|
|
63811
|
-
label: buildAggregationLabel(
|
|
63812
|
-
aggregation,
|
|
63813
|
-
withResolvedXAxis,
|
|
63814
|
-
resolveTableLabel
|
|
63815
|
-
),
|
|
63816
|
-
format: resolveYAxisFormat(field, aggregation)
|
|
63817
|
-
};
|
|
63818
|
-
}).filter((axis) => Boolean(axis)) : [];
|
|
63819
|
-
const mappedValueFields = new Set(
|
|
63820
|
-
yAxisFromAggregations.map((axis) => axis.field)
|
|
63821
|
-
);
|
|
63822
|
-
const yAxisFromPivotRowFields = pivotValueFields.filter((field) => !mappedValueFields.has(field)).map((field) => {
|
|
63823
|
-
const aggregation = findAggregationForFieldStrict(field, aggregations);
|
|
63824
|
-
const cleanedBaseField = aggregation?.aggregationType && hasMultipleAggregations ? trimAggregationSuffix(field, String(aggregation.aggregationType)) : field;
|
|
63825
|
-
const displayBase = aggregation?.valueField && withResolvedXAxis.pivot?.columnField ? trimAggregationSuffix(cleanedBaseField, aggregation.valueField) : cleanedBaseField;
|
|
63826
|
-
const displayBaseField = normalizePivotColumnDisplayValue(displayBase);
|
|
63827
|
-
const aggregationLabel = aggregation ? buildAggregationLabel(
|
|
63828
|
-
aggregation,
|
|
63829
|
-
withResolvedXAxis,
|
|
63830
|
-
resolveTableLabel
|
|
63831
|
-
) : void 0;
|
|
63832
|
-
const isMeasureNamedSeries = Boolean(aggregation?.valueField) && displayBaseField === String(aggregation?.valueField ?? "").trim();
|
|
63833
|
-
let pivotColumnSeriesLabel = displayBaseField;
|
|
63834
|
-
if (withResolvedXAxis.pivot?.columnField && aggregation && aggregationLabel) {
|
|
63835
|
-
if (isMeasureNamedSeries) {
|
|
63836
|
-
pivotColumnSeriesLabel = aggregationLabel;
|
|
63837
|
-
} else if (aggregationLabel !== displayBaseField) {
|
|
63838
|
-
const alreadyCombined = String(displayBaseField).endsWith(` \xB7 ${aggregationLabel}`) || String(displayBaseField).endsWith(` \u2014 ${aggregationLabel}`) || String(displayBaseField).endsWith(` (${aggregationLabel})`);
|
|
63839
|
-
pivotColumnSeriesLabel = alreadyCombined ? displayBaseField : `${displayBaseField} \xB7 ${aggregationLabel}`;
|
|
63840
|
-
}
|
|
63841
|
-
}
|
|
63842
|
-
const label = aggregation ? withResolvedXAxis.pivot?.columnField ? pivotColumnSeriesLabel : aggregationLabel ?? displayBaseField : toTitleCaseLabel(String(field ?? ""));
|
|
63843
|
-
return {
|
|
63844
|
-
field,
|
|
63845
|
-
label,
|
|
63846
|
-
format: resolveYAxisFormat(field, aggregation)
|
|
63847
|
-
};
|
|
63848
|
-
});
|
|
63849
|
-
const supplementalYAxisFromPivotRowFields = yAxisFromAggregations.length > 0 ? yAxisFromPivotRowFields.filter(
|
|
63850
|
-
(axis) => Boolean(findAggregationForFieldStrict(axis.field, aggregations))
|
|
63851
|
-
) : yAxisFromPivotRowFields;
|
|
63852
|
-
const yAxisFields = yAxisFromAggregations.length > 0 ? [...yAxisFromAggregations, ...supplementalYAxisFromPivotRowFields] : supplementalYAxisFromPivotRowFields.length > 0 ? supplementalYAxisFromPivotRowFields : (withResolvedXAxis.pivotColumns ?? []).slice(1).map((column) => ({
|
|
63853
|
-
field: column.field,
|
|
63854
|
-
label: column.label ?? column.field,
|
|
63855
|
-
format: column.format ?? yAxisFallbackFormat
|
|
63856
|
-
}));
|
|
63938
|
+
const pivotRowFields = pivotDisplayFieldKeys(withResolvedXAxis);
|
|
63939
|
+
const pivotValueFields = pivotValueFieldKeys(withResolvedXAxis);
|
|
63940
|
+
const yAxisFields = withResolvedXAxis.yAxisFields ?? [];
|
|
63857
63941
|
const knownColumnsByField = new Map(
|
|
63858
63942
|
[
|
|
63859
63943
|
...withResolvedXAxis.pivotColumns ?? [],
|
|
@@ -63874,21 +63958,21 @@ function normalizePivotChartForDisplay(chart, resolveTableLabel) {
|
|
|
63874
63958
|
};
|
|
63875
63959
|
}) : withResolvedXAxis.columns ?? [];
|
|
63876
63960
|
const isPivotTableChart = String(withResolvedXAxis.chartType ?? "").toLowerCase() === "table" && Boolean(withResolvedXAxis.pivot);
|
|
63877
|
-
const
|
|
63961
|
+
const savedPivotTableColumns = isPivotTableChart && Array.isArray(withResolvedXAxis.pivotColumns) && withResolvedXAxis.pivotColumns.length > 0 ? withResolvedXAxis.pivotColumns : withResolvedXAxis.columns;
|
|
63878
63962
|
const pivotTableDisplayColumns = isPivotTableChart && pivotColumnFields.length > 0 ? normalizedPivotColumns.map((col) => {
|
|
63879
|
-
const
|
|
63880
|
-
|
|
63963
|
+
const savedColumn = getPivotTableReportColumn(
|
|
63964
|
+
savedPivotTableColumns,
|
|
63881
63965
|
aggregations,
|
|
63882
63966
|
pivotRowKey(withResolvedXAxis) || withResolvedXAxis.pivot?.rowField,
|
|
63883
63967
|
col.field
|
|
63884
63968
|
);
|
|
63885
|
-
if (!
|
|
63969
|
+
if (!savedColumn) return col;
|
|
63886
63970
|
const next = {
|
|
63887
63971
|
...col,
|
|
63888
|
-
format:
|
|
63972
|
+
format: savedColumn.format ?? col.format
|
|
63889
63973
|
};
|
|
63890
|
-
if (
|
|
63891
|
-
next.inferFormat =
|
|
63974
|
+
if (savedColumn.inferFormat !== void 0) {
|
|
63975
|
+
next.inferFormat = savedColumn.inferFormat;
|
|
63892
63976
|
}
|
|
63893
63977
|
return next;
|
|
63894
63978
|
}) : normalizedPivotColumns;
|
|
@@ -63949,100 +64033,10 @@ function normalizePivotChartForDisplay(chart, resolveTableLabel) {
|
|
|
63949
64033
|
yAxisFields
|
|
63950
64034
|
};
|
|
63951
64035
|
}
|
|
63952
|
-
function
|
|
63953
|
-
const aggregations = getPivotAggregations(report);
|
|
63954
|
-
const hasMultipleAggregations = aggregations.length > 1;
|
|
63955
|
-
return aggregations.map((aggregation) => {
|
|
63956
|
-
const field = getAggregationFieldKey(
|
|
63957
|
-
aggregation,
|
|
63958
|
-
hasMultipleAggregations
|
|
63959
|
-
);
|
|
63960
|
-
if (!field) return null;
|
|
63961
|
-
return {
|
|
63962
|
-
field,
|
|
63963
|
-
label: buildAggregationLabel(aggregation, report, resolveTableLabel),
|
|
63964
|
-
format: getYAxisFormatFromAggregation(aggregation)
|
|
63965
|
-
};
|
|
63966
|
-
}).filter((axis) => Boolean(axis));
|
|
63967
|
-
}
|
|
63968
|
-
function mergePivotColumnAxisFieldsWithMapped(aggregationAxisFields, mapped) {
|
|
63969
|
-
const byField = /* @__PURE__ */ new Map();
|
|
63970
|
-
for (const y of mapped) {
|
|
63971
|
-
const f = String(y.field ?? "").trim();
|
|
63972
|
-
if (f) byField.set(f, y);
|
|
63973
|
-
}
|
|
63974
|
-
return aggregationAxisFields.map((axis) => {
|
|
63975
|
-
const f = String(axis.field ?? "").trim();
|
|
63976
|
-
const mappedAxis = f ? byField.get(f) : void 0;
|
|
63977
|
-
return mappedAxis ?? axis;
|
|
63978
|
-
});
|
|
63979
|
-
}
|
|
63980
|
-
function normalizePivotChartForAxisControls(chart, reportId, resolveTableLabel) {
|
|
63981
|
-
if (!chart?.pivot?.columnField) return chart;
|
|
63982
|
-
const aggregations = getPivotAggregations(chart);
|
|
63983
|
-
if (aggregations.length === 0) return chart;
|
|
63984
|
-
const aggregationAxisFields = buildPivotAggregationAxisFields(
|
|
63985
|
-
chart,
|
|
63986
|
-
resolveTableLabel
|
|
63987
|
-
);
|
|
63988
|
-
if (aggregationAxisFields.length === 0) return chart;
|
|
63989
|
-
const aggregationAxisByIdentity = /* @__PURE__ */ new Map();
|
|
63990
|
-
for (const aggregationAxisField of aggregationAxisFields) {
|
|
63991
|
-
const aggregation = findAggregationForFieldStrict(
|
|
63992
|
-
aggregationAxisField.field,
|
|
63993
|
-
aggregations
|
|
63994
|
-
);
|
|
63995
|
-
const aggregationIdentity = getAggregationIdentityKey(aggregation);
|
|
63996
|
-
if (!aggregationIdentity || aggregationAxisByIdentity.has(aggregationIdentity)) {
|
|
63997
|
-
continue;
|
|
63998
|
-
}
|
|
63999
|
-
aggregationAxisByIdentity.set(aggregationIdentity, aggregationAxisField);
|
|
64000
|
-
}
|
|
64001
|
-
const mappedExistingYAxisFields = [];
|
|
64002
|
-
const seenMappedFields = /* @__PURE__ */ new Set();
|
|
64003
|
-
for (const existingYAxisField of chart.yAxisFields ?? []) {
|
|
64004
|
-
const aggregation = findAggregationForFieldStrict(
|
|
64005
|
-
existingYAxisField.field,
|
|
64006
|
-
aggregations
|
|
64007
|
-
);
|
|
64008
|
-
const aggregationIdentity = getAggregationIdentityKey(aggregation);
|
|
64009
|
-
if (!aggregationIdentity) continue;
|
|
64010
|
-
const mappedAggregationAxis = aggregationAxisByIdentity.get(aggregationIdentity);
|
|
64011
|
-
if (!mappedAggregationAxis) continue;
|
|
64012
|
-
if (seenMappedFields.has(mappedAggregationAxis.field)) continue;
|
|
64013
|
-
seenMappedFields.add(mappedAggregationAxis.field);
|
|
64014
|
-
mappedExistingYAxisFields.push({
|
|
64015
|
-
field: mappedAggregationAxis.field,
|
|
64016
|
-
label: String(existingYAxisField.label ?? "").trim() || mappedAggregationAxis.label,
|
|
64017
|
-
format: toAxisFormat(
|
|
64018
|
-
existingYAxisField.format,
|
|
64019
|
-
mappedAggregationAxis.format
|
|
64020
|
-
)
|
|
64021
|
-
});
|
|
64022
|
-
}
|
|
64023
|
-
let yAxisFields;
|
|
64024
|
-
if (aggregations.length > 1) {
|
|
64025
|
-
const resolvedReportId = String(reportId ?? chart.id ?? "").trim();
|
|
64026
|
-
if (LEGACY_SINGLE_Y_AXIS_COLUMN_PIVOT_REPORT_IDS.has(resolvedReportId)) {
|
|
64027
|
-
yAxisFields = mappedExistingYAxisFields.length > 0 ? mappedExistingYAxisFields : [aggregationAxisFields[0]];
|
|
64028
|
-
} else {
|
|
64029
|
-
yAxisFields = mappedExistingYAxisFields.length === 0 || mappedExistingYAxisFields.length < aggregationAxisFields.length ? mergePivotColumnAxisFieldsWithMapped(
|
|
64030
|
-
aggregationAxisFields,
|
|
64031
|
-
mappedExistingYAxisFields
|
|
64032
|
-
) : mappedExistingYAxisFields;
|
|
64033
|
-
}
|
|
64034
|
-
} else {
|
|
64035
|
-
yAxisFields = mappedExistingYAxisFields.length > 0 ? mappedExistingYAxisFields : [aggregationAxisFields[0]];
|
|
64036
|
-
}
|
|
64037
|
-
return {
|
|
64038
|
-
...chart,
|
|
64039
|
-
yAxisFields
|
|
64040
|
-
};
|
|
64041
|
-
}
|
|
64042
|
-
function buildPivotColumnPivotTableFormattingColumns(pivot, chart, resolveTableLabel) {
|
|
64036
|
+
function buildPivotTableColumns(pivot, chart, resolveTableLabel) {
|
|
64043
64037
|
if (!pivot) return null;
|
|
64044
|
-
const
|
|
64045
|
-
const aggregations = getPivotAggregations(
|
|
64038
|
+
const chartWithPivot = chart ? { ...chart, pivot } : { pivot };
|
|
64039
|
+
const aggregations = getPivotAggregations(chartWithPivot);
|
|
64046
64040
|
if (aggregations.length === 0) return null;
|
|
64047
64041
|
const hasMultipleAggregations = aggregations.length > 1;
|
|
64048
64042
|
const rowField = String(pivot.rowField ?? "").trim();
|
|
@@ -64076,7 +64070,7 @@ function buildPivotColumnPivotTableFormattingColumns(pivot, chart, resolveTableL
|
|
|
64076
64070
|
field: fieldKey,
|
|
64077
64071
|
label: buildAggregationLabel(
|
|
64078
64072
|
aggregation,
|
|
64079
|
-
|
|
64073
|
+
chartWithPivot,
|
|
64080
64074
|
resolveTableLabel
|
|
64081
64075
|
)
|
|
64082
64076
|
});
|
|
@@ -64103,19 +64097,6 @@ function mergePivotColumnSeriesLabelWithUserEdit(normalizedLabel, userRowLabel,
|
|
|
64103
64097
|
}
|
|
64104
64098
|
return user;
|
|
64105
64099
|
}
|
|
64106
|
-
function applySingleResolvedYAxisFormatToPivotDisplay(normalizedPivotYAxisFields, resolvedYAxisFields) {
|
|
64107
|
-
if (resolvedYAxisFields.length !== 1) return normalizedPivotYAxisFields;
|
|
64108
|
-
const only = resolvedYAxisFields[0];
|
|
64109
|
-
return normalizedPivotYAxisFields.map((axis) => ({
|
|
64110
|
-
...axis,
|
|
64111
|
-
label: mergePivotColumnSeriesLabelWithUserEdit(
|
|
64112
|
-
String(axis.label ?? "").trim(),
|
|
64113
|
-
only.label,
|
|
64114
|
-
String(axis.field ?? "").trim() || void 0
|
|
64115
|
-
),
|
|
64116
|
-
format: toAxisFormat(only.format, axis.format)
|
|
64117
|
-
}));
|
|
64118
|
-
}
|
|
64119
64100
|
function mergeChartColumnFormatsFromYAxisFields(columns, yAxisFields) {
|
|
64120
64101
|
if (!columns?.length || !yAxisFields?.length) return columns;
|
|
64121
64102
|
const formatByField = /* @__PURE__ */ new Map();
|
|
@@ -64173,71 +64154,6 @@ function mergePivotTableDisplayColumnLabelsFromYAxis({
|
|
|
64173
64154
|
return { ...c, label: yl };
|
|
64174
64155
|
});
|
|
64175
64156
|
}
|
|
64176
|
-
function mapResolvedPivotYAxisFieldsForDisplay({
|
|
64177
|
-
chart,
|
|
64178
|
-
resolvedYAxisFields
|
|
64179
|
-
}) {
|
|
64180
|
-
if (!chart.pivot?.columnField) return resolvedYAxisFields;
|
|
64181
|
-
const normalizedPivotYAxisFields = chart.yAxisFields ?? [];
|
|
64182
|
-
if (normalizedPivotYAxisFields.length === 0) return resolvedYAxisFields;
|
|
64183
|
-
const aggregations = getPivotAggregations(chart);
|
|
64184
|
-
if (aggregations.length === 0) {
|
|
64185
|
-
return applySingleResolvedYAxisFormatToPivotDisplay(
|
|
64186
|
-
normalizedPivotYAxisFields,
|
|
64187
|
-
resolvedYAxisFields
|
|
64188
|
-
);
|
|
64189
|
-
}
|
|
64190
|
-
const selectedAggregationByIdentity = /* @__PURE__ */ new Map();
|
|
64191
|
-
for (const yAxisField of resolvedYAxisFields ?? []) {
|
|
64192
|
-
const aggregation = findAggregationForFieldStrict(
|
|
64193
|
-
yAxisField.field,
|
|
64194
|
-
aggregations
|
|
64195
|
-
);
|
|
64196
|
-
const aggregationIdentity = getAggregationIdentityKey(aggregation);
|
|
64197
|
-
if (!aggregationIdentity) continue;
|
|
64198
|
-
selectedAggregationByIdentity.set(aggregationIdentity, yAxisField);
|
|
64199
|
-
}
|
|
64200
|
-
if (selectedAggregationByIdentity.size === 0) {
|
|
64201
|
-
return applySingleResolvedYAxisFormatToPivotDisplay(
|
|
64202
|
-
normalizedPivotYAxisFields,
|
|
64203
|
-
resolvedYAxisFields
|
|
64204
|
-
);
|
|
64205
|
-
}
|
|
64206
|
-
const mappedYAxisFields = [];
|
|
64207
|
-
const seenMappedFields = /* @__PURE__ */ new Set();
|
|
64208
|
-
for (const normalizedYAxisField of normalizedPivotYAxisFields) {
|
|
64209
|
-
const aggregation = findAggregationForFieldStrict(
|
|
64210
|
-
normalizedYAxisField.field,
|
|
64211
|
-
aggregations
|
|
64212
|
-
);
|
|
64213
|
-
const aggregationIdentity = getAggregationIdentityKey(aggregation);
|
|
64214
|
-
if (!aggregationIdentity) continue;
|
|
64215
|
-
const selectedAggregationAxis = selectedAggregationByIdentity.get(aggregationIdentity);
|
|
64216
|
-
if (!selectedAggregationAxis) continue;
|
|
64217
|
-
const field = String(normalizedYAxisField.field ?? "").trim();
|
|
64218
|
-
if (!field || seenMappedFields.has(field)) continue;
|
|
64219
|
-
seenMappedFields.add(field);
|
|
64220
|
-
mappedYAxisFields.push({
|
|
64221
|
-
...normalizedYAxisField,
|
|
64222
|
-
label: mergePivotColumnSeriesLabelWithUserEdit(
|
|
64223
|
-
String(normalizedYAxisField.label ?? "").trim(),
|
|
64224
|
-
selectedAggregationAxis.label,
|
|
64225
|
-
field || void 0
|
|
64226
|
-
),
|
|
64227
|
-
format: toAxisFormat(
|
|
64228
|
-
selectedAggregationAxis.format,
|
|
64229
|
-
normalizedYAxisField.format
|
|
64230
|
-
)
|
|
64231
|
-
});
|
|
64232
|
-
}
|
|
64233
|
-
if (mappedYAxisFields.length > 0) {
|
|
64234
|
-
return mappedYAxisFields;
|
|
64235
|
-
}
|
|
64236
|
-
return applySingleResolvedYAxisFormatToPivotDisplay(
|
|
64237
|
-
normalizedPivotYAxisFields,
|
|
64238
|
-
resolvedYAxisFields
|
|
64239
|
-
);
|
|
64240
|
-
}
|
|
64241
64157
|
function encodeColumnOptionValue(table, field) {
|
|
64242
64158
|
if (!table || !table.trim()) return field;
|
|
64243
64159
|
return `${table}_${field}`;
|
|
@@ -65826,8 +65742,7 @@ async function fetchReportBuilderStateByReportId({
|
|
|
65826
65742
|
if (!state || typeof state !== "object") {
|
|
65827
65743
|
return null;
|
|
65828
65744
|
}
|
|
65829
|
-
|
|
65830
|
-
return parsedState;
|
|
65745
|
+
return state;
|
|
65831
65746
|
} catch (error) {
|
|
65832
65747
|
if (error instanceof Error && error.name === "AbortError") {
|
|
65833
65748
|
throw error;
|
|
@@ -65866,10 +65781,11 @@ function applyFetchedReportBuilderState(result, fetchedReportBuilderState) {
|
|
|
65866
65781
|
}).filter(
|
|
65867
65782
|
(table) => Boolean(table)
|
|
65868
65783
|
);
|
|
65784
|
+
const keptExistingRules = existingRules.rules.length > 0;
|
|
65869
65785
|
const mergedState = {
|
|
65870
65786
|
tables: mergedTables,
|
|
65871
65787
|
columns: existingColumns.length > 0 ? existingColumns : fetchedColumns,
|
|
65872
|
-
rules:
|
|
65788
|
+
rules: keptExistingRules ? existingRules : fetchedRules,
|
|
65873
65789
|
pivot: existingState?.pivot ?? fetchedReportBuilderState.pivot ?? null,
|
|
65874
65790
|
sort: existingSort.length > 0 ? existingSort : fetchedSort,
|
|
65875
65791
|
limit: existingState?.limit ?? fetchedReportBuilderState.limit ?? null
|
|
@@ -66687,7 +66603,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
66687
66603
|
useEffect33(() => {
|
|
66688
66604
|
setTableColumnsEditedSignature(null);
|
|
66689
66605
|
}, [effectiveReportId]);
|
|
66690
|
-
const [
|
|
66606
|
+
const [axisEdits, setAxisEdits] = useState42({});
|
|
66691
66607
|
const [chartVisibilityOverrides, setChartVisibilityOverrides] = useState42({});
|
|
66692
66608
|
const [chartSortOverride, setChartSortOverride] = useState42(void 0);
|
|
66693
66609
|
const [client] = useContext37(ClientContext);
|
|
@@ -66819,7 +66735,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
66819
66735
|
}
|
|
66820
66736
|
}, [createdReportBootstrap?.reportId, propReportId]);
|
|
66821
66737
|
useEffect33(() => {
|
|
66822
|
-
|
|
66738
|
+
setAxisEdits({});
|
|
66823
66739
|
setChartVisibilityOverrides({});
|
|
66824
66740
|
setChartSortOverride(void 0);
|
|
66825
66741
|
}, [effectiveReportId]);
|
|
@@ -68107,6 +68023,24 @@ function useReport(reportIdArg, options = {}) {
|
|
|
68107
68023
|
initialDataUpdatedAt: () => findCachedDashboardReportQuery(queryClient, effectiveReportId)?.state.dataUpdatedAt,
|
|
68108
68024
|
staleTime: DASHBOARD_REPORT_STALE_TIME_MS
|
|
68109
68025
|
});
|
|
68026
|
+
const reportBuilderStateQuery = useQuery({
|
|
68027
|
+
queryKey: ["useReport", "report-builder-state", effectiveReportId],
|
|
68028
|
+
queryFn: createUseFormQueryFn((signal) => {
|
|
68029
|
+
if (!client) {
|
|
68030
|
+
return Promise.resolve(null);
|
|
68031
|
+
}
|
|
68032
|
+
return fetchReportBuilderStateByReportId({
|
|
68033
|
+
reportId: effectiveReportId,
|
|
68034
|
+
client,
|
|
68035
|
+
getToken,
|
|
68036
|
+
draftSessionId: draftSessionId || void 0,
|
|
68037
|
+
tenants,
|
|
68038
|
+
abortSignal: signal
|
|
68039
|
+
});
|
|
68040
|
+
}),
|
|
68041
|
+
enabled: Boolean(effectiveReportId) && Boolean(client) && !reportOverride,
|
|
68042
|
+
staleTime: 0
|
|
68043
|
+
});
|
|
68110
68044
|
const reportNameQueryReportId = String(effectiveReportId ?? "").trim();
|
|
68111
68045
|
const reportNameQuery = useQuery({
|
|
68112
68046
|
queryKey: createUseFormReportNameQueryKey({
|
|
@@ -68137,10 +68071,21 @@ function useReport(reportIdArg, options = {}) {
|
|
|
68137
68071
|
const displayReportName = formReportName !== void 0 ? formReportName : resolvedReportName;
|
|
68138
68072
|
useEffect33(() => {
|
|
68139
68073
|
if (reportOverride) return;
|
|
68140
|
-
const report =
|
|
68074
|
+
const report = applyFetchedReportBuilderState(
|
|
68075
|
+
initialLoadQuery.data ?? { report: null },
|
|
68076
|
+
reportBuilderStateQuery.data ?? null
|
|
68077
|
+
).report ?? null;
|
|
68141
68078
|
initializeSchemaScopeForReport(report);
|
|
68142
68079
|
setSourceReport(report);
|
|
68143
|
-
}, [
|
|
68080
|
+
}, [
|
|
68081
|
+
initialLoadQuery.data,
|
|
68082
|
+
initialLoadQuery.fetchStatus,
|
|
68083
|
+
initialLoadQuery.isFetching,
|
|
68084
|
+
initialLoadQuery.isPending,
|
|
68085
|
+
reportBuilderStateQuery.data,
|
|
68086
|
+
reportOverride,
|
|
68087
|
+
effectiveReportId
|
|
68088
|
+
]);
|
|
68144
68089
|
useEffect33(() => {
|
|
68145
68090
|
if (!sourceReport) {
|
|
68146
68091
|
return;
|
|
@@ -69792,20 +69737,18 @@ function useReport(reportIdArg, options = {}) {
|
|
|
69792
69737
|
chartPivotHydrationEpoch
|
|
69793
69738
|
]);
|
|
69794
69739
|
const baseChart = useMemo33(
|
|
69795
|
-
() => normalizePivotChartForDisplay(chartData
|
|
69796
|
-
[chartData
|
|
69740
|
+
() => normalizePivotChartForDisplay(chartData),
|
|
69741
|
+
[chartData]
|
|
69797
69742
|
);
|
|
69798
|
-
const
|
|
69799
|
-
if (!
|
|
69800
|
-
|
|
69801
|
-
|
|
69802
|
-
|
|
69803
|
-
|
|
69804
|
-
|
|
69805
|
-
|
|
69806
|
-
|
|
69807
|
-
return baseChart;
|
|
69808
|
-
}, [baseChart, chartData, effectiveReportId, resolveTableDisplayLabel]);
|
|
69743
|
+
const yAxisResolved = useMemo33(() => {
|
|
69744
|
+
if (!baseChart) return { measures: [], series: [] };
|
|
69745
|
+
return resolveReportYAxis(
|
|
69746
|
+
baseChart,
|
|
69747
|
+
axisEdits.yAxisFields,
|
|
69748
|
+
resolveTableDisplayLabel
|
|
69749
|
+
);
|
|
69750
|
+
}, [baseChart, axisEdits.yAxisFields, resolveTableDisplayLabel]);
|
|
69751
|
+
const chartAxesBaseChart = baseChart;
|
|
69809
69752
|
const chartAxisOptions = useMemo33(() => {
|
|
69810
69753
|
if (!chartAxesBaseChart) return [];
|
|
69811
69754
|
const optionsByField = /* @__PURE__ */ new Map();
|
|
@@ -69824,7 +69767,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
69824
69767
|
for (const column of chartAxesBaseChart.columns ?? []) {
|
|
69825
69768
|
registerOption(column.field, column.label, column.format);
|
|
69826
69769
|
}
|
|
69827
|
-
for (const yAxis2 of
|
|
69770
|
+
for (const yAxis2 of yAxisResolved.measures) {
|
|
69828
69771
|
registerOption(yAxis2.field, yAxis2.label, yAxis2.format);
|
|
69829
69772
|
if (yAxis2.format) {
|
|
69830
69773
|
const existing = optionsByField.get(yAxis2.field);
|
|
@@ -69836,18 +69779,6 @@ function useReport(reportIdArg, options = {}) {
|
|
|
69836
69779
|
}
|
|
69837
69780
|
}
|
|
69838
69781
|
}
|
|
69839
|
-
if (chartAxesBaseChart.pivot?.columnField) {
|
|
69840
|
-
for (const aggregationAxis of buildPivotAggregationAxisFields(
|
|
69841
|
-
chartAxesBaseChart,
|
|
69842
|
-
resolveTableDisplayLabel
|
|
69843
|
-
)) {
|
|
69844
|
-
registerOption(
|
|
69845
|
-
aggregationAxis.field,
|
|
69846
|
-
aggregationAxis.label,
|
|
69847
|
-
aggregationAxis.format
|
|
69848
|
-
);
|
|
69849
|
-
}
|
|
69850
|
-
}
|
|
69851
69782
|
const xField = String(chartAxesBaseChart.xAxisField ?? "").trim();
|
|
69852
69783
|
const savedXFormat = String(chartAxesBaseChart.xAxisFormat ?? "").trim();
|
|
69853
69784
|
registerOption(
|
|
@@ -69865,7 +69796,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
69865
69796
|
}
|
|
69866
69797
|
}
|
|
69867
69798
|
return Array.from(optionsByField.values());
|
|
69868
|
-
}, [chartAxesBaseChart,
|
|
69799
|
+
}, [chartAxesBaseChart, yAxisResolved.measures]);
|
|
69869
69800
|
const chartAxisOptionByField = useMemo33(() => {
|
|
69870
69801
|
const optionsByField = /* @__PURE__ */ new Map();
|
|
69871
69802
|
for (const option of chartAxisOptions) {
|
|
@@ -69910,19 +69841,15 @@ function useReport(reportIdArg, options = {}) {
|
|
|
69910
69841
|
const pivot = chartAxesBaseChart.pivot;
|
|
69911
69842
|
const pivotRowField = String(pivot?.rowField ?? "").trim();
|
|
69912
69843
|
if (pivot && !pivotRowField) {
|
|
69913
|
-
const
|
|
69914
|
-
|
|
69915
|
-
resolveTableDisplayLabel
|
|
69916
|
-
);
|
|
69917
|
-
if (aggAxis.length > 0) {
|
|
69918
|
-
const allowed = new Set(aggAxis.map((a) => a.field));
|
|
69844
|
+
const allowed = new Set(yAxisResolved.measures.map((axis) => axis.field));
|
|
69845
|
+
if (allowed.size > 0) {
|
|
69919
69846
|
eligible = eligible.filter((o) => allowed.has(o.value));
|
|
69920
69847
|
}
|
|
69921
69848
|
}
|
|
69922
69849
|
const merged = new Map(
|
|
69923
69850
|
eligible.map((o) => [o.value, o])
|
|
69924
69851
|
);
|
|
69925
|
-
for (const yAxisField of
|
|
69852
|
+
for (const yAxisField of yAxisResolved.measures) {
|
|
69926
69853
|
const field = String(yAxisField?.field ?? "").trim();
|
|
69927
69854
|
if (!field || merged.has(field)) continue;
|
|
69928
69855
|
const opt = chartAxisOptionByField.get(field);
|
|
@@ -69933,8 +69860,8 @@ function useReport(reportIdArg, options = {}) {
|
|
|
69933
69860
|
chartAxesBaseChart,
|
|
69934
69861
|
chartAxisOptionByField,
|
|
69935
69862
|
chartAxisOptions,
|
|
69936
|
-
|
|
69937
|
-
|
|
69863
|
+
schemaColumnOptions,
|
|
69864
|
+
yAxisResolved.measures
|
|
69938
69865
|
]);
|
|
69939
69866
|
const normalizedChartXAxisOptions = useMemo33(() => {
|
|
69940
69867
|
return xAxisOptions.map((option) => ({
|
|
@@ -69950,34 +69877,9 @@ function useReport(reportIdArg, options = {}) {
|
|
|
69950
69877
|
format: String(option.format ?? "").trim()
|
|
69951
69878
|
}));
|
|
69952
69879
|
}, [yAxisOptions]);
|
|
69953
|
-
const
|
|
69954
|
-
if (
|
|
69955
|
-
|
|
69956
|
-
const field = String(yAxisFieldRaw?.field ?? "").trim();
|
|
69957
|
-
if (!field) return null;
|
|
69958
|
-
const option = chartAxisOptionByField.get(field);
|
|
69959
|
-
if (!option) return null;
|
|
69960
|
-
const rawLabel = String(yAxisFieldRaw?.label ?? "").trim() || option.label;
|
|
69961
|
-
const label = rawLabel === field ? toTitleCaseLabel(field) : rawLabel;
|
|
69962
|
-
const format9 = toAxisFormat(yAxisFieldRaw?.format, option.format);
|
|
69963
|
-
return {
|
|
69964
|
-
field,
|
|
69965
|
-
label,
|
|
69966
|
-
format: format9
|
|
69967
|
-
};
|
|
69968
|
-
};
|
|
69969
|
-
const fallbackYAxisFields = (chartAxesBaseChart.yAxisFields ?? []).map((yAxisField) => normalizeYAxisField(yAxisField)).filter(
|
|
69970
|
-
(yAxisField) => Boolean(yAxisField)
|
|
69971
|
-
);
|
|
69972
|
-
const requestedYAxisFields = Array.isArray(chartAxisEdits.yAxisFields) ? chartAxisEdits.yAxisFields : fallbackYAxisFields;
|
|
69973
|
-
const normalizedRequestedYAxisFields = requestedYAxisFields.map((yAxisField) => normalizeYAxisField(yAxisField)).filter(
|
|
69974
|
-
(yAxisField) => Boolean(yAxisField)
|
|
69975
|
-
);
|
|
69976
|
-
if (normalizedRequestedYAxisFields.length > 0) {
|
|
69977
|
-
return normalizedRequestedYAxisFields;
|
|
69978
|
-
}
|
|
69979
|
-
if (fallbackYAxisFields.length > 0) {
|
|
69980
|
-
return fallbackYAxisFields;
|
|
69880
|
+
const yAxisMeasures = useMemo33(() => {
|
|
69881
|
+
if (yAxisResolved.measures.length > 0) {
|
|
69882
|
+
return yAxisResolved.measures;
|
|
69981
69883
|
}
|
|
69982
69884
|
const fallbackOption = chartAxisOptions[0];
|
|
69983
69885
|
if (!fallbackOption) return [];
|
|
@@ -69988,12 +69890,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
69988
69890
|
format: fallbackOption.format
|
|
69989
69891
|
}
|
|
69990
69892
|
];
|
|
69991
|
-
}, [
|
|
69992
|
-
chartAxesBaseChart,
|
|
69993
|
-
chartAxisEdits.yAxisFields,
|
|
69994
|
-
chartAxisOptionByField,
|
|
69995
|
-
chartAxisOptions
|
|
69996
|
-
]);
|
|
69893
|
+
}, [chartAxisOptions, yAxisResolved.measures]);
|
|
69997
69894
|
const resolvedXAxisField = useMemo33(() => {
|
|
69998
69895
|
if (!chartAxesBaseChart) return "";
|
|
69999
69896
|
const chartType2 = String(chartAxesBaseChart.chartType ?? "").toLowerCase();
|
|
@@ -70008,7 +69905,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70008
69905
|
return pivotRowField;
|
|
70009
69906
|
}
|
|
70010
69907
|
}
|
|
70011
|
-
const requestedXAxisField = String(
|
|
69908
|
+
const requestedXAxisField = String(axisEdits.xAxisField ?? "").trim();
|
|
70012
69909
|
if (requestedXAxisField && chartAxisOptionByField.has(requestedXAxisField)) {
|
|
70013
69910
|
return requestedXAxisField;
|
|
70014
69911
|
}
|
|
@@ -70016,16 +69913,16 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70016
69913
|
if (baseXAxisField && chartAxisOptionByField.has(baseXAxisField)) {
|
|
70017
69914
|
return baseXAxisField;
|
|
70018
69915
|
}
|
|
70019
|
-
return
|
|
69916
|
+
return yAxisMeasures[0]?.field ?? chartAxisOptions[0]?.value ?? "";
|
|
70020
69917
|
}, [
|
|
70021
69918
|
chartAxesBaseChart,
|
|
70022
|
-
|
|
69919
|
+
axisEdits.xAxisField,
|
|
70023
69920
|
chartAxisOptionByField,
|
|
70024
69921
|
chartAxisOptions,
|
|
70025
|
-
|
|
69922
|
+
yAxisMeasures
|
|
70026
69923
|
]);
|
|
70027
69924
|
const xAxisMetadataField = String(
|
|
70028
|
-
|
|
69925
|
+
axisEdits.xAxisField ?? chartData?.xAxisField ?? ""
|
|
70029
69926
|
).trim();
|
|
70030
69927
|
const xAxisMetadataMatchesResolvedField = !xAxisMetadataField || xAxisMetadataField === resolvedXAxisField;
|
|
70031
69928
|
const resolvedXAxisFormat = useMemo33(() => {
|
|
@@ -70033,7 +69930,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70033
69930
|
return "string";
|
|
70034
69931
|
}
|
|
70035
69932
|
let defaultFormat = toAxisFormat(
|
|
70036
|
-
chartAxisOptionByField.get(resolvedXAxisField)?.format ?? chartAxesBaseChart.xAxisFormat ??
|
|
69933
|
+
chartAxisOptionByField.get(resolvedXAxisField)?.format ?? chartAxesBaseChart.xAxisFormat ?? yAxisMeasures[0]?.format,
|
|
70037
69934
|
"string"
|
|
70038
69935
|
);
|
|
70039
69936
|
const bucketFormat = resolvePivotDateBucketXAxisFormat(
|
|
@@ -70041,16 +69938,16 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70041
69938
|
resolvedXAxisField
|
|
70042
69939
|
);
|
|
70043
69940
|
if (bucketFormat) return bucketFormat;
|
|
70044
|
-
if (isPivotTableDateBucketRowAxis(chartAxesBaseChart, resolvedXAxisField) && (!xAxisMetadataMatchesResolvedField ||
|
|
69941
|
+
if (isPivotTableDateBucketRowAxis(chartAxesBaseChart, resolvedXAxisField) && (!xAxisMetadataMatchesResolvedField || axisEdits.xAxisFormat === void 0)) {
|
|
70045
69942
|
defaultFormat = "string";
|
|
70046
69943
|
}
|
|
70047
|
-
return xAxisMetadataMatchesResolvedField &&
|
|
69944
|
+
return xAxisMetadataMatchesResolvedField && axisEdits.xAxisFormat !== void 0 ? toAxisFormat(axisEdits.xAxisFormat, defaultFormat) : defaultFormat;
|
|
70048
69945
|
}, [
|
|
70049
69946
|
chartAxesBaseChart,
|
|
70050
|
-
|
|
69947
|
+
axisEdits.xAxisFormat,
|
|
70051
69948
|
chartAxisOptionByField,
|
|
70052
69949
|
resolvedXAxisField,
|
|
70053
|
-
|
|
69950
|
+
yAxisMeasures,
|
|
70054
69951
|
xAxisMetadataMatchesResolvedField
|
|
70055
69952
|
]);
|
|
70056
69953
|
const resolvedXAxisLabel = useMemo33(() => {
|
|
@@ -70058,13 +69955,13 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70058
69955
|
const defaultXLabel = String(
|
|
70059
69956
|
xAxisMetadataMatchesResolvedField ? chartAxesBaseChart?.xAxisLabel ?? fieldLabel : fieldLabel
|
|
70060
69957
|
).trim();
|
|
70061
|
-
if (xAxisMetadataMatchesResolvedField &&
|
|
70062
|
-
return String(
|
|
69958
|
+
if (xAxisMetadataMatchesResolvedField && axisEdits.xAxisLabel !== void 0) {
|
|
69959
|
+
return String(axisEdits.xAxisLabel).trim();
|
|
70063
69960
|
}
|
|
70064
69961
|
return !defaultXLabel || defaultXLabel === resolvedXAxisField ? toTitleCaseLabel(resolvedXAxisField) : defaultXLabel;
|
|
70065
69962
|
}, [
|
|
70066
69963
|
chartAxesBaseChart?.xAxisLabel,
|
|
70067
|
-
|
|
69964
|
+
axisEdits.xAxisLabel,
|
|
70068
69965
|
chartAxisOptionByField,
|
|
70069
69966
|
resolvedXAxisField,
|
|
70070
69967
|
xAxisMetadataMatchesResolvedField
|
|
@@ -70094,7 +69991,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70094
69991
|
]);
|
|
70095
69992
|
const yAxis = useMemo33(
|
|
70096
69993
|
() => ({
|
|
70097
|
-
fields:
|
|
69994
|
+
fields: yAxisMeasures.map((yAxisField) => ({
|
|
70098
69995
|
field: yAxisField.field,
|
|
70099
69996
|
label: String(yAxisField.label ?? "").trim(),
|
|
70100
69997
|
format: axisFormatToSelectLabel(
|
|
@@ -70102,24 +69999,23 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70102
69999
|
)
|
|
70103
70000
|
}))
|
|
70104
70001
|
}),
|
|
70105
|
-
[
|
|
70002
|
+
[yAxisMeasures]
|
|
70106
70003
|
);
|
|
70107
|
-
const
|
|
70108
|
-
if (
|
|
70109
|
-
|
|
70110
|
-
|
|
70111
|
-
|
|
70112
|
-
|
|
70113
|
-
}, [baseChart, resolvedYAxisFields]);
|
|
70004
|
+
const yAxisSeries = useMemo33(() => {
|
|
70005
|
+
if (yAxisResolved.series.length > 0) {
|
|
70006
|
+
return yAxisResolved.series;
|
|
70007
|
+
}
|
|
70008
|
+
return yAxisMeasures;
|
|
70009
|
+
}, [yAxisMeasures, yAxisResolved.series]);
|
|
70114
70010
|
const chart = useMemo33(() => {
|
|
70115
70011
|
if (!baseChart) return void 0;
|
|
70116
70012
|
let columns2 = mergeChartColumnFormatsFromYAxisFields(
|
|
70117
70013
|
baseChart.columns,
|
|
70118
|
-
|
|
70014
|
+
yAxisSeries
|
|
70119
70015
|
);
|
|
70120
70016
|
if (String(baseChart.chartType ?? "").toLowerCase() === "table" && baseChart.pivot) {
|
|
70121
70017
|
const pivotAggregations2 = getPivotAggregations(baseChart);
|
|
70122
|
-
const hasCustomMeasureLabel =
|
|
70018
|
+
const hasCustomMeasureLabel = yAxisMeasures.some((axis) => {
|
|
70123
70019
|
const aggregation = findAggregationForFieldStrict(
|
|
70124
70020
|
axis.field,
|
|
70125
70021
|
pivotAggregations2
|
|
@@ -70132,7 +70028,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70132
70028
|
if (pivotAggregations2.length > 1 || hasCustomMeasureLabel) {
|
|
70133
70029
|
columns2 = mergePivotTableDisplayColumnLabelsFromYAxis({
|
|
70134
70030
|
columns: columns2 ?? baseChart.columns,
|
|
70135
|
-
yAxisFields:
|
|
70031
|
+
yAxisFields: yAxisSeries,
|
|
70136
70032
|
pivotRowField: pivotRowKey(baseChart),
|
|
70137
70033
|
xAxisLabel: resolvedXAxisLabel
|
|
70138
70034
|
});
|
|
@@ -70159,7 +70055,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70159
70055
|
xAxisField: resolvedXAxisField,
|
|
70160
70056
|
xAxisFormat: resolvedXAxisFormat,
|
|
70161
70057
|
xAxisLabel: resolvedXAxisLabel,
|
|
70162
|
-
yAxisFields:
|
|
70058
|
+
yAxisFields: yAxisSeries,
|
|
70163
70059
|
columns: columns2 ?? baseChart.columns
|
|
70164
70060
|
};
|
|
70165
70061
|
}, [
|
|
@@ -70167,8 +70063,8 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70167
70063
|
resolvedXAxisField,
|
|
70168
70064
|
resolvedXAxisFormat,
|
|
70169
70065
|
resolvedXAxisLabel,
|
|
70170
|
-
|
|
70171
|
-
|
|
70066
|
+
yAxisMeasures,
|
|
70067
|
+
yAxisSeries
|
|
70172
70068
|
]);
|
|
70173
70069
|
const pivotDateFilterRangeCacheRef = useRef24({ key: "", min: null, max: null });
|
|
70174
70070
|
const filterOptions = useMemo33(() => {
|
|
@@ -70186,10 +70082,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70186
70082
|
if (rowField && isDateType(String(pivot?.rowFieldType ?? ""))) {
|
|
70187
70083
|
const field = pivot?.rowFieldTable ? `${pivot.rowFieldTable}.${rowField}` : rowField;
|
|
70188
70084
|
const chartBucket = dateBucket || pivot?.dateBucket || "month";
|
|
70189
|
-
const bucket = inBucketDateBucketForField(
|
|
70190
|
-
filtersForQueryBuilder.rules ?? [],
|
|
70191
|
-
field
|
|
70192
|
-
) ?? chartBucket;
|
|
70085
|
+
const bucket = inBucketDateBucketForField(filtersForQueryBuilder.rules ?? [], field) ?? chartBucket;
|
|
70193
70086
|
const cacheKey = `${String(effectiveReportId ?? "")}\0${field}\0${bucket}`;
|
|
70194
70087
|
if (pivotDateFilterRangeCacheRef.current.key !== cacheKey) {
|
|
70195
70088
|
pivotDateFilterRangeCacheRef.current = {
|
|
@@ -70322,8 +70215,8 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70322
70215
|
[chartForUi, resolvedChartSort]
|
|
70323
70216
|
);
|
|
70324
70217
|
const isPivotTableChart = String(chartType ?? "").toLowerCase() === "table" && Boolean(pivotState);
|
|
70325
|
-
const
|
|
70326
|
-
() => isPivotTableChart ?
|
|
70218
|
+
const pivotTableColumns = useMemo33(
|
|
70219
|
+
() => isPivotTableChart ? buildPivotTableColumns(
|
|
70327
70220
|
pivotState,
|
|
70328
70221
|
chart,
|
|
70329
70222
|
resolveTableDisplayLabel
|
|
@@ -70331,7 +70224,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70331
70224
|
[chart, isPivotTableChart, pivotState, resolveTableDisplayLabel]
|
|
70332
70225
|
);
|
|
70333
70226
|
const chartAxes = useMemo33(() => {
|
|
70334
|
-
const yAxisItems =
|
|
70227
|
+
const yAxisItems = yAxisMeasures.map(
|
|
70335
70228
|
(yAxisField, index) => ({
|
|
70336
70229
|
id: String(index),
|
|
70337
70230
|
field: yAxisField.field,
|
|
@@ -70339,7 +70232,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70339
70232
|
format: toAxisFormat(yAxisField.format, "string")
|
|
70340
70233
|
})
|
|
70341
70234
|
);
|
|
70342
|
-
const getCurrentYAxisFields = () =>
|
|
70235
|
+
const getCurrentYAxisFields = () => yAxisMeasures.map((yAxisField) => ({
|
|
70343
70236
|
field: yAxisField.field,
|
|
70344
70237
|
label: yAxisField.label,
|
|
70345
70238
|
format: toAxisFormat(yAxisField.format, "string")
|
|
@@ -70351,7 +70244,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70351
70244
|
options: xAxisOptions,
|
|
70352
70245
|
formatOptions: AXIS_FORMAT_OPTIONS,
|
|
70353
70246
|
update: (updates) => {
|
|
70354
|
-
|
|
70247
|
+
setAxisEdits((previousEdits) => {
|
|
70355
70248
|
const nextEdits = { ...previousEdits };
|
|
70356
70249
|
if (updates.field !== void 0) {
|
|
70357
70250
|
const requestedField = String(updates.field ?? "").trim();
|
|
@@ -70408,7 +70301,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70408
70301
|
resolvedXAxisFormat || "string"
|
|
70409
70302
|
)
|
|
70410
70303
|
};
|
|
70411
|
-
|
|
70304
|
+
setAxisEdits((previousEdits) => ({
|
|
70412
70305
|
...previousEdits,
|
|
70413
70306
|
yAxisFields: [...currentYAxisFields, nextYAxisField]
|
|
70414
70307
|
}));
|
|
@@ -70421,7 +70314,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70421
70314
|
if (index < 0 || index >= currentYAxisFields.length) return;
|
|
70422
70315
|
const nextYAxisFields = [...currentYAxisFields];
|
|
70423
70316
|
nextYAxisFields.splice(index, 1);
|
|
70424
|
-
|
|
70317
|
+
setAxisEdits((previousEdits) => ({
|
|
70425
70318
|
...previousEdits,
|
|
70426
70319
|
yAxisFields: nextYAxisFields
|
|
70427
70320
|
}));
|
|
@@ -70434,7 +70327,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70434
70327
|
newIndex
|
|
70435
70328
|
);
|
|
70436
70329
|
if (nextYAxisFields === currentYAxisFields) return;
|
|
70437
|
-
|
|
70330
|
+
setAxisEdits((previousEdits) => ({
|
|
70438
70331
|
...previousEdits,
|
|
70439
70332
|
yAxisFields: nextYAxisFields
|
|
70440
70333
|
}));
|
|
@@ -70463,7 +70356,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70463
70356
|
label: nextLabel,
|
|
70464
70357
|
format: nextFormat
|
|
70465
70358
|
};
|
|
70466
|
-
|
|
70359
|
+
setAxisEdits((previousEdits) => ({
|
|
70467
70360
|
...previousEdits,
|
|
70468
70361
|
yAxisFields: nextYAxisFields
|
|
70469
70362
|
}));
|
|
@@ -70475,7 +70368,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70475
70368
|
chartAxisOptionByField,
|
|
70476
70369
|
resolvedXAxisField,
|
|
70477
70370
|
resolvedXAxisFormat,
|
|
70478
|
-
|
|
70371
|
+
yAxisMeasures,
|
|
70479
70372
|
xAxisOptions,
|
|
70480
70373
|
yAxisOptions
|
|
70481
70374
|
]);
|
|
@@ -70507,7 +70400,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70507
70400
|
includeSelectedSchemaFallback: tableColumnsEditedSignature !== null
|
|
70508
70401
|
});
|
|
70509
70402
|
const pivotRowFieldForTable = pivotRowKey(sourceReport);
|
|
70510
|
-
const pivotRowTableUsesAxisFormat =
|
|
70403
|
+
const pivotRowTableUsesAxisFormat = axisEdits.xAxisFormat !== void 0;
|
|
70511
70404
|
const columns2 = String(chartType ?? "").toLowerCase() === "table" && sourceReport?.pivot && pivotRowFieldForTable && String(resolvedXAxisField ?? "").trim() === pivotRowFieldForTable ? mergedFromReport.map(
|
|
70512
70405
|
(column) => column.field === pivotRowFieldForTable ? {
|
|
70513
70406
|
...column,
|
|
@@ -70517,7 +70410,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70517
70410
|
) : mergedFromReport;
|
|
70518
70411
|
const pivotLabeledColumns = String(chartType ?? "").toLowerCase() === "table" && sourceReport?.pivot ? mergePivotTableDisplayColumnLabelsFromYAxis({
|
|
70519
70412
|
columns: columns2,
|
|
70520
|
-
yAxisFields:
|
|
70413
|
+
yAxisFields: yAxisSeries,
|
|
70521
70414
|
pivotRowField: pivotRowKey(sourceReport),
|
|
70522
70415
|
xAxisLabel: resolvedXAxisLabel
|
|
70523
70416
|
}) ?? columns2 : columns2;
|
|
@@ -70593,14 +70486,14 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70593
70486
|
getPageOptions: () => getPageOptionsFromPageCount(paginationPageCount)
|
|
70594
70487
|
};
|
|
70595
70488
|
}, [
|
|
70596
|
-
|
|
70489
|
+
axisEdits.xAxisFormat,
|
|
70597
70490
|
chartType,
|
|
70598
70491
|
displayColumns,
|
|
70599
70492
|
effectiveReportBuilderTableNames,
|
|
70600
70493
|
resolvedXAxisField,
|
|
70601
70494
|
resolvedXAxisFormat,
|
|
70602
70495
|
resolvedXAxisLabel,
|
|
70603
|
-
|
|
70496
|
+
yAxisSeries,
|
|
70604
70497
|
scopedSchemaColumns,
|
|
70605
70498
|
sourceReport,
|
|
70606
70499
|
tableColumnsEditedSignature,
|
|
@@ -70625,11 +70518,11 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70625
70518
|
columnsOptions: tableFormattingColumnOptions,
|
|
70626
70519
|
hasTableDrivenColumnOrder
|
|
70627
70520
|
} = useMemo33(() => {
|
|
70628
|
-
if (
|
|
70521
|
+
if (pivotTableColumns) {
|
|
70629
70522
|
return getAllColumnOptions({
|
|
70630
70523
|
schemaColumnOptions,
|
|
70631
|
-
tableColumns:
|
|
70632
|
-
selectedColumnIds:
|
|
70524
|
+
tableColumns: pivotTableColumns.tableColumns,
|
|
70525
|
+
selectedColumnIds: pivotTableColumns.selectedColumnIds
|
|
70633
70526
|
});
|
|
70634
70527
|
}
|
|
70635
70528
|
if (isPivotTableChart) {
|
|
@@ -70650,7 +70543,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70650
70543
|
chart?.xAxisLabel,
|
|
70651
70544
|
columns,
|
|
70652
70545
|
isPivotTableChart,
|
|
70653
|
-
|
|
70546
|
+
pivotTableColumns,
|
|
70654
70547
|
schemaColumnOptions,
|
|
70655
70548
|
table.columns
|
|
70656
70549
|
]);
|
|
@@ -70672,8 +70565,8 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70672
70565
|
[tableDerivedColumnOrder]
|
|
70673
70566
|
);
|
|
70674
70567
|
const activeTableColumnIds = useMemo33(() => {
|
|
70675
|
-
if (
|
|
70676
|
-
return
|
|
70568
|
+
if (pivotTableColumns) {
|
|
70569
|
+
return pivotTableColumns.selectedColumnIds;
|
|
70677
70570
|
}
|
|
70678
70571
|
if (isPivotTableChart) {
|
|
70679
70572
|
return [];
|
|
@@ -70701,7 +70594,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70701
70594
|
columns,
|
|
70702
70595
|
hasTableDrivenColumnOrder,
|
|
70703
70596
|
isPivotTableChart,
|
|
70704
|
-
|
|
70597
|
+
pivotTableColumns,
|
|
70705
70598
|
tableDerivedColumnOrder,
|
|
70706
70599
|
tableFormattingColumnOptions
|
|
70707
70600
|
]);
|
|
@@ -70762,44 +70655,12 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70762
70655
|
});
|
|
70763
70656
|
}
|
|
70764
70657
|
const columnPivotMeasureFormatByAggregationField = /* @__PURE__ */ new Map();
|
|
70765
|
-
if (
|
|
70766
|
-
const
|
|
70767
|
-
|
|
70768
|
-
const
|
|
70769
|
-
|
|
70770
|
-
|
|
70771
|
-
const firstValueColumnFormat = String(
|
|
70772
|
-
(chart.columns ?? []).find(
|
|
70773
|
-
(c) => String(c.field ?? "").trim() !== rowField
|
|
70774
|
-
)?.format ?? ""
|
|
70775
|
-
).trim();
|
|
70776
|
-
for (let aggIdx = 0; aggIdx < aggregations.length; aggIdx++) {
|
|
70777
|
-
const agg = aggregations[aggIdx];
|
|
70778
|
-
const fieldKey = getAggregationFieldKey(agg, hasMultiple);
|
|
70779
|
-
if (!fieldKey) continue;
|
|
70780
|
-
let fmt = "";
|
|
70781
|
-
if (!hasMultiple) {
|
|
70782
|
-
fmt = String(chart.yAxisFields?.[0]?.format ?? "").trim() || firstValueColumnFormat;
|
|
70783
|
-
} else {
|
|
70784
|
-
for (const yAxisField of chart.yAxisFields ?? []) {
|
|
70785
|
-
const wf = String(yAxisField.field ?? "").trim();
|
|
70786
|
-
if (!wf) continue;
|
|
70787
|
-
const matched = findAggregationForFieldStrict(wf, aggregations);
|
|
70788
|
-
if (!matched || getAggregationIdentityKey(matched) !== getAggregationIdentityKey(agg)) {
|
|
70789
|
-
continue;
|
|
70790
|
-
}
|
|
70791
|
-
fmt = String(yAxisField.format ?? "").trim();
|
|
70792
|
-
break;
|
|
70793
|
-
}
|
|
70794
|
-
if (!fmt && sourceReport?.columns?.[aggIdx + 1]) {
|
|
70795
|
-
fmt = String(
|
|
70796
|
-
sourceReport.columns[aggIdx + 1]?.format ?? ""
|
|
70797
|
-
).trim();
|
|
70798
|
-
}
|
|
70799
|
-
}
|
|
70800
|
-
if (fmt) {
|
|
70801
|
-
columnPivotMeasureFormatByAggregationField.set(fieldKey, fmt);
|
|
70802
|
-
}
|
|
70658
|
+
if (pivotTableColumns) {
|
|
70659
|
+
for (const measure of yAxisResolved.measures) {
|
|
70660
|
+
const field = String(measure.field ?? "").trim();
|
|
70661
|
+
const fmt = String(measure.format ?? "").trim();
|
|
70662
|
+
if (field && fmt) {
|
|
70663
|
+
columnPivotMeasureFormatByAggregationField.set(field, fmt);
|
|
70803
70664
|
}
|
|
70804
70665
|
}
|
|
70805
70666
|
}
|
|
@@ -70850,11 +70711,11 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70850
70711
|
displayColumnById,
|
|
70851
70712
|
isPivotTableChart,
|
|
70852
70713
|
pivotState,
|
|
70853
|
-
|
|
70714
|
+
pivotTableColumns,
|
|
70854
70715
|
resolvedXAxisFormat,
|
|
70855
70716
|
resolvedXAxisLabel,
|
|
70856
|
-
|
|
70857
|
-
|
|
70717
|
+
tableFormatMerge,
|
|
70718
|
+
yAxisResolved.measures
|
|
70858
70719
|
]);
|
|
70859
70720
|
const tableColumnSettingsCoalesceRef = useRef24(
|
|
70860
70721
|
/* @__PURE__ */ new Map()
|
|
@@ -70876,8 +70737,8 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70876
70737
|
const field = String(option?.field ?? "").trim() || columnId;
|
|
70877
70738
|
const tableName = String(option?.tableName ?? "").trim();
|
|
70878
70739
|
const coercedFormat = coerceTableColumnFormatToAxisValue(format9);
|
|
70879
|
-
const
|
|
70880
|
-
const formatLabel =
|
|
70740
|
+
const isPivotDateRow = isPivotTableChart && field === pivotRowFieldForFormat && isDateType(pivotRowFieldType);
|
|
70741
|
+
const formatLabel = isPivotDateRow && coercedFormat === "string" ? "date" : axisFormatToSelectLabel(coercedFormat);
|
|
70881
70742
|
return {
|
|
70882
70743
|
id: columnId,
|
|
70883
70744
|
label: customLabel || defaultLabel,
|
|
@@ -70920,7 +70781,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70920
70781
|
isPivotTableChart,
|
|
70921
70782
|
tableColumnItems
|
|
70922
70783
|
]);
|
|
70923
|
-
const initialLoadInProgress = !reportOverride && Boolean(effectiveReportId) && (!client || initialLoadQuery.isPending || initialLoadQuery.isFetching);
|
|
70784
|
+
const initialLoadInProgress = !reportOverride && Boolean(effectiveReportId) && (!client || initialLoadQuery.isPending || initialLoadQuery.isFetching || reportBuilderStateQuery.isPending || reportBuilderStateQuery.isFetching);
|
|
70924
70785
|
const filterUniqueValuesLoading = filterUniqueValuesEnabled && (filterUniqueValuesQuery.isPending || filterUniqueValuesQuery.isFetching);
|
|
70925
70786
|
const chartLoading = initialLoadInProgress || pendingPivotRefresh || (Boolean(nextPivot) ? pivotRefreshQuery.isFetching : tableRefreshQuery.isFetching);
|
|
70926
70787
|
const awaitingPivotDetailRows = Boolean(nextPivot || sourceReport?.pivot) && !reportOverride && Boolean(sourceReport) && sourceReportMatchesEffectiveReportId && (!Array.isArray(sourceReport?.rows) || sourceReport.rows.length === 0) && pivotTableDataRefreshQuery.status !== "error";
|
|
@@ -71070,15 +70931,15 @@ function useReport(reportIdArg, options = {}) {
|
|
|
71070
70931
|
chartAxesBaseChart
|
|
71071
70932
|
);
|
|
71072
70933
|
const clickedAgg = findAggregationForFieldStrict(pivotField, aggs);
|
|
71073
|
-
let nextY =
|
|
70934
|
+
let nextY = yAxisMeasures;
|
|
71074
70935
|
if (updates.format !== void 0) {
|
|
71075
70936
|
const axisFormatStr = tableColumnFormatFromUiSelection(
|
|
71076
70937
|
String(updates.format ?? "").trim()
|
|
71077
70938
|
);
|
|
71078
|
-
nextY =
|
|
70939
|
+
nextY = yAxisMeasures.map((y) => {
|
|
71079
70940
|
const yAgg = findAggregationForFieldStrict(y.field, aggs);
|
|
71080
70941
|
const same = clickedAgg && yAgg && getAggregationIdentityKey(clickedAgg) === getAggregationIdentityKey(yAgg);
|
|
71081
|
-
const singleBroadcast = Boolean(clickedAgg) &&
|
|
70942
|
+
const singleBroadcast = Boolean(clickedAgg) && yAxisMeasures.length === 1;
|
|
71082
70943
|
if (same || singleBroadcast) {
|
|
71083
70944
|
return {
|
|
71084
70945
|
...y,
|
|
@@ -71093,9 +70954,9 @@ function useReport(reportIdArg, options = {}) {
|
|
|
71093
70954
|
nextY = nextY.map((y) => {
|
|
71094
70955
|
const yAgg = findAggregationForFieldStrict(y.field, aggs);
|
|
71095
70956
|
const same = clickedAgg && yAgg && getAggregationIdentityKey(clickedAgg) === getAggregationIdentityKey(yAgg);
|
|
71096
|
-
const singleBroadcast = Boolean(clickedAgg) &&
|
|
70957
|
+
const singleBroadcast = Boolean(clickedAgg) && yAxisMeasures.length === 1;
|
|
71097
70958
|
if (same || singleBroadcast) {
|
|
71098
|
-
const nextLabel2 =
|
|
70959
|
+
const nextLabel2 = yAxisMeasures.length === 1 && pivotModel.columnField ? mergePivotColumnSeriesLabelWithUserEdit(
|
|
71099
70960
|
String(y.label ?? "").trim(),
|
|
71100
70961
|
lab,
|
|
71101
70962
|
String(y.field ?? "").trim() || void 0
|
|
@@ -71208,7 +71069,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
71208
71069
|
...effectiveNextState.xAxis !== void 0 ? { xAxis: effectiveNextState.xAxis } : {},
|
|
71209
71070
|
...effectiveNextState.yAxis !== void 0 ? { yAxis: effectiveNextState.yAxis } : {}
|
|
71210
71071
|
};
|
|
71211
|
-
|
|
71072
|
+
setAxisEdits((previousEdits) => {
|
|
71212
71073
|
const nextEdits = { ...previousEdits };
|
|
71213
71074
|
if (cx.xAxis) {
|
|
71214
71075
|
let suppressXAxisLabelFromPayload = false;
|
|
@@ -71748,7 +71609,9 @@ function useReport(reportIdArg, options = {}) {
|
|
|
71748
71609
|
};
|
|
71749
71610
|
const saveChanges = useCallback5(
|
|
71750
71611
|
async (overrides) => {
|
|
71751
|
-
if (!client || !sourceReport || !effectiveReportBuilderState)
|
|
71612
|
+
if (!client || !sourceReport || !effectiveReportBuilderState) {
|
|
71613
|
+
return;
|
|
71614
|
+
}
|
|
71752
71615
|
const sourceRest = {
|
|
71753
71616
|
...sourceReport
|
|
71754
71617
|
};
|
|
@@ -71819,7 +71682,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
71819
71682
|
xAxisField: resolvedXAxisField,
|
|
71820
71683
|
xAxisFormat: resolvedXAxisFormat,
|
|
71821
71684
|
xAxisLabel: resolvedXAxisLabel,
|
|
71822
|
-
yAxisFields:
|
|
71685
|
+
yAxisFields: yAxisMeasures,
|
|
71823
71686
|
showLegend: chartVisibility.showLegend,
|
|
71824
71687
|
chartSort: resolvedChartSort ?? null,
|
|
71825
71688
|
...overrides?.filterMap !== void 0 ? { filterMap: overrides.filterMap } : {},
|
|
@@ -71872,7 +71735,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
71872
71735
|
resolvedXAxisField,
|
|
71873
71736
|
resolvedXAxisFormat,
|
|
71874
71737
|
resolvedXAxisLabel,
|
|
71875
|
-
|
|
71738
|
+
yAxisMeasures,
|
|
71876
71739
|
sourceReport,
|
|
71877
71740
|
table.columns,
|
|
71878
71741
|
tenants
|
|
@@ -71907,9 +71770,9 @@ function useReport(reportIdArg, options = {}) {
|
|
|
71907
71770
|
groupColumnsByOptions,
|
|
71908
71771
|
dateBucket: dateBucketMode === "standard" ? pivotState?.dateBucket : dateBucket,
|
|
71909
71772
|
dateBucketOptions: hasDatePivotRow ? dateBucketMode === "standard" ? STANDARD_PIVOT_DATE_BUCKET_OPTIONS : PIVOT_DATE_BUCKET_OPTIONS : [],
|
|
71910
|
-
/** Encoded selection per aggregation
|
|
71773
|
+
/** Encoded selection per aggregation (`'sum:transactions::amount'`, `'count:transactions'`, `''` = placeholder). Update via `setReport({ aggregations: nextStringArray })`. */
|
|
71911
71774
|
aggregations: aggregationValues,
|
|
71912
|
-
/** Flat aggregation pick list shared by all
|
|
71775
|
+
/** Flat aggregation pick list shared by all aggregations; always contains every non-empty `aggregations` entry. */
|
|
71913
71776
|
aggregationOptions,
|
|
71914
71777
|
aggregationDescriptionOptions: cleanedAggregations,
|
|
71915
71778
|
sort: cleanedSort,
|
|
@@ -72854,10 +72717,9 @@ function useReportFilterDraft(args) {
|
|
|
72854
72717
|
);
|
|
72855
72718
|
return stringField?.name ?? fields[0]?.name ?? "";
|
|
72856
72719
|
}, []);
|
|
72857
|
-
const getDefaultValue = useCallback6(
|
|
72858
|
-
|
|
72859
|
-
|
|
72860
|
-
);
|
|
72720
|
+
const getDefaultValue = useCallback6((rule) => {
|
|
72721
|
+
return defaultFilterRuleValueForOperator(rule?.operator);
|
|
72722
|
+
}, []);
|
|
72861
72723
|
const filterDraftQueryBuilderProps = useMemo35(
|
|
72862
72724
|
() => ({
|
|
72863
72725
|
...queryBuilderProps,
|