@quillsql/react 2.16.96 → 2.16.98
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 +344 -552
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +344 -552
- 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,87 +64154,10 @@ 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}`;
|
|
64244
64160
|
}
|
|
64245
|
-
function isNumericishColumnType(type) {
|
|
64246
|
-
const t = String(type ?? "").toLowerCase();
|
|
64247
|
-
return t === "number" || t === "integer" || t === "float" || t === "decimal" || t === "bigint" || t === "double" || t === "whole_number";
|
|
64248
|
-
}
|
|
64249
|
-
function findSchemaColumnForChartAxisField(chartField, schemaOptions) {
|
|
64250
|
-
const f = String(chartField ?? "").trim();
|
|
64251
|
-
if (!f) return void 0;
|
|
64252
|
-
for (const opt of schemaOptions) {
|
|
64253
|
-
if (opt.value === f || opt.field === f) return opt;
|
|
64254
|
-
}
|
|
64255
|
-
return void 0;
|
|
64256
|
-
}
|
|
64257
64161
|
function getAllColumnOptions({
|
|
64258
64162
|
schemaColumnOptions,
|
|
64259
64163
|
tableColumns,
|
|
@@ -66687,7 +66591,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
66687
66591
|
useEffect33(() => {
|
|
66688
66592
|
setTableColumnsEditedSignature(null);
|
|
66689
66593
|
}, [effectiveReportId]);
|
|
66690
|
-
const [
|
|
66594
|
+
const [axisEdits, setAxisEdits] = useState42({});
|
|
66691
66595
|
const [chartVisibilityOverrides, setChartVisibilityOverrides] = useState42({});
|
|
66692
66596
|
const [chartSortOverride, setChartSortOverride] = useState42(void 0);
|
|
66693
66597
|
const [client] = useContext37(ClientContext);
|
|
@@ -66819,7 +66723,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
66819
66723
|
}
|
|
66820
66724
|
}, [createdReportBootstrap?.reportId, propReportId]);
|
|
66821
66725
|
useEffect33(() => {
|
|
66822
|
-
|
|
66726
|
+
setAxisEdits({});
|
|
66823
66727
|
setChartVisibilityOverrides({});
|
|
66824
66728
|
setChartSortOverride(void 0);
|
|
66825
66729
|
}, [effectiveReportId]);
|
|
@@ -69821,20 +69725,18 @@ function useReport(reportIdArg, options = {}) {
|
|
|
69821
69725
|
chartPivotHydrationEpoch
|
|
69822
69726
|
]);
|
|
69823
69727
|
const baseChart = useMemo33(
|
|
69824
|
-
() => normalizePivotChartForDisplay(chartData
|
|
69825
|
-
[chartData
|
|
69728
|
+
() => normalizePivotChartForDisplay(chartData),
|
|
69729
|
+
[chartData]
|
|
69826
69730
|
);
|
|
69827
|
-
const
|
|
69828
|
-
if (!
|
|
69829
|
-
|
|
69830
|
-
|
|
69831
|
-
|
|
69832
|
-
|
|
69833
|
-
|
|
69834
|
-
|
|
69835
|
-
|
|
69836
|
-
return baseChart;
|
|
69837
|
-
}, [baseChart, chartData, effectiveReportId, resolveTableDisplayLabel]);
|
|
69731
|
+
const yAxisResolved = useMemo33(() => {
|
|
69732
|
+
if (!baseChart) return { measures: [], series: [] };
|
|
69733
|
+
return resolveReportYAxis(
|
|
69734
|
+
baseChart,
|
|
69735
|
+
axisEdits.yAxisFields,
|
|
69736
|
+
resolveTableDisplayLabel
|
|
69737
|
+
);
|
|
69738
|
+
}, [baseChart, axisEdits.yAxisFields, resolveTableDisplayLabel]);
|
|
69739
|
+
const chartAxesBaseChart = baseChart;
|
|
69838
69740
|
const chartAxisOptions = useMemo33(() => {
|
|
69839
69741
|
if (!chartAxesBaseChart) return [];
|
|
69840
69742
|
const optionsByField = /* @__PURE__ */ new Map();
|
|
@@ -69853,7 +69755,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
69853
69755
|
for (const column of chartAxesBaseChart.columns ?? []) {
|
|
69854
69756
|
registerOption(column.field, column.label, column.format);
|
|
69855
69757
|
}
|
|
69856
|
-
for (const yAxis2 of
|
|
69758
|
+
for (const yAxis2 of yAxisResolved.measures) {
|
|
69857
69759
|
registerOption(yAxis2.field, yAxis2.label, yAxis2.format);
|
|
69858
69760
|
if (yAxis2.format) {
|
|
69859
69761
|
const existing = optionsByField.get(yAxis2.field);
|
|
@@ -69865,18 +69767,6 @@ function useReport(reportIdArg, options = {}) {
|
|
|
69865
69767
|
}
|
|
69866
69768
|
}
|
|
69867
69769
|
}
|
|
69868
|
-
if (chartAxesBaseChart.pivot?.columnField) {
|
|
69869
|
-
for (const aggregationAxis of buildPivotAggregationAxisFields(
|
|
69870
|
-
chartAxesBaseChart,
|
|
69871
|
-
resolveTableDisplayLabel
|
|
69872
|
-
)) {
|
|
69873
|
-
registerOption(
|
|
69874
|
-
aggregationAxis.field,
|
|
69875
|
-
aggregationAxis.label,
|
|
69876
|
-
aggregationAxis.format
|
|
69877
|
-
);
|
|
69878
|
-
}
|
|
69879
|
-
}
|
|
69880
69770
|
const xField = String(chartAxesBaseChart.xAxisField ?? "").trim();
|
|
69881
69771
|
const savedXFormat = String(chartAxesBaseChart.xAxisFormat ?? "").trim();
|
|
69882
69772
|
registerOption(
|
|
@@ -69894,7 +69784,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
69894
69784
|
}
|
|
69895
69785
|
}
|
|
69896
69786
|
return Array.from(optionsByField.values());
|
|
69897
|
-
}, [chartAxesBaseChart,
|
|
69787
|
+
}, [chartAxesBaseChart, yAxisResolved.measures]);
|
|
69898
69788
|
const chartAxisOptionByField = useMemo33(() => {
|
|
69899
69789
|
const optionsByField = /* @__PURE__ */ new Map();
|
|
69900
69790
|
for (const option of chartAxisOptions) {
|
|
@@ -69925,46 +69815,6 @@ function useReport(reportIdArg, options = {}) {
|
|
|
69925
69815
|
}
|
|
69926
69816
|
return chartAxisOptions;
|
|
69927
69817
|
}, [chartAxesBaseChart, chartAxisOptions, chartAxisOptionByField]);
|
|
69928
|
-
const yAxisOptions = useMemo33(() => {
|
|
69929
|
-
if (!chartAxesBaseChart) return [];
|
|
69930
|
-
const keepOption = (option) => {
|
|
69931
|
-
const col = findSchemaColumnForChartAxisField(
|
|
69932
|
-
option.value,
|
|
69933
|
-
schemaColumnOptions
|
|
69934
|
-
);
|
|
69935
|
-
if (!col) return true;
|
|
69936
|
-
return isNumericishColumnType(col.type);
|
|
69937
|
-
};
|
|
69938
|
-
let eligible = chartAxisOptions.filter(keepOption);
|
|
69939
|
-
const pivot = chartAxesBaseChart.pivot;
|
|
69940
|
-
const pivotRowField = String(pivot?.rowField ?? "").trim();
|
|
69941
|
-
if (pivot && !pivotRowField) {
|
|
69942
|
-
const aggAxis = buildPivotAggregationAxisFields(
|
|
69943
|
-
chartAxesBaseChart,
|
|
69944
|
-
resolveTableDisplayLabel
|
|
69945
|
-
);
|
|
69946
|
-
if (aggAxis.length > 0) {
|
|
69947
|
-
const allowed = new Set(aggAxis.map((a) => a.field));
|
|
69948
|
-
eligible = eligible.filter((o) => allowed.has(o.value));
|
|
69949
|
-
}
|
|
69950
|
-
}
|
|
69951
|
-
const merged = new Map(
|
|
69952
|
-
eligible.map((o) => [o.value, o])
|
|
69953
|
-
);
|
|
69954
|
-
for (const yAxisField of chartAxesBaseChart.yAxisFields ?? []) {
|
|
69955
|
-
const field = String(yAxisField?.field ?? "").trim();
|
|
69956
|
-
if (!field || merged.has(field)) continue;
|
|
69957
|
-
const opt = chartAxisOptionByField.get(field);
|
|
69958
|
-
if (opt) merged.set(field, opt);
|
|
69959
|
-
}
|
|
69960
|
-
return Array.from(merged.values());
|
|
69961
|
-
}, [
|
|
69962
|
-
chartAxesBaseChart,
|
|
69963
|
-
chartAxisOptionByField,
|
|
69964
|
-
chartAxisOptions,
|
|
69965
|
-
resolveTableDisplayLabel,
|
|
69966
|
-
schemaColumnOptions
|
|
69967
|
-
]);
|
|
69968
69818
|
const normalizedChartXAxisOptions = useMemo33(() => {
|
|
69969
69819
|
return xAxisOptions.map((option) => ({
|
|
69970
69820
|
value: String(option.value ?? "").trim(),
|
|
@@ -69972,41 +69822,9 @@ function useReport(reportIdArg, options = {}) {
|
|
|
69972
69822
|
format: String(option.format ?? "").trim()
|
|
69973
69823
|
}));
|
|
69974
69824
|
}, [xAxisOptions]);
|
|
69975
|
-
const
|
|
69976
|
-
|
|
69977
|
-
|
|
69978
|
-
label: String(option.label ?? option.value ?? "").trim(),
|
|
69979
|
-
format: String(option.format ?? "").trim()
|
|
69980
|
-
}));
|
|
69981
|
-
}, [yAxisOptions]);
|
|
69982
|
-
const resolvedYAxisFields = useMemo33(() => {
|
|
69983
|
-
if (!chartAxesBaseChart) return [];
|
|
69984
|
-
const normalizeYAxisField = (yAxisFieldRaw) => {
|
|
69985
|
-
const field = String(yAxisFieldRaw?.field ?? "").trim();
|
|
69986
|
-
if (!field) return null;
|
|
69987
|
-
const option = chartAxisOptionByField.get(field);
|
|
69988
|
-
if (!option) return null;
|
|
69989
|
-
const rawLabel = String(yAxisFieldRaw?.label ?? "").trim() || option.label;
|
|
69990
|
-
const label = rawLabel === field ? toTitleCaseLabel(field) : rawLabel;
|
|
69991
|
-
const format9 = toAxisFormat(yAxisFieldRaw?.format, option.format);
|
|
69992
|
-
return {
|
|
69993
|
-
field,
|
|
69994
|
-
label,
|
|
69995
|
-
format: format9
|
|
69996
|
-
};
|
|
69997
|
-
};
|
|
69998
|
-
const fallbackYAxisFields = (chartAxesBaseChart.yAxisFields ?? []).map((yAxisField) => normalizeYAxisField(yAxisField)).filter(
|
|
69999
|
-
(yAxisField) => Boolean(yAxisField)
|
|
70000
|
-
);
|
|
70001
|
-
const requestedYAxisFields = Array.isArray(chartAxisEdits.yAxisFields) ? chartAxisEdits.yAxisFields : fallbackYAxisFields;
|
|
70002
|
-
const normalizedRequestedYAxisFields = requestedYAxisFields.map((yAxisField) => normalizeYAxisField(yAxisField)).filter(
|
|
70003
|
-
(yAxisField) => Boolean(yAxisField)
|
|
70004
|
-
);
|
|
70005
|
-
if (normalizedRequestedYAxisFields.length > 0) {
|
|
70006
|
-
return normalizedRequestedYAxisFields;
|
|
70007
|
-
}
|
|
70008
|
-
if (fallbackYAxisFields.length > 0) {
|
|
70009
|
-
return fallbackYAxisFields;
|
|
69825
|
+
const yAxisMeasures = useMemo33(() => {
|
|
69826
|
+
if (yAxisResolved.measures.length > 0) {
|
|
69827
|
+
return yAxisResolved.measures;
|
|
70010
69828
|
}
|
|
70011
69829
|
const fallbackOption = chartAxisOptions[0];
|
|
70012
69830
|
if (!fallbackOption) return [];
|
|
@@ -70017,12 +69835,22 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70017
69835
|
format: fallbackOption.format
|
|
70018
69836
|
}
|
|
70019
69837
|
];
|
|
70020
|
-
}, [
|
|
70021
|
-
|
|
70022
|
-
|
|
70023
|
-
|
|
70024
|
-
|
|
70025
|
-
|
|
69838
|
+
}, [chartAxisOptions, yAxisResolved.measures]);
|
|
69839
|
+
const yAxisOptions = useMemo33(
|
|
69840
|
+
() => yAxisMeasures.map((measure) => ({
|
|
69841
|
+
value: measure.field,
|
|
69842
|
+
label: measure.label,
|
|
69843
|
+
format: toAxisFormat(measure.format, "string")
|
|
69844
|
+
})),
|
|
69845
|
+
[yAxisMeasures]
|
|
69846
|
+
);
|
|
69847
|
+
const normalizedChartYAxisOptions = useMemo33(() => {
|
|
69848
|
+
return yAxisOptions.map((option) => ({
|
|
69849
|
+
value: String(option.value ?? "").trim(),
|
|
69850
|
+
label: String(option.label ?? option.value ?? "").trim(),
|
|
69851
|
+
format: String(option.format ?? "").trim()
|
|
69852
|
+
}));
|
|
69853
|
+
}, [yAxisOptions]);
|
|
70026
69854
|
const resolvedXAxisField = useMemo33(() => {
|
|
70027
69855
|
if (!chartAxesBaseChart) return "";
|
|
70028
69856
|
const chartType2 = String(chartAxesBaseChart.chartType ?? "").toLowerCase();
|
|
@@ -70037,7 +69865,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70037
69865
|
return pivotRowField;
|
|
70038
69866
|
}
|
|
70039
69867
|
}
|
|
70040
|
-
const requestedXAxisField = String(
|
|
69868
|
+
const requestedXAxisField = String(axisEdits.xAxisField ?? "").trim();
|
|
70041
69869
|
if (requestedXAxisField && chartAxisOptionByField.has(requestedXAxisField)) {
|
|
70042
69870
|
return requestedXAxisField;
|
|
70043
69871
|
}
|
|
@@ -70045,16 +69873,16 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70045
69873
|
if (baseXAxisField && chartAxisOptionByField.has(baseXAxisField)) {
|
|
70046
69874
|
return baseXAxisField;
|
|
70047
69875
|
}
|
|
70048
|
-
return
|
|
69876
|
+
return yAxisMeasures[0]?.field ?? chartAxisOptions[0]?.value ?? "";
|
|
70049
69877
|
}, [
|
|
70050
69878
|
chartAxesBaseChart,
|
|
70051
|
-
|
|
69879
|
+
axisEdits.xAxisField,
|
|
70052
69880
|
chartAxisOptionByField,
|
|
70053
69881
|
chartAxisOptions,
|
|
70054
|
-
|
|
69882
|
+
yAxisMeasures
|
|
70055
69883
|
]);
|
|
70056
69884
|
const xAxisMetadataField = String(
|
|
70057
|
-
|
|
69885
|
+
axisEdits.xAxisField ?? chartData?.xAxisField ?? ""
|
|
70058
69886
|
).trim();
|
|
70059
69887
|
const xAxisMetadataMatchesResolvedField = !xAxisMetadataField || xAxisMetadataField === resolvedXAxisField;
|
|
70060
69888
|
const resolvedXAxisFormat = useMemo33(() => {
|
|
@@ -70062,7 +69890,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70062
69890
|
return "string";
|
|
70063
69891
|
}
|
|
70064
69892
|
let defaultFormat = toAxisFormat(
|
|
70065
|
-
chartAxisOptionByField.get(resolvedXAxisField)?.format ?? chartAxesBaseChart.xAxisFormat ??
|
|
69893
|
+
chartAxisOptionByField.get(resolvedXAxisField)?.format ?? chartAxesBaseChart.xAxisFormat ?? yAxisMeasures[0]?.format,
|
|
70066
69894
|
"string"
|
|
70067
69895
|
);
|
|
70068
69896
|
const bucketFormat = resolvePivotDateBucketXAxisFormat(
|
|
@@ -70070,16 +69898,16 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70070
69898
|
resolvedXAxisField
|
|
70071
69899
|
);
|
|
70072
69900
|
if (bucketFormat) return bucketFormat;
|
|
70073
|
-
if (isPivotTableDateBucketRowAxis(chartAxesBaseChart, resolvedXAxisField) && (!xAxisMetadataMatchesResolvedField ||
|
|
69901
|
+
if (isPivotTableDateBucketRowAxis(chartAxesBaseChart, resolvedXAxisField) && (!xAxisMetadataMatchesResolvedField || axisEdits.xAxisFormat === void 0)) {
|
|
70074
69902
|
defaultFormat = "string";
|
|
70075
69903
|
}
|
|
70076
|
-
return xAxisMetadataMatchesResolvedField &&
|
|
69904
|
+
return xAxisMetadataMatchesResolvedField && axisEdits.xAxisFormat !== void 0 ? toAxisFormat(axisEdits.xAxisFormat, defaultFormat) : defaultFormat;
|
|
70077
69905
|
}, [
|
|
70078
69906
|
chartAxesBaseChart,
|
|
70079
|
-
|
|
69907
|
+
axisEdits.xAxisFormat,
|
|
70080
69908
|
chartAxisOptionByField,
|
|
70081
69909
|
resolvedXAxisField,
|
|
70082
|
-
|
|
69910
|
+
yAxisMeasures,
|
|
70083
69911
|
xAxisMetadataMatchesResolvedField
|
|
70084
69912
|
]);
|
|
70085
69913
|
const resolvedXAxisLabel = useMemo33(() => {
|
|
@@ -70087,13 +69915,13 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70087
69915
|
const defaultXLabel = String(
|
|
70088
69916
|
xAxisMetadataMatchesResolvedField ? chartAxesBaseChart?.xAxisLabel ?? fieldLabel : fieldLabel
|
|
70089
69917
|
).trim();
|
|
70090
|
-
if (xAxisMetadataMatchesResolvedField &&
|
|
70091
|
-
return String(
|
|
69918
|
+
if (xAxisMetadataMatchesResolvedField && axisEdits.xAxisLabel !== void 0) {
|
|
69919
|
+
return String(axisEdits.xAxisLabel).trim();
|
|
70092
69920
|
}
|
|
70093
69921
|
return !defaultXLabel || defaultXLabel === resolvedXAxisField ? toTitleCaseLabel(resolvedXAxisField) : defaultXLabel;
|
|
70094
69922
|
}, [
|
|
70095
69923
|
chartAxesBaseChart?.xAxisLabel,
|
|
70096
|
-
|
|
69924
|
+
axisEdits.xAxisLabel,
|
|
70097
69925
|
chartAxisOptionByField,
|
|
70098
69926
|
resolvedXAxisField,
|
|
70099
69927
|
xAxisMetadataMatchesResolvedField
|
|
@@ -70123,7 +69951,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70123
69951
|
]);
|
|
70124
69952
|
const yAxis = useMemo33(
|
|
70125
69953
|
() => ({
|
|
70126
|
-
fields:
|
|
69954
|
+
fields: yAxisMeasures.map((yAxisField) => ({
|
|
70127
69955
|
field: yAxisField.field,
|
|
70128
69956
|
label: String(yAxisField.label ?? "").trim(),
|
|
70129
69957
|
format: axisFormatToSelectLabel(
|
|
@@ -70131,24 +69959,23 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70131
69959
|
)
|
|
70132
69960
|
}))
|
|
70133
69961
|
}),
|
|
70134
|
-
[
|
|
69962
|
+
[yAxisMeasures]
|
|
70135
69963
|
);
|
|
70136
|
-
const
|
|
70137
|
-
if (
|
|
70138
|
-
|
|
70139
|
-
|
|
70140
|
-
|
|
70141
|
-
|
|
70142
|
-
}, [baseChart, resolvedYAxisFields]);
|
|
69964
|
+
const yAxisSeries = useMemo33(() => {
|
|
69965
|
+
if (yAxisResolved.series.length > 0) {
|
|
69966
|
+
return yAxisResolved.series;
|
|
69967
|
+
}
|
|
69968
|
+
return yAxisMeasures;
|
|
69969
|
+
}, [yAxisMeasures, yAxisResolved.series]);
|
|
70143
69970
|
const chart = useMemo33(() => {
|
|
70144
69971
|
if (!baseChart) return void 0;
|
|
70145
69972
|
let columns2 = mergeChartColumnFormatsFromYAxisFields(
|
|
70146
69973
|
baseChart.columns,
|
|
70147
|
-
|
|
69974
|
+
yAxisSeries
|
|
70148
69975
|
);
|
|
70149
69976
|
if (String(baseChart.chartType ?? "").toLowerCase() === "table" && baseChart.pivot) {
|
|
70150
69977
|
const pivotAggregations2 = getPivotAggregations(baseChart);
|
|
70151
|
-
const hasCustomMeasureLabel =
|
|
69978
|
+
const hasCustomMeasureLabel = yAxisMeasures.some((axis) => {
|
|
70152
69979
|
const aggregation = findAggregationForFieldStrict(
|
|
70153
69980
|
axis.field,
|
|
70154
69981
|
pivotAggregations2
|
|
@@ -70161,7 +69988,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70161
69988
|
if (pivotAggregations2.length > 1 || hasCustomMeasureLabel) {
|
|
70162
69989
|
columns2 = mergePivotTableDisplayColumnLabelsFromYAxis({
|
|
70163
69990
|
columns: columns2 ?? baseChart.columns,
|
|
70164
|
-
yAxisFields:
|
|
69991
|
+
yAxisFields: yAxisSeries,
|
|
70165
69992
|
pivotRowField: pivotRowKey(baseChart),
|
|
70166
69993
|
xAxisLabel: resolvedXAxisLabel
|
|
70167
69994
|
});
|
|
@@ -70188,7 +70015,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70188
70015
|
xAxisField: resolvedXAxisField,
|
|
70189
70016
|
xAxisFormat: resolvedXAxisFormat,
|
|
70190
70017
|
xAxisLabel: resolvedXAxisLabel,
|
|
70191
|
-
yAxisFields:
|
|
70018
|
+
yAxisFields: yAxisSeries,
|
|
70192
70019
|
columns: columns2 ?? baseChart.columns
|
|
70193
70020
|
};
|
|
70194
70021
|
}, [
|
|
@@ -70196,8 +70023,8 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70196
70023
|
resolvedXAxisField,
|
|
70197
70024
|
resolvedXAxisFormat,
|
|
70198
70025
|
resolvedXAxisLabel,
|
|
70199
|
-
|
|
70200
|
-
|
|
70026
|
+
yAxisMeasures,
|
|
70027
|
+
yAxisSeries
|
|
70201
70028
|
]);
|
|
70202
70029
|
const pivotDateFilterRangeCacheRef = useRef24({ key: "", min: null, max: null });
|
|
70203
70030
|
const filterOptions = useMemo33(() => {
|
|
@@ -70215,10 +70042,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70215
70042
|
if (rowField && isDateType(String(pivot?.rowFieldType ?? ""))) {
|
|
70216
70043
|
const field = pivot?.rowFieldTable ? `${pivot.rowFieldTable}.${rowField}` : rowField;
|
|
70217
70044
|
const chartBucket = dateBucket || pivot?.dateBucket || "month";
|
|
70218
|
-
const bucket = inBucketDateBucketForField(
|
|
70219
|
-
filtersForQueryBuilder.rules ?? [],
|
|
70220
|
-
field
|
|
70221
|
-
) ?? chartBucket;
|
|
70045
|
+
const bucket = inBucketDateBucketForField(filtersForQueryBuilder.rules ?? [], field) ?? chartBucket;
|
|
70222
70046
|
const cacheKey = `${String(effectiveReportId ?? "")}\0${field}\0${bucket}`;
|
|
70223
70047
|
if (pivotDateFilterRangeCacheRef.current.key !== cacheKey) {
|
|
70224
70048
|
pivotDateFilterRangeCacheRef.current = {
|
|
@@ -70351,8 +70175,8 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70351
70175
|
[chartForUi, resolvedChartSort]
|
|
70352
70176
|
);
|
|
70353
70177
|
const isPivotTableChart = String(chartType ?? "").toLowerCase() === "table" && Boolean(pivotState);
|
|
70354
|
-
const
|
|
70355
|
-
() => isPivotTableChart ?
|
|
70178
|
+
const pivotTableColumns = useMemo33(
|
|
70179
|
+
() => isPivotTableChart ? buildPivotTableColumns(
|
|
70356
70180
|
pivotState,
|
|
70357
70181
|
chart,
|
|
70358
70182
|
resolveTableDisplayLabel
|
|
@@ -70360,7 +70184,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70360
70184
|
[chart, isPivotTableChart, pivotState, resolveTableDisplayLabel]
|
|
70361
70185
|
);
|
|
70362
70186
|
const chartAxes = useMemo33(() => {
|
|
70363
|
-
const yAxisItems =
|
|
70187
|
+
const yAxisItems = yAxisMeasures.map(
|
|
70364
70188
|
(yAxisField, index) => ({
|
|
70365
70189
|
id: String(index),
|
|
70366
70190
|
field: yAxisField.field,
|
|
@@ -70368,7 +70192,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70368
70192
|
format: toAxisFormat(yAxisField.format, "string")
|
|
70369
70193
|
})
|
|
70370
70194
|
);
|
|
70371
|
-
const getCurrentYAxisFields = () =>
|
|
70195
|
+
const getCurrentYAxisFields = () => yAxisMeasures.map((yAxisField) => ({
|
|
70372
70196
|
field: yAxisField.field,
|
|
70373
70197
|
label: yAxisField.label,
|
|
70374
70198
|
format: toAxisFormat(yAxisField.format, "string")
|
|
@@ -70380,7 +70204,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70380
70204
|
options: xAxisOptions,
|
|
70381
70205
|
formatOptions: AXIS_FORMAT_OPTIONS,
|
|
70382
70206
|
update: (updates) => {
|
|
70383
|
-
|
|
70207
|
+
setAxisEdits((previousEdits) => {
|
|
70384
70208
|
const nextEdits = { ...previousEdits };
|
|
70385
70209
|
if (updates.field !== void 0) {
|
|
70386
70210
|
const requestedField = String(updates.field ?? "").trim();
|
|
@@ -70437,7 +70261,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70437
70261
|
resolvedXAxisFormat || "string"
|
|
70438
70262
|
)
|
|
70439
70263
|
};
|
|
70440
|
-
|
|
70264
|
+
setAxisEdits((previousEdits) => ({
|
|
70441
70265
|
...previousEdits,
|
|
70442
70266
|
yAxisFields: [...currentYAxisFields, nextYAxisField]
|
|
70443
70267
|
}));
|
|
@@ -70450,7 +70274,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70450
70274
|
if (index < 0 || index >= currentYAxisFields.length) return;
|
|
70451
70275
|
const nextYAxisFields = [...currentYAxisFields];
|
|
70452
70276
|
nextYAxisFields.splice(index, 1);
|
|
70453
|
-
|
|
70277
|
+
setAxisEdits((previousEdits) => ({
|
|
70454
70278
|
...previousEdits,
|
|
70455
70279
|
yAxisFields: nextYAxisFields
|
|
70456
70280
|
}));
|
|
@@ -70463,7 +70287,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70463
70287
|
newIndex
|
|
70464
70288
|
);
|
|
70465
70289
|
if (nextYAxisFields === currentYAxisFields) return;
|
|
70466
|
-
|
|
70290
|
+
setAxisEdits((previousEdits) => ({
|
|
70467
70291
|
...previousEdits,
|
|
70468
70292
|
yAxisFields: nextYAxisFields
|
|
70469
70293
|
}));
|
|
@@ -70492,7 +70316,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70492
70316
|
label: nextLabel,
|
|
70493
70317
|
format: nextFormat
|
|
70494
70318
|
};
|
|
70495
|
-
|
|
70319
|
+
setAxisEdits((previousEdits) => ({
|
|
70496
70320
|
...previousEdits,
|
|
70497
70321
|
yAxisFields: nextYAxisFields
|
|
70498
70322
|
}));
|
|
@@ -70504,7 +70328,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70504
70328
|
chartAxisOptionByField,
|
|
70505
70329
|
resolvedXAxisField,
|
|
70506
70330
|
resolvedXAxisFormat,
|
|
70507
|
-
|
|
70331
|
+
yAxisMeasures,
|
|
70508
70332
|
xAxisOptions,
|
|
70509
70333
|
yAxisOptions
|
|
70510
70334
|
]);
|
|
@@ -70536,7 +70360,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70536
70360
|
includeSelectedSchemaFallback: tableColumnsEditedSignature !== null
|
|
70537
70361
|
});
|
|
70538
70362
|
const pivotRowFieldForTable = pivotRowKey(sourceReport);
|
|
70539
|
-
const pivotRowTableUsesAxisFormat =
|
|
70363
|
+
const pivotRowTableUsesAxisFormat = axisEdits.xAxisFormat !== void 0;
|
|
70540
70364
|
const columns2 = String(chartType ?? "").toLowerCase() === "table" && sourceReport?.pivot && pivotRowFieldForTable && String(resolvedXAxisField ?? "").trim() === pivotRowFieldForTable ? mergedFromReport.map(
|
|
70541
70365
|
(column) => column.field === pivotRowFieldForTable ? {
|
|
70542
70366
|
...column,
|
|
@@ -70546,7 +70370,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70546
70370
|
) : mergedFromReport;
|
|
70547
70371
|
const pivotLabeledColumns = String(chartType ?? "").toLowerCase() === "table" && sourceReport?.pivot ? mergePivotTableDisplayColumnLabelsFromYAxis({
|
|
70548
70372
|
columns: columns2,
|
|
70549
|
-
yAxisFields:
|
|
70373
|
+
yAxisFields: yAxisSeries,
|
|
70550
70374
|
pivotRowField: pivotRowKey(sourceReport),
|
|
70551
70375
|
xAxisLabel: resolvedXAxisLabel
|
|
70552
70376
|
}) ?? columns2 : columns2;
|
|
@@ -70622,14 +70446,14 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70622
70446
|
getPageOptions: () => getPageOptionsFromPageCount(paginationPageCount)
|
|
70623
70447
|
};
|
|
70624
70448
|
}, [
|
|
70625
|
-
|
|
70449
|
+
axisEdits.xAxisFormat,
|
|
70626
70450
|
chartType,
|
|
70627
70451
|
displayColumns,
|
|
70628
70452
|
effectiveReportBuilderTableNames,
|
|
70629
70453
|
resolvedXAxisField,
|
|
70630
70454
|
resolvedXAxisFormat,
|
|
70631
70455
|
resolvedXAxisLabel,
|
|
70632
|
-
|
|
70456
|
+
yAxisSeries,
|
|
70633
70457
|
scopedSchemaColumns,
|
|
70634
70458
|
sourceReport,
|
|
70635
70459
|
tableColumnsEditedSignature,
|
|
@@ -70654,11 +70478,11 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70654
70478
|
columnsOptions: tableFormattingColumnOptions,
|
|
70655
70479
|
hasTableDrivenColumnOrder
|
|
70656
70480
|
} = useMemo33(() => {
|
|
70657
|
-
if (
|
|
70481
|
+
if (pivotTableColumns) {
|
|
70658
70482
|
return getAllColumnOptions({
|
|
70659
70483
|
schemaColumnOptions,
|
|
70660
|
-
tableColumns:
|
|
70661
|
-
selectedColumnIds:
|
|
70484
|
+
tableColumns: pivotTableColumns.tableColumns,
|
|
70485
|
+
selectedColumnIds: pivotTableColumns.selectedColumnIds
|
|
70662
70486
|
});
|
|
70663
70487
|
}
|
|
70664
70488
|
if (isPivotTableChart) {
|
|
@@ -70679,7 +70503,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70679
70503
|
chart?.xAxisLabel,
|
|
70680
70504
|
columns,
|
|
70681
70505
|
isPivotTableChart,
|
|
70682
|
-
|
|
70506
|
+
pivotTableColumns,
|
|
70683
70507
|
schemaColumnOptions,
|
|
70684
70508
|
table.columns
|
|
70685
70509
|
]);
|
|
@@ -70701,8 +70525,8 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70701
70525
|
[tableDerivedColumnOrder]
|
|
70702
70526
|
);
|
|
70703
70527
|
const activeTableColumnIds = useMemo33(() => {
|
|
70704
|
-
if (
|
|
70705
|
-
return
|
|
70528
|
+
if (pivotTableColumns) {
|
|
70529
|
+
return pivotTableColumns.selectedColumnIds;
|
|
70706
70530
|
}
|
|
70707
70531
|
if (isPivotTableChart) {
|
|
70708
70532
|
return [];
|
|
@@ -70730,7 +70554,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70730
70554
|
columns,
|
|
70731
70555
|
hasTableDrivenColumnOrder,
|
|
70732
70556
|
isPivotTableChart,
|
|
70733
|
-
|
|
70557
|
+
pivotTableColumns,
|
|
70734
70558
|
tableDerivedColumnOrder,
|
|
70735
70559
|
tableFormattingColumnOptions
|
|
70736
70560
|
]);
|
|
@@ -70791,44 +70615,12 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70791
70615
|
});
|
|
70792
70616
|
}
|
|
70793
70617
|
const columnPivotMeasureFormatByAggregationField = /* @__PURE__ */ new Map();
|
|
70794
|
-
if (
|
|
70795
|
-
const
|
|
70796
|
-
|
|
70797
|
-
const
|
|
70798
|
-
|
|
70799
|
-
|
|
70800
|
-
const firstValueColumnFormat = String(
|
|
70801
|
-
(chart.columns ?? []).find(
|
|
70802
|
-
(c) => String(c.field ?? "").trim() !== rowField
|
|
70803
|
-
)?.format ?? ""
|
|
70804
|
-
).trim();
|
|
70805
|
-
for (let aggIdx = 0; aggIdx < aggregations.length; aggIdx++) {
|
|
70806
|
-
const agg = aggregations[aggIdx];
|
|
70807
|
-
const fieldKey = getAggregationFieldKey(agg, hasMultiple);
|
|
70808
|
-
if (!fieldKey) continue;
|
|
70809
|
-
let fmt = "";
|
|
70810
|
-
if (!hasMultiple) {
|
|
70811
|
-
fmt = String(chart.yAxisFields?.[0]?.format ?? "").trim() || firstValueColumnFormat;
|
|
70812
|
-
} else {
|
|
70813
|
-
for (const yAxisField of chart.yAxisFields ?? []) {
|
|
70814
|
-
const wf = String(yAxisField.field ?? "").trim();
|
|
70815
|
-
if (!wf) continue;
|
|
70816
|
-
const matched = findAggregationForFieldStrict(wf, aggregations);
|
|
70817
|
-
if (!matched || getAggregationIdentityKey(matched) !== getAggregationIdentityKey(agg)) {
|
|
70818
|
-
continue;
|
|
70819
|
-
}
|
|
70820
|
-
fmt = String(yAxisField.format ?? "").trim();
|
|
70821
|
-
break;
|
|
70822
|
-
}
|
|
70823
|
-
if (!fmt && sourceReport?.columns?.[aggIdx + 1]) {
|
|
70824
|
-
fmt = String(
|
|
70825
|
-
sourceReport.columns[aggIdx + 1]?.format ?? ""
|
|
70826
|
-
).trim();
|
|
70827
|
-
}
|
|
70828
|
-
}
|
|
70829
|
-
if (fmt) {
|
|
70830
|
-
columnPivotMeasureFormatByAggregationField.set(fieldKey, fmt);
|
|
70831
|
-
}
|
|
70618
|
+
if (pivotTableColumns) {
|
|
70619
|
+
for (const measure of yAxisResolved.measures) {
|
|
70620
|
+
const field = String(measure.field ?? "").trim();
|
|
70621
|
+
const fmt = String(measure.format ?? "").trim();
|
|
70622
|
+
if (field && fmt) {
|
|
70623
|
+
columnPivotMeasureFormatByAggregationField.set(field, fmt);
|
|
70832
70624
|
}
|
|
70833
70625
|
}
|
|
70834
70626
|
}
|
|
@@ -70879,11 +70671,11 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70879
70671
|
displayColumnById,
|
|
70880
70672
|
isPivotTableChart,
|
|
70881
70673
|
pivotState,
|
|
70882
|
-
|
|
70674
|
+
pivotTableColumns,
|
|
70883
70675
|
resolvedXAxisFormat,
|
|
70884
70676
|
resolvedXAxisLabel,
|
|
70885
|
-
|
|
70886
|
-
|
|
70677
|
+
tableFormatMerge,
|
|
70678
|
+
yAxisResolved.measures
|
|
70887
70679
|
]);
|
|
70888
70680
|
const tableColumnSettingsCoalesceRef = useRef24(
|
|
70889
70681
|
/* @__PURE__ */ new Map()
|
|
@@ -70905,8 +70697,8 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70905
70697
|
const field = String(option?.field ?? "").trim() || columnId;
|
|
70906
70698
|
const tableName = String(option?.tableName ?? "").trim();
|
|
70907
70699
|
const coercedFormat = coerceTableColumnFormatToAxisValue(format9);
|
|
70908
|
-
const
|
|
70909
|
-
const formatLabel =
|
|
70700
|
+
const isPivotDateRow = isPivotTableChart && field === pivotRowFieldForFormat && isDateType(pivotRowFieldType);
|
|
70701
|
+
const formatLabel = isPivotDateRow && coercedFormat === "string" ? "date" : axisFormatToSelectLabel(coercedFormat);
|
|
70910
70702
|
return {
|
|
70911
70703
|
id: columnId,
|
|
70912
70704
|
label: customLabel || defaultLabel,
|
|
@@ -71099,15 +70891,15 @@ function useReport(reportIdArg, options = {}) {
|
|
|
71099
70891
|
chartAxesBaseChart
|
|
71100
70892
|
);
|
|
71101
70893
|
const clickedAgg = findAggregationForFieldStrict(pivotField, aggs);
|
|
71102
|
-
let nextY =
|
|
70894
|
+
let nextY = yAxisMeasures;
|
|
71103
70895
|
if (updates.format !== void 0) {
|
|
71104
70896
|
const axisFormatStr = tableColumnFormatFromUiSelection(
|
|
71105
70897
|
String(updates.format ?? "").trim()
|
|
71106
70898
|
);
|
|
71107
|
-
nextY =
|
|
70899
|
+
nextY = yAxisMeasures.map((y) => {
|
|
71108
70900
|
const yAgg = findAggregationForFieldStrict(y.field, aggs);
|
|
71109
70901
|
const same = clickedAgg && yAgg && getAggregationIdentityKey(clickedAgg) === getAggregationIdentityKey(yAgg);
|
|
71110
|
-
const singleBroadcast = Boolean(clickedAgg) &&
|
|
70902
|
+
const singleBroadcast = Boolean(clickedAgg) && yAxisMeasures.length === 1;
|
|
71111
70903
|
if (same || singleBroadcast) {
|
|
71112
70904
|
return {
|
|
71113
70905
|
...y,
|
|
@@ -71122,9 +70914,9 @@ function useReport(reportIdArg, options = {}) {
|
|
|
71122
70914
|
nextY = nextY.map((y) => {
|
|
71123
70915
|
const yAgg = findAggregationForFieldStrict(y.field, aggs);
|
|
71124
70916
|
const same = clickedAgg && yAgg && getAggregationIdentityKey(clickedAgg) === getAggregationIdentityKey(yAgg);
|
|
71125
|
-
const singleBroadcast = Boolean(clickedAgg) &&
|
|
70917
|
+
const singleBroadcast = Boolean(clickedAgg) && yAxisMeasures.length === 1;
|
|
71126
70918
|
if (same || singleBroadcast) {
|
|
71127
|
-
const nextLabel2 =
|
|
70919
|
+
const nextLabel2 = yAxisMeasures.length === 1 && pivotModel.columnField ? mergePivotColumnSeriesLabelWithUserEdit(
|
|
71128
70920
|
String(y.label ?? "").trim(),
|
|
71129
70921
|
lab,
|
|
71130
70922
|
String(y.field ?? "").trim() || void 0
|
|
@@ -71237,7 +71029,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
71237
71029
|
...effectiveNextState.xAxis !== void 0 ? { xAxis: effectiveNextState.xAxis } : {},
|
|
71238
71030
|
...effectiveNextState.yAxis !== void 0 ? { yAxis: effectiveNextState.yAxis } : {}
|
|
71239
71031
|
};
|
|
71240
|
-
|
|
71032
|
+
setAxisEdits((previousEdits) => {
|
|
71241
71033
|
const nextEdits = { ...previousEdits };
|
|
71242
71034
|
if (cx.xAxis) {
|
|
71243
71035
|
let suppressXAxisLabelFromPayload = false;
|
|
@@ -71850,7 +71642,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
71850
71642
|
xAxisField: resolvedXAxisField,
|
|
71851
71643
|
xAxisFormat: resolvedXAxisFormat,
|
|
71852
71644
|
xAxisLabel: resolvedXAxisLabel,
|
|
71853
|
-
yAxisFields:
|
|
71645
|
+
yAxisFields: yAxisMeasures,
|
|
71854
71646
|
showLegend: chartVisibility.showLegend,
|
|
71855
71647
|
chartSort: resolvedChartSort ?? null,
|
|
71856
71648
|
...overrides?.filterMap !== void 0 ? { filterMap: overrides.filterMap } : {},
|
|
@@ -71903,7 +71695,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
71903
71695
|
resolvedXAxisField,
|
|
71904
71696
|
resolvedXAxisFormat,
|
|
71905
71697
|
resolvedXAxisLabel,
|
|
71906
|
-
|
|
71698
|
+
yAxisMeasures,
|
|
71907
71699
|
sourceReport,
|
|
71908
71700
|
table.columns,
|
|
71909
71701
|
tenants
|
|
@@ -71938,9 +71730,9 @@ function useReport(reportIdArg, options = {}) {
|
|
|
71938
71730
|
groupColumnsByOptions,
|
|
71939
71731
|
dateBucket: dateBucketMode === "standard" ? pivotState?.dateBucket : dateBucket,
|
|
71940
71732
|
dateBucketOptions: hasDatePivotRow ? dateBucketMode === "standard" ? STANDARD_PIVOT_DATE_BUCKET_OPTIONS : PIVOT_DATE_BUCKET_OPTIONS : [],
|
|
71941
|
-
/** Encoded selection per aggregation
|
|
71733
|
+
/** Encoded selection per aggregation (`'sum:transactions::amount'`, `'count:transactions'`, `''` = placeholder). Update via `setReport({ aggregations: nextStringArray })`. */
|
|
71942
71734
|
aggregations: aggregationValues,
|
|
71943
|
-
/** Flat aggregation pick list shared by all
|
|
71735
|
+
/** Flat aggregation pick list shared by all aggregations; always contains every non-empty `aggregations` entry. */
|
|
71944
71736
|
aggregationOptions,
|
|
71945
71737
|
aggregationDescriptionOptions: cleanedAggregations,
|
|
71946
71738
|
sort: cleanedSort,
|