@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.cjs
CHANGED
|
@@ -23802,11 +23802,17 @@ function formattedPivotRowsAndColumns(report, dashboardFilters = [], options = {
|
|
|
23802
23802
|
dashboardFilters
|
|
23803
23803
|
);
|
|
23804
23804
|
const pivotValueColumns = columns?.slice(1) ?? [];
|
|
23805
|
-
const yAxisFields = report.pivot && !report.pivot.columnField && pivotValueColumns.length > 0 ? pivotValueColumns.map((col
|
|
23806
|
-
|
|
23807
|
-
|
|
23808
|
-
|
|
23809
|
-
|
|
23805
|
+
const yAxisFields = report.pivot && !report.pivot.columnField && pivotValueColumns.length > 0 ? pivotValueColumns.map((col) => {
|
|
23806
|
+
const saved = report.yAxisFields?.find(
|
|
23807
|
+
(axis) => axis.field === col.field
|
|
23808
|
+
);
|
|
23809
|
+
const savedLabel = String(saved?.label ?? "").trim();
|
|
23810
|
+
return {
|
|
23811
|
+
field: col.field,
|
|
23812
|
+
label: savedLabel || col.label || col.field,
|
|
23813
|
+
format: saved?.format ?? legacyPivotFormat ?? col.format ?? "whole_number"
|
|
23814
|
+
};
|
|
23815
|
+
}) : formattedYAxisFields?.length > 0 ? formattedYAxisFields : pivotValueColumns.map((col) => ({
|
|
23810
23816
|
field: col.field,
|
|
23811
23817
|
label: col.label ?? col.field,
|
|
23812
23818
|
format: legacyPivotFormat ?? col.format ?? "whole_number"
|
|
@@ -41087,7 +41093,7 @@ function D3Gauge({
|
|
|
41087
41093
|
if (!containerRef.current || !select) return;
|
|
41088
41094
|
const container = containerRef.current;
|
|
41089
41095
|
select(container).select("svg").remove();
|
|
41090
|
-
svgRef.current = select(container).append("svg").attr("width", "100%").attr("height", "100%").attr("preserveAspectRatio", "xMidYMid meet");
|
|
41096
|
+
svgRef.current = select(container).append("svg").attr("width", "100%").attr("height", "100%").attr("preserveAspectRatio", "xMidYMid meet").style("display", "block");
|
|
41091
41097
|
gaugeGroupRef.current = svgRef.current.append("g");
|
|
41092
41098
|
for (let i = 0; i < 3; i++) {
|
|
41093
41099
|
gaugeGroupRef.current.append("path").attr("class", `arc-seg seg${i}`);
|
|
@@ -41222,7 +41228,7 @@ function D3Gauge({
|
|
|
41222
41228
|
"div",
|
|
41223
41229
|
{
|
|
41224
41230
|
ref: containerRef,
|
|
41225
|
-
style: { width: "100%", ...containerStyle },
|
|
41231
|
+
style: { width: "100%", height: "100%", ...containerStyle },
|
|
41226
41232
|
className
|
|
41227
41233
|
}
|
|
41228
41234
|
);
|
|
@@ -49324,10 +49330,10 @@ function InternalChart({
|
|
|
49324
49330
|
config: report,
|
|
49325
49331
|
containerStyle: {
|
|
49326
49332
|
minHeight: 300,
|
|
49327
|
-
width: ["US map", "World map"].includes(report.chartType) ? "70%" :
|
|
49328
|
-
height: ["US map", "World map"].includes(report.chartType) ? "fit-content" :
|
|
49329
|
-
marginLeft:
|
|
49330
|
-
marginRight:
|
|
49333
|
+
width: ["US map", "World map"].includes(report.chartType) ? "70%" : "100%",
|
|
49334
|
+
height: ["US map", "World map"].includes(report.chartType) ? "fit-content" : report.chartType === "gauge" ? 300 : void 0,
|
|
49335
|
+
marginLeft: "auto",
|
|
49336
|
+
marginRight: "auto"
|
|
49331
49337
|
},
|
|
49332
49338
|
reportId: report.id,
|
|
49333
49339
|
colors,
|
|
@@ -62592,9 +62598,6 @@ function getPageOptionsFromPageCount(pageCount) {
|
|
|
62592
62598
|
|
|
62593
62599
|
// src/hooks/useForm.tsx
|
|
62594
62600
|
var INTERNAL_PIVOT_ROW_FIELDS = /* @__PURE__ */ new Set(["__quillRawDate"]);
|
|
62595
|
-
var LEGACY_SINGLE_Y_AXIS_COLUMN_PIVOT_REPORT_IDS = /* @__PURE__ */ new Set([
|
|
62596
|
-
"69b63941ac8df4cda178a38a"
|
|
62597
|
-
]);
|
|
62598
62601
|
var AGGREGATION_OPTION_TYPES = [
|
|
62599
62602
|
"sum",
|
|
62600
62603
|
"average",
|
|
@@ -63399,10 +63402,7 @@ function normalizePivotColumnDisplayValue(value) {
|
|
|
63399
63402
|
if (!normalized) return "-";
|
|
63400
63403
|
return ["undefined", "null"].includes(normalized.toLowerCase()) ? "-" : normalized;
|
|
63401
63404
|
}
|
|
63402
|
-
function
|
|
63403
|
-
return aggregation?.aggregationType === "percentage" ? "percentage" : "whole_number";
|
|
63404
|
-
}
|
|
63405
|
-
function getPivotTableSlotReportColumn(reportColumns, aggregations, rowField, pivotTableColumnKey) {
|
|
63405
|
+
function getPivotTableReportColumn(reportColumns, aggregations, rowField, pivotTableColumnKey) {
|
|
63406
63406
|
const cols = reportColumns ?? [];
|
|
63407
63407
|
if (cols.length === 0) return void 0;
|
|
63408
63408
|
const row = String(rowField ?? "").trim();
|
|
@@ -63480,7 +63480,214 @@ function shouldUsePivotRowFieldAsXAxis(chartType, pivotRowField, rowColumnFormat
|
|
|
63480
63480
|
}
|
|
63481
63481
|
return true;
|
|
63482
63482
|
}
|
|
63483
|
-
function
|
|
63483
|
+
function pivotDisplayFieldKeys(chart) {
|
|
63484
|
+
const rowField = String(chart.pivot?.rowField ?? "").trim();
|
|
63485
|
+
const firstPivotRow = (chart.rows ?? []).find(
|
|
63486
|
+
(row) => Object.keys(row).length > 0
|
|
63487
|
+
);
|
|
63488
|
+
if (!firstPivotRow) return [];
|
|
63489
|
+
const keys = Object.keys(firstPivotRow).filter(
|
|
63490
|
+
(field) => !INTERNAL_PIVOT_ROW_FIELDS.has(field)
|
|
63491
|
+
);
|
|
63492
|
+
if (rowField && keys.includes(rowField)) {
|
|
63493
|
+
return [rowField, ...keys.filter((field) => field !== rowField)];
|
|
63494
|
+
}
|
|
63495
|
+
return keys;
|
|
63496
|
+
}
|
|
63497
|
+
function pivotValueFieldKeys(chart) {
|
|
63498
|
+
const rowKey = pivotRowKey(chart);
|
|
63499
|
+
const rowField = String(chart.pivot?.rowField ?? "").trim();
|
|
63500
|
+
return pivotDisplayFieldKeys(chart).filter(
|
|
63501
|
+
(field) => field !== rowKey && field !== rowField
|
|
63502
|
+
);
|
|
63503
|
+
}
|
|
63504
|
+
function pivotFallbackValueKeys(chart) {
|
|
63505
|
+
return (chart.pivotColumns ?? []).slice(1).map((column) => String(column.field ?? "").trim()).filter(Boolean);
|
|
63506
|
+
}
|
|
63507
|
+
function findSavedYAxisField(saved, field) {
|
|
63508
|
+
return saved.find((axis) => String(axis.field ?? "").trim() === field) ?? (saved.length === 1 ? saved[0] : void 0);
|
|
63509
|
+
}
|
|
63510
|
+
function isPlaceholderAxisLabel(label, field) {
|
|
63511
|
+
const trimmed = String(label ?? "").trim();
|
|
63512
|
+
const fieldTrim = String(field ?? "").trim();
|
|
63513
|
+
if (!trimmed) return true;
|
|
63514
|
+
if (trimmed.toLowerCase() === fieldTrim.toLowerCase()) return true;
|
|
63515
|
+
return trimmed === toTitleCaseLabel(fieldTrim);
|
|
63516
|
+
}
|
|
63517
|
+
function resolvedAxisLabel(savedLabel, field, generatedLabel) {
|
|
63518
|
+
return isPlaceholderAxisLabel(savedLabel, field) ? generatedLabel : savedLabel;
|
|
63519
|
+
}
|
|
63520
|
+
function resolveYAxisFormatForField(field, aggregation, saved, fallback) {
|
|
63521
|
+
const formatByField = new Map(
|
|
63522
|
+
saved.map((axis) => [String(axis.field ?? "").trim(), axis.format])
|
|
63523
|
+
);
|
|
63524
|
+
if (aggregation?.aggregationType === "count") {
|
|
63525
|
+
return formatByField.get(field) ?? formatByField.get("count") ?? saved[0]?.format ?? "whole_number";
|
|
63526
|
+
}
|
|
63527
|
+
if (aggregation?.aggregationType === "percentage") {
|
|
63528
|
+
const savedFormat = formatByField.get(field);
|
|
63529
|
+
if (savedFormat === "percent" || savedFormat === "percentage") {
|
|
63530
|
+
return savedFormat;
|
|
63531
|
+
}
|
|
63532
|
+
return "percentage";
|
|
63533
|
+
}
|
|
63534
|
+
const aggType = aggregation?.aggregationType ? String(aggregation.aggregationType) : void 0;
|
|
63535
|
+
return formatByField.get(field) ?? formatByField.get(trimAggregationSuffix(field, aggType)) ?? (aggregation?.valueField ? formatByField.get(aggregation.valueField) : void 0) ?? fallback;
|
|
63536
|
+
}
|
|
63537
|
+
function aggregationIdentityForField(field, aggregations) {
|
|
63538
|
+
return getAggregationIdentityKey(
|
|
63539
|
+
findAggregationForFieldStrict(field, aggregations)
|
|
63540
|
+
);
|
|
63541
|
+
}
|
|
63542
|
+
function indexByAggregationIdentity(axes, aggregations) {
|
|
63543
|
+
const byIdentity = /* @__PURE__ */ new Map();
|
|
63544
|
+
for (const axis of axes) {
|
|
63545
|
+
const identity = aggregationIdentityForField(axis.field, aggregations);
|
|
63546
|
+
if (identity && !byIdentity.has(identity)) {
|
|
63547
|
+
byIdentity.set(identity, axis);
|
|
63548
|
+
}
|
|
63549
|
+
}
|
|
63550
|
+
return byIdentity;
|
|
63551
|
+
}
|
|
63552
|
+
function matchedValueKeyForAggregation(aggregation, valueKeys, canonicalField) {
|
|
63553
|
+
if (valueKeys.includes(canonicalField)) return canonicalField;
|
|
63554
|
+
return valueKeys.find(
|
|
63555
|
+
(key) => findAggregationForFieldStrict(key, [aggregation])
|
|
63556
|
+
);
|
|
63557
|
+
}
|
|
63558
|
+
function composePivotColumnSeriesLabel(field, aggregation, measureLabel, hasMultipleAggregations) {
|
|
63559
|
+
if (!aggregation) return toTitleCaseLabel(String(field ?? ""));
|
|
63560
|
+
const category = normalizePivotColumnDisplayValue(
|
|
63561
|
+
getPivotColumnValueForSeries(field, aggregation, hasMultipleAggregations)
|
|
63562
|
+
);
|
|
63563
|
+
const isMeasureNamedSeries = Boolean(aggregation.valueField) && category === String(aggregation.valueField ?? "").trim();
|
|
63564
|
+
if (isMeasureNamedSeries) return measureLabel;
|
|
63565
|
+
if (!measureLabel || measureLabel === category) return category;
|
|
63566
|
+
return `${category} \xB7 ${measureLabel}`;
|
|
63567
|
+
}
|
|
63568
|
+
function measureFromAggregation(aggregation, chart, saved, fallback, hasMultipleAggregations, resolveTableLabel) {
|
|
63569
|
+
const canonicalField = getAggregationFieldKey(
|
|
63570
|
+
aggregation,
|
|
63571
|
+
hasMultipleAggregations
|
|
63572
|
+
);
|
|
63573
|
+
if (!canonicalField) return null;
|
|
63574
|
+
const previous = findSavedYAxisField(saved, canonicalField);
|
|
63575
|
+
const savedLabel = String(previous?.label ?? "").trim();
|
|
63576
|
+
const generatedLabel = buildAggregationLabel(
|
|
63577
|
+
aggregation,
|
|
63578
|
+
chart,
|
|
63579
|
+
resolveTableLabel
|
|
63580
|
+
);
|
|
63581
|
+
return {
|
|
63582
|
+
field: canonicalField,
|
|
63583
|
+
label: resolvedAxisLabel(savedLabel, canonicalField, generatedLabel),
|
|
63584
|
+
format: resolveYAxisFormatForField(
|
|
63585
|
+
canonicalField,
|
|
63586
|
+
aggregation,
|
|
63587
|
+
saved,
|
|
63588
|
+
fallback
|
|
63589
|
+
)
|
|
63590
|
+
};
|
|
63591
|
+
}
|
|
63592
|
+
function applyYAxisEdits(measures, edits, aggregations) {
|
|
63593
|
+
if (!edits) return measures;
|
|
63594
|
+
const byField = new Map(
|
|
63595
|
+
measures.map((measure) => [String(measure.field ?? "").trim(), measure])
|
|
63596
|
+
);
|
|
63597
|
+
const byIdentity = indexByAggregationIdentity(measures, aggregations);
|
|
63598
|
+
const next = [];
|
|
63599
|
+
for (const edit of edits) {
|
|
63600
|
+
const field = String(edit.field ?? "").trim();
|
|
63601
|
+
if (!field) continue;
|
|
63602
|
+
const identity = aggregationIdentityForField(field, aggregations);
|
|
63603
|
+
const base = (identity ? byIdentity.get(identity) : void 0) ?? byField.get(field);
|
|
63604
|
+
const label = String(edit.label ?? "").trim();
|
|
63605
|
+
if (!base) {
|
|
63606
|
+
next.push({
|
|
63607
|
+
field,
|
|
63608
|
+
label: label || toTitleCaseLabel(field),
|
|
63609
|
+
format: toAxisFormat(edit.format, "string")
|
|
63610
|
+
});
|
|
63611
|
+
continue;
|
|
63612
|
+
}
|
|
63613
|
+
next.push({
|
|
63614
|
+
field: base.field,
|
|
63615
|
+
label: label || base.label,
|
|
63616
|
+
format: toAxisFormat(edit.format, base.format)
|
|
63617
|
+
});
|
|
63618
|
+
}
|
|
63619
|
+
return next.length > 0 ? next : measures;
|
|
63620
|
+
}
|
|
63621
|
+
function resolveReportYAxis(chart, edits, resolveTableLabel) {
|
|
63622
|
+
const saved = chart.yAxisFields ?? [];
|
|
63623
|
+
if (!chart.pivot) {
|
|
63624
|
+
const measures2 = applyYAxisEdits(saved, edits, []);
|
|
63625
|
+
return { measures: measures2, series: measures2 };
|
|
63626
|
+
}
|
|
63627
|
+
const aggregations = getPivotAggregations(chart);
|
|
63628
|
+
const hasMultipleAggregations = aggregations.length > 1;
|
|
63629
|
+
const columnField = String(chart.pivot?.columnField ?? "").trim();
|
|
63630
|
+
const isAggregationOnlyPivot = !String(chart.pivot?.rowField ?? "").trim() && !columnField;
|
|
63631
|
+
const fallback = saved[0]?.format ?? chart.xAxisFormat ?? "whole_number";
|
|
63632
|
+
const valueKeys = pivotValueFieldKeys(chart);
|
|
63633
|
+
const fallbackKeys = pivotFallbackValueKeys(chart);
|
|
63634
|
+
let measures = aggregations.flatMap((aggregation) => {
|
|
63635
|
+
const measure = measureFromAggregation(
|
|
63636
|
+
aggregation,
|
|
63637
|
+
chart,
|
|
63638
|
+
saved,
|
|
63639
|
+
fallback,
|
|
63640
|
+
hasMultipleAggregations,
|
|
63641
|
+
resolveTableLabel
|
|
63642
|
+
);
|
|
63643
|
+
if (!measure) return [];
|
|
63644
|
+
if (columnField) return [measure];
|
|
63645
|
+
if (valueKeys.length === 0) return [measure];
|
|
63646
|
+
const matchedKey = matchedValueKeyForAggregation(
|
|
63647
|
+
aggregation,
|
|
63648
|
+
valueKeys,
|
|
63649
|
+
measure.field
|
|
63650
|
+
);
|
|
63651
|
+
if (matchedKey) return [{ ...measure, field: matchedKey }];
|
|
63652
|
+
return isAggregationOnlyPivot ? [measure] : [];
|
|
63653
|
+
});
|
|
63654
|
+
if (!columnField && measures.length === 0 && saved.length > 0) {
|
|
63655
|
+
measures = saved;
|
|
63656
|
+
}
|
|
63657
|
+
measures = applyYAxisEdits(measures, edits, aggregations);
|
|
63658
|
+
if (!columnField) {
|
|
63659
|
+
return { measures, series: measures };
|
|
63660
|
+
}
|
|
63661
|
+
const keys = valueKeys.length > 0 ? valueKeys : fallbackKeys;
|
|
63662
|
+
const measureByIdentity = indexByAggregationIdentity(measures, aggregations);
|
|
63663
|
+
const selectedIdentities = new Set(measureByIdentity.keys());
|
|
63664
|
+
const series = keys.flatMap((field) => {
|
|
63665
|
+
const aggregation = findAggregationForFieldStrict(field, aggregations);
|
|
63666
|
+
const identity = getAggregationIdentityKey(aggregation);
|
|
63667
|
+
if (selectedIdentities.size > 0 && identity && !selectedIdentities.has(identity)) {
|
|
63668
|
+
return [];
|
|
63669
|
+
}
|
|
63670
|
+
const measure = (identity ? measureByIdentity.get(identity) : void 0) ?? (measures.length === 1 ? measures[0] : void 0);
|
|
63671
|
+
const measureLabel = String(measure?.label ?? "").trim() || (aggregation ? buildAggregationLabel(aggregation, chart, resolveTableLabel) : toTitleCaseLabel(field));
|
|
63672
|
+
return [
|
|
63673
|
+
{
|
|
63674
|
+
field,
|
|
63675
|
+
label: composePivotColumnSeriesLabel(
|
|
63676
|
+
field,
|
|
63677
|
+
aggregation,
|
|
63678
|
+
measureLabel,
|
|
63679
|
+
hasMultipleAggregations
|
|
63680
|
+
),
|
|
63681
|
+
format: measure?.format ?? resolveYAxisFormatForField(field, aggregation, saved, fallback)
|
|
63682
|
+
}
|
|
63683
|
+
];
|
|
63684
|
+
});
|
|
63685
|
+
if (series.length > 0) {
|
|
63686
|
+
return { measures, series };
|
|
63687
|
+
}
|
|
63688
|
+
return { measures, series: measures };
|
|
63689
|
+
}
|
|
63690
|
+
function normalizePivotChartForDisplay(chart) {
|
|
63484
63691
|
const swapPivotRowsForChartRows = Boolean(chart?.pivot) && Array.isArray(chart?.pivotRows) && chart.pivotRows.length > 0;
|
|
63485
63692
|
const syntheticAggregationOnlyRows = chart && !swapPivotRowsForChartRows ? buildSyntheticAggregationOnlyDisplayRows(chart) : null;
|
|
63486
63693
|
const hasExplicitEmptyGroupedPivot = Boolean(
|
|
@@ -63516,136 +63723,13 @@ function normalizePivotChartForDisplay(chart, resolveTableLabel) {
|
|
|
63516
63723
|
String(withResolvedXAxis.chartType ?? "").toLowerCase()
|
|
63517
63724
|
);
|
|
63518
63725
|
const aggregations = getPivotAggregations(withResolvedXAxis);
|
|
63519
|
-
const hasMultipleAggregations = aggregations.length > 1;
|
|
63520
63726
|
const yAxisFallbackFormat = withResolvedXAxis.yAxisFields?.[0]?.format ?? withResolvedXAxis.xAxisFormat ?? "whole_number";
|
|
63521
63727
|
const firstPivotRow = (withResolvedXAxis.rows ?? []).find(
|
|
63522
63728
|
(row) => Object.keys(row).length > 0
|
|
63523
63729
|
);
|
|
63524
|
-
const
|
|
63525
|
-
|
|
63526
|
-
|
|
63527
|
-
const pivotRowFields = firstPivotRow ? (() => {
|
|
63528
|
-
const keys = Object.keys(firstPivotRow).filter(
|
|
63529
|
-
(field) => !INTERNAL_PIVOT_ROW_FIELDS.has(field)
|
|
63530
|
-
);
|
|
63531
|
-
if (pivotRowFieldName && keys.includes(pivotRowFieldName)) {
|
|
63532
|
-
return [
|
|
63533
|
-
pivotRowFieldName,
|
|
63534
|
-
...keys.filter((field) => field !== pivotRowFieldName)
|
|
63535
|
-
];
|
|
63536
|
-
}
|
|
63537
|
-
return keys;
|
|
63538
|
-
})() : [];
|
|
63539
|
-
const pivotValueFields = pivotRowFields.filter(
|
|
63540
|
-
(field) => field !== pivotRowKey(withResolvedXAxis) && field !== withResolvedXAxis.pivot?.rowField
|
|
63541
|
-
);
|
|
63542
|
-
const isAggregationOnlyPivot = !String(withResolvedXAxis.pivot?.rowField ?? "").trim() && !String(withResolvedXAxis.pivot?.columnField ?? "").trim();
|
|
63543
|
-
const yAxisFormatByField = new Map(
|
|
63544
|
-
(withResolvedXAxis.yAxisFields ?? []).map((axis) => [
|
|
63545
|
-
axis.field,
|
|
63546
|
-
axis.format
|
|
63547
|
-
])
|
|
63548
|
-
);
|
|
63549
|
-
const resolveYAxisFormat = (field, aggregation) => {
|
|
63550
|
-
if (aggregation?.aggregationType === "count") {
|
|
63551
|
-
const savedFormat = yAxisFormatByField.get(field) ?? yAxisFormatByField.get("count") ?? withResolvedXAxis.yAxisFields?.find(
|
|
63552
|
-
(axis) => String(axis.field ?? "").trim() === field
|
|
63553
|
-
)?.format ?? withResolvedXAxis.yAxisFields?.[0]?.format;
|
|
63554
|
-
if (savedFormat) return savedFormat;
|
|
63555
|
-
return "whole_number";
|
|
63556
|
-
}
|
|
63557
|
-
if (aggregation?.aggregationType === "percentage") {
|
|
63558
|
-
const savedFormat = yAxisFormatByField.get(field);
|
|
63559
|
-
if (savedFormat === "percent" || savedFormat === "percentage") {
|
|
63560
|
-
return savedFormat;
|
|
63561
|
-
}
|
|
63562
|
-
return "percentage";
|
|
63563
|
-
}
|
|
63564
|
-
const directAxisFormat = yAxisFormatByField.get(field);
|
|
63565
|
-
if (directAxisFormat) return directAxisFormat;
|
|
63566
|
-
const aggType = aggregation?.aggregationType ? String(aggregation.aggregationType) : void 0;
|
|
63567
|
-
const baseField = trimAggregationSuffix(field, aggType);
|
|
63568
|
-
const baseAxisFormat = yAxisFormatByField.get(baseField);
|
|
63569
|
-
if (baseAxisFormat) return baseAxisFormat;
|
|
63570
|
-
if (aggregation?.valueField) {
|
|
63571
|
-
const aggregationValueFieldFormat = yAxisFormatByField.get(
|
|
63572
|
-
aggregation.valueField
|
|
63573
|
-
);
|
|
63574
|
-
if (aggregationValueFieldFormat) return aggregationValueFieldFormat;
|
|
63575
|
-
}
|
|
63576
|
-
return yAxisFallbackFormat;
|
|
63577
|
-
};
|
|
63578
|
-
const resolveAggregationAxisFieldForDisplay = (aggregation, canonicalField) => {
|
|
63579
|
-
if (!canonicalField) return null;
|
|
63580
|
-
if (pivotValueFields.includes(canonicalField)) {
|
|
63581
|
-
return canonicalField;
|
|
63582
|
-
}
|
|
63583
|
-
if (!isAggregationOnlyPivot) {
|
|
63584
|
-
return null;
|
|
63585
|
-
}
|
|
63586
|
-
const matchedPivotKey = pivotValueFields.find(
|
|
63587
|
-
(pf) => findAggregationForFieldStrict(pf, [aggregation])
|
|
63588
|
-
);
|
|
63589
|
-
return matchedPivotKey ?? canonicalField;
|
|
63590
|
-
};
|
|
63591
|
-
const yAxisFromAggregations = !withResolvedXAxis.pivot?.columnField && aggregations.length > 0 ? aggregations.map((aggregation) => {
|
|
63592
|
-
const canonicalField = getAggregationFieldKey(
|
|
63593
|
-
aggregation,
|
|
63594
|
-
hasMultipleAggregations
|
|
63595
|
-
);
|
|
63596
|
-
const field = resolveAggregationAxisFieldForDisplay(
|
|
63597
|
-
aggregation,
|
|
63598
|
-
canonicalField
|
|
63599
|
-
);
|
|
63600
|
-
if (!field) return null;
|
|
63601
|
-
return {
|
|
63602
|
-
field,
|
|
63603
|
-
label: buildAggregationLabel(
|
|
63604
|
-
aggregation,
|
|
63605
|
-
withResolvedXAxis,
|
|
63606
|
-
resolveTableLabel
|
|
63607
|
-
),
|
|
63608
|
-
format: resolveYAxisFormat(field, aggregation)
|
|
63609
|
-
};
|
|
63610
|
-
}).filter((axis) => Boolean(axis)) : [];
|
|
63611
|
-
const mappedValueFields = new Set(
|
|
63612
|
-
yAxisFromAggregations.map((axis) => axis.field)
|
|
63613
|
-
);
|
|
63614
|
-
const yAxisFromPivotRowFields = pivotValueFields.filter((field) => !mappedValueFields.has(field)).map((field) => {
|
|
63615
|
-
const aggregation = findAggregationForFieldStrict(field, aggregations);
|
|
63616
|
-
const cleanedBaseField = aggregation?.aggregationType && hasMultipleAggregations ? trimAggregationSuffix(field, String(aggregation.aggregationType)) : field;
|
|
63617
|
-
const displayBase = aggregation?.valueField && withResolvedXAxis.pivot?.columnField ? trimAggregationSuffix(cleanedBaseField, aggregation.valueField) : cleanedBaseField;
|
|
63618
|
-
const displayBaseField = normalizePivotColumnDisplayValue(displayBase);
|
|
63619
|
-
const aggregationLabel = aggregation ? buildAggregationLabel(
|
|
63620
|
-
aggregation,
|
|
63621
|
-
withResolvedXAxis,
|
|
63622
|
-
resolveTableLabel
|
|
63623
|
-
) : void 0;
|
|
63624
|
-
const isMeasureNamedSeries = Boolean(aggregation?.valueField) && displayBaseField === String(aggregation?.valueField ?? "").trim();
|
|
63625
|
-
let pivotColumnSeriesLabel = displayBaseField;
|
|
63626
|
-
if (withResolvedXAxis.pivot?.columnField && aggregation && aggregationLabel) {
|
|
63627
|
-
if (isMeasureNamedSeries) {
|
|
63628
|
-
pivotColumnSeriesLabel = aggregationLabel;
|
|
63629
|
-
} else if (aggregationLabel !== displayBaseField) {
|
|
63630
|
-
const alreadyCombined = String(displayBaseField).endsWith(` \xB7 ${aggregationLabel}`) || String(displayBaseField).endsWith(` \u2014 ${aggregationLabel}`) || String(displayBaseField).endsWith(` (${aggregationLabel})`);
|
|
63631
|
-
pivotColumnSeriesLabel = alreadyCombined ? displayBaseField : `${displayBaseField} \xB7 ${aggregationLabel}`;
|
|
63632
|
-
}
|
|
63633
|
-
}
|
|
63634
|
-
const label = aggregation ? withResolvedXAxis.pivot?.columnField ? pivotColumnSeriesLabel : aggregationLabel ?? displayBaseField : toTitleCaseLabel(String(field ?? ""));
|
|
63635
|
-
return {
|
|
63636
|
-
field,
|
|
63637
|
-
label,
|
|
63638
|
-
format: resolveYAxisFormat(field, aggregation)
|
|
63639
|
-
};
|
|
63640
|
-
});
|
|
63641
|
-
const supplementalYAxisFromPivotRowFields = yAxisFromAggregations.length > 0 ? yAxisFromPivotRowFields.filter(
|
|
63642
|
-
(axis) => Boolean(findAggregationForFieldStrict(axis.field, aggregations))
|
|
63643
|
-
) : yAxisFromPivotRowFields;
|
|
63644
|
-
const yAxisFields = yAxisFromAggregations.length > 0 ? [...yAxisFromAggregations, ...supplementalYAxisFromPivotRowFields] : supplementalYAxisFromPivotRowFields.length > 0 ? supplementalYAxisFromPivotRowFields : (withResolvedXAxis.pivotColumns ?? []).slice(1).map((column) => ({
|
|
63645
|
-
field: column.field,
|
|
63646
|
-
label: column.label ?? column.field,
|
|
63647
|
-
format: column.format ?? yAxisFallbackFormat
|
|
63648
|
-
}));
|
|
63730
|
+
const pivotRowFields = pivotDisplayFieldKeys(withResolvedXAxis);
|
|
63731
|
+
const pivotValueFields = pivotValueFieldKeys(withResolvedXAxis);
|
|
63732
|
+
const yAxisFields = withResolvedXAxis.yAxisFields ?? [];
|
|
63649
63733
|
const knownColumnsByField = new Map(
|
|
63650
63734
|
[
|
|
63651
63735
|
...withResolvedXAxis.pivotColumns ?? [],
|
|
@@ -63666,21 +63750,21 @@ function normalizePivotChartForDisplay(chart, resolveTableLabel) {
|
|
|
63666
63750
|
};
|
|
63667
63751
|
}) : withResolvedXAxis.columns ?? [];
|
|
63668
63752
|
const isPivotTableChart = String(withResolvedXAxis.chartType ?? "").toLowerCase() === "table" && Boolean(withResolvedXAxis.pivot);
|
|
63669
|
-
const
|
|
63753
|
+
const savedPivotTableColumns = isPivotTableChart && Array.isArray(withResolvedXAxis.pivotColumns) && withResolvedXAxis.pivotColumns.length > 0 ? withResolvedXAxis.pivotColumns : withResolvedXAxis.columns;
|
|
63670
63754
|
const pivotTableDisplayColumns = isPivotTableChart && pivotColumnFields.length > 0 ? normalizedPivotColumns.map((col) => {
|
|
63671
|
-
const
|
|
63672
|
-
|
|
63755
|
+
const savedColumn = getPivotTableReportColumn(
|
|
63756
|
+
savedPivotTableColumns,
|
|
63673
63757
|
aggregations,
|
|
63674
63758
|
pivotRowKey(withResolvedXAxis) || withResolvedXAxis.pivot?.rowField,
|
|
63675
63759
|
col.field
|
|
63676
63760
|
);
|
|
63677
|
-
if (!
|
|
63761
|
+
if (!savedColumn) return col;
|
|
63678
63762
|
const next = {
|
|
63679
63763
|
...col,
|
|
63680
|
-
format:
|
|
63764
|
+
format: savedColumn.format ?? col.format
|
|
63681
63765
|
};
|
|
63682
|
-
if (
|
|
63683
|
-
next.inferFormat =
|
|
63766
|
+
if (savedColumn.inferFormat !== void 0) {
|
|
63767
|
+
next.inferFormat = savedColumn.inferFormat;
|
|
63684
63768
|
}
|
|
63685
63769
|
return next;
|
|
63686
63770
|
}) : normalizedPivotColumns;
|
|
@@ -63741,100 +63825,10 @@ function normalizePivotChartForDisplay(chart, resolveTableLabel) {
|
|
|
63741
63825
|
yAxisFields
|
|
63742
63826
|
};
|
|
63743
63827
|
}
|
|
63744
|
-
function
|
|
63745
|
-
const aggregations = getPivotAggregations(report);
|
|
63746
|
-
const hasMultipleAggregations = aggregations.length > 1;
|
|
63747
|
-
return aggregations.map((aggregation) => {
|
|
63748
|
-
const field = getAggregationFieldKey(
|
|
63749
|
-
aggregation,
|
|
63750
|
-
hasMultipleAggregations
|
|
63751
|
-
);
|
|
63752
|
-
if (!field) return null;
|
|
63753
|
-
return {
|
|
63754
|
-
field,
|
|
63755
|
-
label: buildAggregationLabel(aggregation, report, resolveTableLabel),
|
|
63756
|
-
format: getYAxisFormatFromAggregation(aggregation)
|
|
63757
|
-
};
|
|
63758
|
-
}).filter((axis) => Boolean(axis));
|
|
63759
|
-
}
|
|
63760
|
-
function mergePivotColumnAxisFieldsWithMapped(aggregationAxisFields, mapped) {
|
|
63761
|
-
const byField = /* @__PURE__ */ new Map();
|
|
63762
|
-
for (const y of mapped) {
|
|
63763
|
-
const f = String(y.field ?? "").trim();
|
|
63764
|
-
if (f) byField.set(f, y);
|
|
63765
|
-
}
|
|
63766
|
-
return aggregationAxisFields.map((axis) => {
|
|
63767
|
-
const f = String(axis.field ?? "").trim();
|
|
63768
|
-
const mappedAxis = f ? byField.get(f) : void 0;
|
|
63769
|
-
return mappedAxis ?? axis;
|
|
63770
|
-
});
|
|
63771
|
-
}
|
|
63772
|
-
function normalizePivotChartForAxisControls(chart, reportId, resolveTableLabel) {
|
|
63773
|
-
if (!chart?.pivot?.columnField) return chart;
|
|
63774
|
-
const aggregations = getPivotAggregations(chart);
|
|
63775
|
-
if (aggregations.length === 0) return chart;
|
|
63776
|
-
const aggregationAxisFields = buildPivotAggregationAxisFields(
|
|
63777
|
-
chart,
|
|
63778
|
-
resolveTableLabel
|
|
63779
|
-
);
|
|
63780
|
-
if (aggregationAxisFields.length === 0) return chart;
|
|
63781
|
-
const aggregationAxisByIdentity = /* @__PURE__ */ new Map();
|
|
63782
|
-
for (const aggregationAxisField of aggregationAxisFields) {
|
|
63783
|
-
const aggregation = findAggregationForFieldStrict(
|
|
63784
|
-
aggregationAxisField.field,
|
|
63785
|
-
aggregations
|
|
63786
|
-
);
|
|
63787
|
-
const aggregationIdentity = getAggregationIdentityKey(aggregation);
|
|
63788
|
-
if (!aggregationIdentity || aggregationAxisByIdentity.has(aggregationIdentity)) {
|
|
63789
|
-
continue;
|
|
63790
|
-
}
|
|
63791
|
-
aggregationAxisByIdentity.set(aggregationIdentity, aggregationAxisField);
|
|
63792
|
-
}
|
|
63793
|
-
const mappedExistingYAxisFields = [];
|
|
63794
|
-
const seenMappedFields = /* @__PURE__ */ new Set();
|
|
63795
|
-
for (const existingYAxisField of chart.yAxisFields ?? []) {
|
|
63796
|
-
const aggregation = findAggregationForFieldStrict(
|
|
63797
|
-
existingYAxisField.field,
|
|
63798
|
-
aggregations
|
|
63799
|
-
);
|
|
63800
|
-
const aggregationIdentity = getAggregationIdentityKey(aggregation);
|
|
63801
|
-
if (!aggregationIdentity) continue;
|
|
63802
|
-
const mappedAggregationAxis = aggregationAxisByIdentity.get(aggregationIdentity);
|
|
63803
|
-
if (!mappedAggregationAxis) continue;
|
|
63804
|
-
if (seenMappedFields.has(mappedAggregationAxis.field)) continue;
|
|
63805
|
-
seenMappedFields.add(mappedAggregationAxis.field);
|
|
63806
|
-
mappedExistingYAxisFields.push({
|
|
63807
|
-
field: mappedAggregationAxis.field,
|
|
63808
|
-
label: String(existingYAxisField.label ?? "").trim() || mappedAggregationAxis.label,
|
|
63809
|
-
format: toAxisFormat(
|
|
63810
|
-
existingYAxisField.format,
|
|
63811
|
-
mappedAggregationAxis.format
|
|
63812
|
-
)
|
|
63813
|
-
});
|
|
63814
|
-
}
|
|
63815
|
-
let yAxisFields;
|
|
63816
|
-
if (aggregations.length > 1) {
|
|
63817
|
-
const resolvedReportId = String(reportId ?? chart.id ?? "").trim();
|
|
63818
|
-
if (LEGACY_SINGLE_Y_AXIS_COLUMN_PIVOT_REPORT_IDS.has(resolvedReportId)) {
|
|
63819
|
-
yAxisFields = mappedExistingYAxisFields.length > 0 ? mappedExistingYAxisFields : [aggregationAxisFields[0]];
|
|
63820
|
-
} else {
|
|
63821
|
-
yAxisFields = mappedExistingYAxisFields.length === 0 || mappedExistingYAxisFields.length < aggregationAxisFields.length ? mergePivotColumnAxisFieldsWithMapped(
|
|
63822
|
-
aggregationAxisFields,
|
|
63823
|
-
mappedExistingYAxisFields
|
|
63824
|
-
) : mappedExistingYAxisFields;
|
|
63825
|
-
}
|
|
63826
|
-
} else {
|
|
63827
|
-
yAxisFields = mappedExistingYAxisFields.length > 0 ? mappedExistingYAxisFields : [aggregationAxisFields[0]];
|
|
63828
|
-
}
|
|
63829
|
-
return {
|
|
63830
|
-
...chart,
|
|
63831
|
-
yAxisFields
|
|
63832
|
-
};
|
|
63833
|
-
}
|
|
63834
|
-
function buildPivotColumnPivotTableFormattingColumns(pivot, chart, resolveTableLabel) {
|
|
63828
|
+
function buildPivotTableColumns(pivot, chart, resolveTableLabel) {
|
|
63835
63829
|
if (!pivot) return null;
|
|
63836
|
-
const
|
|
63837
|
-
const aggregations = getPivotAggregations(
|
|
63830
|
+
const chartWithPivot = chart ? { ...chart, pivot } : { pivot };
|
|
63831
|
+
const aggregations = getPivotAggregations(chartWithPivot);
|
|
63838
63832
|
if (aggregations.length === 0) return null;
|
|
63839
63833
|
const hasMultipleAggregations = aggregations.length > 1;
|
|
63840
63834
|
const rowField = String(pivot.rowField ?? "").trim();
|
|
@@ -63868,7 +63862,7 @@ function buildPivotColumnPivotTableFormattingColumns(pivot, chart, resolveTableL
|
|
|
63868
63862
|
field: fieldKey,
|
|
63869
63863
|
label: buildAggregationLabel(
|
|
63870
63864
|
aggregation,
|
|
63871
|
-
|
|
63865
|
+
chartWithPivot,
|
|
63872
63866
|
resolveTableLabel
|
|
63873
63867
|
)
|
|
63874
63868
|
});
|
|
@@ -63895,19 +63889,6 @@ function mergePivotColumnSeriesLabelWithUserEdit(normalizedLabel, userRowLabel,
|
|
|
63895
63889
|
}
|
|
63896
63890
|
return user;
|
|
63897
63891
|
}
|
|
63898
|
-
function applySingleResolvedYAxisFormatToPivotDisplay(normalizedPivotYAxisFields, resolvedYAxisFields) {
|
|
63899
|
-
if (resolvedYAxisFields.length !== 1) return normalizedPivotYAxisFields;
|
|
63900
|
-
const only = resolvedYAxisFields[0];
|
|
63901
|
-
return normalizedPivotYAxisFields.map((axis) => ({
|
|
63902
|
-
...axis,
|
|
63903
|
-
label: mergePivotColumnSeriesLabelWithUserEdit(
|
|
63904
|
-
String(axis.label ?? "").trim(),
|
|
63905
|
-
only.label,
|
|
63906
|
-
String(axis.field ?? "").trim() || void 0
|
|
63907
|
-
),
|
|
63908
|
-
format: toAxisFormat(only.format, axis.format)
|
|
63909
|
-
}));
|
|
63910
|
-
}
|
|
63911
63892
|
function mergeChartColumnFormatsFromYAxisFields(columns, yAxisFields) {
|
|
63912
63893
|
if (!columns?.length || !yAxisFields?.length) return columns;
|
|
63913
63894
|
const formatByField = /* @__PURE__ */ new Map();
|
|
@@ -63965,87 +63946,10 @@ function mergePivotTableDisplayColumnLabelsFromYAxis({
|
|
|
63965
63946
|
return { ...c, label: yl };
|
|
63966
63947
|
});
|
|
63967
63948
|
}
|
|
63968
|
-
function mapResolvedPivotYAxisFieldsForDisplay({
|
|
63969
|
-
chart,
|
|
63970
|
-
resolvedYAxisFields
|
|
63971
|
-
}) {
|
|
63972
|
-
if (!chart.pivot?.columnField) return resolvedYAxisFields;
|
|
63973
|
-
const normalizedPivotYAxisFields = chart.yAxisFields ?? [];
|
|
63974
|
-
if (normalizedPivotYAxisFields.length === 0) return resolvedYAxisFields;
|
|
63975
|
-
const aggregations = getPivotAggregations(chart);
|
|
63976
|
-
if (aggregations.length === 0) {
|
|
63977
|
-
return applySingleResolvedYAxisFormatToPivotDisplay(
|
|
63978
|
-
normalizedPivotYAxisFields,
|
|
63979
|
-
resolvedYAxisFields
|
|
63980
|
-
);
|
|
63981
|
-
}
|
|
63982
|
-
const selectedAggregationByIdentity = /* @__PURE__ */ new Map();
|
|
63983
|
-
for (const yAxisField of resolvedYAxisFields ?? []) {
|
|
63984
|
-
const aggregation = findAggregationForFieldStrict(
|
|
63985
|
-
yAxisField.field,
|
|
63986
|
-
aggregations
|
|
63987
|
-
);
|
|
63988
|
-
const aggregationIdentity = getAggregationIdentityKey(aggregation);
|
|
63989
|
-
if (!aggregationIdentity) continue;
|
|
63990
|
-
selectedAggregationByIdentity.set(aggregationIdentity, yAxisField);
|
|
63991
|
-
}
|
|
63992
|
-
if (selectedAggregationByIdentity.size === 0) {
|
|
63993
|
-
return applySingleResolvedYAxisFormatToPivotDisplay(
|
|
63994
|
-
normalizedPivotYAxisFields,
|
|
63995
|
-
resolvedYAxisFields
|
|
63996
|
-
);
|
|
63997
|
-
}
|
|
63998
|
-
const mappedYAxisFields = [];
|
|
63999
|
-
const seenMappedFields = /* @__PURE__ */ new Set();
|
|
64000
|
-
for (const normalizedYAxisField of normalizedPivotYAxisFields) {
|
|
64001
|
-
const aggregation = findAggregationForFieldStrict(
|
|
64002
|
-
normalizedYAxisField.field,
|
|
64003
|
-
aggregations
|
|
64004
|
-
);
|
|
64005
|
-
const aggregationIdentity = getAggregationIdentityKey(aggregation);
|
|
64006
|
-
if (!aggregationIdentity) continue;
|
|
64007
|
-
const selectedAggregationAxis = selectedAggregationByIdentity.get(aggregationIdentity);
|
|
64008
|
-
if (!selectedAggregationAxis) continue;
|
|
64009
|
-
const field = String(normalizedYAxisField.field ?? "").trim();
|
|
64010
|
-
if (!field || seenMappedFields.has(field)) continue;
|
|
64011
|
-
seenMappedFields.add(field);
|
|
64012
|
-
mappedYAxisFields.push({
|
|
64013
|
-
...normalizedYAxisField,
|
|
64014
|
-
label: mergePivotColumnSeriesLabelWithUserEdit(
|
|
64015
|
-
String(normalizedYAxisField.label ?? "").trim(),
|
|
64016
|
-
selectedAggregationAxis.label,
|
|
64017
|
-
field || void 0
|
|
64018
|
-
),
|
|
64019
|
-
format: toAxisFormat(
|
|
64020
|
-
selectedAggregationAxis.format,
|
|
64021
|
-
normalizedYAxisField.format
|
|
64022
|
-
)
|
|
64023
|
-
});
|
|
64024
|
-
}
|
|
64025
|
-
if (mappedYAxisFields.length > 0) {
|
|
64026
|
-
return mappedYAxisFields;
|
|
64027
|
-
}
|
|
64028
|
-
return applySingleResolvedYAxisFormatToPivotDisplay(
|
|
64029
|
-
normalizedPivotYAxisFields,
|
|
64030
|
-
resolvedYAxisFields
|
|
64031
|
-
);
|
|
64032
|
-
}
|
|
64033
63949
|
function encodeColumnOptionValue(table, field) {
|
|
64034
63950
|
if (!table || !table.trim()) return field;
|
|
64035
63951
|
return `${table}_${field}`;
|
|
64036
63952
|
}
|
|
64037
|
-
function isNumericishColumnType(type) {
|
|
64038
|
-
const t = String(type ?? "").toLowerCase();
|
|
64039
|
-
return t === "number" || t === "integer" || t === "float" || t === "decimal" || t === "bigint" || t === "double" || t === "whole_number";
|
|
64040
|
-
}
|
|
64041
|
-
function findSchemaColumnForChartAxisField(chartField, schemaOptions) {
|
|
64042
|
-
const f = String(chartField ?? "").trim();
|
|
64043
|
-
if (!f) return void 0;
|
|
64044
|
-
for (const opt of schemaOptions) {
|
|
64045
|
-
if (opt.value === f || opt.field === f) return opt;
|
|
64046
|
-
}
|
|
64047
|
-
return void 0;
|
|
64048
|
-
}
|
|
64049
63953
|
function getAllColumnOptions({
|
|
64050
63954
|
schemaColumnOptions,
|
|
64051
63955
|
tableColumns,
|
|
@@ -66479,7 +66383,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
66479
66383
|
(0, import_react63.useEffect)(() => {
|
|
66480
66384
|
setTableColumnsEditedSignature(null);
|
|
66481
66385
|
}, [effectiveReportId]);
|
|
66482
|
-
const [
|
|
66386
|
+
const [axisEdits, setAxisEdits] = (0, import_react63.useState)({});
|
|
66483
66387
|
const [chartVisibilityOverrides, setChartVisibilityOverrides] = (0, import_react63.useState)({});
|
|
66484
66388
|
const [chartSortOverride, setChartSortOverride] = (0, import_react63.useState)(void 0);
|
|
66485
66389
|
const [client] = (0, import_react63.useContext)(ClientContext);
|
|
@@ -66611,7 +66515,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
66611
66515
|
}
|
|
66612
66516
|
}, [createdReportBootstrap?.reportId, propReportId]);
|
|
66613
66517
|
(0, import_react63.useEffect)(() => {
|
|
66614
|
-
|
|
66518
|
+
setAxisEdits({});
|
|
66615
66519
|
setChartVisibilityOverrides({});
|
|
66616
66520
|
setChartSortOverride(void 0);
|
|
66617
66521
|
}, [effectiveReportId]);
|
|
@@ -69613,20 +69517,18 @@ function useReport(reportIdArg, options = {}) {
|
|
|
69613
69517
|
chartPivotHydrationEpoch
|
|
69614
69518
|
]);
|
|
69615
69519
|
const baseChart = (0, import_react63.useMemo)(
|
|
69616
|
-
() => normalizePivotChartForDisplay(chartData
|
|
69617
|
-
[chartData
|
|
69520
|
+
() => normalizePivotChartForDisplay(chartData),
|
|
69521
|
+
[chartData]
|
|
69618
69522
|
);
|
|
69619
|
-
const
|
|
69620
|
-
if (!
|
|
69621
|
-
|
|
69622
|
-
|
|
69623
|
-
|
|
69624
|
-
|
|
69625
|
-
|
|
69626
|
-
|
|
69627
|
-
|
|
69628
|
-
return baseChart;
|
|
69629
|
-
}, [baseChart, chartData, effectiveReportId, resolveTableDisplayLabel]);
|
|
69523
|
+
const yAxisResolved = (0, import_react63.useMemo)(() => {
|
|
69524
|
+
if (!baseChart) return { measures: [], series: [] };
|
|
69525
|
+
return resolveReportYAxis(
|
|
69526
|
+
baseChart,
|
|
69527
|
+
axisEdits.yAxisFields,
|
|
69528
|
+
resolveTableDisplayLabel
|
|
69529
|
+
);
|
|
69530
|
+
}, [baseChart, axisEdits.yAxisFields, resolveTableDisplayLabel]);
|
|
69531
|
+
const chartAxesBaseChart = baseChart;
|
|
69630
69532
|
const chartAxisOptions = (0, import_react63.useMemo)(() => {
|
|
69631
69533
|
if (!chartAxesBaseChart) return [];
|
|
69632
69534
|
const optionsByField = /* @__PURE__ */ new Map();
|
|
@@ -69645,7 +69547,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
69645
69547
|
for (const column of chartAxesBaseChart.columns ?? []) {
|
|
69646
69548
|
registerOption(column.field, column.label, column.format);
|
|
69647
69549
|
}
|
|
69648
|
-
for (const yAxis2 of
|
|
69550
|
+
for (const yAxis2 of yAxisResolved.measures) {
|
|
69649
69551
|
registerOption(yAxis2.field, yAxis2.label, yAxis2.format);
|
|
69650
69552
|
if (yAxis2.format) {
|
|
69651
69553
|
const existing = optionsByField.get(yAxis2.field);
|
|
@@ -69657,18 +69559,6 @@ function useReport(reportIdArg, options = {}) {
|
|
|
69657
69559
|
}
|
|
69658
69560
|
}
|
|
69659
69561
|
}
|
|
69660
|
-
if (chartAxesBaseChart.pivot?.columnField) {
|
|
69661
|
-
for (const aggregationAxis of buildPivotAggregationAxisFields(
|
|
69662
|
-
chartAxesBaseChart,
|
|
69663
|
-
resolveTableDisplayLabel
|
|
69664
|
-
)) {
|
|
69665
|
-
registerOption(
|
|
69666
|
-
aggregationAxis.field,
|
|
69667
|
-
aggregationAxis.label,
|
|
69668
|
-
aggregationAxis.format
|
|
69669
|
-
);
|
|
69670
|
-
}
|
|
69671
|
-
}
|
|
69672
69562
|
const xField = String(chartAxesBaseChart.xAxisField ?? "").trim();
|
|
69673
69563
|
const savedXFormat = String(chartAxesBaseChart.xAxisFormat ?? "").trim();
|
|
69674
69564
|
registerOption(
|
|
@@ -69686,7 +69576,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
69686
69576
|
}
|
|
69687
69577
|
}
|
|
69688
69578
|
return Array.from(optionsByField.values());
|
|
69689
|
-
}, [chartAxesBaseChart,
|
|
69579
|
+
}, [chartAxesBaseChart, yAxisResolved.measures]);
|
|
69690
69580
|
const chartAxisOptionByField = (0, import_react63.useMemo)(() => {
|
|
69691
69581
|
const optionsByField = /* @__PURE__ */ new Map();
|
|
69692
69582
|
for (const option of chartAxisOptions) {
|
|
@@ -69717,46 +69607,6 @@ function useReport(reportIdArg, options = {}) {
|
|
|
69717
69607
|
}
|
|
69718
69608
|
return chartAxisOptions;
|
|
69719
69609
|
}, [chartAxesBaseChart, chartAxisOptions, chartAxisOptionByField]);
|
|
69720
|
-
const yAxisOptions = (0, import_react63.useMemo)(() => {
|
|
69721
|
-
if (!chartAxesBaseChart) return [];
|
|
69722
|
-
const keepOption = (option) => {
|
|
69723
|
-
const col = findSchemaColumnForChartAxisField(
|
|
69724
|
-
option.value,
|
|
69725
|
-
schemaColumnOptions
|
|
69726
|
-
);
|
|
69727
|
-
if (!col) return true;
|
|
69728
|
-
return isNumericishColumnType(col.type);
|
|
69729
|
-
};
|
|
69730
|
-
let eligible = chartAxisOptions.filter(keepOption);
|
|
69731
|
-
const pivot = chartAxesBaseChart.pivot;
|
|
69732
|
-
const pivotRowField = String(pivot?.rowField ?? "").trim();
|
|
69733
|
-
if (pivot && !pivotRowField) {
|
|
69734
|
-
const aggAxis = buildPivotAggregationAxisFields(
|
|
69735
|
-
chartAxesBaseChart,
|
|
69736
|
-
resolveTableDisplayLabel
|
|
69737
|
-
);
|
|
69738
|
-
if (aggAxis.length > 0) {
|
|
69739
|
-
const allowed = new Set(aggAxis.map((a) => a.field));
|
|
69740
|
-
eligible = eligible.filter((o) => allowed.has(o.value));
|
|
69741
|
-
}
|
|
69742
|
-
}
|
|
69743
|
-
const merged = new Map(
|
|
69744
|
-
eligible.map((o) => [o.value, o])
|
|
69745
|
-
);
|
|
69746
|
-
for (const yAxisField of chartAxesBaseChart.yAxisFields ?? []) {
|
|
69747
|
-
const field = String(yAxisField?.field ?? "").trim();
|
|
69748
|
-
if (!field || merged.has(field)) continue;
|
|
69749
|
-
const opt = chartAxisOptionByField.get(field);
|
|
69750
|
-
if (opt) merged.set(field, opt);
|
|
69751
|
-
}
|
|
69752
|
-
return Array.from(merged.values());
|
|
69753
|
-
}, [
|
|
69754
|
-
chartAxesBaseChart,
|
|
69755
|
-
chartAxisOptionByField,
|
|
69756
|
-
chartAxisOptions,
|
|
69757
|
-
resolveTableDisplayLabel,
|
|
69758
|
-
schemaColumnOptions
|
|
69759
|
-
]);
|
|
69760
69610
|
const normalizedChartXAxisOptions = (0, import_react63.useMemo)(() => {
|
|
69761
69611
|
return xAxisOptions.map((option) => ({
|
|
69762
69612
|
value: String(option.value ?? "").trim(),
|
|
@@ -69764,41 +69614,9 @@ function useReport(reportIdArg, options = {}) {
|
|
|
69764
69614
|
format: String(option.format ?? "").trim()
|
|
69765
69615
|
}));
|
|
69766
69616
|
}, [xAxisOptions]);
|
|
69767
|
-
const
|
|
69768
|
-
|
|
69769
|
-
|
|
69770
|
-
label: String(option.label ?? option.value ?? "").trim(),
|
|
69771
|
-
format: String(option.format ?? "").trim()
|
|
69772
|
-
}));
|
|
69773
|
-
}, [yAxisOptions]);
|
|
69774
|
-
const resolvedYAxisFields = (0, import_react63.useMemo)(() => {
|
|
69775
|
-
if (!chartAxesBaseChart) return [];
|
|
69776
|
-
const normalizeYAxisField = (yAxisFieldRaw) => {
|
|
69777
|
-
const field = String(yAxisFieldRaw?.field ?? "").trim();
|
|
69778
|
-
if (!field) return null;
|
|
69779
|
-
const option = chartAxisOptionByField.get(field);
|
|
69780
|
-
if (!option) return null;
|
|
69781
|
-
const rawLabel = String(yAxisFieldRaw?.label ?? "").trim() || option.label;
|
|
69782
|
-
const label = rawLabel === field ? toTitleCaseLabel(field) : rawLabel;
|
|
69783
|
-
const format9 = toAxisFormat(yAxisFieldRaw?.format, option.format);
|
|
69784
|
-
return {
|
|
69785
|
-
field,
|
|
69786
|
-
label,
|
|
69787
|
-
format: format9
|
|
69788
|
-
};
|
|
69789
|
-
};
|
|
69790
|
-
const fallbackYAxisFields = (chartAxesBaseChart.yAxisFields ?? []).map((yAxisField) => normalizeYAxisField(yAxisField)).filter(
|
|
69791
|
-
(yAxisField) => Boolean(yAxisField)
|
|
69792
|
-
);
|
|
69793
|
-
const requestedYAxisFields = Array.isArray(chartAxisEdits.yAxisFields) ? chartAxisEdits.yAxisFields : fallbackYAxisFields;
|
|
69794
|
-
const normalizedRequestedYAxisFields = requestedYAxisFields.map((yAxisField) => normalizeYAxisField(yAxisField)).filter(
|
|
69795
|
-
(yAxisField) => Boolean(yAxisField)
|
|
69796
|
-
);
|
|
69797
|
-
if (normalizedRequestedYAxisFields.length > 0) {
|
|
69798
|
-
return normalizedRequestedYAxisFields;
|
|
69799
|
-
}
|
|
69800
|
-
if (fallbackYAxisFields.length > 0) {
|
|
69801
|
-
return fallbackYAxisFields;
|
|
69617
|
+
const yAxisMeasures = (0, import_react63.useMemo)(() => {
|
|
69618
|
+
if (yAxisResolved.measures.length > 0) {
|
|
69619
|
+
return yAxisResolved.measures;
|
|
69802
69620
|
}
|
|
69803
69621
|
const fallbackOption = chartAxisOptions[0];
|
|
69804
69622
|
if (!fallbackOption) return [];
|
|
@@ -69809,12 +69627,22 @@ function useReport(reportIdArg, options = {}) {
|
|
|
69809
69627
|
format: fallbackOption.format
|
|
69810
69628
|
}
|
|
69811
69629
|
];
|
|
69812
|
-
}, [
|
|
69813
|
-
|
|
69814
|
-
|
|
69815
|
-
|
|
69816
|
-
|
|
69817
|
-
|
|
69630
|
+
}, [chartAxisOptions, yAxisResolved.measures]);
|
|
69631
|
+
const yAxisOptions = (0, import_react63.useMemo)(
|
|
69632
|
+
() => yAxisMeasures.map((measure) => ({
|
|
69633
|
+
value: measure.field,
|
|
69634
|
+
label: measure.label,
|
|
69635
|
+
format: toAxisFormat(measure.format, "string")
|
|
69636
|
+
})),
|
|
69637
|
+
[yAxisMeasures]
|
|
69638
|
+
);
|
|
69639
|
+
const normalizedChartYAxisOptions = (0, import_react63.useMemo)(() => {
|
|
69640
|
+
return yAxisOptions.map((option) => ({
|
|
69641
|
+
value: String(option.value ?? "").trim(),
|
|
69642
|
+
label: String(option.label ?? option.value ?? "").trim(),
|
|
69643
|
+
format: String(option.format ?? "").trim()
|
|
69644
|
+
}));
|
|
69645
|
+
}, [yAxisOptions]);
|
|
69818
69646
|
const resolvedXAxisField = (0, import_react63.useMemo)(() => {
|
|
69819
69647
|
if (!chartAxesBaseChart) return "";
|
|
69820
69648
|
const chartType2 = String(chartAxesBaseChart.chartType ?? "").toLowerCase();
|
|
@@ -69829,7 +69657,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
69829
69657
|
return pivotRowField;
|
|
69830
69658
|
}
|
|
69831
69659
|
}
|
|
69832
|
-
const requestedXAxisField = String(
|
|
69660
|
+
const requestedXAxisField = String(axisEdits.xAxisField ?? "").trim();
|
|
69833
69661
|
if (requestedXAxisField && chartAxisOptionByField.has(requestedXAxisField)) {
|
|
69834
69662
|
return requestedXAxisField;
|
|
69835
69663
|
}
|
|
@@ -69837,16 +69665,16 @@ function useReport(reportIdArg, options = {}) {
|
|
|
69837
69665
|
if (baseXAxisField && chartAxisOptionByField.has(baseXAxisField)) {
|
|
69838
69666
|
return baseXAxisField;
|
|
69839
69667
|
}
|
|
69840
|
-
return
|
|
69668
|
+
return yAxisMeasures[0]?.field ?? chartAxisOptions[0]?.value ?? "";
|
|
69841
69669
|
}, [
|
|
69842
69670
|
chartAxesBaseChart,
|
|
69843
|
-
|
|
69671
|
+
axisEdits.xAxisField,
|
|
69844
69672
|
chartAxisOptionByField,
|
|
69845
69673
|
chartAxisOptions,
|
|
69846
|
-
|
|
69674
|
+
yAxisMeasures
|
|
69847
69675
|
]);
|
|
69848
69676
|
const xAxisMetadataField = String(
|
|
69849
|
-
|
|
69677
|
+
axisEdits.xAxisField ?? chartData?.xAxisField ?? ""
|
|
69850
69678
|
).trim();
|
|
69851
69679
|
const xAxisMetadataMatchesResolvedField = !xAxisMetadataField || xAxisMetadataField === resolvedXAxisField;
|
|
69852
69680
|
const resolvedXAxisFormat = (0, import_react63.useMemo)(() => {
|
|
@@ -69854,7 +69682,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
69854
69682
|
return "string";
|
|
69855
69683
|
}
|
|
69856
69684
|
let defaultFormat = toAxisFormat(
|
|
69857
|
-
chartAxisOptionByField.get(resolvedXAxisField)?.format ?? chartAxesBaseChart.xAxisFormat ??
|
|
69685
|
+
chartAxisOptionByField.get(resolvedXAxisField)?.format ?? chartAxesBaseChart.xAxisFormat ?? yAxisMeasures[0]?.format,
|
|
69858
69686
|
"string"
|
|
69859
69687
|
);
|
|
69860
69688
|
const bucketFormat = resolvePivotDateBucketXAxisFormat(
|
|
@@ -69862,16 +69690,16 @@ function useReport(reportIdArg, options = {}) {
|
|
|
69862
69690
|
resolvedXAxisField
|
|
69863
69691
|
);
|
|
69864
69692
|
if (bucketFormat) return bucketFormat;
|
|
69865
|
-
if (isPivotTableDateBucketRowAxis(chartAxesBaseChart, resolvedXAxisField) && (!xAxisMetadataMatchesResolvedField ||
|
|
69693
|
+
if (isPivotTableDateBucketRowAxis(chartAxesBaseChart, resolvedXAxisField) && (!xAxisMetadataMatchesResolvedField || axisEdits.xAxisFormat === void 0)) {
|
|
69866
69694
|
defaultFormat = "string";
|
|
69867
69695
|
}
|
|
69868
|
-
return xAxisMetadataMatchesResolvedField &&
|
|
69696
|
+
return xAxisMetadataMatchesResolvedField && axisEdits.xAxisFormat !== void 0 ? toAxisFormat(axisEdits.xAxisFormat, defaultFormat) : defaultFormat;
|
|
69869
69697
|
}, [
|
|
69870
69698
|
chartAxesBaseChart,
|
|
69871
|
-
|
|
69699
|
+
axisEdits.xAxisFormat,
|
|
69872
69700
|
chartAxisOptionByField,
|
|
69873
69701
|
resolvedXAxisField,
|
|
69874
|
-
|
|
69702
|
+
yAxisMeasures,
|
|
69875
69703
|
xAxisMetadataMatchesResolvedField
|
|
69876
69704
|
]);
|
|
69877
69705
|
const resolvedXAxisLabel = (0, import_react63.useMemo)(() => {
|
|
@@ -69879,13 +69707,13 @@ function useReport(reportIdArg, options = {}) {
|
|
|
69879
69707
|
const defaultXLabel = String(
|
|
69880
69708
|
xAxisMetadataMatchesResolvedField ? chartAxesBaseChart?.xAxisLabel ?? fieldLabel : fieldLabel
|
|
69881
69709
|
).trim();
|
|
69882
|
-
if (xAxisMetadataMatchesResolvedField &&
|
|
69883
|
-
return String(
|
|
69710
|
+
if (xAxisMetadataMatchesResolvedField && axisEdits.xAxisLabel !== void 0) {
|
|
69711
|
+
return String(axisEdits.xAxisLabel).trim();
|
|
69884
69712
|
}
|
|
69885
69713
|
return !defaultXLabel || defaultXLabel === resolvedXAxisField ? toTitleCaseLabel(resolvedXAxisField) : defaultXLabel;
|
|
69886
69714
|
}, [
|
|
69887
69715
|
chartAxesBaseChart?.xAxisLabel,
|
|
69888
|
-
|
|
69716
|
+
axisEdits.xAxisLabel,
|
|
69889
69717
|
chartAxisOptionByField,
|
|
69890
69718
|
resolvedXAxisField,
|
|
69891
69719
|
xAxisMetadataMatchesResolvedField
|
|
@@ -69915,7 +69743,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
69915
69743
|
]);
|
|
69916
69744
|
const yAxis = (0, import_react63.useMemo)(
|
|
69917
69745
|
() => ({
|
|
69918
|
-
fields:
|
|
69746
|
+
fields: yAxisMeasures.map((yAxisField) => ({
|
|
69919
69747
|
field: yAxisField.field,
|
|
69920
69748
|
label: String(yAxisField.label ?? "").trim(),
|
|
69921
69749
|
format: axisFormatToSelectLabel(
|
|
@@ -69923,24 +69751,23 @@ function useReport(reportIdArg, options = {}) {
|
|
|
69923
69751
|
)
|
|
69924
69752
|
}))
|
|
69925
69753
|
}),
|
|
69926
|
-
[
|
|
69754
|
+
[yAxisMeasures]
|
|
69927
69755
|
);
|
|
69928
|
-
const
|
|
69929
|
-
if (
|
|
69930
|
-
|
|
69931
|
-
|
|
69932
|
-
|
|
69933
|
-
|
|
69934
|
-
}, [baseChart, resolvedYAxisFields]);
|
|
69756
|
+
const yAxisSeries = (0, import_react63.useMemo)(() => {
|
|
69757
|
+
if (yAxisResolved.series.length > 0) {
|
|
69758
|
+
return yAxisResolved.series;
|
|
69759
|
+
}
|
|
69760
|
+
return yAxisMeasures;
|
|
69761
|
+
}, [yAxisMeasures, yAxisResolved.series]);
|
|
69935
69762
|
const chart = (0, import_react63.useMemo)(() => {
|
|
69936
69763
|
if (!baseChart) return void 0;
|
|
69937
69764
|
let columns2 = mergeChartColumnFormatsFromYAxisFields(
|
|
69938
69765
|
baseChart.columns,
|
|
69939
|
-
|
|
69766
|
+
yAxisSeries
|
|
69940
69767
|
);
|
|
69941
69768
|
if (String(baseChart.chartType ?? "").toLowerCase() === "table" && baseChart.pivot) {
|
|
69942
69769
|
const pivotAggregations2 = getPivotAggregations(baseChart);
|
|
69943
|
-
const hasCustomMeasureLabel =
|
|
69770
|
+
const hasCustomMeasureLabel = yAxisMeasures.some((axis) => {
|
|
69944
69771
|
const aggregation = findAggregationForFieldStrict(
|
|
69945
69772
|
axis.field,
|
|
69946
69773
|
pivotAggregations2
|
|
@@ -69953,7 +69780,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
69953
69780
|
if (pivotAggregations2.length > 1 || hasCustomMeasureLabel) {
|
|
69954
69781
|
columns2 = mergePivotTableDisplayColumnLabelsFromYAxis({
|
|
69955
69782
|
columns: columns2 ?? baseChart.columns,
|
|
69956
|
-
yAxisFields:
|
|
69783
|
+
yAxisFields: yAxisSeries,
|
|
69957
69784
|
pivotRowField: pivotRowKey(baseChart),
|
|
69958
69785
|
xAxisLabel: resolvedXAxisLabel
|
|
69959
69786
|
});
|
|
@@ -69980,7 +69807,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
69980
69807
|
xAxisField: resolvedXAxisField,
|
|
69981
69808
|
xAxisFormat: resolvedXAxisFormat,
|
|
69982
69809
|
xAxisLabel: resolvedXAxisLabel,
|
|
69983
|
-
yAxisFields:
|
|
69810
|
+
yAxisFields: yAxisSeries,
|
|
69984
69811
|
columns: columns2 ?? baseChart.columns
|
|
69985
69812
|
};
|
|
69986
69813
|
}, [
|
|
@@ -69988,8 +69815,8 @@ function useReport(reportIdArg, options = {}) {
|
|
|
69988
69815
|
resolvedXAxisField,
|
|
69989
69816
|
resolvedXAxisFormat,
|
|
69990
69817
|
resolvedXAxisLabel,
|
|
69991
|
-
|
|
69992
|
-
|
|
69818
|
+
yAxisMeasures,
|
|
69819
|
+
yAxisSeries
|
|
69993
69820
|
]);
|
|
69994
69821
|
const pivotDateFilterRangeCacheRef = (0, import_react63.useRef)({ key: "", min: null, max: null });
|
|
69995
69822
|
const filterOptions = (0, import_react63.useMemo)(() => {
|
|
@@ -70007,10 +69834,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70007
69834
|
if (rowField && isDateType(String(pivot?.rowFieldType ?? ""))) {
|
|
70008
69835
|
const field = pivot?.rowFieldTable ? `${pivot.rowFieldTable}.${rowField}` : rowField;
|
|
70009
69836
|
const chartBucket = dateBucket || pivot?.dateBucket || "month";
|
|
70010
|
-
const bucket = inBucketDateBucketForField(
|
|
70011
|
-
filtersForQueryBuilder.rules ?? [],
|
|
70012
|
-
field
|
|
70013
|
-
) ?? chartBucket;
|
|
69837
|
+
const bucket = inBucketDateBucketForField(filtersForQueryBuilder.rules ?? [], field) ?? chartBucket;
|
|
70014
69838
|
const cacheKey = `${String(effectiveReportId ?? "")}\0${field}\0${bucket}`;
|
|
70015
69839
|
if (pivotDateFilterRangeCacheRef.current.key !== cacheKey) {
|
|
70016
69840
|
pivotDateFilterRangeCacheRef.current = {
|
|
@@ -70143,8 +69967,8 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70143
69967
|
[chartForUi, resolvedChartSort]
|
|
70144
69968
|
);
|
|
70145
69969
|
const isPivotTableChart = String(chartType ?? "").toLowerCase() === "table" && Boolean(pivotState);
|
|
70146
|
-
const
|
|
70147
|
-
() => isPivotTableChart ?
|
|
69970
|
+
const pivotTableColumns = (0, import_react63.useMemo)(
|
|
69971
|
+
() => isPivotTableChart ? buildPivotTableColumns(
|
|
70148
69972
|
pivotState,
|
|
70149
69973
|
chart,
|
|
70150
69974
|
resolveTableDisplayLabel
|
|
@@ -70152,7 +69976,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70152
69976
|
[chart, isPivotTableChart, pivotState, resolveTableDisplayLabel]
|
|
70153
69977
|
);
|
|
70154
69978
|
const chartAxes = (0, import_react63.useMemo)(() => {
|
|
70155
|
-
const yAxisItems =
|
|
69979
|
+
const yAxisItems = yAxisMeasures.map(
|
|
70156
69980
|
(yAxisField, index) => ({
|
|
70157
69981
|
id: String(index),
|
|
70158
69982
|
field: yAxisField.field,
|
|
@@ -70160,7 +69984,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70160
69984
|
format: toAxisFormat(yAxisField.format, "string")
|
|
70161
69985
|
})
|
|
70162
69986
|
);
|
|
70163
|
-
const getCurrentYAxisFields = () =>
|
|
69987
|
+
const getCurrentYAxisFields = () => yAxisMeasures.map((yAxisField) => ({
|
|
70164
69988
|
field: yAxisField.field,
|
|
70165
69989
|
label: yAxisField.label,
|
|
70166
69990
|
format: toAxisFormat(yAxisField.format, "string")
|
|
@@ -70172,7 +69996,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70172
69996
|
options: xAxisOptions,
|
|
70173
69997
|
formatOptions: AXIS_FORMAT_OPTIONS,
|
|
70174
69998
|
update: (updates) => {
|
|
70175
|
-
|
|
69999
|
+
setAxisEdits((previousEdits) => {
|
|
70176
70000
|
const nextEdits = { ...previousEdits };
|
|
70177
70001
|
if (updates.field !== void 0) {
|
|
70178
70002
|
const requestedField = String(updates.field ?? "").trim();
|
|
@@ -70229,7 +70053,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70229
70053
|
resolvedXAxisFormat || "string"
|
|
70230
70054
|
)
|
|
70231
70055
|
};
|
|
70232
|
-
|
|
70056
|
+
setAxisEdits((previousEdits) => ({
|
|
70233
70057
|
...previousEdits,
|
|
70234
70058
|
yAxisFields: [...currentYAxisFields, nextYAxisField]
|
|
70235
70059
|
}));
|
|
@@ -70242,7 +70066,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70242
70066
|
if (index < 0 || index >= currentYAxisFields.length) return;
|
|
70243
70067
|
const nextYAxisFields = [...currentYAxisFields];
|
|
70244
70068
|
nextYAxisFields.splice(index, 1);
|
|
70245
|
-
|
|
70069
|
+
setAxisEdits((previousEdits) => ({
|
|
70246
70070
|
...previousEdits,
|
|
70247
70071
|
yAxisFields: nextYAxisFields
|
|
70248
70072
|
}));
|
|
@@ -70255,7 +70079,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70255
70079
|
newIndex
|
|
70256
70080
|
);
|
|
70257
70081
|
if (nextYAxisFields === currentYAxisFields) return;
|
|
70258
|
-
|
|
70082
|
+
setAxisEdits((previousEdits) => ({
|
|
70259
70083
|
...previousEdits,
|
|
70260
70084
|
yAxisFields: nextYAxisFields
|
|
70261
70085
|
}));
|
|
@@ -70284,7 +70108,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70284
70108
|
label: nextLabel,
|
|
70285
70109
|
format: nextFormat
|
|
70286
70110
|
};
|
|
70287
|
-
|
|
70111
|
+
setAxisEdits((previousEdits) => ({
|
|
70288
70112
|
...previousEdits,
|
|
70289
70113
|
yAxisFields: nextYAxisFields
|
|
70290
70114
|
}));
|
|
@@ -70296,7 +70120,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70296
70120
|
chartAxisOptionByField,
|
|
70297
70121
|
resolvedXAxisField,
|
|
70298
70122
|
resolvedXAxisFormat,
|
|
70299
|
-
|
|
70123
|
+
yAxisMeasures,
|
|
70300
70124
|
xAxisOptions,
|
|
70301
70125
|
yAxisOptions
|
|
70302
70126
|
]);
|
|
@@ -70328,7 +70152,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70328
70152
|
includeSelectedSchemaFallback: tableColumnsEditedSignature !== null
|
|
70329
70153
|
});
|
|
70330
70154
|
const pivotRowFieldForTable = pivotRowKey(sourceReport);
|
|
70331
|
-
const pivotRowTableUsesAxisFormat =
|
|
70155
|
+
const pivotRowTableUsesAxisFormat = axisEdits.xAxisFormat !== void 0;
|
|
70332
70156
|
const columns2 = String(chartType ?? "").toLowerCase() === "table" && sourceReport?.pivot && pivotRowFieldForTable && String(resolvedXAxisField ?? "").trim() === pivotRowFieldForTable ? mergedFromReport.map(
|
|
70333
70157
|
(column) => column.field === pivotRowFieldForTable ? {
|
|
70334
70158
|
...column,
|
|
@@ -70338,7 +70162,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70338
70162
|
) : mergedFromReport;
|
|
70339
70163
|
const pivotLabeledColumns = String(chartType ?? "").toLowerCase() === "table" && sourceReport?.pivot ? mergePivotTableDisplayColumnLabelsFromYAxis({
|
|
70340
70164
|
columns: columns2,
|
|
70341
|
-
yAxisFields:
|
|
70165
|
+
yAxisFields: yAxisSeries,
|
|
70342
70166
|
pivotRowField: pivotRowKey(sourceReport),
|
|
70343
70167
|
xAxisLabel: resolvedXAxisLabel
|
|
70344
70168
|
}) ?? columns2 : columns2;
|
|
@@ -70414,14 +70238,14 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70414
70238
|
getPageOptions: () => getPageOptionsFromPageCount(paginationPageCount)
|
|
70415
70239
|
};
|
|
70416
70240
|
}, [
|
|
70417
|
-
|
|
70241
|
+
axisEdits.xAxisFormat,
|
|
70418
70242
|
chartType,
|
|
70419
70243
|
displayColumns,
|
|
70420
70244
|
effectiveReportBuilderTableNames,
|
|
70421
70245
|
resolvedXAxisField,
|
|
70422
70246
|
resolvedXAxisFormat,
|
|
70423
70247
|
resolvedXAxisLabel,
|
|
70424
|
-
|
|
70248
|
+
yAxisSeries,
|
|
70425
70249
|
scopedSchemaColumns,
|
|
70426
70250
|
sourceReport,
|
|
70427
70251
|
tableColumnsEditedSignature,
|
|
@@ -70446,11 +70270,11 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70446
70270
|
columnsOptions: tableFormattingColumnOptions,
|
|
70447
70271
|
hasTableDrivenColumnOrder
|
|
70448
70272
|
} = (0, import_react63.useMemo)(() => {
|
|
70449
|
-
if (
|
|
70273
|
+
if (pivotTableColumns) {
|
|
70450
70274
|
return getAllColumnOptions({
|
|
70451
70275
|
schemaColumnOptions,
|
|
70452
|
-
tableColumns:
|
|
70453
|
-
selectedColumnIds:
|
|
70276
|
+
tableColumns: pivotTableColumns.tableColumns,
|
|
70277
|
+
selectedColumnIds: pivotTableColumns.selectedColumnIds
|
|
70454
70278
|
});
|
|
70455
70279
|
}
|
|
70456
70280
|
if (isPivotTableChart) {
|
|
@@ -70471,7 +70295,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70471
70295
|
chart?.xAxisLabel,
|
|
70472
70296
|
columns,
|
|
70473
70297
|
isPivotTableChart,
|
|
70474
|
-
|
|
70298
|
+
pivotTableColumns,
|
|
70475
70299
|
schemaColumnOptions,
|
|
70476
70300
|
table.columns
|
|
70477
70301
|
]);
|
|
@@ -70493,8 +70317,8 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70493
70317
|
[tableDerivedColumnOrder]
|
|
70494
70318
|
);
|
|
70495
70319
|
const activeTableColumnIds = (0, import_react63.useMemo)(() => {
|
|
70496
|
-
if (
|
|
70497
|
-
return
|
|
70320
|
+
if (pivotTableColumns) {
|
|
70321
|
+
return pivotTableColumns.selectedColumnIds;
|
|
70498
70322
|
}
|
|
70499
70323
|
if (isPivotTableChart) {
|
|
70500
70324
|
return [];
|
|
@@ -70522,7 +70346,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70522
70346
|
columns,
|
|
70523
70347
|
hasTableDrivenColumnOrder,
|
|
70524
70348
|
isPivotTableChart,
|
|
70525
|
-
|
|
70349
|
+
pivotTableColumns,
|
|
70526
70350
|
tableDerivedColumnOrder,
|
|
70527
70351
|
tableFormattingColumnOptions
|
|
70528
70352
|
]);
|
|
@@ -70583,44 +70407,12 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70583
70407
|
});
|
|
70584
70408
|
}
|
|
70585
70409
|
const columnPivotMeasureFormatByAggregationField = /* @__PURE__ */ new Map();
|
|
70586
|
-
if (
|
|
70587
|
-
const
|
|
70588
|
-
|
|
70589
|
-
const
|
|
70590
|
-
|
|
70591
|
-
|
|
70592
|
-
const firstValueColumnFormat = String(
|
|
70593
|
-
(chart.columns ?? []).find(
|
|
70594
|
-
(c) => String(c.field ?? "").trim() !== rowField
|
|
70595
|
-
)?.format ?? ""
|
|
70596
|
-
).trim();
|
|
70597
|
-
for (let aggIdx = 0; aggIdx < aggregations.length; aggIdx++) {
|
|
70598
|
-
const agg = aggregations[aggIdx];
|
|
70599
|
-
const fieldKey = getAggregationFieldKey(agg, hasMultiple);
|
|
70600
|
-
if (!fieldKey) continue;
|
|
70601
|
-
let fmt = "";
|
|
70602
|
-
if (!hasMultiple) {
|
|
70603
|
-
fmt = String(chart.yAxisFields?.[0]?.format ?? "").trim() || firstValueColumnFormat;
|
|
70604
|
-
} else {
|
|
70605
|
-
for (const yAxisField of chart.yAxisFields ?? []) {
|
|
70606
|
-
const wf = String(yAxisField.field ?? "").trim();
|
|
70607
|
-
if (!wf) continue;
|
|
70608
|
-
const matched = findAggregationForFieldStrict(wf, aggregations);
|
|
70609
|
-
if (!matched || getAggregationIdentityKey(matched) !== getAggregationIdentityKey(agg)) {
|
|
70610
|
-
continue;
|
|
70611
|
-
}
|
|
70612
|
-
fmt = String(yAxisField.format ?? "").trim();
|
|
70613
|
-
break;
|
|
70614
|
-
}
|
|
70615
|
-
if (!fmt && sourceReport?.columns?.[aggIdx + 1]) {
|
|
70616
|
-
fmt = String(
|
|
70617
|
-
sourceReport.columns[aggIdx + 1]?.format ?? ""
|
|
70618
|
-
).trim();
|
|
70619
|
-
}
|
|
70620
|
-
}
|
|
70621
|
-
if (fmt) {
|
|
70622
|
-
columnPivotMeasureFormatByAggregationField.set(fieldKey, fmt);
|
|
70623
|
-
}
|
|
70410
|
+
if (pivotTableColumns) {
|
|
70411
|
+
for (const measure of yAxisResolved.measures) {
|
|
70412
|
+
const field = String(measure.field ?? "").trim();
|
|
70413
|
+
const fmt = String(measure.format ?? "").trim();
|
|
70414
|
+
if (field && fmt) {
|
|
70415
|
+
columnPivotMeasureFormatByAggregationField.set(field, fmt);
|
|
70624
70416
|
}
|
|
70625
70417
|
}
|
|
70626
70418
|
}
|
|
@@ -70671,11 +70463,11 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70671
70463
|
displayColumnById,
|
|
70672
70464
|
isPivotTableChart,
|
|
70673
70465
|
pivotState,
|
|
70674
|
-
|
|
70466
|
+
pivotTableColumns,
|
|
70675
70467
|
resolvedXAxisFormat,
|
|
70676
70468
|
resolvedXAxisLabel,
|
|
70677
|
-
|
|
70678
|
-
|
|
70469
|
+
tableFormatMerge,
|
|
70470
|
+
yAxisResolved.measures
|
|
70679
70471
|
]);
|
|
70680
70472
|
const tableColumnSettingsCoalesceRef = (0, import_react63.useRef)(
|
|
70681
70473
|
/* @__PURE__ */ new Map()
|
|
@@ -70697,8 +70489,8 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70697
70489
|
const field = String(option?.field ?? "").trim() || columnId;
|
|
70698
70490
|
const tableName = String(option?.tableName ?? "").trim();
|
|
70699
70491
|
const coercedFormat = coerceTableColumnFormatToAxisValue(format9);
|
|
70700
|
-
const
|
|
70701
|
-
const formatLabel =
|
|
70492
|
+
const isPivotDateRow = isPivotTableChart && field === pivotRowFieldForFormat && isDateType(pivotRowFieldType);
|
|
70493
|
+
const formatLabel = isPivotDateRow && coercedFormat === "string" ? "date" : axisFormatToSelectLabel(coercedFormat);
|
|
70702
70494
|
return {
|
|
70703
70495
|
id: columnId,
|
|
70704
70496
|
label: customLabel || defaultLabel,
|
|
@@ -70891,15 +70683,15 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70891
70683
|
chartAxesBaseChart
|
|
70892
70684
|
);
|
|
70893
70685
|
const clickedAgg = findAggregationForFieldStrict(pivotField, aggs);
|
|
70894
|
-
let nextY =
|
|
70686
|
+
let nextY = yAxisMeasures;
|
|
70895
70687
|
if (updates.format !== void 0) {
|
|
70896
70688
|
const axisFormatStr = tableColumnFormatFromUiSelection(
|
|
70897
70689
|
String(updates.format ?? "").trim()
|
|
70898
70690
|
);
|
|
70899
|
-
nextY =
|
|
70691
|
+
nextY = yAxisMeasures.map((y) => {
|
|
70900
70692
|
const yAgg = findAggregationForFieldStrict(y.field, aggs);
|
|
70901
70693
|
const same = clickedAgg && yAgg && getAggregationIdentityKey(clickedAgg) === getAggregationIdentityKey(yAgg);
|
|
70902
|
-
const singleBroadcast = Boolean(clickedAgg) &&
|
|
70694
|
+
const singleBroadcast = Boolean(clickedAgg) && yAxisMeasures.length === 1;
|
|
70903
70695
|
if (same || singleBroadcast) {
|
|
70904
70696
|
return {
|
|
70905
70697
|
...y,
|
|
@@ -70914,9 +70706,9 @@ function useReport(reportIdArg, options = {}) {
|
|
|
70914
70706
|
nextY = nextY.map((y) => {
|
|
70915
70707
|
const yAgg = findAggregationForFieldStrict(y.field, aggs);
|
|
70916
70708
|
const same = clickedAgg && yAgg && getAggregationIdentityKey(clickedAgg) === getAggregationIdentityKey(yAgg);
|
|
70917
|
-
const singleBroadcast = Boolean(clickedAgg) &&
|
|
70709
|
+
const singleBroadcast = Boolean(clickedAgg) && yAxisMeasures.length === 1;
|
|
70918
70710
|
if (same || singleBroadcast) {
|
|
70919
|
-
const nextLabel2 =
|
|
70711
|
+
const nextLabel2 = yAxisMeasures.length === 1 && pivotModel.columnField ? mergePivotColumnSeriesLabelWithUserEdit(
|
|
70920
70712
|
String(y.label ?? "").trim(),
|
|
70921
70713
|
lab,
|
|
70922
70714
|
String(y.field ?? "").trim() || void 0
|
|
@@ -71029,7 +70821,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
71029
70821
|
...effectiveNextState.xAxis !== void 0 ? { xAxis: effectiveNextState.xAxis } : {},
|
|
71030
70822
|
...effectiveNextState.yAxis !== void 0 ? { yAxis: effectiveNextState.yAxis } : {}
|
|
71031
70823
|
};
|
|
71032
|
-
|
|
70824
|
+
setAxisEdits((previousEdits) => {
|
|
71033
70825
|
const nextEdits = { ...previousEdits };
|
|
71034
70826
|
if (cx.xAxis) {
|
|
71035
70827
|
let suppressXAxisLabelFromPayload = false;
|
|
@@ -71642,7 +71434,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
71642
71434
|
xAxisField: resolvedXAxisField,
|
|
71643
71435
|
xAxisFormat: resolvedXAxisFormat,
|
|
71644
71436
|
xAxisLabel: resolvedXAxisLabel,
|
|
71645
|
-
yAxisFields:
|
|
71437
|
+
yAxisFields: yAxisMeasures,
|
|
71646
71438
|
showLegend: chartVisibility.showLegend,
|
|
71647
71439
|
chartSort: resolvedChartSort ?? null,
|
|
71648
71440
|
...overrides?.filterMap !== void 0 ? { filterMap: overrides.filterMap } : {},
|
|
@@ -71695,7 +71487,7 @@ function useReport(reportIdArg, options = {}) {
|
|
|
71695
71487
|
resolvedXAxisField,
|
|
71696
71488
|
resolvedXAxisFormat,
|
|
71697
71489
|
resolvedXAxisLabel,
|
|
71698
|
-
|
|
71490
|
+
yAxisMeasures,
|
|
71699
71491
|
sourceReport,
|
|
71700
71492
|
table.columns,
|
|
71701
71493
|
tenants
|
|
@@ -71730,9 +71522,9 @@ function useReport(reportIdArg, options = {}) {
|
|
|
71730
71522
|
groupColumnsByOptions,
|
|
71731
71523
|
dateBucket: dateBucketMode === "standard" ? pivotState?.dateBucket : dateBucket,
|
|
71732
71524
|
dateBucketOptions: hasDatePivotRow ? dateBucketMode === "standard" ? STANDARD_PIVOT_DATE_BUCKET_OPTIONS : PIVOT_DATE_BUCKET_OPTIONS : [],
|
|
71733
|
-
/** Encoded selection per aggregation
|
|
71525
|
+
/** Encoded selection per aggregation (`'sum:transactions::amount'`, `'count:transactions'`, `''` = placeholder). Update via `setReport({ aggregations: nextStringArray })`. */
|
|
71734
71526
|
aggregations: aggregationValues,
|
|
71735
|
-
/** Flat aggregation pick list shared by all
|
|
71527
|
+
/** Flat aggregation pick list shared by all aggregations; always contains every non-empty `aggregations` entry. */
|
|
71736
71528
|
aggregationOptions,
|
|
71737
71529
|
aggregationDescriptionOptions: cleanedAggregations,
|
|
71738
71530
|
sort: cleanedSort,
|