@odoo/o-spreadsheet 19.3.19 → 19.3.20

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.
@@ -2,9 +2,9 @@
2
2
  /**
3
3
  * This file is generated by o-spreadsheet build tools. Do not edit it.
4
4
  * @see https://github.com/odoo/o-spreadsheet
5
- * @version 19.3.19
6
- * @date 2026-09-04T07:38:14.356Z
7
- * @hash c8c526d
5
+ * @version 19.3.20
6
+ * @date 2026-09-10T05:38:03.233Z
7
+ * @hash e488e8d
8
8
  */
9
9
 
10
10
  (function(exports, _odoo_owl) {
@@ -9627,7 +9627,7 @@ stores.inject(MyMetaStore, storeInstance);
9627
9627
  const point = dataset.data[i];
9628
9628
  const xPosition = point.x;
9629
9629
  let yPosition = 0;
9630
- if (chart.config.type === "line" || chart.config.type === "radar") yPosition = value < 0 ? point.y + 10 : point.y - 10;
9630
+ if (dataset.type === "line" || dataset.type === "radar") yPosition = value < 0 ? point.y + 10 : point.y - 10;
9631
9631
  else {
9632
9632
  const yZeroLine = yAxisScale.getPixelForValue(0);
9633
9633
  const distanceFromAxisOrigin = Math.abs(yZeroLine - point.y);
@@ -18575,7 +18575,7 @@ stores.inject(MyMetaStore, storeInstance);
18575
18575
  ["MoreThanOneRangeSelected"]: _t("Please select only one range of cells"),
18576
18576
  ["EmptySelectedRange"]: _t("Please select a range of cells containing values."),
18577
18577
  ["NoColumnsProvided"]: _t("Please select at latest one column to analyze."),
18578
- ["WillRemoveExistingMerge"]: _t("This operation is not possible due to a merge. Please remove the merges first than try again.")
18578
+ ["WillRemoveExistingMerge"]: _t("Cannot perform this action on merged cells. Unmerge the cells and try again.")
18579
18579
  } };
18580
18580
  const DVTerms = {
18581
18581
  DateIs: {
@@ -26816,7 +26816,7 @@ stores.inject(MyMetaStore, storeInstance);
26816
26816
  col: range.zone.left,
26817
26817
  row: range.zone.top
26818
26818
  });
26819
- if (spreadZone) return this.getters.getRangeFromZone(sheetId, spreadZone);
26819
+ if (spreadZone) return this.getters.getRangeFromZone(range.sheetId, spreadZone);
26820
26820
  return range;
26821
26821
  }
26822
26822
  updateAutoCompleteProvider() {
@@ -32827,433 +32827,6 @@ stores.inject(MyMetaStore, storeInstance);
32827
32827
  }
32828
32828
  };
32829
32829
 
32830
- //#endregion
32831
- //#region src/helpers/figures/chart.ts
32832
- var SpreadsheetChart = class SpreadsheetChart {
32833
- getters;
32834
- sheetId;
32835
- definition;
32836
- chartTypeBuilder;
32837
- dataSourceBuilder;
32838
- dataSource;
32839
- constructor(getters, sheetId, definition, chartTypeBuilder, dataSourceBuilder) {
32840
- this.getters = getters;
32841
- this.sheetId = sheetId;
32842
- this.definition = definition;
32843
- this.chartTypeBuilder = chartTypeBuilder;
32844
- this.dataSourceBuilder = dataSourceBuilder;
32845
- this.dataSource = definition.dataSource;
32846
- }
32847
- static fromStrDefinition(getters, sheetId, definition) {
32848
- const dataSourceBuilder = chartDataSourceRegistry.get(definition.dataSource?.type ?? "none");
32849
- const chartTypeBuilder = chartTypeRegistry.get(definition.type);
32850
- const dataSource = dataSourceBuilder.fromExternalDefinition(definition.dataSource ?? { type: "none" }, sheetId, getters);
32851
- const rangeDefinition = {
32852
- ...chartTypeBuilder.fromStrDefinition(definition, sheetId, getters),
32853
- dataSource
32854
- };
32855
- return new SpreadsheetChart(getters, sheetId, SpreadsheetChart.deleteInvalidKeys(rangeDefinition), chartTypeBuilder, dataSourceBuilder);
32856
- }
32857
- static fromDefinition(getters, sheetId, definition) {
32858
- const dataSourceBuilder = chartDataSourceRegistry.get(definition.dataSource?.type ?? "none");
32859
- return new SpreadsheetChart(getters, sheetId, definition, chartTypeRegistry.get(definition.type), dataSourceBuilder);
32860
- }
32861
- static validate(validator, definition) {
32862
- const chartTypeBuilder = chartTypeRegistry.get(definition.type);
32863
- const dataSourceBuilder = chartDataSourceRegistry.get(definition.dataSource?.type ?? "none");
32864
- return validator.batchValidations(() => chartTypeBuilder.validateDefinition(validator, definition), () => dataSourceBuilder.validate(definition.dataSource ?? { type: "none" }, validator))(void 0);
32865
- }
32866
- static transformDefinition(chartSheetId, definition, rangeAdapters) {
32867
- const chartTypeBuilder = chartTypeRegistry.get(definition.type);
32868
- if (!definition.dataSource) return chartTypeBuilder.transformDefinition(definition, chartSheetId, rangeAdapters);
32869
- const newDataSource = chartDataSourceRegistry.get(definition.dataSource?.type ?? "none").transform(definition.dataSource, chartSheetId, rangeAdapters);
32870
- return {
32871
- ...chartTypeBuilder.transformDefinition(definition, chartSheetId, rangeAdapters),
32872
- dataSource: newDataSource
32873
- };
32874
- }
32875
- getRangeDefinition() {
32876
- return {
32877
- ...this.definition,
32878
- dataSource: this.dataSource
32879
- };
32880
- }
32881
- getDefinition() {
32882
- return {
32883
- ...this.chartTypeBuilder.toStrDefinition(this.definition, this.sheetId, this.getters),
32884
- dataSource: this.dataSource && this.dataSourceBuilder.getDefinition(this.dataSource, this.sheetId, this.getters)
32885
- };
32886
- }
32887
- updateRanges(rangeAdapters) {
32888
- return {
32889
- ...this.chartTypeBuilder.updateRanges(this.definition, rangeAdapters, this.sheetId),
32890
- dataSource: this.dataSource && this.dataSourceBuilder.adaptRanges(this.dataSource, rangeAdapters)
32891
- };
32892
- }
32893
- duplicateInDuplicatedSheet(sheetIdFrom, sheetIdTo) {
32894
- const newDataSource = this.dataSource && this.dataSourceBuilder.duplicateInDuplicatedSheet(this.dataSource, sheetIdFrom, sheetIdTo, this.getters);
32895
- const definition = {
32896
- ...this.chartTypeBuilder.duplicateInDuplicatedSheet(this.definition, sheetIdFrom, sheetIdTo, this.getters),
32897
- dataSource: newDataSource
32898
- };
32899
- return SpreadsheetChart.fromDefinition(this.getters, sheetIdTo, definition).getDefinition();
32900
- }
32901
- copyInSheetId(sheetIdTo) {
32902
- return {
32903
- ...this.chartTypeBuilder.copyInSheetId(this.definition, this.sheetId, sheetIdTo, this.getters),
32904
- dataSource: this.dataSource
32905
- };
32906
- }
32907
- getContextCreation() {
32908
- const definition = this.getDefinition();
32909
- return {
32910
- ...this.dataSourceBuilder.getContextCreation(definition.dataSource ?? { type: "none" }),
32911
- ...this.chartTypeBuilder.getContextCreation(definition, this.dataSourceBuilder, definition.dataSource)
32912
- };
32913
- }
32914
- getDefinitionForExcel(getters) {
32915
- const definition = this.definition;
32916
- const excelDataSets = this.dataSourceBuilder.toExcelDataSets(this.dataSource, "dataSetStyles" in definition ? definition.dataSetStyles : {}, getters);
32917
- if (excelDataSets === void 0) return;
32918
- return this.chartTypeBuilder.getDefinitionForExcel(getters, definition, excelDataSets);
32919
- }
32920
- getData(getters, chartId) {
32921
- const dataSource = this.dataSource;
32922
- return dataSource ? this.dataSourceBuilder.extractData(dataSource, chartId, getters) : {
32923
- dataSetsValues: [],
32924
- labelValues: []
32925
- };
32926
- }
32927
- getRuntime(getters, chartId) {
32928
- const dataSource = this.dataSource;
32929
- const dataExtractors = dataSource ? {
32930
- extractData: () => this.dataSourceBuilder.extractData(dataSource, chartId, getters),
32931
- extractHierarchicalData: () => this.dataSourceBuilder.extractHierarchicalData(dataSource, chartId, getters)
32932
- } : {
32933
- extractData: () => ({
32934
- dataSetsValues: [],
32935
- labelValues: []
32936
- }),
32937
- extractHierarchicalData: () => ({
32938
- dataSetsValues: [],
32939
- labelValues: []
32940
- })
32941
- };
32942
- return this.chartTypeBuilder.getRuntime(getters, this.definition, dataExtractors, this.sheetId, {
32943
- onClick: (event, items, chartJsChart) => {
32944
- return this.dataSourceBuilder.onDataSetClick?.(this.definition.type, chartId, event, items, chartJsChart, getters);
32945
- },
32946
- onHover: (event, items, chartJsChart) => this.dataSourceBuilder.onDataSetHover?.(this.definition.type, chartId, event, items, chartJsChart)
32947
- });
32948
- }
32949
- static deleteInvalidKeys(definition) {
32950
- definition = { ...definition };
32951
- const keys = new Set(chartTypeRegistry.get(definition.type).allowedDefinitionKeys);
32952
- for (const key of Object.keys(definition)) if (!keys.has(key)) delete definition[key];
32953
- return definition;
32954
- }
32955
- };
32956
-
32957
- //#endregion
32958
- //#region src/helpers/figures/charts/chart_data_sources.ts
32959
- const EMPTY = Object.freeze({ value: null });
32960
- const ONE = Object.freeze({ value: 1 });
32961
- const ChartRangeDataSourceHandler = {
32962
- supportedChartTypes: CHART_TYPES,
32963
- fromExternalDefinition(dataSource, defaultSheetId, getters) {
32964
- const dataSets = createDataSets(getters, defaultSheetId, dataSource);
32965
- const labelRange = createValidRange(getters, defaultSheetId, dataSource.labelRange);
32966
- return {
32967
- ...dataSource,
32968
- dataSets,
32969
- labelRange
32970
- };
32971
- },
32972
- fromContextCreation(context) {
32973
- return {
32974
- type: "range",
32975
- dataSets: [],
32976
- dataSetsHaveTitle: false,
32977
- labelRange: context.auxiliaryRange,
32978
- ...context.dataSource
32979
- };
32980
- },
32981
- fromHierarchicalContextCreation(context) {
32982
- if (context.dataSource?.type !== "range" || context.hierarchicalDataSource !== void 0 && context.hierarchicalDataSource.type !== "range") return {
32983
- type: "range",
32984
- dataSets: [],
32985
- dataSetsHaveTitle: false
32986
- };
32987
- let dataSource = {
32988
- type: "range",
32989
- dataSets: [],
32990
- dataSetsHaveTitle: context.dataSource?.dataSetsHaveTitle ?? false,
32991
- labelRange: context.dataSource?.dataSets?.[0]?.dataRange
32992
- };
32993
- if (context.hierarchicalDataSource?.dataSets.length) dataSource = context.hierarchicalDataSource;
32994
- else if (context.auxiliaryRange) dataSource = {
32995
- ...dataSource,
32996
- dataSets: [{
32997
- dataRange: context.auxiliaryRange,
32998
- dataSetId: "0"
32999
- }]
33000
- };
33001
- return dataSource;
33002
- },
33003
- validate: (dataSource, validator) => validator.checkValidations(dataSource, checkDataset, checkLabelRange),
33004
- transform(dataSource, defaultSheetId, { adaptRangeString }) {
33005
- let labelRange;
33006
- if (dataSource.labelRange) {
33007
- const { changeType, range: adaptedRange } = adaptRangeString(defaultSheetId, dataSource.labelRange);
33008
- if (changeType !== "REMOVE") labelRange = adaptedRange;
33009
- }
33010
- const dataSets = [];
33011
- for (const dataSet of dataSource.dataSets) {
33012
- const newDataSet = { ...dataSet };
33013
- const { changeType, range: adaptedRange } = adaptRangeString(defaultSheetId, dataSet.dataRange);
33014
- if (changeType !== "REMOVE") {
33015
- newDataSet.dataRange = adaptedRange;
33016
- dataSets.push(newDataSet);
33017
- }
33018
- }
33019
- return {
33020
- ...dataSource,
33021
- dataSets,
33022
- labelRange
33023
- };
33024
- },
33025
- extractData: (dataSource, chartId, getters) => getChartData(getters, dataSource),
33026
- extractHierarchicalData(dataSource, chartId, getters) {
33027
- const dataSets = dataSource.dataSets;
33028
- const labelRange = dataSource.labelRange;
33029
- const labelValues = getChartLabelValues(getters, dataSets, labelRange);
33030
- const dataSetsValues = getHierarchicalDatasetValues(getters, dataSets);
33031
- const data = {
33032
- labelValues,
33033
- dataSetsValues
33034
- };
33035
- if (shouldRemoveFirstLabel(labelValues.length, dataSetsValues[0]?.data.length + (dataSetsValues[0]?.label !== void 0 ? 1 : 0), dataSource.dataSetsHaveTitle || false)) labelValues.shift();
33036
- return data;
33037
- },
33038
- adaptRanges(dataSource, { applyChange }) {
33039
- const dataSetsWithUndefined = dataSource.dataSets.map((ds) => {
33040
- const { range: adaptedRangeStr, changeType } = applyChange(ds.dataRange);
33041
- if (changeType === "REMOVE") return;
33042
- let labelCell = void 0;
33043
- if (ds.labelCell) {
33044
- const { range: adaptedLabelCellRange, changeType: labelCellChangeType } = applyChange(ds.labelCell);
33045
- if (labelCellChangeType !== "REMOVE") labelCell = adaptedLabelCellRange;
33046
- }
33047
- return {
33048
- ...ds,
33049
- dataRange: adaptedRangeStr,
33050
- labelCell
33051
- };
33052
- }).filter(isDefined);
33053
- let labelRange = dataSource.labelRange;
33054
- if (labelRange) {
33055
- const { range: adaptedLabelRange, changeType } = applyChange(labelRange);
33056
- if (changeType === "REMOVE") labelRange = void 0;
33057
- else labelRange = adaptedLabelRange;
33058
- }
33059
- const dataSets = dataSetsWithUndefined;
33060
- return {
33061
- ...dataSource,
33062
- dataSets,
33063
- labelRange: labelRange?.invalidSheetName || labelRange?.invalidXc ? void 0 : labelRange
33064
- };
33065
- },
33066
- getDefinition(dataSource, defaultSheetId, getters) {
33067
- return {
33068
- labelRange: dataSource.labelRange ? getters.getRangeString(dataSource.labelRange, defaultSheetId) : void 0,
33069
- type: "range",
33070
- dataSets: dataSource.dataSets.map((dataSet) => ({
33071
- dataSetId: dataSet.dataSetId,
33072
- dataRange: getters.getRangeString(dataSet.dataRange, defaultSheetId)
33073
- })),
33074
- dataSetsHaveTitle: dataSource.dataSetsHaveTitle
33075
- };
33076
- },
33077
- /**
33078
- * Duplicate the dataSets. All ranges on sheetIdFrom are adapted to target
33079
- * sheetIdTo.
33080
- */
33081
- duplicateInDuplicatedSheet(dataSource, sheetIdFrom, sheetIdTo, getters) {
33082
- return {
33083
- ...dataSource,
33084
- labelRange: duplicateLabelRangeInDuplicatedSheet(sheetIdFrom, sheetIdTo, dataSource.labelRange),
33085
- dataSets: dataSource.dataSets.map((ds) => ({
33086
- ...ds,
33087
- dataRange: duplicateRangeInDuplicatedSheet(sheetIdFrom, sheetIdTo, ds.dataRange)
33088
- }))
33089
- };
33090
- },
33091
- getContextCreation: (dataSource) => ({
33092
- auxiliaryRange: dataSource.labelRange,
33093
- dataSource
33094
- }),
33095
- getHierarchicalContextCreation(dataSource) {
33096
- const leafRange = dataSource.dataSets.at(-1)?.dataRange;
33097
- const dataSetsHaveTitle = dataSource.dataSetsHaveTitle;
33098
- return {
33099
- auxiliaryRange: leafRange,
33100
- hierarchicalDataSource: dataSource,
33101
- dataSource: dataSource.labelRange ? {
33102
- type: "range",
33103
- dataSets: [{
33104
- dataRange: dataSource.labelRange,
33105
- dataSetId: "0"
33106
- }],
33107
- dataSetsHaveTitle
33108
- } : {
33109
- type: "range",
33110
- dataSets: [],
33111
- dataSetsHaveTitle
33112
- }
33113
- };
33114
- },
33115
- toExcelDataSets(dataSource, dataSetStyles, getters) {
33116
- const dataSets = dataSource.dataSets;
33117
- const labelRange = dataSource.labelRange;
33118
- const excelDataSets = dataSets.map((ds) => toExcelDataset(getters, dataSetStyles, ds)).filter((ds) => ds.range !== "" && ds.range !== CellErrorType.InvalidReference);
33119
- const datasetLength = dataSets[0] ? getZoneArea(dataSets[0].dataRange.zone) : void 0;
33120
- return {
33121
- dataSets: excelDataSets,
33122
- labelRange: toExcelLabelRange(getters, labelRange, shouldRemoveFirstLabel(labelRange ? getZoneArea(labelRange.zone) : 0, datasetLength, dataSource.dataSetsHaveTitle))
33123
- };
33124
- }
33125
- };
33126
- function getChartData(getters, dataSource) {
33127
- const dataSets = dataSource.dataSets;
33128
- const labelRange = dataSource.labelRange;
33129
- const labelValues = getChartLabelValues(getters, dataSets, labelRange);
33130
- const dataSetsValues = getChartDatasetValues(getters, dataSets);
33131
- const data = {
33132
- labelValues,
33133
- dataSetsValues
33134
- };
33135
- const numberOfDataPoints = dataSetsValues.length ? dataSetsValues[0]?.data.length + (dataSetsValues[0]?.label !== void 0 ? 1 : 0) : 0;
33136
- if (shouldRemoveFirstLabel(labelValues.length, numberOfDataPoints, dataSource.dataSetsHaveTitle || false)) labelValues.shift();
33137
- return data;
33138
- }
33139
- function getChartDatasetValues(getters, dataSets) {
33140
- const datasetValues = [];
33141
- for (const [dsIndex, ds] of Object.entries(dataSets)) {
33142
- let label = `${ChartTerms.Series} ${parseInt(dsIndex) + 1}`;
33143
- let hidden = getters.isColHidden(ds.dataRange.sheetId, ds.dataRange.zone.left);
33144
- if (ds.labelCell) {
33145
- const { sheetId, zone } = ds.labelCell;
33146
- const cell = getters.getEvaluatedCell({
33147
- sheetId,
33148
- col: zone.left,
33149
- row: zone.top
33150
- });
33151
- if (cell) label = cell.formattedValue;
33152
- }
33153
- let data = ds.dataRange ? getData(getters, ds) : [];
33154
- if (data.every((cell) => !cell.value || isTextResult(cell)) && data.filter(isTextResult).length > 1) data = data.map((cell) => cell.value && !isErrorResult(cell) ? ONE : EMPTY);
33155
- else if (data.every((cell) => !isNumberResult(cell))) hidden = true;
33156
- datasetValues.push({
33157
- data,
33158
- label,
33159
- hidden,
33160
- dataSetId: ds.dataSetId
33161
- });
33162
- }
33163
- return datasetValues;
33164
- }
33165
- function getChartLabelValues(getters, dataSets, labelRange) {
33166
- if (labelRange) {
33167
- const { left } = labelRange.zone;
33168
- if (!labelRange.invalidXc && !labelRange.invalidSheetName && !getters.isColHidden(labelRange.sheetId, left)) return getters.getVisibleRangeValues(labelRange);
33169
- }
33170
- if (dataSets[0]) {
33171
- const dataLength = getData(getters, dataSets[0]).length;
33172
- return Array.from({ length: dataLength }, () => ({ value: "" }));
33173
- }
33174
- return [];
33175
- }
33176
- /**
33177
- * Get the values for a hierarchical dataset. The values can be defined in a tree-like structure
33178
- * in the sheet, and this function will fill up the blanks.
33179
- *
33180
- * @example the following dataset:
33181
- *
33182
- * 2024 Q1 W1 100
33183
- * W2 200
33184
- *
33185
- * will have the same value as the dataset:
33186
- * 2024 Q1 W1 100
33187
- * 2024 Q1 W2 200
33188
- */
33189
- function getHierarchicalDatasetValues(getters, dataSets) {
33190
- dataSets = dataSets.filter((ds) => !getters.isColHidden(ds.dataRange.sheetId, ds.dataRange.zone.left));
33191
- const datasetValues = dataSets.map((ds) => ({
33192
- data: [],
33193
- label: "",
33194
- dataSetId: ds.dataSetId
33195
- }));
33196
- const locale = getters.getLocale();
33197
- const dataSetsData = dataSets.map((ds) => getData(getters, ds)).map((values) => values.map(({ value, format }) => value === null ? EMPTY : { value: formatValue(value, {
33198
- format,
33199
- locale
33200
- }) }));
33201
- if (!dataSetsData.length) return datasetValues;
33202
- const minLength = Math.min(...dataSetsData.map((ds) => ds.length));
33203
- let currentValues = [];
33204
- const leafDatasetIndex = dataSets.length - 1;
33205
- for (let i = 0; i < minLength; i++) for (let dsIndex = 0; dsIndex < dataSetsData.length; dsIndex++) {
33206
- let cell = dataSetsData[dsIndex][i];
33207
- if ((cell === void 0 || cell.value === null) && dsIndex !== leafDatasetIndex) cell = currentValues[dsIndex];
33208
- if (cell?.value !== currentValues[dsIndex]?.value) {
33209
- currentValues = currentValues.slice(0, dsIndex);
33210
- currentValues[dsIndex] = cell;
33211
- }
33212
- datasetValues[dsIndex].data.push(cell ?? EMPTY);
33213
- }
33214
- return datasetValues.filter((ds) => ds.data.some((d) => d.value !== null));
33215
- }
33216
- /**
33217
- * Get the data from a dataSet
33218
- */
33219
- function getData(getters, ds) {
33220
- if (ds.dataRange) {
33221
- const labelCellZone = ds.labelCell ? [ds.labelCell.zone] : [];
33222
- const dataZone = recomputeZones([ds.dataRange.zone], labelCellZone)[0];
33223
- if (dataZone === void 0) return [];
33224
- const dataRange = getters.getRangeFromZone(ds.dataRange.sheetId, dataZone);
33225
- return getters.getVisibleRangeValues(dataRange).map((cell) => cell.value === "" ? EMPTY : cell);
33226
- }
33227
- return [];
33228
- }
33229
- const ChartNeverDataSourceHandler = {
33230
- supportedChartTypes: [],
33231
- fromExternalDefinition: () => ({ type: "none" }),
33232
- fromContextCreation: () => ({ type: "none" }),
33233
- fromHierarchicalContextCreation: () => ({ type: "none" }),
33234
- validate: () => "Success",
33235
- transform: () => ({ type: "none" }),
33236
- extractData: () => ({
33237
- dataSetsValues: [],
33238
- labelValues: []
33239
- }),
33240
- extractHierarchicalData: () => ({
33241
- dataSetsValues: [],
33242
- labelValues: []
33243
- }),
33244
- adaptRanges: (dataSource) => dataSource,
33245
- getDefinition: (dataSource) => dataSource,
33246
- duplicateInDuplicatedSheet: (dataSource) => dataSource,
33247
- getContextCreation: () => ({}),
33248
- getHierarchicalContextCreation: () => ({}),
33249
- toExcelDataSets: () => ({
33250
- dataSets: [],
33251
- labelRange: void 0
33252
- })
33253
- };
33254
- chartDataSourceRegistry.add("range", ChartRangeDataSourceHandler);
33255
- chartDataSourceRegistry.add("none", ChartNeverDataSourceHandler);
33256
-
33257
32830
  //#endregion
33258
32831
  //#region src/types/chart/calendar_chart.ts
33259
32832
  const CALENDAR_CHART_GRANULARITIES = [
@@ -33280,41 +32853,6 @@ stores.inject(MyMetaStore, storeInstance);
33280
32853
  value,
33281
32854
  label: ALL_PERIODS[value]
33282
32855
  }));
33283
- getGroupByOptions() {
33284
- const sheetId = this.env.model.getters.getFigureSheetId(this.env.model.getters.getFigureIdFromChartId(this.props.chartId));
33285
- const definition = SpreadsheetChart.fromStrDefinition(this.env.model.getters, sheetId, this.props.definition).getRangeDefinition();
33286
- const labels = getBarChartData(definition, getChartData(this.env.model.getters, definition.dataSource), this.env.model.getters).labels.filter((l) => isDateTime(l, DEFAULT_LOCALE));
33287
- if (labels.length === 0) return [];
33288
- const dates = labels.map((label) => toJsDate(label, this.env.model.getters.getLocale()));
33289
- const uniqueYears = /* @__PURE__ */ new Set();
33290
- const uniqueMonths = /* @__PURE__ */ new Set();
33291
- const uniqueDays = /* @__PURE__ */ new Set();
33292
- const uniqueHours = /* @__PURE__ */ new Set();
33293
- const uniqueMinutes = /* @__PURE__ */ new Set();
33294
- const uniqueSeconds = /* @__PURE__ */ new Set();
33295
- for (const date of dates) {
33296
- uniqueYears.add(date.getFullYear());
33297
- uniqueMonths.add(date.getMonth());
33298
- uniqueDays.add(date.getDate());
33299
- uniqueHours.add(date.getHours());
33300
- uniqueMinutes.add(date.getMinutes());
33301
- uniqueSeconds.add(date.getSeconds());
33302
- }
33303
- return this.groupByChoices.filter((groupBy) => {
33304
- switch (groupBy.value) {
33305
- case "year": return uniqueYears.size > 1;
33306
- case "quarter_number":
33307
- case "month_number": return uniqueMonths.size > 1;
33308
- case "iso_week_number":
33309
- case "day_of_month":
33310
- case "day_of_week": return uniqueDays.size > 1;
33311
- case "hour_number": return uniqueHours.size > 1;
33312
- case "minute_number": return uniqueMinutes.size > 1;
33313
- case "second_number": return uniqueSeconds.size > 1;
33314
- default: return false;
33315
- }
33316
- });
33317
- }
33318
32856
  getGroupByType(currentAxis) {
33319
32857
  return (currentAxis === "horizontal" ? this.props.definition.horizontalGroupBy : this.props.definition.verticalGroupBy) || "year";
33320
32858
  }
@@ -34520,6 +34058,133 @@ stores.inject(MyMetaStore, storeInstance);
34520
34058
  }
34521
34059
  };
34522
34060
 
34061
+ //#endregion
34062
+ //#region src/helpers/figures/chart.ts
34063
+ var SpreadsheetChart = class SpreadsheetChart {
34064
+ getters;
34065
+ sheetId;
34066
+ definition;
34067
+ chartTypeBuilder;
34068
+ dataSourceBuilder;
34069
+ dataSource;
34070
+ constructor(getters, sheetId, definition, chartTypeBuilder, dataSourceBuilder) {
34071
+ this.getters = getters;
34072
+ this.sheetId = sheetId;
34073
+ this.definition = definition;
34074
+ this.chartTypeBuilder = chartTypeBuilder;
34075
+ this.dataSourceBuilder = dataSourceBuilder;
34076
+ this.dataSource = definition.dataSource;
34077
+ }
34078
+ static fromStrDefinition(getters, sheetId, definition) {
34079
+ const dataSourceBuilder = chartDataSourceRegistry.get(definition.dataSource?.type ?? "none");
34080
+ const chartTypeBuilder = chartTypeRegistry.get(definition.type);
34081
+ const dataSource = dataSourceBuilder.fromExternalDefinition(definition.dataSource ?? { type: "none" }, sheetId, getters);
34082
+ const rangeDefinition = {
34083
+ ...chartTypeBuilder.fromStrDefinition(definition, sheetId, getters),
34084
+ dataSource
34085
+ };
34086
+ return new SpreadsheetChart(getters, sheetId, SpreadsheetChart.deleteInvalidKeys(rangeDefinition), chartTypeBuilder, dataSourceBuilder);
34087
+ }
34088
+ static fromDefinition(getters, sheetId, definition) {
34089
+ const dataSourceBuilder = chartDataSourceRegistry.get(definition.dataSource?.type ?? "none");
34090
+ return new SpreadsheetChart(getters, sheetId, definition, chartTypeRegistry.get(definition.type), dataSourceBuilder);
34091
+ }
34092
+ static validate(validator, definition) {
34093
+ const chartTypeBuilder = chartTypeRegistry.get(definition.type);
34094
+ const dataSourceBuilder = chartDataSourceRegistry.get(definition.dataSource?.type ?? "none");
34095
+ return validator.batchValidations(() => chartTypeBuilder.validateDefinition(validator, definition), () => dataSourceBuilder.validate(definition.dataSource ?? { type: "none" }, validator))(void 0);
34096
+ }
34097
+ static transformDefinition(chartSheetId, definition, rangeAdapters) {
34098
+ const chartTypeBuilder = chartTypeRegistry.get(definition.type);
34099
+ if (!definition.dataSource) return chartTypeBuilder.transformDefinition(definition, chartSheetId, rangeAdapters);
34100
+ const newDataSource = chartDataSourceRegistry.get(definition.dataSource?.type ?? "none").transform(definition.dataSource, chartSheetId, rangeAdapters);
34101
+ return {
34102
+ ...chartTypeBuilder.transformDefinition(definition, chartSheetId, rangeAdapters),
34103
+ dataSource: newDataSource
34104
+ };
34105
+ }
34106
+ getRangeDefinition() {
34107
+ return {
34108
+ ...this.definition,
34109
+ dataSource: this.dataSource
34110
+ };
34111
+ }
34112
+ getDefinition() {
34113
+ return {
34114
+ ...this.chartTypeBuilder.toStrDefinition(this.definition, this.sheetId, this.getters),
34115
+ dataSource: this.dataSource && this.dataSourceBuilder.getDefinition(this.dataSource, this.sheetId, this.getters)
34116
+ };
34117
+ }
34118
+ updateRanges(rangeAdapters) {
34119
+ return {
34120
+ ...this.chartTypeBuilder.updateRanges(this.definition, rangeAdapters, this.sheetId),
34121
+ dataSource: this.dataSource && this.dataSourceBuilder.adaptRanges(this.dataSource, rangeAdapters)
34122
+ };
34123
+ }
34124
+ duplicateInDuplicatedSheet(sheetIdFrom, sheetIdTo) {
34125
+ const newDataSource = this.dataSource && this.dataSourceBuilder.duplicateInDuplicatedSheet(this.dataSource, sheetIdFrom, sheetIdTo, this.getters);
34126
+ const definition = {
34127
+ ...this.chartTypeBuilder.duplicateInDuplicatedSheet(this.definition, sheetIdFrom, sheetIdTo, this.getters),
34128
+ dataSource: newDataSource
34129
+ };
34130
+ return SpreadsheetChart.fromDefinition(this.getters, sheetIdTo, definition).getDefinition();
34131
+ }
34132
+ copyInSheetId(sheetIdTo) {
34133
+ return {
34134
+ ...this.chartTypeBuilder.copyInSheetId(this.definition, this.sheetId, sheetIdTo, this.getters),
34135
+ dataSource: this.dataSource
34136
+ };
34137
+ }
34138
+ getContextCreation() {
34139
+ const definition = this.getDefinition();
34140
+ return {
34141
+ ...this.dataSourceBuilder.getContextCreation(definition.dataSource ?? { type: "none" }),
34142
+ ...this.chartTypeBuilder.getContextCreation(definition, this.dataSourceBuilder, definition.dataSource)
34143
+ };
34144
+ }
34145
+ getDefinitionForExcel(getters) {
34146
+ const definition = this.definition;
34147
+ const excelDataSets = this.dataSourceBuilder.toExcelDataSets(this.dataSource, "dataSetStyles" in definition ? definition.dataSetStyles : {}, getters);
34148
+ if (excelDataSets === void 0) return;
34149
+ return this.chartTypeBuilder.getDefinitionForExcel(getters, definition, excelDataSets);
34150
+ }
34151
+ getData(getters, chartId) {
34152
+ const dataSource = this.dataSource;
34153
+ return dataSource ? this.dataSourceBuilder.extractData(dataSource, chartId, getters) : {
34154
+ dataSetsValues: [],
34155
+ labelValues: []
34156
+ };
34157
+ }
34158
+ getRuntime(getters, chartId) {
34159
+ const dataSource = this.dataSource;
34160
+ const dataExtractors = dataSource ? {
34161
+ extractData: () => this.dataSourceBuilder.extractData(dataSource, chartId, getters),
34162
+ extractHierarchicalData: () => this.dataSourceBuilder.extractHierarchicalData(dataSource, chartId, getters)
34163
+ } : {
34164
+ extractData: () => ({
34165
+ dataSetsValues: [],
34166
+ labelValues: []
34167
+ }),
34168
+ extractHierarchicalData: () => ({
34169
+ dataSetsValues: [],
34170
+ labelValues: []
34171
+ })
34172
+ };
34173
+ return this.chartTypeBuilder.getRuntime(getters, this.definition, dataExtractors, this.sheetId, {
34174
+ onClick: (event, items, chartJsChart) => {
34175
+ return this.dataSourceBuilder.onDataSetClick?.(this.definition.type, chartId, event, items, chartJsChart, getters);
34176
+ },
34177
+ onHover: (event, items, chartJsChart) => this.dataSourceBuilder.onDataSetHover?.(this.definition.type, chartId, event, items, chartJsChart)
34178
+ });
34179
+ }
34180
+ static deleteInvalidKeys(definition) {
34181
+ definition = { ...definition };
34182
+ const keys = new Set(chartTypeRegistry.get(definition.type).allowedDefinitionKeys);
34183
+ for (const key of Object.keys(definition)) if (!keys.has(key)) delete definition[key];
34184
+ return definition;
34185
+ }
34186
+ };
34187
+
34523
34188
  //#endregion
34524
34189
  //#region src/components/side_panel/chart/main_chart_panel/main_chart_panel_store.ts
34525
34190
  var MainChartPanelStore = class extends SpreadsheetStore {
@@ -36508,7 +36173,7 @@ stores.inject(MyMetaStore, storeInstance);
36508
36173
  }
36509
36174
  get specificRangeMatchesCount() {
36510
36175
  const range = this.searchOptions.specificRange;
36511
- if (!range) return "";
36176
+ if (!range || range.invalidSheetName || range.invalidXc) return "";
36512
36177
  const { sheetId, zone } = range;
36513
36178
  return _t("%(matches)s matches in range %(range)s of %(sheetName)s", {
36514
36179
  matches: this.store.specificRangeMatchesCount,
@@ -46137,6 +45802,11 @@ stores.inject(MyMetaStore, storeInstance);
46137
45802
  });
46138
45803
  return icon?.onClick ? icon : void 0;
46139
45804
  }
45805
+ get isFooterVisible() {
45806
+ const { y } = this.env.model.getters.getMainViewportCoordinates();
45807
+ const { height } = this.env.model.getters.getSheetViewDimension();
45808
+ return !this.env.model.getters.isReadonly() && height - y > 46;
45809
+ }
46140
45810
  };
46141
45811
 
46142
45812
  //#endregion
@@ -54620,7 +54290,7 @@ stores.inject(MyMetaStore, storeInstance);
54620
54290
  if (rangeError) return [[rangeError]];
54621
54291
  const sheetId = range.sheetId;
54622
54292
  const zone = range.zone;
54623
- const _zone = intersection(zone, this.getters.getSheetZone(sheetId));
54293
+ const _zone = this.getters.clipRangeToSheet(range)?.zone;
54624
54294
  if (!_zone) return [[]];
54625
54295
  const { top, left, bottom, right } = zone;
54626
54296
  const cacheKey = `${sheetId}-${top}-${left}-${bottom}-${right}`;
@@ -55603,10 +55273,10 @@ stores.inject(MyMetaStore, storeInstance);
55603
55273
  updateDependencies(position) {
55604
55274
  this.formulaDependencies().removeAllDependencies(position);
55605
55275
  const dependencies = this.getDirectDependencies(position);
55606
- this.formulaDependencies().addDependencies(position, dependencies);
55276
+ this.formulaDependencies().addDependencies(position, this.getters.clipRangesToSheet(dependencies));
55607
55277
  }
55608
55278
  addDependencies(position, dependencies) {
55609
- this.formulaDependencies().addDependencies(position, dependencies);
55279
+ this.formulaDependencies().addDependencies(position, this.getters.clipRangesToSheet(dependencies));
55610
55280
  this.computeDependencies(dependencies);
55611
55281
  }
55612
55282
  computeDependencies(dependencies) {
@@ -55668,7 +55338,8 @@ stores.inject(MyMetaStore, storeInstance);
55668
55338
  const graph = new FormulaDependencyGraph();
55669
55339
  for (const sheetId of this.getters.getSheetIds()) for (const cell of this.getters.getCells(sheetId)) if (cell.isFormula) {
55670
55340
  const cellPosition = this.getters.getCellPosition(cell.id);
55671
- graph.addDependencies(cellPosition, cell.compiledFormula.rangeDependencies);
55341
+ const dependencies = this.getters.clipRangesToSheet(cell.compiledFormula.rangeDependencies);
55342
+ graph.addDependencies(cellPosition, dependencies);
55672
55343
  }
55673
55344
  return graph;
55674
55345
  });
@@ -61433,7 +61104,8 @@ stores.inject(MyMetaStore, storeInstance);
61433
61104
  "getGeoJsonFeatures",
61434
61105
  "geoFeatureNameToId",
61435
61106
  "getGeoChartAvailableRegions",
61436
- "getAvailableChartRegions"
61107
+ "getAvailableChartRegions",
61108
+ "loadUsedGeoJsonFeatures"
61437
61109
  ];
61438
61110
  geoJsonService;
61439
61111
  geoJsonCache = {};
@@ -61516,6 +61188,23 @@ stores.inject(MyMetaStore, storeInstance);
61516
61188
  }
61517
61189
  return this.geoJsonService.geoFeatureNameToId(region, featureName);
61518
61190
  }
61191
+ loadUsedGeoJsonFeatures() {
61192
+ const regions = this.getters.getSheetIds().flatMap((sheetId) => this.getters.getChartIds(sheetId).map((chartId) => {
61193
+ const definition = this.getters.getChartDefinition(chartId);
61194
+ return definition.type === "geo" ? definition.region || this.getters.getGeoChartAvailableRegions()[0]?.id : void 0;
61195
+ })).filter(isDefined);
61196
+ const uniqueRegions = Array.from(new Set(regions));
61197
+ if (uniqueRegions.length && !this.geoJsonService) {
61198
+ console.error("No geoJsonService provided to the model");
61199
+ return Promise.resolve();
61200
+ }
61201
+ for (const region of uniqueRegions) this.getGeoJsonFeatures(region);
61202
+ const promises = uniqueRegions.map((region) => {
61203
+ const cachedGeoJson = this.geoJsonCache[region];
61204
+ return cachedGeoJson instanceof Promise ? cachedGeoJson : Promise.resolve();
61205
+ });
61206
+ return Promise.all(promises).then(() => {});
61207
+ }
61519
61208
  convertToGeoJson(json) {
61520
61209
  if (!json) return null;
61521
61210
  if (json.type === "Topology") {
@@ -64577,7 +64266,7 @@ stores.inject(MyMetaStore, storeInstance);
64577
64266
  let height = lastRowEnd - this.offsetCorrectionY;
64578
64267
  if (this.canScrollVertically) {
64579
64268
  height = Math.max(height, this.viewportHeight);
64580
- if (lastRowEnd + 46 > height && !this.getters.isReadonly()) height += 46;
64269
+ if (lastRowEnd + 46 > height && !this.getters.isReadonly() && this.viewportHeight > 46) height += 46;
64581
64270
  }
64582
64271
  return {
64583
64272
  width,
@@ -69024,12 +68713,11 @@ stores.inject(MyMetaStore, storeInstance);
69024
68713
  const { width: printWidth, height: printHeight } = this.pageDimensionWithMargins;
69025
68714
  const start = dimension === "COL" ? printZone.left : printZone.top;
69026
68715
  const end = dimension === "COL" ? printZone.right : printZone.bottom;
69027
- const getHeaderSize = dimension === "COL" ? this.getters.getColDimensions : this.getters.getRowDimensions;
69028
68716
  const max = dimension === "COL" ? printWidth : printHeight;
69029
68717
  const breaks = [];
69030
68718
  let current = 0;
69031
68719
  for (let i = start; i <= end; i++) {
69032
- const headerSize = getHeaderSize(sheetId, i).size * zoom;
68720
+ const headerSize = this.getters.getHeaderSize(sheetId, dimension, i) * zoom;
69033
68721
  current += headerSize;
69034
68722
  if (current >= max) {
69035
68723
  breaks.push(i);
@@ -71514,6 +71202,8 @@ stores.inject(MyMetaStore, storeInstance);
71514
71202
  "extendRange",
71515
71203
  "getRangeString",
71516
71204
  "getRangeFromSheetXC",
71205
+ "clipRangesToSheet",
71206
+ "clipRangeToSheet",
71517
71207
  "createAdaptedRanges",
71518
71208
  "getRangeData",
71519
71209
  "getRangeDataFromXc",
@@ -71552,6 +71242,22 @@ stores.inject(MyMetaStore, storeInstance);
71552
71242
  addRangeProvider(provider) {
71553
71243
  this.providers.push(provider);
71554
71244
  }
71245
+ clipRangeToSheet(range) {
71246
+ if (range.invalidXc) return range;
71247
+ const sheetZone = this.getters.getSheetZone(range.sheetId);
71248
+ if (isZoneInside(range.zone, sheetZone)) return range;
71249
+ const newZone = intersection(range.zone, sheetZone);
71250
+ if (!newZone) return;
71251
+ return this.getters.getRangeFromZone(range.sheetId, newZone);
71252
+ }
71253
+ clipRangesToSheet(ranges) {
71254
+ const clippedRanges = [];
71255
+ for (const range of ranges) {
71256
+ const clippedRange = this.clipRangeToSheet(range);
71257
+ if (clippedRange) clippedRanges.push(clippedRange);
71258
+ }
71259
+ return clippedRanges;
71260
+ }
71555
71261
  createAdaptedRanges(ranges, offsetX, offsetY, sheetId) {
71556
71262
  return ranges.map((range) => {
71557
71263
  if (!isZoneValid(range.zone)) return range;
@@ -74749,6 +74455,8 @@ stores.inject(MyMetaStore, storeInstance);
74749
74455
  this.range = new RangeAdapterPlugin(this.coreGetters);
74750
74456
  this.coreGetters.getRangeString = this.range.getRangeString.bind(this.range);
74751
74457
  this.coreGetters.getRangeFromSheetXC = this.range.getRangeFromSheetXC.bind(this.range);
74458
+ this.coreGetters.clipRangesToSheet = this.range.clipRangesToSheet.bind(this.range);
74459
+ this.coreGetters.clipRangeToSheet = this.range.clipRangeToSheet.bind(this.range);
74752
74460
  this.coreGetters.createAdaptedRanges = this.range.createAdaptedRanges.bind(this.range);
74753
74461
  this.coreGetters.getRangeData = this.range.getRangeData.bind(this.range);
74754
74462
  this.coreGetters.getRangeDataFromXc = this.range.getRangeDataFromXc.bind(this.range);
@@ -75155,6 +74863,306 @@ stores.inject(MyMetaStore, storeInstance);
75155
74863
  return command;
75156
74864
  }
75157
74865
 
74866
+ //#endregion
74867
+ //#region src/helpers/figures/charts/chart_data_sources.ts
74868
+ const EMPTY = Object.freeze({ value: null });
74869
+ const ONE = Object.freeze({ value: 1 });
74870
+ const ChartRangeDataSourceHandler = {
74871
+ supportedChartTypes: CHART_TYPES,
74872
+ fromExternalDefinition(dataSource, defaultSheetId, getters) {
74873
+ const dataSets = createDataSets(getters, defaultSheetId, dataSource);
74874
+ const labelRange = createValidRange(getters, defaultSheetId, dataSource.labelRange);
74875
+ return {
74876
+ ...dataSource,
74877
+ dataSets,
74878
+ labelRange
74879
+ };
74880
+ },
74881
+ fromContextCreation(context) {
74882
+ return {
74883
+ type: "range",
74884
+ dataSets: [],
74885
+ dataSetsHaveTitle: false,
74886
+ labelRange: context.auxiliaryRange,
74887
+ ...context.dataSource
74888
+ };
74889
+ },
74890
+ fromHierarchicalContextCreation(context) {
74891
+ if (context.dataSource?.type !== "range" || context.hierarchicalDataSource !== void 0 && context.hierarchicalDataSource.type !== "range") return {
74892
+ type: "range",
74893
+ dataSets: [],
74894
+ dataSetsHaveTitle: false
74895
+ };
74896
+ let dataSource = {
74897
+ type: "range",
74898
+ dataSets: [],
74899
+ dataSetsHaveTitle: context.dataSource?.dataSetsHaveTitle ?? false,
74900
+ labelRange: context.dataSource?.dataSets?.[0]?.dataRange
74901
+ };
74902
+ if (context.hierarchicalDataSource?.dataSets.length) dataSource = context.hierarchicalDataSource;
74903
+ else if (context.auxiliaryRange) dataSource = {
74904
+ ...dataSource,
74905
+ dataSets: [{
74906
+ dataRange: context.auxiliaryRange,
74907
+ dataSetId: "0"
74908
+ }]
74909
+ };
74910
+ return dataSource;
74911
+ },
74912
+ validate: (dataSource, validator) => validator.checkValidations(dataSource, checkDataset, checkLabelRange),
74913
+ transform(dataSource, defaultSheetId, { adaptRangeString }) {
74914
+ let labelRange;
74915
+ if (dataSource.labelRange) {
74916
+ const { changeType, range: adaptedRange } = adaptRangeString(defaultSheetId, dataSource.labelRange);
74917
+ if (changeType !== "REMOVE") labelRange = adaptedRange;
74918
+ }
74919
+ const dataSets = [];
74920
+ for (const dataSet of dataSource.dataSets) {
74921
+ const newDataSet = { ...dataSet };
74922
+ const { changeType, range: adaptedRange } = adaptRangeString(defaultSheetId, dataSet.dataRange);
74923
+ if (changeType !== "REMOVE") {
74924
+ newDataSet.dataRange = adaptedRange;
74925
+ dataSets.push(newDataSet);
74926
+ }
74927
+ }
74928
+ return {
74929
+ ...dataSource,
74930
+ dataSets,
74931
+ labelRange
74932
+ };
74933
+ },
74934
+ extractData: (dataSource, chartId, getters) => getChartData(getters, dataSource),
74935
+ extractHierarchicalData(dataSource, chartId, getters) {
74936
+ const dataSets = dataSource.dataSets;
74937
+ const labelRange = dataSource.labelRange;
74938
+ const labelValues = getChartLabelValues(getters, dataSets, labelRange);
74939
+ const dataSetsValues = getHierarchicalDatasetValues(getters, dataSets);
74940
+ const data = {
74941
+ labelValues,
74942
+ dataSetsValues
74943
+ };
74944
+ if (shouldRemoveFirstLabel(labelValues.length, dataSetsValues[0]?.data.length + (dataSetsValues[0]?.label !== void 0 ? 1 : 0), dataSource.dataSetsHaveTitle || false)) labelValues.shift();
74945
+ return data;
74946
+ },
74947
+ adaptRanges(dataSource, { applyChange }) {
74948
+ const dataSetsWithUndefined = dataSource.dataSets.map((ds) => {
74949
+ const { range: adaptedRangeStr, changeType } = applyChange(ds.dataRange);
74950
+ if (changeType === "REMOVE") return;
74951
+ let labelCell = void 0;
74952
+ if (ds.labelCell) {
74953
+ const { range: adaptedLabelCellRange, changeType: labelCellChangeType } = applyChange(ds.labelCell);
74954
+ if (labelCellChangeType !== "REMOVE") labelCell = adaptedLabelCellRange;
74955
+ }
74956
+ return {
74957
+ ...ds,
74958
+ dataRange: adaptedRangeStr,
74959
+ labelCell
74960
+ };
74961
+ }).filter(isDefined);
74962
+ let labelRange = dataSource.labelRange;
74963
+ if (labelRange) {
74964
+ const { range: adaptedLabelRange, changeType } = applyChange(labelRange);
74965
+ if (changeType === "REMOVE") labelRange = void 0;
74966
+ else labelRange = adaptedLabelRange;
74967
+ }
74968
+ const dataSets = dataSetsWithUndefined;
74969
+ return {
74970
+ ...dataSource,
74971
+ dataSets,
74972
+ labelRange: labelRange?.invalidSheetName || labelRange?.invalidXc ? void 0 : labelRange
74973
+ };
74974
+ },
74975
+ getDefinition(dataSource, defaultSheetId, getters) {
74976
+ return {
74977
+ labelRange: dataSource.labelRange ? getters.getRangeString(dataSource.labelRange, defaultSheetId) : void 0,
74978
+ type: "range",
74979
+ dataSets: dataSource.dataSets.map((dataSet) => ({
74980
+ dataSetId: dataSet.dataSetId,
74981
+ dataRange: getters.getRangeString(dataSet.dataRange, defaultSheetId)
74982
+ })),
74983
+ dataSetsHaveTitle: dataSource.dataSetsHaveTitle
74984
+ };
74985
+ },
74986
+ /**
74987
+ * Duplicate the dataSets. All ranges on sheetIdFrom are adapted to target
74988
+ * sheetIdTo.
74989
+ */
74990
+ duplicateInDuplicatedSheet(dataSource, sheetIdFrom, sheetIdTo, getters) {
74991
+ return {
74992
+ ...dataSource,
74993
+ labelRange: duplicateLabelRangeInDuplicatedSheet(sheetIdFrom, sheetIdTo, dataSource.labelRange),
74994
+ dataSets: dataSource.dataSets.map((ds) => ({
74995
+ ...ds,
74996
+ dataRange: duplicateRangeInDuplicatedSheet(sheetIdFrom, sheetIdTo, ds.dataRange)
74997
+ }))
74998
+ };
74999
+ },
75000
+ getContextCreation: (dataSource) => ({
75001
+ auxiliaryRange: dataSource.labelRange,
75002
+ dataSource
75003
+ }),
75004
+ getHierarchicalContextCreation(dataSource) {
75005
+ const leafRange = dataSource.dataSets.at(-1)?.dataRange;
75006
+ const dataSetsHaveTitle = dataSource.dataSetsHaveTitle;
75007
+ return {
75008
+ auxiliaryRange: leafRange,
75009
+ hierarchicalDataSource: dataSource,
75010
+ dataSource: dataSource.labelRange ? {
75011
+ type: "range",
75012
+ dataSets: [{
75013
+ dataRange: dataSource.labelRange,
75014
+ dataSetId: "0"
75015
+ }],
75016
+ dataSetsHaveTitle
75017
+ } : {
75018
+ type: "range",
75019
+ dataSets: [],
75020
+ dataSetsHaveTitle
75021
+ }
75022
+ };
75023
+ },
75024
+ toExcelDataSets(dataSource, dataSetStyles, getters) {
75025
+ const dataSets = dataSource.dataSets;
75026
+ const labelRange = dataSource.labelRange;
75027
+ const excelDataSets = dataSets.map((ds) => toExcelDataset(getters, dataSetStyles, ds)).filter((ds) => ds.range !== "" && ds.range !== CellErrorType.InvalidReference);
75028
+ const datasetLength = dataSets[0] ? getZoneArea(dataSets[0].dataRange.zone) : void 0;
75029
+ return {
75030
+ dataSets: excelDataSets,
75031
+ labelRange: toExcelLabelRange(getters, labelRange, shouldRemoveFirstLabel(labelRange ? getZoneArea(labelRange.zone) : 0, datasetLength, dataSource.dataSetsHaveTitle))
75032
+ };
75033
+ }
75034
+ };
75035
+ function getChartData(getters, dataSource) {
75036
+ const dataSets = dataSource.dataSets;
75037
+ const labelRange = dataSource.labelRange;
75038
+ const labelValues = getChartLabelValues(getters, dataSets, labelRange);
75039
+ const dataSetsValues = getChartDatasetValues(getters, dataSets);
75040
+ const data = {
75041
+ labelValues,
75042
+ dataSetsValues
75043
+ };
75044
+ const numberOfDataPoints = dataSetsValues.length ? dataSetsValues[0]?.data.length + (dataSetsValues[0]?.label !== void 0 ? 1 : 0) : 0;
75045
+ if (shouldRemoveFirstLabel(labelValues.length, numberOfDataPoints, dataSource.dataSetsHaveTitle || false)) labelValues.shift();
75046
+ return data;
75047
+ }
75048
+ function getChartDatasetValues(getters, dataSets) {
75049
+ const datasetValues = [];
75050
+ for (const [dsIndex, ds] of Object.entries(dataSets)) {
75051
+ let label = `${ChartTerms.Series} ${parseInt(dsIndex) + 1}`;
75052
+ let hidden = getters.isColHidden(ds.dataRange.sheetId, ds.dataRange.zone.left);
75053
+ if (ds.labelCell) {
75054
+ const { sheetId, zone } = ds.labelCell;
75055
+ const cell = getters.getEvaluatedCell({
75056
+ sheetId,
75057
+ col: zone.left,
75058
+ row: zone.top
75059
+ });
75060
+ if (cell) label = cell.formattedValue;
75061
+ }
75062
+ let data = ds.dataRange ? getData(getters, ds) : [];
75063
+ if (data.every((cell) => !cell.value || isTextResult(cell)) && data.filter(isTextResult).length > 1) data = data.map((cell) => cell.value && !isErrorResult(cell) ? ONE : EMPTY);
75064
+ else if (data.every((cell) => !isNumberResult(cell))) hidden = true;
75065
+ datasetValues.push({
75066
+ data,
75067
+ label,
75068
+ hidden,
75069
+ dataSetId: ds.dataSetId
75070
+ });
75071
+ }
75072
+ return datasetValues;
75073
+ }
75074
+ function getChartLabelValues(getters, dataSets, labelRange) {
75075
+ if (labelRange) {
75076
+ const { left } = labelRange.zone;
75077
+ if (!labelRange.invalidXc && !labelRange.invalidSheetName && !getters.isColHidden(labelRange.sheetId, left)) return getters.getVisibleRangeValues(labelRange);
75078
+ }
75079
+ if (dataSets[0]) {
75080
+ const dataLength = getData(getters, dataSets[0]).length;
75081
+ return Array.from({ length: dataLength }, () => ({ value: "" }));
75082
+ }
75083
+ return [];
75084
+ }
75085
+ /**
75086
+ * Get the values for a hierarchical dataset. The values can be defined in a tree-like structure
75087
+ * in the sheet, and this function will fill up the blanks.
75088
+ *
75089
+ * @example the following dataset:
75090
+ *
75091
+ * 2024 Q1 W1 100
75092
+ * W2 200
75093
+ *
75094
+ * will have the same value as the dataset:
75095
+ * 2024 Q1 W1 100
75096
+ * 2024 Q1 W2 200
75097
+ */
75098
+ function getHierarchicalDatasetValues(getters, dataSets) {
75099
+ dataSets = dataSets.filter((ds) => !getters.isColHidden(ds.dataRange.sheetId, ds.dataRange.zone.left));
75100
+ const datasetValues = dataSets.map((ds) => ({
75101
+ data: [],
75102
+ label: "",
75103
+ dataSetId: ds.dataSetId
75104
+ }));
75105
+ const locale = getters.getLocale();
75106
+ const dataSetsData = dataSets.map((ds) => getData(getters, ds)).map((values) => values.map(({ value, format }) => value === null ? EMPTY : { value: formatValue(value, {
75107
+ format,
75108
+ locale
75109
+ }) }));
75110
+ if (!dataSetsData.length) return datasetValues;
75111
+ const minLength = Math.min(...dataSetsData.map((ds) => ds.length));
75112
+ let currentValues = [];
75113
+ const leafDatasetIndex = dataSets.length - 1;
75114
+ for (let i = 0; i < minLength; i++) for (let dsIndex = 0; dsIndex < dataSetsData.length; dsIndex++) {
75115
+ let cell = dataSetsData[dsIndex][i];
75116
+ if ((cell === void 0 || cell.value === null) && dsIndex !== leafDatasetIndex) cell = currentValues[dsIndex];
75117
+ if (cell?.value !== currentValues[dsIndex]?.value) {
75118
+ currentValues = currentValues.slice(0, dsIndex);
75119
+ currentValues[dsIndex] = cell;
75120
+ }
75121
+ datasetValues[dsIndex].data.push(cell ?? EMPTY);
75122
+ }
75123
+ return datasetValues.filter((ds) => ds.data.some((d) => d.value !== null));
75124
+ }
75125
+ /**
75126
+ * Get the data from a dataSet
75127
+ */
75128
+ function getData(getters, ds) {
75129
+ if (ds.dataRange) {
75130
+ const labelCellZone = ds.labelCell ? [ds.labelCell.zone] : [];
75131
+ const dataZone = recomputeZones([ds.dataRange.zone], labelCellZone)[0];
75132
+ if (dataZone === void 0) return [];
75133
+ const dataRange = getters.getRangeFromZone(ds.dataRange.sheetId, dataZone);
75134
+ return getters.getVisibleRangeValues(dataRange).map((cell) => cell.value === "" ? EMPTY : cell);
75135
+ }
75136
+ return [];
75137
+ }
75138
+ const ChartNeverDataSourceHandler = {
75139
+ supportedChartTypes: [],
75140
+ fromExternalDefinition: () => ({ type: "none" }),
75141
+ fromContextCreation: () => ({ type: "none" }),
75142
+ fromHierarchicalContextCreation: () => ({ type: "none" }),
75143
+ validate: () => "Success",
75144
+ transform: () => ({ type: "none" }),
75145
+ extractData: () => ({
75146
+ dataSetsValues: [],
75147
+ labelValues: []
75148
+ }),
75149
+ extractHierarchicalData: () => ({
75150
+ dataSetsValues: [],
75151
+ labelValues: []
75152
+ }),
75153
+ adaptRanges: (dataSource) => dataSource,
75154
+ getDefinition: (dataSource) => dataSource,
75155
+ duplicateInDuplicatedSheet: (dataSource) => dataSource,
75156
+ getContextCreation: () => ({}),
75157
+ getHierarchicalContextCreation: () => ({}),
75158
+ toExcelDataSets: () => ({
75159
+ dataSets: [],
75160
+ labelRange: void 0
75161
+ })
75162
+ };
75163
+ chartDataSourceRegistry.add("range", ChartRangeDataSourceHandler);
75164
+ chartDataSourceRegistry.add("none", ChartNeverDataSourceHandler);
75165
+
75158
75166
  //#endregion
75159
75167
  //#region src/helpers/figures/charts/calendar_chart.ts
75160
75168
  function checkDateGranularity(definition) {
@@ -84830,8 +84838,8 @@ exports.stores = stores;
84830
84838
  exports.tokenColors = tokenColors;
84831
84839
  exports.tokenize = tokenize;
84832
84840
 
84833
- __info__.version = "19.3.19";
84834
- __info__.date = "2026-09-04T07:38:14.356Z";
84835
- __info__.hash = "c8c526d";
84841
+ __info__.version = "19.3.20";
84842
+ __info__.date = "2026-09-10T05:38:03.233Z";
84843
+ __info__.hash = "e488e8d";
84836
84844
 
84837
84845
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);