@quillsql/react 2.16.102 → 2.16.103

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 CHANGED
@@ -63922,22 +63922,21 @@ function isPlaceholderAxisLabel(label, field) {
63922
63922
  function resolvedAxisLabel(savedLabel, field, generatedLabel) {
63923
63923
  return isPlaceholderAxisLabel(savedLabel, field) ? generatedLabel : savedLabel;
63924
63924
  }
63925
+ function uniqueAxisFormat(formats) {
63926
+ const values = formats.map((format9) => String(format9 ?? "").trim()).filter(Boolean);
63927
+ if (values.length === 0) return void 0;
63928
+ return values.every((format9) => format9 === values[0]) ? values[0] : void 0;
63929
+ }
63925
63930
  function resolveYAxisFormatForField(field, aggregation, saved, fallback) {
63926
63931
  const formatByField = new Map(
63927
63932
  saved.map((axis) => [String(axis.field ?? "").trim(), axis.format])
63928
63933
  );
63934
+ const savedFormats = uniqueAxisFormat(saved.map((axis) => axis.format));
63929
63935
  if (aggregation?.aggregationType === "count") {
63930
- return formatByField.get(field) ?? formatByField.get("count") ?? saved[0]?.format ?? "whole_number";
63931
- }
63932
- if (aggregation?.aggregationType === "percentage") {
63933
- const savedFormat = formatByField.get(field);
63934
- if (savedFormat === "percent" || savedFormat === "percentage") {
63935
- return savedFormat;
63936
- }
63937
- return "percentage";
63936
+ return formatByField.get(field) ?? formatByField.get("count") ?? savedFormats ?? "whole_number";
63938
63937
  }
63939
63938
  const aggType = aggregation?.aggregationType ? String(aggregation.aggregationType) : void 0;
63940
- return formatByField.get(field) ?? formatByField.get(trimAggregationSuffix(field, aggType)) ?? (aggregation?.valueField ? formatByField.get(aggregation.valueField) : void 0) ?? fallback;
63939
+ return formatByField.get(field) ?? formatByField.get(trimAggregationSuffix(field, aggType)) ?? (aggregation?.valueField ? formatByField.get(aggregation.valueField) : void 0) ?? savedFormats ?? fallback;
63941
63940
  }
63942
63941
  function aggregationIdentityForField(field, aggregations) {
63943
63942
  return getAggregationIdentityKey(
@@ -64008,6 +64007,7 @@ function applyYAxisEdits(measures, edits, aggregations) {
64008
64007
  const base = (identity ? byIdentity.get(identity) : void 0) ?? byField.get(field);
64009
64008
  const label = String(edit.label ?? "").trim();
64010
64009
  if (!base) {
64010
+ if (aggregations.length > 0) continue;
64011
64011
  next.push({
64012
64012
  field,
64013
64013
  label: label || toTitleCaseLabel(field),
@@ -64021,7 +64021,16 @@ function applyYAxisEdits(measures, edits, aggregations) {
64021
64021
  format: toAxisFormat(edit.format, base.format)
64022
64022
  });
64023
64023
  }
64024
- return next.length > 0 ? next : measures;
64024
+ if (next.length > 0) return next;
64025
+ if (aggregations.length > 0 && measures.length === 1 && edits.length === 1 && edits[0]?.format) {
64026
+ return [
64027
+ {
64028
+ ...measures[0],
64029
+ format: toAxisFormat(edits[0].format, measures[0].format)
64030
+ }
64031
+ ];
64032
+ }
64033
+ return measures;
64025
64034
  }
64026
64035
  function resolveReportYAxis(chart, edits, resolveTableLabel) {
64027
64036
  const saved = chart.yAxisFields ?? [];
@@ -64032,7 +64041,6 @@ function resolveReportYAxis(chart, edits, resolveTableLabel) {
64032
64041
  const aggregations = getPivotAggregations(chart);
64033
64042
  const hasMultipleAggregations = aggregations.length > 1;
64034
64043
  const columnField = String(chart.pivot?.columnField ?? "").trim();
64035
- const isAggregationOnlyPivot = !String(chart.pivot?.rowField ?? "").trim() && !columnField;
64036
64044
  const fallback = saved[0]?.format ?? chart.xAxisFormat ?? "whole_number";
64037
64045
  const valueKeys = pivotValueFieldKeys(chart);
64038
64046
  const fallbackKeys = pivotFallbackValueKeys(chart);
@@ -64054,9 +64062,9 @@ function resolveReportYAxis(chart, edits, resolveTableLabel) {
64054
64062
  measure.field
64055
64063
  );
64056
64064
  if (matchedKey) return [{ ...measure, field: matchedKey }];
64057
- return isAggregationOnlyPivot ? [measure] : [];
64065
+ return [measure];
64058
64066
  });
64059
- if (!columnField && measures.length === 0 && saved.length > 0) {
64067
+ if (!columnField && measures.length === 0 && saved.length > 0 && aggregations.length === 0) {
64060
64068
  measures = saved;
64061
64069
  }
64062
64070
  measures = applyYAxisEdits(measures, edits, aggregations);
@@ -64083,7 +64091,12 @@ function resolveReportYAxis(chart, edits, resolveTableLabel) {
64083
64091
  measureLabel,
64084
64092
  hasMultipleAggregations
64085
64093
  ),
64086
- format: measure?.format ?? resolveYAxisFormatForField(field, aggregation, saved, fallback)
64094
+ format: measure?.format ?? resolveYAxisFormatForField(
64095
+ field,
64096
+ aggregation,
64097
+ saved,
64098
+ fallback
64099
+ )
64087
64100
  }
64088
64101
  ];
64089
64102
  });
@@ -64123,7 +64136,11 @@ function normalizePivotChartForDisplay(chart) {
64123
64136
  pivotRowFieldEarly,
64124
64137
  String(rowColumn?.format ?? "")
64125
64138
  ) ? pivotRowFieldEarly : config.xAxisField;
64126
- const withResolvedXAxis = resolvedXAxisField && resolvedXAxisField !== config.xAxisField ? { ...config, xAxisField: resolvedXAxisField } : config;
64139
+ const withResolvedXAxis = resolvedXAxisField && resolvedXAxisField !== config.xAxisField ? {
64140
+ ...config,
64141
+ xAxisField: resolvedXAxisField,
64142
+ xAxisFormat: toAxisFormat(rowColumn?.format, "string")
64143
+ } : config;
64127
64144
  const isMetricOrGauge = ["metric", "gauge"].includes(
64128
64145
  String(withResolvedXAxis.chartType ?? "").toLowerCase()
64129
64146
  );
package/dist/index.js CHANGED
@@ -64130,22 +64130,21 @@ function isPlaceholderAxisLabel(label, field) {
64130
64130
  function resolvedAxisLabel(savedLabel, field, generatedLabel) {
64131
64131
  return isPlaceholderAxisLabel(savedLabel, field) ? generatedLabel : savedLabel;
64132
64132
  }
64133
+ function uniqueAxisFormat(formats) {
64134
+ const values = formats.map((format9) => String(format9 ?? "").trim()).filter(Boolean);
64135
+ if (values.length === 0) return void 0;
64136
+ return values.every((format9) => format9 === values[0]) ? values[0] : void 0;
64137
+ }
64133
64138
  function resolveYAxisFormatForField(field, aggregation, saved, fallback) {
64134
64139
  const formatByField = new Map(
64135
64140
  saved.map((axis) => [String(axis.field ?? "").trim(), axis.format])
64136
64141
  );
64142
+ const savedFormats = uniqueAxisFormat(saved.map((axis) => axis.format));
64137
64143
  if (aggregation?.aggregationType === "count") {
64138
- return formatByField.get(field) ?? formatByField.get("count") ?? saved[0]?.format ?? "whole_number";
64139
- }
64140
- if (aggregation?.aggregationType === "percentage") {
64141
- const savedFormat = formatByField.get(field);
64142
- if (savedFormat === "percent" || savedFormat === "percentage") {
64143
- return savedFormat;
64144
- }
64145
- return "percentage";
64144
+ return formatByField.get(field) ?? formatByField.get("count") ?? savedFormats ?? "whole_number";
64146
64145
  }
64147
64146
  const aggType = aggregation?.aggregationType ? String(aggregation.aggregationType) : void 0;
64148
- return formatByField.get(field) ?? formatByField.get(trimAggregationSuffix(field, aggType)) ?? (aggregation?.valueField ? formatByField.get(aggregation.valueField) : void 0) ?? fallback;
64147
+ return formatByField.get(field) ?? formatByField.get(trimAggregationSuffix(field, aggType)) ?? (aggregation?.valueField ? formatByField.get(aggregation.valueField) : void 0) ?? savedFormats ?? fallback;
64149
64148
  }
64150
64149
  function aggregationIdentityForField(field, aggregations) {
64151
64150
  return getAggregationIdentityKey(
@@ -64216,6 +64215,7 @@ function applyYAxisEdits(measures, edits, aggregations) {
64216
64215
  const base = (identity ? byIdentity.get(identity) : void 0) ?? byField.get(field);
64217
64216
  const label = String(edit.label ?? "").trim();
64218
64217
  if (!base) {
64218
+ if (aggregations.length > 0) continue;
64219
64219
  next.push({
64220
64220
  field,
64221
64221
  label: label || toTitleCaseLabel(field),
@@ -64229,7 +64229,16 @@ function applyYAxisEdits(measures, edits, aggregations) {
64229
64229
  format: toAxisFormat(edit.format, base.format)
64230
64230
  });
64231
64231
  }
64232
- return next.length > 0 ? next : measures;
64232
+ if (next.length > 0) return next;
64233
+ if (aggregations.length > 0 && measures.length === 1 && edits.length === 1 && edits[0]?.format) {
64234
+ return [
64235
+ {
64236
+ ...measures[0],
64237
+ format: toAxisFormat(edits[0].format, measures[0].format)
64238
+ }
64239
+ ];
64240
+ }
64241
+ return measures;
64233
64242
  }
64234
64243
  function resolveReportYAxis(chart, edits, resolveTableLabel) {
64235
64244
  const saved = chart.yAxisFields ?? [];
@@ -64240,7 +64249,6 @@ function resolveReportYAxis(chart, edits, resolveTableLabel) {
64240
64249
  const aggregations = getPivotAggregations(chart);
64241
64250
  const hasMultipleAggregations = aggregations.length > 1;
64242
64251
  const columnField = String(chart.pivot?.columnField ?? "").trim();
64243
- const isAggregationOnlyPivot = !String(chart.pivot?.rowField ?? "").trim() && !columnField;
64244
64252
  const fallback = saved[0]?.format ?? chart.xAxisFormat ?? "whole_number";
64245
64253
  const valueKeys = pivotValueFieldKeys(chart);
64246
64254
  const fallbackKeys = pivotFallbackValueKeys(chart);
@@ -64262,9 +64270,9 @@ function resolveReportYAxis(chart, edits, resolveTableLabel) {
64262
64270
  measure.field
64263
64271
  );
64264
64272
  if (matchedKey) return [{ ...measure, field: matchedKey }];
64265
- return isAggregationOnlyPivot ? [measure] : [];
64273
+ return [measure];
64266
64274
  });
64267
- if (!columnField && measures.length === 0 && saved.length > 0) {
64275
+ if (!columnField && measures.length === 0 && saved.length > 0 && aggregations.length === 0) {
64268
64276
  measures = saved;
64269
64277
  }
64270
64278
  measures = applyYAxisEdits(measures, edits, aggregations);
@@ -64291,7 +64299,12 @@ function resolveReportYAxis(chart, edits, resolveTableLabel) {
64291
64299
  measureLabel,
64292
64300
  hasMultipleAggregations
64293
64301
  ),
64294
- format: measure?.format ?? resolveYAxisFormatForField(field, aggregation, saved, fallback)
64302
+ format: measure?.format ?? resolveYAxisFormatForField(
64303
+ field,
64304
+ aggregation,
64305
+ saved,
64306
+ fallback
64307
+ )
64295
64308
  }
64296
64309
  ];
64297
64310
  });
@@ -64331,7 +64344,11 @@ function normalizePivotChartForDisplay(chart) {
64331
64344
  pivotRowFieldEarly,
64332
64345
  String(rowColumn?.format ?? "")
64333
64346
  ) ? pivotRowFieldEarly : config.xAxisField;
64334
- const withResolvedXAxis = resolvedXAxisField && resolvedXAxisField !== config.xAxisField ? { ...config, xAxisField: resolvedXAxisField } : config;
64347
+ const withResolvedXAxis = resolvedXAxisField && resolvedXAxisField !== config.xAxisField ? {
64348
+ ...config,
64349
+ xAxisField: resolvedXAxisField,
64350
+ xAxisFormat: toAxisFormat(rowColumn?.format, "string")
64351
+ } : config;
64335
64352
  const isMetricOrGauge = ["metric", "gauge"].includes(
64336
64353
  String(withResolvedXAxis.chartType ?? "").toLowerCase()
64337
64354
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quillsql/react",
3
- "version": "2.16.102",
3
+ "version": "2.16.103",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {