@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
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
@@ -9626,7 +9626,7 @@ function drawLineOrBarOrRadarChartValues(chart, options, ctx) {
9626
9626
  const point = dataset.data[i];
9627
9627
  const xPosition = point.x;
9628
9628
  let yPosition = 0;
9629
- if (chart.config.type === "line" || chart.config.type === "radar") yPosition = value < 0 ? point.y + 10 : point.y - 10;
9629
+ if (dataset.type === "line" || dataset.type === "radar") yPosition = value < 0 ? point.y + 10 : point.y - 10;
9630
9630
  else {
9631
9631
  const yZeroLine = yAxisScale.getPixelForValue(0);
9632
9632
  const distanceFromAxisOrigin = Math.abs(yZeroLine - point.y);
@@ -18574,7 +18574,7 @@ const RemoveDuplicateTerms = { Errors: {
18574
18574
  ["MoreThanOneRangeSelected"]: _t("Please select only one range of cells"),
18575
18575
  ["EmptySelectedRange"]: _t("Please select a range of cells containing values."),
18576
18576
  ["NoColumnsProvided"]: _t("Please select at latest one column to analyze."),
18577
- ["WillRemoveExistingMerge"]: _t("This operation is not possible due to a merge. Please remove the merges first than try again.")
18577
+ ["WillRemoveExistingMerge"]: _t("Cannot perform this action on merged cells. Unmerge the cells and try again.")
18578
18578
  } };
18579
18579
  const DVTerms = {
18580
18580
  DateIs: {
@@ -26815,7 +26815,7 @@ var AbstractComposerStore = class extends SpreadsheetStore {
26815
26815
  col: range.zone.left,
26816
26816
  row: range.zone.top
26817
26817
  });
26818
- if (spreadZone) return this.getters.getRangeFromZone(sheetId, spreadZone);
26818
+ if (spreadZone) return this.getters.getRangeFromZone(range.sheetId, spreadZone);
26819
26819
  return range;
26820
26820
  }
26821
26821
  updateAutoCompleteProvider() {
@@ -32826,433 +32826,6 @@ var ChartRangeDataSourceComponent = class extends _odoo_owl.Component {
32826
32826
  }
32827
32827
  };
32828
32828
 
32829
- //#endregion
32830
- //#region src/helpers/figures/chart.ts
32831
- var SpreadsheetChart = class SpreadsheetChart {
32832
- getters;
32833
- sheetId;
32834
- definition;
32835
- chartTypeBuilder;
32836
- dataSourceBuilder;
32837
- dataSource;
32838
- constructor(getters, sheetId, definition, chartTypeBuilder, dataSourceBuilder) {
32839
- this.getters = getters;
32840
- this.sheetId = sheetId;
32841
- this.definition = definition;
32842
- this.chartTypeBuilder = chartTypeBuilder;
32843
- this.dataSourceBuilder = dataSourceBuilder;
32844
- this.dataSource = definition.dataSource;
32845
- }
32846
- static fromStrDefinition(getters, sheetId, definition) {
32847
- const dataSourceBuilder = chartDataSourceRegistry.get(definition.dataSource?.type ?? "none");
32848
- const chartTypeBuilder = chartTypeRegistry.get(definition.type);
32849
- const dataSource = dataSourceBuilder.fromExternalDefinition(definition.dataSource ?? { type: "none" }, sheetId, getters);
32850
- const rangeDefinition = {
32851
- ...chartTypeBuilder.fromStrDefinition(definition, sheetId, getters),
32852
- dataSource
32853
- };
32854
- return new SpreadsheetChart(getters, sheetId, SpreadsheetChart.deleteInvalidKeys(rangeDefinition), chartTypeBuilder, dataSourceBuilder);
32855
- }
32856
- static fromDefinition(getters, sheetId, definition) {
32857
- const dataSourceBuilder = chartDataSourceRegistry.get(definition.dataSource?.type ?? "none");
32858
- return new SpreadsheetChart(getters, sheetId, definition, chartTypeRegistry.get(definition.type), dataSourceBuilder);
32859
- }
32860
- static validate(validator, definition) {
32861
- const chartTypeBuilder = chartTypeRegistry.get(definition.type);
32862
- const dataSourceBuilder = chartDataSourceRegistry.get(definition.dataSource?.type ?? "none");
32863
- return validator.batchValidations(() => chartTypeBuilder.validateDefinition(validator, definition), () => dataSourceBuilder.validate(definition.dataSource ?? { type: "none" }, validator))(void 0);
32864
- }
32865
- static transformDefinition(chartSheetId, definition, rangeAdapters) {
32866
- const chartTypeBuilder = chartTypeRegistry.get(definition.type);
32867
- if (!definition.dataSource) return chartTypeBuilder.transformDefinition(definition, chartSheetId, rangeAdapters);
32868
- const newDataSource = chartDataSourceRegistry.get(definition.dataSource?.type ?? "none").transform(definition.dataSource, chartSheetId, rangeAdapters);
32869
- return {
32870
- ...chartTypeBuilder.transformDefinition(definition, chartSheetId, rangeAdapters),
32871
- dataSource: newDataSource
32872
- };
32873
- }
32874
- getRangeDefinition() {
32875
- return {
32876
- ...this.definition,
32877
- dataSource: this.dataSource
32878
- };
32879
- }
32880
- getDefinition() {
32881
- return {
32882
- ...this.chartTypeBuilder.toStrDefinition(this.definition, this.sheetId, this.getters),
32883
- dataSource: this.dataSource && this.dataSourceBuilder.getDefinition(this.dataSource, this.sheetId, this.getters)
32884
- };
32885
- }
32886
- updateRanges(rangeAdapters) {
32887
- return {
32888
- ...this.chartTypeBuilder.updateRanges(this.definition, rangeAdapters, this.sheetId),
32889
- dataSource: this.dataSource && this.dataSourceBuilder.adaptRanges(this.dataSource, rangeAdapters)
32890
- };
32891
- }
32892
- duplicateInDuplicatedSheet(sheetIdFrom, sheetIdTo) {
32893
- const newDataSource = this.dataSource && this.dataSourceBuilder.duplicateInDuplicatedSheet(this.dataSource, sheetIdFrom, sheetIdTo, this.getters);
32894
- const definition = {
32895
- ...this.chartTypeBuilder.duplicateInDuplicatedSheet(this.definition, sheetIdFrom, sheetIdTo, this.getters),
32896
- dataSource: newDataSource
32897
- };
32898
- return SpreadsheetChart.fromDefinition(this.getters, sheetIdTo, definition).getDefinition();
32899
- }
32900
- copyInSheetId(sheetIdTo) {
32901
- return {
32902
- ...this.chartTypeBuilder.copyInSheetId(this.definition, this.sheetId, sheetIdTo, this.getters),
32903
- dataSource: this.dataSource
32904
- };
32905
- }
32906
- getContextCreation() {
32907
- const definition = this.getDefinition();
32908
- return {
32909
- ...this.dataSourceBuilder.getContextCreation(definition.dataSource ?? { type: "none" }),
32910
- ...this.chartTypeBuilder.getContextCreation(definition, this.dataSourceBuilder, definition.dataSource)
32911
- };
32912
- }
32913
- getDefinitionForExcel(getters) {
32914
- const definition = this.definition;
32915
- const excelDataSets = this.dataSourceBuilder.toExcelDataSets(this.dataSource, "dataSetStyles" in definition ? definition.dataSetStyles : {}, getters);
32916
- if (excelDataSets === void 0) return;
32917
- return this.chartTypeBuilder.getDefinitionForExcel(getters, definition, excelDataSets);
32918
- }
32919
- getData(getters, chartId) {
32920
- const dataSource = this.dataSource;
32921
- return dataSource ? this.dataSourceBuilder.extractData(dataSource, chartId, getters) : {
32922
- dataSetsValues: [],
32923
- labelValues: []
32924
- };
32925
- }
32926
- getRuntime(getters, chartId) {
32927
- const dataSource = this.dataSource;
32928
- const dataExtractors = dataSource ? {
32929
- extractData: () => this.dataSourceBuilder.extractData(dataSource, chartId, getters),
32930
- extractHierarchicalData: () => this.dataSourceBuilder.extractHierarchicalData(dataSource, chartId, getters)
32931
- } : {
32932
- extractData: () => ({
32933
- dataSetsValues: [],
32934
- labelValues: []
32935
- }),
32936
- extractHierarchicalData: () => ({
32937
- dataSetsValues: [],
32938
- labelValues: []
32939
- })
32940
- };
32941
- return this.chartTypeBuilder.getRuntime(getters, this.definition, dataExtractors, this.sheetId, {
32942
- onClick: (event, items, chartJsChart) => {
32943
- return this.dataSourceBuilder.onDataSetClick?.(this.definition.type, chartId, event, items, chartJsChart, getters);
32944
- },
32945
- onHover: (event, items, chartJsChart) => this.dataSourceBuilder.onDataSetHover?.(this.definition.type, chartId, event, items, chartJsChart)
32946
- });
32947
- }
32948
- static deleteInvalidKeys(definition) {
32949
- definition = { ...definition };
32950
- const keys = new Set(chartTypeRegistry.get(definition.type).allowedDefinitionKeys);
32951
- for (const key of Object.keys(definition)) if (!keys.has(key)) delete definition[key];
32952
- return definition;
32953
- }
32954
- };
32955
-
32956
- //#endregion
32957
- //#region src/helpers/figures/charts/chart_data_sources.ts
32958
- const EMPTY = Object.freeze({ value: null });
32959
- const ONE = Object.freeze({ value: 1 });
32960
- const ChartRangeDataSourceHandler = {
32961
- supportedChartTypes: CHART_TYPES,
32962
- fromExternalDefinition(dataSource, defaultSheetId, getters) {
32963
- const dataSets = createDataSets(getters, defaultSheetId, dataSource);
32964
- const labelRange = createValidRange(getters, defaultSheetId, dataSource.labelRange);
32965
- return {
32966
- ...dataSource,
32967
- dataSets,
32968
- labelRange
32969
- };
32970
- },
32971
- fromContextCreation(context) {
32972
- return {
32973
- type: "range",
32974
- dataSets: [],
32975
- dataSetsHaveTitle: false,
32976
- labelRange: context.auxiliaryRange,
32977
- ...context.dataSource
32978
- };
32979
- },
32980
- fromHierarchicalContextCreation(context) {
32981
- if (context.dataSource?.type !== "range" || context.hierarchicalDataSource !== void 0 && context.hierarchicalDataSource.type !== "range") return {
32982
- type: "range",
32983
- dataSets: [],
32984
- dataSetsHaveTitle: false
32985
- };
32986
- let dataSource = {
32987
- type: "range",
32988
- dataSets: [],
32989
- dataSetsHaveTitle: context.dataSource?.dataSetsHaveTitle ?? false,
32990
- labelRange: context.dataSource?.dataSets?.[0]?.dataRange
32991
- };
32992
- if (context.hierarchicalDataSource?.dataSets.length) dataSource = context.hierarchicalDataSource;
32993
- else if (context.auxiliaryRange) dataSource = {
32994
- ...dataSource,
32995
- dataSets: [{
32996
- dataRange: context.auxiliaryRange,
32997
- dataSetId: "0"
32998
- }]
32999
- };
33000
- return dataSource;
33001
- },
33002
- validate: (dataSource, validator) => validator.checkValidations(dataSource, checkDataset, checkLabelRange),
33003
- transform(dataSource, defaultSheetId, { adaptRangeString }) {
33004
- let labelRange;
33005
- if (dataSource.labelRange) {
33006
- const { changeType, range: adaptedRange } = adaptRangeString(defaultSheetId, dataSource.labelRange);
33007
- if (changeType !== "REMOVE") labelRange = adaptedRange;
33008
- }
33009
- const dataSets = [];
33010
- for (const dataSet of dataSource.dataSets) {
33011
- const newDataSet = { ...dataSet };
33012
- const { changeType, range: adaptedRange } = adaptRangeString(defaultSheetId, dataSet.dataRange);
33013
- if (changeType !== "REMOVE") {
33014
- newDataSet.dataRange = adaptedRange;
33015
- dataSets.push(newDataSet);
33016
- }
33017
- }
33018
- return {
33019
- ...dataSource,
33020
- dataSets,
33021
- labelRange
33022
- };
33023
- },
33024
- extractData: (dataSource, chartId, getters) => getChartData(getters, dataSource),
33025
- extractHierarchicalData(dataSource, chartId, getters) {
33026
- const dataSets = dataSource.dataSets;
33027
- const labelRange = dataSource.labelRange;
33028
- const labelValues = getChartLabelValues(getters, dataSets, labelRange);
33029
- const dataSetsValues = getHierarchicalDatasetValues(getters, dataSets);
33030
- const data = {
33031
- labelValues,
33032
- dataSetsValues
33033
- };
33034
- if (shouldRemoveFirstLabel(labelValues.length, dataSetsValues[0]?.data.length + (dataSetsValues[0]?.label !== void 0 ? 1 : 0), dataSource.dataSetsHaveTitle || false)) labelValues.shift();
33035
- return data;
33036
- },
33037
- adaptRanges(dataSource, { applyChange }) {
33038
- const dataSetsWithUndefined = dataSource.dataSets.map((ds) => {
33039
- const { range: adaptedRangeStr, changeType } = applyChange(ds.dataRange);
33040
- if (changeType === "REMOVE") return;
33041
- let labelCell = void 0;
33042
- if (ds.labelCell) {
33043
- const { range: adaptedLabelCellRange, changeType: labelCellChangeType } = applyChange(ds.labelCell);
33044
- if (labelCellChangeType !== "REMOVE") labelCell = adaptedLabelCellRange;
33045
- }
33046
- return {
33047
- ...ds,
33048
- dataRange: adaptedRangeStr,
33049
- labelCell
33050
- };
33051
- }).filter(isDefined);
33052
- let labelRange = dataSource.labelRange;
33053
- if (labelRange) {
33054
- const { range: adaptedLabelRange, changeType } = applyChange(labelRange);
33055
- if (changeType === "REMOVE") labelRange = void 0;
33056
- else labelRange = adaptedLabelRange;
33057
- }
33058
- const dataSets = dataSetsWithUndefined;
33059
- return {
33060
- ...dataSource,
33061
- dataSets,
33062
- labelRange: labelRange?.invalidSheetName || labelRange?.invalidXc ? void 0 : labelRange
33063
- };
33064
- },
33065
- getDefinition(dataSource, defaultSheetId, getters) {
33066
- return {
33067
- labelRange: dataSource.labelRange ? getters.getRangeString(dataSource.labelRange, defaultSheetId) : void 0,
33068
- type: "range",
33069
- dataSets: dataSource.dataSets.map((dataSet) => ({
33070
- dataSetId: dataSet.dataSetId,
33071
- dataRange: getters.getRangeString(dataSet.dataRange, defaultSheetId)
33072
- })),
33073
- dataSetsHaveTitle: dataSource.dataSetsHaveTitle
33074
- };
33075
- },
33076
- /**
33077
- * Duplicate the dataSets. All ranges on sheetIdFrom are adapted to target
33078
- * sheetIdTo.
33079
- */
33080
- duplicateInDuplicatedSheet(dataSource, sheetIdFrom, sheetIdTo, getters) {
33081
- return {
33082
- ...dataSource,
33083
- labelRange: duplicateLabelRangeInDuplicatedSheet(sheetIdFrom, sheetIdTo, dataSource.labelRange),
33084
- dataSets: dataSource.dataSets.map((ds) => ({
33085
- ...ds,
33086
- dataRange: duplicateRangeInDuplicatedSheet(sheetIdFrom, sheetIdTo, ds.dataRange)
33087
- }))
33088
- };
33089
- },
33090
- getContextCreation: (dataSource) => ({
33091
- auxiliaryRange: dataSource.labelRange,
33092
- dataSource
33093
- }),
33094
- getHierarchicalContextCreation(dataSource) {
33095
- const leafRange = dataSource.dataSets.at(-1)?.dataRange;
33096
- const dataSetsHaveTitle = dataSource.dataSetsHaveTitle;
33097
- return {
33098
- auxiliaryRange: leafRange,
33099
- hierarchicalDataSource: dataSource,
33100
- dataSource: dataSource.labelRange ? {
33101
- type: "range",
33102
- dataSets: [{
33103
- dataRange: dataSource.labelRange,
33104
- dataSetId: "0"
33105
- }],
33106
- dataSetsHaveTitle
33107
- } : {
33108
- type: "range",
33109
- dataSets: [],
33110
- dataSetsHaveTitle
33111
- }
33112
- };
33113
- },
33114
- toExcelDataSets(dataSource, dataSetStyles, getters) {
33115
- const dataSets = dataSource.dataSets;
33116
- const labelRange = dataSource.labelRange;
33117
- const excelDataSets = dataSets.map((ds) => toExcelDataset(getters, dataSetStyles, ds)).filter((ds) => ds.range !== "" && ds.range !== CellErrorType.InvalidReference);
33118
- const datasetLength = dataSets[0] ? getZoneArea(dataSets[0].dataRange.zone) : void 0;
33119
- return {
33120
- dataSets: excelDataSets,
33121
- labelRange: toExcelLabelRange(getters, labelRange, shouldRemoveFirstLabel(labelRange ? getZoneArea(labelRange.zone) : 0, datasetLength, dataSource.dataSetsHaveTitle))
33122
- };
33123
- }
33124
- };
33125
- function getChartData(getters, dataSource) {
33126
- const dataSets = dataSource.dataSets;
33127
- const labelRange = dataSource.labelRange;
33128
- const labelValues = getChartLabelValues(getters, dataSets, labelRange);
33129
- const dataSetsValues = getChartDatasetValues(getters, dataSets);
33130
- const data = {
33131
- labelValues,
33132
- dataSetsValues
33133
- };
33134
- const numberOfDataPoints = dataSetsValues.length ? dataSetsValues[0]?.data.length + (dataSetsValues[0]?.label !== void 0 ? 1 : 0) : 0;
33135
- if (shouldRemoveFirstLabel(labelValues.length, numberOfDataPoints, dataSource.dataSetsHaveTitle || false)) labelValues.shift();
33136
- return data;
33137
- }
33138
- function getChartDatasetValues(getters, dataSets) {
33139
- const datasetValues = [];
33140
- for (const [dsIndex, ds] of Object.entries(dataSets)) {
33141
- let label = `${ChartTerms.Series} ${parseInt(dsIndex) + 1}`;
33142
- let hidden = getters.isColHidden(ds.dataRange.sheetId, ds.dataRange.zone.left);
33143
- if (ds.labelCell) {
33144
- const { sheetId, zone } = ds.labelCell;
33145
- const cell = getters.getEvaluatedCell({
33146
- sheetId,
33147
- col: zone.left,
33148
- row: zone.top
33149
- });
33150
- if (cell) label = cell.formattedValue;
33151
- }
33152
- let data = ds.dataRange ? getData(getters, ds) : [];
33153
- if (data.every((cell) => !cell.value || isTextResult(cell)) && data.filter(isTextResult).length > 1) data = data.map((cell) => cell.value && !isErrorResult(cell) ? ONE : EMPTY);
33154
- else if (data.every((cell) => !isNumberResult(cell))) hidden = true;
33155
- datasetValues.push({
33156
- data,
33157
- label,
33158
- hidden,
33159
- dataSetId: ds.dataSetId
33160
- });
33161
- }
33162
- return datasetValues;
33163
- }
33164
- function getChartLabelValues(getters, dataSets, labelRange) {
33165
- if (labelRange) {
33166
- const { left } = labelRange.zone;
33167
- if (!labelRange.invalidXc && !labelRange.invalidSheetName && !getters.isColHidden(labelRange.sheetId, left)) return getters.getVisibleRangeValues(labelRange);
33168
- }
33169
- if (dataSets[0]) {
33170
- const dataLength = getData(getters, dataSets[0]).length;
33171
- return Array.from({ length: dataLength }, () => ({ value: "" }));
33172
- }
33173
- return [];
33174
- }
33175
- /**
33176
- * Get the values for a hierarchical dataset. The values can be defined in a tree-like structure
33177
- * in the sheet, and this function will fill up the blanks.
33178
- *
33179
- * @example the following dataset:
33180
- *
33181
- * 2024 Q1 W1 100
33182
- * W2 200
33183
- *
33184
- * will have the same value as the dataset:
33185
- * 2024 Q1 W1 100
33186
- * 2024 Q1 W2 200
33187
- */
33188
- function getHierarchicalDatasetValues(getters, dataSets) {
33189
- dataSets = dataSets.filter((ds) => !getters.isColHidden(ds.dataRange.sheetId, ds.dataRange.zone.left));
33190
- const datasetValues = dataSets.map((ds) => ({
33191
- data: [],
33192
- label: "",
33193
- dataSetId: ds.dataSetId
33194
- }));
33195
- const locale = getters.getLocale();
33196
- const dataSetsData = dataSets.map((ds) => getData(getters, ds)).map((values) => values.map(({ value, format }) => value === null ? EMPTY : { value: formatValue(value, {
33197
- format,
33198
- locale
33199
- }) }));
33200
- if (!dataSetsData.length) return datasetValues;
33201
- const minLength = Math.min(...dataSetsData.map((ds) => ds.length));
33202
- let currentValues = [];
33203
- const leafDatasetIndex = dataSets.length - 1;
33204
- for (let i = 0; i < minLength; i++) for (let dsIndex = 0; dsIndex < dataSetsData.length; dsIndex++) {
33205
- let cell = dataSetsData[dsIndex][i];
33206
- if ((cell === void 0 || cell.value === null) && dsIndex !== leafDatasetIndex) cell = currentValues[dsIndex];
33207
- if (cell?.value !== currentValues[dsIndex]?.value) {
33208
- currentValues = currentValues.slice(0, dsIndex);
33209
- currentValues[dsIndex] = cell;
33210
- }
33211
- datasetValues[dsIndex].data.push(cell ?? EMPTY);
33212
- }
33213
- return datasetValues.filter((ds) => ds.data.some((d) => d.value !== null));
33214
- }
33215
- /**
33216
- * Get the data from a dataSet
33217
- */
33218
- function getData(getters, ds) {
33219
- if (ds.dataRange) {
33220
- const labelCellZone = ds.labelCell ? [ds.labelCell.zone] : [];
33221
- const dataZone = recomputeZones([ds.dataRange.zone], labelCellZone)[0];
33222
- if (dataZone === void 0) return [];
33223
- const dataRange = getters.getRangeFromZone(ds.dataRange.sheetId, dataZone);
33224
- return getters.getVisibleRangeValues(dataRange).map((cell) => cell.value === "" ? EMPTY : cell);
33225
- }
33226
- return [];
33227
- }
33228
- const ChartNeverDataSourceHandler = {
33229
- supportedChartTypes: [],
33230
- fromExternalDefinition: () => ({ type: "none" }),
33231
- fromContextCreation: () => ({ type: "none" }),
33232
- fromHierarchicalContextCreation: () => ({ type: "none" }),
33233
- validate: () => "Success",
33234
- transform: () => ({ type: "none" }),
33235
- extractData: () => ({
33236
- dataSetsValues: [],
33237
- labelValues: []
33238
- }),
33239
- extractHierarchicalData: () => ({
33240
- dataSetsValues: [],
33241
- labelValues: []
33242
- }),
33243
- adaptRanges: (dataSource) => dataSource,
33244
- getDefinition: (dataSource) => dataSource,
33245
- duplicateInDuplicatedSheet: (dataSource) => dataSource,
33246
- getContextCreation: () => ({}),
33247
- getHierarchicalContextCreation: () => ({}),
33248
- toExcelDataSets: () => ({
33249
- dataSets: [],
33250
- labelRange: void 0
33251
- })
33252
- };
33253
- chartDataSourceRegistry.add("range", ChartRangeDataSourceHandler);
33254
- chartDataSourceRegistry.add("none", ChartNeverDataSourceHandler);
33255
-
33256
32829
  //#endregion
33257
32830
  //#region src/types/chart/calendar_chart.ts
33258
32831
  const CALENDAR_CHART_GRANULARITIES = [
@@ -33279,41 +32852,6 @@ var CalendarChartConfigPanel = class extends GenericChartConfigPanel {
33279
32852
  value,
33280
32853
  label: ALL_PERIODS[value]
33281
32854
  }));
33282
- getGroupByOptions() {
33283
- const sheetId = this.env.model.getters.getFigureSheetId(this.env.model.getters.getFigureIdFromChartId(this.props.chartId));
33284
- const definition = SpreadsheetChart.fromStrDefinition(this.env.model.getters, sheetId, this.props.definition).getRangeDefinition();
33285
- const labels = getBarChartData(definition, getChartData(this.env.model.getters, definition.dataSource), this.env.model.getters).labels.filter((l) => isDateTime(l, DEFAULT_LOCALE));
33286
- if (labels.length === 0) return [];
33287
- const dates = labels.map((label) => toJsDate(label, this.env.model.getters.getLocale()));
33288
- const uniqueYears = /* @__PURE__ */ new Set();
33289
- const uniqueMonths = /* @__PURE__ */ new Set();
33290
- const uniqueDays = /* @__PURE__ */ new Set();
33291
- const uniqueHours = /* @__PURE__ */ new Set();
33292
- const uniqueMinutes = /* @__PURE__ */ new Set();
33293
- const uniqueSeconds = /* @__PURE__ */ new Set();
33294
- for (const date of dates) {
33295
- uniqueYears.add(date.getFullYear());
33296
- uniqueMonths.add(date.getMonth());
33297
- uniqueDays.add(date.getDate());
33298
- uniqueHours.add(date.getHours());
33299
- uniqueMinutes.add(date.getMinutes());
33300
- uniqueSeconds.add(date.getSeconds());
33301
- }
33302
- return this.groupByChoices.filter((groupBy) => {
33303
- switch (groupBy.value) {
33304
- case "year": return uniqueYears.size > 1;
33305
- case "quarter_number":
33306
- case "month_number": return uniqueMonths.size > 1;
33307
- case "iso_week_number":
33308
- case "day_of_month":
33309
- case "day_of_week": return uniqueDays.size > 1;
33310
- case "hour_number": return uniqueHours.size > 1;
33311
- case "minute_number": return uniqueMinutes.size > 1;
33312
- case "second_number": return uniqueSeconds.size > 1;
33313
- default: return false;
33314
- }
33315
- });
33316
- }
33317
32855
  getGroupByType(currentAxis) {
33318
32856
  return (currentAxis === "horizontal" ? this.props.definition.horizontalGroupBy : this.props.definition.verticalGroupBy) || "year";
33319
32857
  }
@@ -34519,6 +34057,133 @@ var ChartTypePicker = class extends _odoo_owl.Component {
34519
34057
  }
34520
34058
  };
34521
34059
 
34060
+ //#endregion
34061
+ //#region src/helpers/figures/chart.ts
34062
+ var SpreadsheetChart = class SpreadsheetChart {
34063
+ getters;
34064
+ sheetId;
34065
+ definition;
34066
+ chartTypeBuilder;
34067
+ dataSourceBuilder;
34068
+ dataSource;
34069
+ constructor(getters, sheetId, definition, chartTypeBuilder, dataSourceBuilder) {
34070
+ this.getters = getters;
34071
+ this.sheetId = sheetId;
34072
+ this.definition = definition;
34073
+ this.chartTypeBuilder = chartTypeBuilder;
34074
+ this.dataSourceBuilder = dataSourceBuilder;
34075
+ this.dataSource = definition.dataSource;
34076
+ }
34077
+ static fromStrDefinition(getters, sheetId, definition) {
34078
+ const dataSourceBuilder = chartDataSourceRegistry.get(definition.dataSource?.type ?? "none");
34079
+ const chartTypeBuilder = chartTypeRegistry.get(definition.type);
34080
+ const dataSource = dataSourceBuilder.fromExternalDefinition(definition.dataSource ?? { type: "none" }, sheetId, getters);
34081
+ const rangeDefinition = {
34082
+ ...chartTypeBuilder.fromStrDefinition(definition, sheetId, getters),
34083
+ dataSource
34084
+ };
34085
+ return new SpreadsheetChart(getters, sheetId, SpreadsheetChart.deleteInvalidKeys(rangeDefinition), chartTypeBuilder, dataSourceBuilder);
34086
+ }
34087
+ static fromDefinition(getters, sheetId, definition) {
34088
+ const dataSourceBuilder = chartDataSourceRegistry.get(definition.dataSource?.type ?? "none");
34089
+ return new SpreadsheetChart(getters, sheetId, definition, chartTypeRegistry.get(definition.type), dataSourceBuilder);
34090
+ }
34091
+ static validate(validator, definition) {
34092
+ const chartTypeBuilder = chartTypeRegistry.get(definition.type);
34093
+ const dataSourceBuilder = chartDataSourceRegistry.get(definition.dataSource?.type ?? "none");
34094
+ return validator.batchValidations(() => chartTypeBuilder.validateDefinition(validator, definition), () => dataSourceBuilder.validate(definition.dataSource ?? { type: "none" }, validator))(void 0);
34095
+ }
34096
+ static transformDefinition(chartSheetId, definition, rangeAdapters) {
34097
+ const chartTypeBuilder = chartTypeRegistry.get(definition.type);
34098
+ if (!definition.dataSource) return chartTypeBuilder.transformDefinition(definition, chartSheetId, rangeAdapters);
34099
+ const newDataSource = chartDataSourceRegistry.get(definition.dataSource?.type ?? "none").transform(definition.dataSource, chartSheetId, rangeAdapters);
34100
+ return {
34101
+ ...chartTypeBuilder.transformDefinition(definition, chartSheetId, rangeAdapters),
34102
+ dataSource: newDataSource
34103
+ };
34104
+ }
34105
+ getRangeDefinition() {
34106
+ return {
34107
+ ...this.definition,
34108
+ dataSource: this.dataSource
34109
+ };
34110
+ }
34111
+ getDefinition() {
34112
+ return {
34113
+ ...this.chartTypeBuilder.toStrDefinition(this.definition, this.sheetId, this.getters),
34114
+ dataSource: this.dataSource && this.dataSourceBuilder.getDefinition(this.dataSource, this.sheetId, this.getters)
34115
+ };
34116
+ }
34117
+ updateRanges(rangeAdapters) {
34118
+ return {
34119
+ ...this.chartTypeBuilder.updateRanges(this.definition, rangeAdapters, this.sheetId),
34120
+ dataSource: this.dataSource && this.dataSourceBuilder.adaptRanges(this.dataSource, rangeAdapters)
34121
+ };
34122
+ }
34123
+ duplicateInDuplicatedSheet(sheetIdFrom, sheetIdTo) {
34124
+ const newDataSource = this.dataSource && this.dataSourceBuilder.duplicateInDuplicatedSheet(this.dataSource, sheetIdFrom, sheetIdTo, this.getters);
34125
+ const definition = {
34126
+ ...this.chartTypeBuilder.duplicateInDuplicatedSheet(this.definition, sheetIdFrom, sheetIdTo, this.getters),
34127
+ dataSource: newDataSource
34128
+ };
34129
+ return SpreadsheetChart.fromDefinition(this.getters, sheetIdTo, definition).getDefinition();
34130
+ }
34131
+ copyInSheetId(sheetIdTo) {
34132
+ return {
34133
+ ...this.chartTypeBuilder.copyInSheetId(this.definition, this.sheetId, sheetIdTo, this.getters),
34134
+ dataSource: this.dataSource
34135
+ };
34136
+ }
34137
+ getContextCreation() {
34138
+ const definition = this.getDefinition();
34139
+ return {
34140
+ ...this.dataSourceBuilder.getContextCreation(definition.dataSource ?? { type: "none" }),
34141
+ ...this.chartTypeBuilder.getContextCreation(definition, this.dataSourceBuilder, definition.dataSource)
34142
+ };
34143
+ }
34144
+ getDefinitionForExcel(getters) {
34145
+ const definition = this.definition;
34146
+ const excelDataSets = this.dataSourceBuilder.toExcelDataSets(this.dataSource, "dataSetStyles" in definition ? definition.dataSetStyles : {}, getters);
34147
+ if (excelDataSets === void 0) return;
34148
+ return this.chartTypeBuilder.getDefinitionForExcel(getters, definition, excelDataSets);
34149
+ }
34150
+ getData(getters, chartId) {
34151
+ const dataSource = this.dataSource;
34152
+ return dataSource ? this.dataSourceBuilder.extractData(dataSource, chartId, getters) : {
34153
+ dataSetsValues: [],
34154
+ labelValues: []
34155
+ };
34156
+ }
34157
+ getRuntime(getters, chartId) {
34158
+ const dataSource = this.dataSource;
34159
+ const dataExtractors = dataSource ? {
34160
+ extractData: () => this.dataSourceBuilder.extractData(dataSource, chartId, getters),
34161
+ extractHierarchicalData: () => this.dataSourceBuilder.extractHierarchicalData(dataSource, chartId, getters)
34162
+ } : {
34163
+ extractData: () => ({
34164
+ dataSetsValues: [],
34165
+ labelValues: []
34166
+ }),
34167
+ extractHierarchicalData: () => ({
34168
+ dataSetsValues: [],
34169
+ labelValues: []
34170
+ })
34171
+ };
34172
+ return this.chartTypeBuilder.getRuntime(getters, this.definition, dataExtractors, this.sheetId, {
34173
+ onClick: (event, items, chartJsChart) => {
34174
+ return this.dataSourceBuilder.onDataSetClick?.(this.definition.type, chartId, event, items, chartJsChart, getters);
34175
+ },
34176
+ onHover: (event, items, chartJsChart) => this.dataSourceBuilder.onDataSetHover?.(this.definition.type, chartId, event, items, chartJsChart)
34177
+ });
34178
+ }
34179
+ static deleteInvalidKeys(definition) {
34180
+ definition = { ...definition };
34181
+ const keys = new Set(chartTypeRegistry.get(definition.type).allowedDefinitionKeys);
34182
+ for (const key of Object.keys(definition)) if (!keys.has(key)) delete definition[key];
34183
+ return definition;
34184
+ }
34185
+ };
34186
+
34522
34187
  //#endregion
34523
34188
  //#region src/components/side_panel/chart/main_chart_panel/main_chart_panel_store.ts
34524
34189
  var MainChartPanelStore = class extends SpreadsheetStore {
@@ -36507,7 +36172,7 @@ var FindAndReplacePanel = class extends _odoo_owl.Component {
36507
36172
  }
36508
36173
  get specificRangeMatchesCount() {
36509
36174
  const range = this.searchOptions.specificRange;
36510
- if (!range) return "";
36175
+ if (!range || range.invalidSheetName || range.invalidXc) return "";
36511
36176
  const { sheetId, zone } = range;
36512
36177
  return _t("%(matches)s matches in range %(range)s of %(sheetName)s", {
36513
36178
  matches: this.store.specificRangeMatchesCount,
@@ -46136,6 +45801,11 @@ var GridOverlay = class extends _odoo_owl.Component {
46136
45801
  });
46137
45802
  return icon?.onClick ? icon : void 0;
46138
45803
  }
45804
+ get isFooterVisible() {
45805
+ const { y } = this.env.model.getters.getMainViewportCoordinates();
45806
+ const { height } = this.env.model.getters.getSheetViewDimension();
45807
+ return !this.env.model.getters.isReadonly() && height - y > 46;
45808
+ }
46139
45809
  };
46140
45810
 
46141
45811
  //#endregion
@@ -54619,7 +54289,7 @@ var CompilationParametersBuilder = class {
54619
54289
  if (rangeError) return [[rangeError]];
54620
54290
  const sheetId = range.sheetId;
54621
54291
  const zone = range.zone;
54622
- const _zone = intersection(zone, this.getters.getSheetZone(sheetId));
54292
+ const _zone = this.getters.clipRangeToSheet(range)?.zone;
54623
54293
  if (!_zone) return [[]];
54624
54294
  const { top, left, bottom, right } = zone;
54625
54295
  const cacheKey = `${sheetId}-${top}-${left}-${bottom}-${right}`;
@@ -55786,10 +55456,10 @@ var Evaluator = class {
55786
55456
  updateDependencies(position) {
55787
55457
  this.formulaDependencies().removeAllDependencies(position);
55788
55458
  const dependencies = this.getDirectDependencies(position);
55789
- this.formulaDependencies().addDependencies(position, dependencies);
55459
+ this.formulaDependencies().addDependencies(position, this.getters.clipRangesToSheet(dependencies));
55790
55460
  }
55791
55461
  addDependencies(position, dependencies) {
55792
- this.formulaDependencies().addDependencies(position, dependencies);
55462
+ this.formulaDependencies().addDependencies(position, this.getters.clipRangesToSheet(dependencies));
55793
55463
  this.computeDependencies(dependencies);
55794
55464
  }
55795
55465
  computeDependencies(dependencies) {
@@ -55851,7 +55521,8 @@ var Evaluator = class {
55851
55521
  const graph = new FormulaDependencyGraph();
55852
55522
  for (const sheetId of this.getters.getSheetIds()) for (const cell of this.getters.getCells(sheetId)) if (cell.isFormula) {
55853
55523
  const cellPosition = this.getters.getCellPosition(cell.id);
55854
- graph.addDependencies(cellPosition, cell.compiledFormula.rangeDependencies);
55524
+ const dependencies = this.getters.clipRangesToSheet(cell.compiledFormula.rangeDependencies);
55525
+ graph.addDependencies(cellPosition, dependencies);
55855
55526
  }
55856
55527
  return graph;
55857
55528
  });
@@ -61616,7 +61287,8 @@ var GeoFeaturePlugin = class extends UIPlugin {
61616
61287
  "getGeoJsonFeatures",
61617
61288
  "geoFeatureNameToId",
61618
61289
  "getGeoChartAvailableRegions",
61619
- "getAvailableChartRegions"
61290
+ "getAvailableChartRegions",
61291
+ "loadUsedGeoJsonFeatures"
61620
61292
  ];
61621
61293
  geoJsonService;
61622
61294
  geoJsonCache = {};
@@ -61699,6 +61371,23 @@ var GeoFeaturePlugin = class extends UIPlugin {
61699
61371
  }
61700
61372
  return this.geoJsonService.geoFeatureNameToId(region, featureName);
61701
61373
  }
61374
+ loadUsedGeoJsonFeatures() {
61375
+ const regions = this.getters.getSheetIds().flatMap((sheetId) => this.getters.getChartIds(sheetId).map((chartId) => {
61376
+ const definition = this.getters.getChartDefinition(chartId);
61377
+ return definition.type === "geo" ? definition.region || this.getters.getGeoChartAvailableRegions()[0]?.id : void 0;
61378
+ })).filter(isDefined);
61379
+ const uniqueRegions = Array.from(new Set(regions));
61380
+ if (uniqueRegions.length && !this.geoJsonService) {
61381
+ console.error("No geoJsonService provided to the model");
61382
+ return Promise.resolve();
61383
+ }
61384
+ for (const region of uniqueRegions) this.getGeoJsonFeatures(region);
61385
+ const promises = uniqueRegions.map((region) => {
61386
+ const cachedGeoJson = this.geoJsonCache[region];
61387
+ return cachedGeoJson instanceof Promise ? cachedGeoJson : Promise.resolve();
61388
+ });
61389
+ return Promise.all(promises).then(() => {});
61390
+ }
61702
61391
  convertToGeoJson(json) {
61703
61392
  if (!json) return null;
61704
61393
  if (json.type === "Topology") {
@@ -64760,7 +64449,7 @@ var InternalViewport = class {
64760
64449
  let height = lastRowEnd - this.offsetCorrectionY;
64761
64450
  if (this.canScrollVertically) {
64762
64451
  height = Math.max(height, this.viewportHeight);
64763
- if (lastRowEnd + 46 > height && !this.getters.isReadonly()) height += 46;
64452
+ if (lastRowEnd + 46 > height && !this.getters.isReadonly() && this.viewportHeight > 46) height += 46;
64764
64453
  }
64765
64454
  return {
64766
64455
  width,
@@ -69207,12 +68896,11 @@ var SpreadsheetPrintStore = class extends SpreadsheetStore {
69207
68896
  const { width: printWidth, height: printHeight } = this.pageDimensionWithMargins;
69208
68897
  const start = dimension === "COL" ? printZone.left : printZone.top;
69209
68898
  const end = dimension === "COL" ? printZone.right : printZone.bottom;
69210
- const getHeaderSize = dimension === "COL" ? this.getters.getColDimensions : this.getters.getRowDimensions;
69211
68899
  const max = dimension === "COL" ? printWidth : printHeight;
69212
68900
  const breaks = [];
69213
68901
  let current = 0;
69214
68902
  for (let i = start; i <= end; i++) {
69215
- const headerSize = getHeaderSize(sheetId, i).size * zoom;
68903
+ const headerSize = this.getters.getHeaderSize(sheetId, dimension, i) * zoom;
69216
68904
  current += headerSize;
69217
68905
  if (current >= max) {
69218
68906
  breaks.push(i);
@@ -71697,6 +71385,8 @@ var RangeAdapterPlugin = class {
71697
71385
  "extendRange",
71698
71386
  "getRangeString",
71699
71387
  "getRangeFromSheetXC",
71388
+ "clipRangesToSheet",
71389
+ "clipRangeToSheet",
71700
71390
  "createAdaptedRanges",
71701
71391
  "getRangeData",
71702
71392
  "getRangeDataFromXc",
@@ -71735,6 +71425,22 @@ var RangeAdapterPlugin = class {
71735
71425
  addRangeProvider(provider) {
71736
71426
  this.providers.push(provider);
71737
71427
  }
71428
+ clipRangeToSheet(range) {
71429
+ if (range.invalidXc) return range;
71430
+ const sheetZone = this.getters.getSheetZone(range.sheetId);
71431
+ if (isZoneInside(range.zone, sheetZone)) return range;
71432
+ const newZone = intersection(range.zone, sheetZone);
71433
+ if (!newZone) return;
71434
+ return this.getters.getRangeFromZone(range.sheetId, newZone);
71435
+ }
71436
+ clipRangesToSheet(ranges) {
71437
+ const clippedRanges = [];
71438
+ for (const range of ranges) {
71439
+ const clippedRange = this.clipRangeToSheet(range);
71440
+ if (clippedRange) clippedRanges.push(clippedRange);
71441
+ }
71442
+ return clippedRanges;
71443
+ }
71738
71444
  createAdaptedRanges(ranges, offsetX, offsetY, sheetId) {
71739
71445
  return ranges.map((range) => {
71740
71446
  if (!isZoneValid(range.zone)) return range;
@@ -74932,6 +74638,8 @@ var Model = class Model extends EventBus {
74932
74638
  this.range = new RangeAdapterPlugin(this.coreGetters);
74933
74639
  this.coreGetters.getRangeString = this.range.getRangeString.bind(this.range);
74934
74640
  this.coreGetters.getRangeFromSheetXC = this.range.getRangeFromSheetXC.bind(this.range);
74641
+ this.coreGetters.clipRangesToSheet = this.range.clipRangesToSheet.bind(this.range);
74642
+ this.coreGetters.clipRangeToSheet = this.range.clipRangeToSheet.bind(this.range);
74935
74643
  this.coreGetters.createAdaptedRanges = this.range.createAdaptedRanges.bind(this.range);
74936
74644
  this.coreGetters.getRangeData = this.range.getRangeData.bind(this.range);
74937
74645
  this.coreGetters.getRangeDataFromXc = this.range.getRangeDataFromXc.bind(this.range);
@@ -75338,6 +75046,306 @@ function createCommand(type, payload = {}) {
75338
75046
  return command;
75339
75047
  }
75340
75048
 
75049
+ //#endregion
75050
+ //#region src/helpers/figures/charts/chart_data_sources.ts
75051
+ const EMPTY = Object.freeze({ value: null });
75052
+ const ONE = Object.freeze({ value: 1 });
75053
+ const ChartRangeDataSourceHandler = {
75054
+ supportedChartTypes: CHART_TYPES,
75055
+ fromExternalDefinition(dataSource, defaultSheetId, getters) {
75056
+ const dataSets = createDataSets(getters, defaultSheetId, dataSource);
75057
+ const labelRange = createValidRange(getters, defaultSheetId, dataSource.labelRange);
75058
+ return {
75059
+ ...dataSource,
75060
+ dataSets,
75061
+ labelRange
75062
+ };
75063
+ },
75064
+ fromContextCreation(context) {
75065
+ return {
75066
+ type: "range",
75067
+ dataSets: [],
75068
+ dataSetsHaveTitle: false,
75069
+ labelRange: context.auxiliaryRange,
75070
+ ...context.dataSource
75071
+ };
75072
+ },
75073
+ fromHierarchicalContextCreation(context) {
75074
+ if (context.dataSource?.type !== "range" || context.hierarchicalDataSource !== void 0 && context.hierarchicalDataSource.type !== "range") return {
75075
+ type: "range",
75076
+ dataSets: [],
75077
+ dataSetsHaveTitle: false
75078
+ };
75079
+ let dataSource = {
75080
+ type: "range",
75081
+ dataSets: [],
75082
+ dataSetsHaveTitle: context.dataSource?.dataSetsHaveTitle ?? false,
75083
+ labelRange: context.dataSource?.dataSets?.[0]?.dataRange
75084
+ };
75085
+ if (context.hierarchicalDataSource?.dataSets.length) dataSource = context.hierarchicalDataSource;
75086
+ else if (context.auxiliaryRange) dataSource = {
75087
+ ...dataSource,
75088
+ dataSets: [{
75089
+ dataRange: context.auxiliaryRange,
75090
+ dataSetId: "0"
75091
+ }]
75092
+ };
75093
+ return dataSource;
75094
+ },
75095
+ validate: (dataSource, validator) => validator.checkValidations(dataSource, checkDataset, checkLabelRange),
75096
+ transform(dataSource, defaultSheetId, { adaptRangeString }) {
75097
+ let labelRange;
75098
+ if (dataSource.labelRange) {
75099
+ const { changeType, range: adaptedRange } = adaptRangeString(defaultSheetId, dataSource.labelRange);
75100
+ if (changeType !== "REMOVE") labelRange = adaptedRange;
75101
+ }
75102
+ const dataSets = [];
75103
+ for (const dataSet of dataSource.dataSets) {
75104
+ const newDataSet = { ...dataSet };
75105
+ const { changeType, range: adaptedRange } = adaptRangeString(defaultSheetId, dataSet.dataRange);
75106
+ if (changeType !== "REMOVE") {
75107
+ newDataSet.dataRange = adaptedRange;
75108
+ dataSets.push(newDataSet);
75109
+ }
75110
+ }
75111
+ return {
75112
+ ...dataSource,
75113
+ dataSets,
75114
+ labelRange
75115
+ };
75116
+ },
75117
+ extractData: (dataSource, chartId, getters) => getChartData(getters, dataSource),
75118
+ extractHierarchicalData(dataSource, chartId, getters) {
75119
+ const dataSets = dataSource.dataSets;
75120
+ const labelRange = dataSource.labelRange;
75121
+ const labelValues = getChartLabelValues(getters, dataSets, labelRange);
75122
+ const dataSetsValues = getHierarchicalDatasetValues(getters, dataSets);
75123
+ const data = {
75124
+ labelValues,
75125
+ dataSetsValues
75126
+ };
75127
+ if (shouldRemoveFirstLabel(labelValues.length, dataSetsValues[0]?.data.length + (dataSetsValues[0]?.label !== void 0 ? 1 : 0), dataSource.dataSetsHaveTitle || false)) labelValues.shift();
75128
+ return data;
75129
+ },
75130
+ adaptRanges(dataSource, { applyChange }) {
75131
+ const dataSetsWithUndefined = dataSource.dataSets.map((ds) => {
75132
+ const { range: adaptedRangeStr, changeType } = applyChange(ds.dataRange);
75133
+ if (changeType === "REMOVE") return;
75134
+ let labelCell = void 0;
75135
+ if (ds.labelCell) {
75136
+ const { range: adaptedLabelCellRange, changeType: labelCellChangeType } = applyChange(ds.labelCell);
75137
+ if (labelCellChangeType !== "REMOVE") labelCell = adaptedLabelCellRange;
75138
+ }
75139
+ return {
75140
+ ...ds,
75141
+ dataRange: adaptedRangeStr,
75142
+ labelCell
75143
+ };
75144
+ }).filter(isDefined);
75145
+ let labelRange = dataSource.labelRange;
75146
+ if (labelRange) {
75147
+ const { range: adaptedLabelRange, changeType } = applyChange(labelRange);
75148
+ if (changeType === "REMOVE") labelRange = void 0;
75149
+ else labelRange = adaptedLabelRange;
75150
+ }
75151
+ const dataSets = dataSetsWithUndefined;
75152
+ return {
75153
+ ...dataSource,
75154
+ dataSets,
75155
+ labelRange: labelRange?.invalidSheetName || labelRange?.invalidXc ? void 0 : labelRange
75156
+ };
75157
+ },
75158
+ getDefinition(dataSource, defaultSheetId, getters) {
75159
+ return {
75160
+ labelRange: dataSource.labelRange ? getters.getRangeString(dataSource.labelRange, defaultSheetId) : void 0,
75161
+ type: "range",
75162
+ dataSets: dataSource.dataSets.map((dataSet) => ({
75163
+ dataSetId: dataSet.dataSetId,
75164
+ dataRange: getters.getRangeString(dataSet.dataRange, defaultSheetId)
75165
+ })),
75166
+ dataSetsHaveTitle: dataSource.dataSetsHaveTitle
75167
+ };
75168
+ },
75169
+ /**
75170
+ * Duplicate the dataSets. All ranges on sheetIdFrom are adapted to target
75171
+ * sheetIdTo.
75172
+ */
75173
+ duplicateInDuplicatedSheet(dataSource, sheetIdFrom, sheetIdTo, getters) {
75174
+ return {
75175
+ ...dataSource,
75176
+ labelRange: duplicateLabelRangeInDuplicatedSheet(sheetIdFrom, sheetIdTo, dataSource.labelRange),
75177
+ dataSets: dataSource.dataSets.map((ds) => ({
75178
+ ...ds,
75179
+ dataRange: duplicateRangeInDuplicatedSheet(sheetIdFrom, sheetIdTo, ds.dataRange)
75180
+ }))
75181
+ };
75182
+ },
75183
+ getContextCreation: (dataSource) => ({
75184
+ auxiliaryRange: dataSource.labelRange,
75185
+ dataSource
75186
+ }),
75187
+ getHierarchicalContextCreation(dataSource) {
75188
+ const leafRange = dataSource.dataSets.at(-1)?.dataRange;
75189
+ const dataSetsHaveTitle = dataSource.dataSetsHaveTitle;
75190
+ return {
75191
+ auxiliaryRange: leafRange,
75192
+ hierarchicalDataSource: dataSource,
75193
+ dataSource: dataSource.labelRange ? {
75194
+ type: "range",
75195
+ dataSets: [{
75196
+ dataRange: dataSource.labelRange,
75197
+ dataSetId: "0"
75198
+ }],
75199
+ dataSetsHaveTitle
75200
+ } : {
75201
+ type: "range",
75202
+ dataSets: [],
75203
+ dataSetsHaveTitle
75204
+ }
75205
+ };
75206
+ },
75207
+ toExcelDataSets(dataSource, dataSetStyles, getters) {
75208
+ const dataSets = dataSource.dataSets;
75209
+ const labelRange = dataSource.labelRange;
75210
+ const excelDataSets = dataSets.map((ds) => toExcelDataset(getters, dataSetStyles, ds)).filter((ds) => ds.range !== "" && ds.range !== CellErrorType.InvalidReference);
75211
+ const datasetLength = dataSets[0] ? getZoneArea(dataSets[0].dataRange.zone) : void 0;
75212
+ return {
75213
+ dataSets: excelDataSets,
75214
+ labelRange: toExcelLabelRange(getters, labelRange, shouldRemoveFirstLabel(labelRange ? getZoneArea(labelRange.zone) : 0, datasetLength, dataSource.dataSetsHaveTitle))
75215
+ };
75216
+ }
75217
+ };
75218
+ function getChartData(getters, dataSource) {
75219
+ const dataSets = dataSource.dataSets;
75220
+ const labelRange = dataSource.labelRange;
75221
+ const labelValues = getChartLabelValues(getters, dataSets, labelRange);
75222
+ const dataSetsValues = getChartDatasetValues(getters, dataSets);
75223
+ const data = {
75224
+ labelValues,
75225
+ dataSetsValues
75226
+ };
75227
+ const numberOfDataPoints = dataSetsValues.length ? dataSetsValues[0]?.data.length + (dataSetsValues[0]?.label !== void 0 ? 1 : 0) : 0;
75228
+ if (shouldRemoveFirstLabel(labelValues.length, numberOfDataPoints, dataSource.dataSetsHaveTitle || false)) labelValues.shift();
75229
+ return data;
75230
+ }
75231
+ function getChartDatasetValues(getters, dataSets) {
75232
+ const datasetValues = [];
75233
+ for (const [dsIndex, ds] of Object.entries(dataSets)) {
75234
+ let label = `${ChartTerms.Series} ${parseInt(dsIndex) + 1}`;
75235
+ let hidden = getters.isColHidden(ds.dataRange.sheetId, ds.dataRange.zone.left);
75236
+ if (ds.labelCell) {
75237
+ const { sheetId, zone } = ds.labelCell;
75238
+ const cell = getters.getEvaluatedCell({
75239
+ sheetId,
75240
+ col: zone.left,
75241
+ row: zone.top
75242
+ });
75243
+ if (cell) label = cell.formattedValue;
75244
+ }
75245
+ let data = ds.dataRange ? getData(getters, ds) : [];
75246
+ if (data.every((cell) => !cell.value || isTextResult(cell)) && data.filter(isTextResult).length > 1) data = data.map((cell) => cell.value && !isErrorResult(cell) ? ONE : EMPTY);
75247
+ else if (data.every((cell) => !isNumberResult(cell))) hidden = true;
75248
+ datasetValues.push({
75249
+ data,
75250
+ label,
75251
+ hidden,
75252
+ dataSetId: ds.dataSetId
75253
+ });
75254
+ }
75255
+ return datasetValues;
75256
+ }
75257
+ function getChartLabelValues(getters, dataSets, labelRange) {
75258
+ if (labelRange) {
75259
+ const { left } = labelRange.zone;
75260
+ if (!labelRange.invalidXc && !labelRange.invalidSheetName && !getters.isColHidden(labelRange.sheetId, left)) return getters.getVisibleRangeValues(labelRange);
75261
+ }
75262
+ if (dataSets[0]) {
75263
+ const dataLength = getData(getters, dataSets[0]).length;
75264
+ return Array.from({ length: dataLength }, () => ({ value: "" }));
75265
+ }
75266
+ return [];
75267
+ }
75268
+ /**
75269
+ * Get the values for a hierarchical dataset. The values can be defined in a tree-like structure
75270
+ * in the sheet, and this function will fill up the blanks.
75271
+ *
75272
+ * @example the following dataset:
75273
+ *
75274
+ * 2024 Q1 W1 100
75275
+ * W2 200
75276
+ *
75277
+ * will have the same value as the dataset:
75278
+ * 2024 Q1 W1 100
75279
+ * 2024 Q1 W2 200
75280
+ */
75281
+ function getHierarchicalDatasetValues(getters, dataSets) {
75282
+ dataSets = dataSets.filter((ds) => !getters.isColHidden(ds.dataRange.sheetId, ds.dataRange.zone.left));
75283
+ const datasetValues = dataSets.map((ds) => ({
75284
+ data: [],
75285
+ label: "",
75286
+ dataSetId: ds.dataSetId
75287
+ }));
75288
+ const locale = getters.getLocale();
75289
+ const dataSetsData = dataSets.map((ds) => getData(getters, ds)).map((values) => values.map(({ value, format }) => value === null ? EMPTY : { value: formatValue(value, {
75290
+ format,
75291
+ locale
75292
+ }) }));
75293
+ if (!dataSetsData.length) return datasetValues;
75294
+ const minLength = Math.min(...dataSetsData.map((ds) => ds.length));
75295
+ let currentValues = [];
75296
+ const leafDatasetIndex = dataSets.length - 1;
75297
+ for (let i = 0; i < minLength; i++) for (let dsIndex = 0; dsIndex < dataSetsData.length; dsIndex++) {
75298
+ let cell = dataSetsData[dsIndex][i];
75299
+ if ((cell === void 0 || cell.value === null) && dsIndex !== leafDatasetIndex) cell = currentValues[dsIndex];
75300
+ if (cell?.value !== currentValues[dsIndex]?.value) {
75301
+ currentValues = currentValues.slice(0, dsIndex);
75302
+ currentValues[dsIndex] = cell;
75303
+ }
75304
+ datasetValues[dsIndex].data.push(cell ?? EMPTY);
75305
+ }
75306
+ return datasetValues.filter((ds) => ds.data.some((d) => d.value !== null));
75307
+ }
75308
+ /**
75309
+ * Get the data from a dataSet
75310
+ */
75311
+ function getData(getters, ds) {
75312
+ if (ds.dataRange) {
75313
+ const labelCellZone = ds.labelCell ? [ds.labelCell.zone] : [];
75314
+ const dataZone = recomputeZones([ds.dataRange.zone], labelCellZone)[0];
75315
+ if (dataZone === void 0) return [];
75316
+ const dataRange = getters.getRangeFromZone(ds.dataRange.sheetId, dataZone);
75317
+ return getters.getVisibleRangeValues(dataRange).map((cell) => cell.value === "" ? EMPTY : cell);
75318
+ }
75319
+ return [];
75320
+ }
75321
+ const ChartNeverDataSourceHandler = {
75322
+ supportedChartTypes: [],
75323
+ fromExternalDefinition: () => ({ type: "none" }),
75324
+ fromContextCreation: () => ({ type: "none" }),
75325
+ fromHierarchicalContextCreation: () => ({ type: "none" }),
75326
+ validate: () => "Success",
75327
+ transform: () => ({ type: "none" }),
75328
+ extractData: () => ({
75329
+ dataSetsValues: [],
75330
+ labelValues: []
75331
+ }),
75332
+ extractHierarchicalData: () => ({
75333
+ dataSetsValues: [],
75334
+ labelValues: []
75335
+ }),
75336
+ adaptRanges: (dataSource) => dataSource,
75337
+ getDefinition: (dataSource) => dataSource,
75338
+ duplicateInDuplicatedSheet: (dataSource) => dataSource,
75339
+ getContextCreation: () => ({}),
75340
+ getHierarchicalContextCreation: () => ({}),
75341
+ toExcelDataSets: () => ({
75342
+ dataSets: [],
75343
+ labelRange: void 0
75344
+ })
75345
+ };
75346
+ chartDataSourceRegistry.add("range", ChartRangeDataSourceHandler);
75347
+ chartDataSourceRegistry.add("none", ChartNeverDataSourceHandler);
75348
+
75341
75349
  //#endregion
75342
75350
  //#region src/helpers/figures/charts/calendar_chart.ts
75343
75351
  function checkDateGranularity(definition) {
@@ -85013,6 +85021,6 @@ exports.stores = stores;
85013
85021
  exports.tokenColors = tokenColors;
85014
85022
  exports.tokenize = tokenize;
85015
85023
 
85016
- __info__.version = "19.3.19";
85017
- __info__.date = "2026-09-04T07:38:14.356Z";
85018
- __info__.hash = "c8c526d";
85024
+ __info__.version = "19.3.20";
85025
+ __info__.date = "2026-09-10T05:38:03.233Z";
85026
+ __info__.hash = "e488e8d";