@odoo/o-spreadsheet 17.5.0-alpha.4 → 17.5.0-alpha.5

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 17.5.0-alpha.4
6
- * @date 2024-08-06T12:05:55.642Z
7
- * @hash a941df3
5
+ * @version 17.5.0-alpha.5
6
+ * @date 2024-08-09T12:24:12.813Z
7
+ * @hash 5d4bc65
8
8
  */
9
9
 
10
10
  'use strict';
@@ -24,6 +24,7 @@ const SELECTION_BORDER_COLOR = "#3266ca";
24
24
  const HEADER_BORDER_COLOR = "#C0C0C0";
25
25
  const CELL_BORDER_COLOR = "#E2E3E3";
26
26
  const BACKGROUND_CHART_COLOR = "#FFFFFF";
27
+ const BORDER_CHART_COLOR = "#FFFFFF";
27
28
  const BG_HOVER_COLOR = "#EBEBEB";
28
29
  const DISABLED_TEXT_COLOR = "#CACACA";
29
30
  const DEFAULT_COLOR_SCALE_MIDPOINT_COLOR = 0xb6d7a8;
@@ -38,8 +39,8 @@ const GRID_BORDER_COLOR = "#E2E3E3";
38
39
  const FROZEN_PANE_HEADER_BORDER_COLOR = "#BCBCBC";
39
40
  const FROZEN_PANE_BORDER_COLOR = "#DADFE8";
40
41
  const COMPOSER_ASSISTANT_COLOR = "#9B359B";
41
- const CHART_WATERFALL_POSITIVE_COLOR = "#006FBE";
42
- const CHART_WATERFALL_NEGATIVE_COLOR = "#E40000";
42
+ const CHART_WATERFALL_POSITIVE_COLOR = "#4EA7F2";
43
+ const CHART_WATERFALL_NEGATIVE_COLOR = "#EA6175";
43
44
  const CHART_WATERFALL_SUBTOTAL_COLOR = "#AAAAAA";
44
45
  const DEFAULT_CHART_PADDING = 20;
45
46
  const DEFAULT_CHART_FONT_SIZE = 22;
@@ -190,12 +191,12 @@ const MIN_FIG_SIZE = 80;
190
191
  // Chart
191
192
  const MAX_CHAR_LABEL = 20;
192
193
  const FIGURE_ID_SPLITTER = "??";
193
- const DEFAULT_GAUGE_LOWER_COLOR = "#cc0000";
194
- const DEFAULT_GAUGE_MIDDLE_COLOR = "#f1c232";
195
- const DEFAULT_GAUGE_UPPER_COLOR = "#6aa84f";
194
+ const DEFAULT_GAUGE_LOWER_COLOR = "#EA6175";
195
+ const DEFAULT_GAUGE_MIDDLE_COLOR = "#FFD86D";
196
+ const DEFAULT_GAUGE_UPPER_COLOR = "#43C5B1";
196
197
  const DEFAULT_SCORECARD_BASELINE_MODE = "difference";
197
- const DEFAULT_SCORECARD_BASELINE_COLOR_UP = "#6AA84F";
198
- const DEFAULT_SCORECARD_BASELINE_COLOR_DOWN = "#E06666";
198
+ const DEFAULT_SCORECARD_BASELINE_COLOR_UP = "#43C5B1";
199
+ const DEFAULT_SCORECARD_BASELINE_COLOR_DOWN = "#EA6175";
199
200
  const LINE_FILL_TRANSPARENCY = 0.4;
200
201
  // session
201
202
  const DEBOUNCE_TIME = 200;
@@ -1090,42 +1091,117 @@ function darkenColor(color, percentage) {
1090
1091
  hsla.l = hsla.l - percentage * hsla.l;
1091
1092
  return hslaToHex(hsla);
1092
1093
  }
1093
- const ColorsList = [
1094
- // the same colors as those used in odoo reporting
1095
- "rgb(31,119,180)",
1096
- "rgb(255,127,14)",
1097
- "rgb(174,199,232)",
1098
- "rgb(255,187,120)",
1099
- "rgb(44,160,44)",
1100
- "rgb(152,223,138)",
1101
- "rgb(214,39,40)",
1102
- "rgb(255,152,150)",
1103
- "rgb(148,103,189)",
1104
- "rgb(197,176,213)",
1105
- "rgb(140,86,75)",
1106
- "rgb(196,156,148)",
1107
- "rgb(227,119,194)",
1108
- "rgb(247,182,210)",
1109
- "rgb(127,127,127)",
1110
- "rgb(199,199,199)",
1111
- "rgb(188,189,34)",
1112
- "rgb(219,219,141)",
1113
- "rgb(23,190,207)",
1114
- "rgb(158,218,229)",
1094
+ const COLORS_SM = [
1095
+ "#4EA7F2", // Blue
1096
+ "#EA6175", // Red
1097
+ "#43C5B1", // Teal
1098
+ "#F4A261", // Orange
1099
+ "#8481DD", // Purple
1100
+ "#FFD86D", // Yellow
1115
1101
  ];
1116
- function getNthColor(index) {
1117
- return ColorsList[index % ColorsList.length];
1102
+ const COLORS_MD = [
1103
+ "#4EA7F2", // Blue #1
1104
+ "#3188E6", // Blue #2
1105
+ "#43C5B1", // Teal #1
1106
+ "#00A78D", // Teal #2
1107
+ "#EA6175", // Red #1
1108
+ "#CE4257", // Red #2
1109
+ "#F4A261", // Orange #1
1110
+ "#F48935", // Orange #2
1111
+ "#8481DD", // Purple #1
1112
+ "#5752D1", // Purple #2
1113
+ "#FFD86D", // Yellow #1
1114
+ "#FFBC2C", // Yellow #2
1115
+ ];
1116
+ const COLORS_LG = [
1117
+ "#4EA7F2", // Blue #1
1118
+ "#3188E6", // Blue #2
1119
+ "#056BD9", // Blue #3
1120
+ "#A76DBC", // Violet #1
1121
+ "#7F4295", // Violet #2
1122
+ "#6D2387", // Violet #3
1123
+ "#EA6175", // Red #1
1124
+ "#CE4257", // Red #2
1125
+ "#982738", // Red #3
1126
+ "#43C5B1", // Teal #1
1127
+ "#00A78D", // Teal #2
1128
+ "#0E8270", // Teal #3
1129
+ "#F4A261", // Orange #1
1130
+ "#F48935", // Orange #2
1131
+ "#BE5D10", // Orange #3
1132
+ "#8481DD", // Purple #1
1133
+ "#5752D1", // Purple #2
1134
+ "#3A3580", // Purple #3
1135
+ "#A4A8B6", // Gray #1
1136
+ "#7E8290", // Gray #2
1137
+ "#545B70", // Gray #3
1138
+ "#FFD86D", // Yellow #1
1139
+ "#FFBC2C", // Yellow #2
1140
+ "#C08A16", // Yellow #3
1141
+ ];
1142
+ const COLORS_XL = [
1143
+ "#4EA7F2", // Blue #1
1144
+ "#3188E6", // Blue #2
1145
+ "#056BD9", // Blue #3
1146
+ "#155193", // Blue #4
1147
+ "#A76DBC", // Violet #1
1148
+ "#7F4295", // Violet #1
1149
+ "#6D2387", // Violet #1
1150
+ "#4F1565", // Violet #1
1151
+ "#EA6175", // Red #1
1152
+ "#CE4257", // Red #2
1153
+ "#982738", // Red #3
1154
+ "#791B29", // Red #4
1155
+ "#43C5B1", // Teal #1
1156
+ "#00A78D", // Teal #2
1157
+ "#0E8270", // Teal #3
1158
+ "#105F53", // Teal #4
1159
+ "#F4A261", // Orange #1
1160
+ "#F48935", // Orange #2
1161
+ "#BE5D10", // Orange #3
1162
+ "#7D380D", // Orange #4
1163
+ "#8481DD", // Purple #1
1164
+ "#5752D1", // Purple #2
1165
+ "#3A3580", // Purple #3
1166
+ "#26235F", // Purple #4
1167
+ "#A4A8B6", // Grey #1
1168
+ "#7E8290", // Grey #2
1169
+ "#545B70", // Grey #3
1170
+ "#3F4250", // Grey #4
1171
+ "#FFD86D", // Yellow #1
1172
+ "#FFBC2C", // Yellow #2
1173
+ "#C08A16", // Yellow #3
1174
+ "#936A12", // Yellow #4
1175
+ ];
1176
+ function getNthColor(index, palette) {
1177
+ return palette[index % palette.length];
1178
+ }
1179
+ function getColorsPalette(quantity) {
1180
+ if (quantity <= 6) {
1181
+ return COLORS_SM;
1182
+ }
1183
+ else if (quantity <= 12) {
1184
+ return COLORS_MD;
1185
+ }
1186
+ else if (quantity <= 24) {
1187
+ return COLORS_LG;
1188
+ }
1189
+ else {
1190
+ return COLORS_XL;
1191
+ }
1118
1192
  }
1119
1193
  class ColorGenerator {
1194
+ preferredColors;
1120
1195
  currentColorIndex = 0;
1121
- colors;
1122
- constructor(colors = []) {
1123
- this.colors = colors;
1196
+ palette;
1197
+ constructor(paletteSize, preferredColors = []) {
1198
+ this.preferredColors = preferredColors;
1199
+ this.palette = getColorsPalette(paletteSize).filter((c) => !preferredColors.includes(c));
1124
1200
  }
1125
1201
  next() {
1126
- return this.colors?.[this.currentColorIndex]
1127
- ? this.colors[this.currentColorIndex++]
1128
- : getNthColor(this.currentColorIndex++);
1202
+ return this.preferredColors?.[this.currentColorIndex]
1203
+ ? this.preferredColors[this.currentColorIndex++]
1204
+ : getNthColor(this.currentColorIndex++, this.palette);
1129
1205
  }
1130
1206
  }
1131
1207
 
@@ -8425,6 +8501,7 @@ function getFullTrendingLineDataSet(dataset, config, data) {
8425
8501
  backgroundColor,
8426
8502
  borderColor: backgroundColor,
8427
8503
  borderDash: [5, 5],
8504
+ borderWidth: undefined,
8428
8505
  };
8429
8506
  }
8430
8507
  function interpolateData(config, values, labels, newLabels) {
@@ -8461,6 +8538,21 @@ function interpolateData(config, values, labels, newLabels) {
8461
8538
  return [];
8462
8539
  }
8463
8540
  }
8541
+ function formatTickValue(localeFormat) {
8542
+ return (value) => {
8543
+ value = Number(value);
8544
+ if (isNaN(value))
8545
+ return value;
8546
+ const { locale, format } = localeFormat;
8547
+ return formatValue(value, {
8548
+ locale,
8549
+ format: !format && Math.abs(value) >= 1000 ? "#,##" : format,
8550
+ });
8551
+ };
8552
+ }
8553
+ function getChartColorsGenerator(definition, dataSetsSize) {
8554
+ return new ColorGenerator(dataSetsSize, definition.dataSets.map((ds) => ds.backgroundColor));
8555
+ }
8464
8556
 
8465
8557
  /** This is a chartJS plugin that will draw the values of each data next to the point/bar/pie slice */
8466
8558
  const chartShowValuesPlugin = {
@@ -8799,8 +8891,8 @@ let ScorecardChart$1 = class ScorecardChart extends AbstractChart {
8799
8891
  this.baselineMode = definition.baselineMode;
8800
8892
  this.baselineDescr = definition.baselineDescr;
8801
8893
  this.background = definition.background;
8802
- this.baselineColorUp = definition.baselineColorUp;
8803
- this.baselineColorDown = definition.baselineColorDown;
8894
+ this.baselineColorUp = definition.baselineColorUp ?? DEFAULT_SCORECARD_BASELINE_COLOR_UP;
8895
+ this.baselineColorDown = definition.baselineColorDown ?? DEFAULT_SCORECARD_BASELINE_COLOR_DOWN;
8804
8896
  this.humanize = definition.humanize ?? false;
8805
8897
  }
8806
8898
  static validateChartDefinition(validator, definition) {
@@ -18654,14 +18746,6 @@ for (let category of categories) {
18654
18746
  }
18655
18747
  const notAvailableError = new NotAvailableError(_t("Array arguments to [[FUNCTION_NAME]] are of different size."));
18656
18748
  function createComputeFunction(descr, functionName) {
18657
- function runtimeCompute(...args) {
18658
- try {
18659
- return vectorizedCompute.apply(this, args);
18660
- }
18661
- catch (e) {
18662
- return handleError(e, functionName);
18663
- }
18664
- }
18665
18749
  function vectorizedCompute(...args) {
18666
18750
  let countVectorizableCol = 1;
18667
18751
  let countVectorizableRow = 1;
@@ -18702,13 +18786,13 @@ function createComputeFunction(descr, functionName) {
18702
18786
  }
18703
18787
  }
18704
18788
  if (!isMatrix(arg) && argDefinition.acceptMatrixOnly) {
18705
- throw new BadExpressionError(_t("Function [[FUNCTION_NAME]] expects the parameter '%s' to be reference to a cell or range.", (i + 1).toString()));
18789
+ throw new BadExpressionError(_t("Function %s expects the parameter '%s' to be reference to a cell or range.", functionName, (i + 1).toString()));
18706
18790
  }
18707
18791
  }
18708
18792
  //#endregion
18709
18793
  if (countVectorizableCol === 1 && countVectorizableRow === 1) {
18710
18794
  // either this function is not vectorized or it ends up with a 1x1 dimension
18711
- return computeFunctionToObject.apply(this, args);
18795
+ return errorHandlingCompute.apply(this, args);
18712
18796
  }
18713
18797
  const getArgOffset = (i, j) => args.map((arg, index) => {
18714
18798
  switch (vectorArgsType?.[index]) {
@@ -18726,7 +18810,7 @@ function createComputeFunction(descr, functionName) {
18726
18810
  if (col > vectorizableColLimit - 1 || row > vectorizableRowLimit - 1) {
18727
18811
  return notAvailableError;
18728
18812
  }
18729
- const singleCellComputeResult = computeFunctionToObject.apply(this, getArgOffset(col, row));
18813
+ const singleCellComputeResult = errorHandlingCompute.apply(this, getArgOffset(col, row));
18730
18814
  // In the case where the user tries to vectorize arguments of an array formula, we will get an
18731
18815
  // array for every combination of the vectorized arguments, which will lead to a 3D matrix and
18732
18816
  // we won't be able to return the values.
@@ -18741,6 +18825,14 @@ function createComputeFunction(descr, functionName) {
18741
18825
  : singleCellComputeResult;
18742
18826
  });
18743
18827
  }
18828
+ function errorHandlingCompute(...args) {
18829
+ try {
18830
+ return computeFunctionToObject.apply(this, args);
18831
+ }
18832
+ catch (e) {
18833
+ return handleError(e, functionName);
18834
+ }
18835
+ }
18744
18836
  function computeFunctionToObject(...args) {
18745
18837
  const result = descr.compute.apply(this, args);
18746
18838
  if (!isMatrix(result)) {
@@ -18756,7 +18848,7 @@ function createComputeFunction(descr, functionName) {
18756
18848
  }
18757
18849
  return matrixMap(result, (row) => ({ value: row }));
18758
18850
  }
18759
- return runtimeCompute;
18851
+ return vectorizedCompute;
18760
18852
  }
18761
18853
  function handleError(e, functionName) {
18762
18854
  // the error could be an user error (instance of EvaluationError)
@@ -27100,23 +27192,13 @@ function createBarChartRuntime(chart, getters) {
27100
27192
  }),
27101
27193
  };
27102
27194
  config.options.indexAxis = chart.horizontal ? "y" : "x";
27103
- const formatCallback = (value) => {
27104
- value = Number(value);
27105
- if (isNaN(value))
27106
- return value;
27107
- const { locale, format } = localeFormat;
27108
- return formatValue(value, {
27109
- locale,
27110
- format: !format && Math.abs(value) >= 1000 ? "#,##" : format,
27111
- });
27112
- };
27113
27195
  config.options.scales = {};
27114
27196
  const labelsAxis = { ticks: { padding: 5, color: fontColor } };
27115
27197
  const valuesAxis = {
27116
27198
  beginAtZero: true, // the origin of the y axis is always zero
27117
27199
  ticks: {
27118
27200
  color: fontColor,
27119
- callback: formatCallback,
27201
+ callback: formatTickValue(localeFormat),
27120
27202
  },
27121
27203
  };
27122
27204
  const xAxis = chart.horizontal ? valuesAxis : labelsAxis;
@@ -27153,26 +27235,22 @@ function createBarChartRuntime(chart, getters) {
27153
27235
  showValues: chart.showValues,
27154
27236
  background: chart.background,
27155
27237
  horizontal: chart.horizontal,
27156
- callback: formatCallback,
27238
+ callback: formatTickValue(localeFormat),
27157
27239
  };
27158
- const colors = new ColorGenerator();
27159
- const trendDatasets = [];
27160
27240
  const definition = chart.getDefinition();
27241
+ const colors = getChartColorsGenerator(definition, dataSetsValues.length);
27242
+ const trendDatasets = [];
27161
27243
  for (const index in dataSetsValues) {
27162
27244
  const { label, data } = dataSetsValues[index];
27163
27245
  const color = colors.next();
27164
27246
  const dataset = {
27165
27247
  label,
27166
27248
  data,
27167
- borderColor: color,
27249
+ borderColor: BORDER_CHART_COLOR,
27250
+ borderWidth: 1,
27168
27251
  backgroundColor: color,
27169
27252
  };
27170
27253
  config.data.datasets.push(dataset);
27171
- if (definition.dataSets?.[index]?.backgroundColor) {
27172
- const color = definition.dataSets[index].backgroundColor;
27173
- dataset.backgroundColor = color;
27174
- dataset.borderColor = color;
27175
- }
27176
27254
  if (definition.dataSets?.[index]?.label) {
27177
27255
  const label = definition.dataSets[index].label;
27178
27256
  dataset.label = label;
@@ -27515,21 +27593,11 @@ function createLineOrScatterChartRuntime(chart, getters) {
27515
27593
  config.options.scales = {
27516
27594
  x: xAxis,
27517
27595
  };
27518
- const formatCallback = (value) => {
27519
- value = Number(value);
27520
- if (isNaN(value))
27521
- return value;
27522
- const { locale, format } = options;
27523
- return formatValue(value, {
27524
- locale,
27525
- format: !format && Math.abs(value) >= 1000 ? "#,##" : format,
27526
- });
27527
- };
27528
27596
  const yAxis = {
27529
27597
  beginAtZero: true, // the origin of the y axis is always zero
27530
27598
  ticks: {
27531
27599
  color: fontColor,
27532
- callback: formatCallback,
27600
+ callback: formatTickValue(options),
27533
27601
  },
27534
27602
  };
27535
27603
  const { useLeftAxis, useRightAxis } = getDefinedAxis(chart.getDefinition());
@@ -27560,7 +27628,7 @@ function createLineOrScatterChartRuntime(chart, getters) {
27560
27628
  config.options.plugins.chartShowValuesPlugin = {
27561
27629
  showValues: chart.showValues,
27562
27630
  background: chart.background,
27563
- callback: formatCallback,
27631
+ callback: formatTickValue(options),
27564
27632
  };
27565
27633
  if (chart.dataSetsHaveTitle &&
27566
27634
  dataSetsValues[0] &&
@@ -27597,8 +27665,8 @@ function createLineOrScatterChartRuntime(chart, getters) {
27597
27665
  const areaChart = "fillArea" in chart ? chart.fillArea : false;
27598
27666
  const stackedChart = "stacked" in chart ? chart.stacked : false;
27599
27667
  const cumulative = "cumulative" in chart ? chart.cumulative : false;
27600
- const colors = new ColorGenerator();
27601
27668
  const definition = chart.getDefinition();
27669
+ const colors = getChartColorsGenerator(definition, dataSetsValues.length);
27602
27670
  for (let [index, { label, data }] of dataSetsValues.entries()) {
27603
27671
  const color = colors.next();
27604
27672
  let backgroundRGBA = colorToRGBA(color);
@@ -27634,13 +27702,6 @@ function createLineOrScatterChartRuntime(chart, getters) {
27634
27702
  let maxLength = 0;
27635
27703
  const trendDatasets = [];
27636
27704
  for (const [index, dataset] of config.data.datasets.entries()) {
27637
- if (definition.dataSets?.[index]?.backgroundColor) {
27638
- const color = definition.dataSets[index].backgroundColor;
27639
- dataset.backgroundColor = color;
27640
- dataset.borderColor = color;
27641
- //@ts-ignore
27642
- dataset.pointBackgroundColor = color;
27643
- }
27644
27705
  if (definition.dataSets?.[index]?.label) {
27645
27706
  const label = definition.dataSets[index].label;
27646
27707
  dataset.label = label;
@@ -27855,30 +27916,18 @@ function createComboChartRuntime(chart, getters) {
27855
27916
  title: getChartAxisTitleRuntime(chart.axesDesign?.x),
27856
27917
  },
27857
27918
  };
27858
- const formatCallback = (format) => {
27859
- return (value) => {
27860
- value = Number(value);
27861
- if (isNaN(value))
27862
- return value;
27863
- const { locale } = localeFormat;
27864
- return formatValue(value, {
27865
- locale,
27866
- format: !format && Math.abs(value) >= 1000 ? "#,##" : format,
27867
- });
27868
- };
27869
- };
27870
27919
  const leftVerticalAxis = {
27871
27920
  beginAtZero: true, // the origin of the y axis is always zero
27872
27921
  ticks: {
27873
27922
  color: fontColor,
27874
- callback: formatCallback(mainDataSetFormat),
27923
+ callback: formatTickValue({ format: mainDataSetFormat, locale }),
27875
27924
  },
27876
27925
  };
27877
27926
  const rightVerticalAxis = {
27878
27927
  beginAtZero: true, // the origin of the y axis is always zero
27879
27928
  ticks: {
27880
27929
  color: fontColor,
27881
- callback: formatCallback(lineDataSetsFormat),
27930
+ callback: formatTickValue({ format: lineDataSetsFormat, locale }),
27882
27931
  },
27883
27932
  };
27884
27933
  const definition = chart.getDefinition();
@@ -27903,9 +27952,9 @@ function createComboChartRuntime(chart, getters) {
27903
27952
  config.options.plugins.chartShowValuesPlugin = {
27904
27953
  showValues: chart.showValues,
27905
27954
  background: chart.background,
27906
- callback: formatCallback(mainDataSetFormat),
27955
+ callback: formatTickValue({ format: mainDataSetFormat, locale }),
27907
27956
  };
27908
- const colors = new ColorGenerator();
27957
+ const colors = getChartColorsGenerator(definition, dataSetsValues.length);
27909
27958
  let maxLength = 0;
27910
27959
  const trendDatasets = [];
27911
27960
  for (let [index, { label, data }] of dataSetsValues.entries()) {
@@ -27914,8 +27963,8 @@ function createComboChartRuntime(chart, getters) {
27914
27963
  const dataset = {
27915
27964
  label: design?.label ?? label,
27916
27965
  data,
27917
- borderColor: design?.backgroundColor ?? color,
27918
- backgroundColor: design.backgroundColor ?? color,
27966
+ borderColor: color,
27967
+ backgroundColor: color,
27919
27968
  yAxisID: design?.yAxisId ?? "y",
27920
27969
  type: index === 0 ? "bar" : "line",
27921
27970
  order: -index,
@@ -28464,7 +28513,10 @@ function getPieConfiguration(chart, labels, localeFormat) {
28464
28513
  const yLabelStr = formatValue(yLabel, { format: toolTipFormat, locale });
28465
28514
  return xLabel ? `${xLabel}: ${yLabelStr} (${percentage}%)` : `${yLabelStr} (${percentage}%)`;
28466
28515
  };
28467
- config.options.plugins.chartShowValuesPlugin = { showValues: chart.showValues };
28516
+ config.options.plugins.chartShowValuesPlugin = {
28517
+ showValues: chart.showValues,
28518
+ callback: formatTickValue(localeFormat),
28519
+ };
28468
28520
  return config;
28469
28521
  }
28470
28522
  function getPieColors(colors, dataSetsValues) {
@@ -28522,13 +28574,15 @@ function createPieChartRuntime(chart, getters) {
28522
28574
  const dataSetFormat = getChartDatasetFormat(getters, chart.dataSets);
28523
28575
  const locale = getters.getLocale();
28524
28576
  const config = getPieConfiguration(chart, labels, { format: dataSetFormat, locale });
28525
- const backgroundColor = getPieColors(new ColorGenerator(), dataSetsValues);
28577
+ const dataSetsLength = Math.max(0, ...dataSetsValues.map((ds) => ds?.data?.length ?? 0));
28578
+ const backgroundColor = getPieColors(new ColorGenerator(dataSetsLength), dataSetsValues);
28526
28579
  for (const { label, data } of dataSetsValues) {
28527
28580
  const dataset = {
28528
28581
  label,
28529
28582
  data,
28530
- borderColor: "#FFFFFF",
28583
+ borderColor: BACKGROUND_CHART_COLOR,
28531
28584
  backgroundColor,
28585
+ hoverOffset: 30,
28532
28586
  };
28533
28587
  config.data.datasets.push(dataset);
28534
28588
  }
@@ -28958,14 +29012,25 @@ function getWaterfallConfiguration(chart, labels, dataSeriesLabels, localeFormat
28958
29012
  labels: {
28959
29013
  generateLabels: () => {
28960
29014
  const legendValues = [
28961
- { text: _t("Positive values"), fontColor, fillStyle: positiveColor },
28962
- { text: _t("Negative values"), fontColor, fillStyle: negativeColor },
29015
+ {
29016
+ text: _t("Positive values"),
29017
+ fontColor,
29018
+ fillStyle: positiveColor,
29019
+ strokeStyle: positiveColor,
29020
+ },
29021
+ {
29022
+ text: _t("Negative values"),
29023
+ fontColor,
29024
+ fillStyle: negativeColor,
29025
+ strokeStyle: negativeColor,
29026
+ },
28963
29027
  ];
28964
29028
  if (chart.showSubTotals || chart.firstValueAsSubtotal) {
28965
29029
  legendValues.push({
28966
29030
  text: _t("Subtotals"),
28967
29031
  fontColor,
28968
29032
  fillStyle: subTotalColor,
29033
+ strokeStyle: subTotalColor,
28969
29034
  });
28970
29035
  }
28971
29036
  return legendValues;
@@ -29032,6 +29097,7 @@ function getWaterfallConfiguration(chart, labels, dataSeriesLabels, localeFormat
29032
29097
  config.options.plugins.chartShowValuesPlugin = {
29033
29098
  showValues: chart.showValues,
29034
29099
  background: chart.background,
29100
+ callback: formatTickValue(localeFormat),
29035
29101
  };
29036
29102
  return config;
29037
29103
  }
@@ -34300,7 +34366,7 @@ class SelectionInputStore extends SpreadsheetStore {
34300
34366
  * e.g. ["A1", "Sheet2!B3", "E12"]
34301
34367
  */
34302
34368
  get selectionInputs() {
34303
- const generator = new ColorGenerator(this.colors);
34369
+ const generator = new ColorGenerator(this.ranges.length, this.colors);
34304
34370
  return this.ranges.map((input, index) => Object.assign({}, input, {
34305
34371
  color: this.hasMainFocus &&
34306
34372
  this.focusedRangeIndex !== null &&
@@ -34382,7 +34448,7 @@ class SelectionInputStore extends SpreadsheetStore {
34382
34448
  */
34383
34449
  insertNewRange(index, values) {
34384
34450
  const currentMaxId = Math.max(0, ...this.ranges.map((range) => Number(range.id)));
34385
- const colors = new ColorGenerator(this.colors);
34451
+ const colors = new ColorGenerator(this.ranges.length, this.colors);
34386
34452
  for (let i = 0; i < index; i++) {
34387
34453
  colors.next();
34388
34454
  }
@@ -35798,7 +35864,7 @@ class ChartWithAxisDesignPanel extends owl.Component {
35798
35864
  return "";
35799
35865
  }
35800
35866
  const color = dataSets[this.state.index].backgroundColor;
35801
- return color ? toHex(color) : getNthColor(this.state.index);
35867
+ return color ? toHex(color) : getNthColor(this.state.index, getColorsPalette(dataSets.length));
35802
35868
  }
35803
35869
  updateDataSeriesAxis(ev) {
35804
35870
  const axis = ev.target.value;
@@ -54711,18 +54777,23 @@ class Evaluator {
54711
54777
  this.evaluate(this.getAllCells());
54712
54778
  console.info("evaluate all cells", performance.now() - start, "ms");
54713
54779
  }
54714
- evaluateFormula(sheetId, formulaString) {
54780
+ evaluateFormulaResult(sheetId, formulaString) {
54715
54781
  const compiledFormula = compile(formulaString);
54716
54782
  const ranges = compiledFormula.dependencies.map((xc) => this.getters.getRangeFromSheetXC(sheetId, xc));
54717
54783
  this.updateCompilationParameters();
54718
- const result = updateEvalContextAndExecute({ ...compiledFormula, dependencies: ranges }, this.compilationParams, sheetId, undefined);
54719
- if (isMatrix(result)) {
54720
- return matrixMap(result, (cell) => cell.value);
54784
+ try {
54785
+ const result = updateEvalContextAndExecute({ ...compiledFormula, dependencies: ranges }, this.compilationParams, sheetId, undefined);
54786
+ if (isMatrix(result)) {
54787
+ return result;
54788
+ }
54789
+ if (result.value === null) {
54790
+ return { value: 0, format: result.format };
54791
+ }
54792
+ return result;
54721
54793
  }
54722
- if (result.value === null) {
54723
- return 0;
54794
+ catch (error) {
54795
+ return handleError(error, "");
54724
54796
  }
54725
- return result.value;
54726
54797
  }
54727
54798
  getAllCells() {
54728
54799
  const positions = this.createEmptyPositionSet();
@@ -55076,6 +55147,7 @@ function updateEvalContextAndExecute(compiledFormula, compilationParams, sheetId
55076
55147
  class EvaluationPlugin extends UIPlugin {
55077
55148
  static getters = [
55078
55149
  "evaluateFormula",
55150
+ "evaluateFormulaResult",
55079
55151
  "getCorrespondingFormulaCell",
55080
55152
  "getRangeFormattedValues",
55081
55153
  "getRangeValues",
@@ -55135,12 +55207,14 @@ class EvaluationPlugin extends UIPlugin {
55135
55207
  // Getters
55136
55208
  // ---------------------------------------------------------------------------
55137
55209
  evaluateFormula(sheetId, formulaString) {
55138
- try {
55139
- return this.evaluator.evaluateFormula(sheetId, formulaString);
55140
- }
55141
- catch (error) {
55142
- return error.value || CellErrorType.GenericError;
55210
+ const result = this.evaluateFormulaResult(sheetId, formulaString);
55211
+ if (isMatrix(result)) {
55212
+ return matrixMap(result, (cell) => cell.value);
55143
55213
  }
55214
+ return result.value;
55215
+ }
55216
+ evaluateFormulaResult(sheetId, formulaString) {
55217
+ return this.evaluator.evaluateFormulaResult(sheetId, formulaString);
55144
55218
  }
55145
55219
  /**
55146
55220
  * Return the value of each cell in the range as they are displayed in the grid.
@@ -56508,28 +56582,33 @@ class PivotUIPlugin extends UIPlugin {
56508
56582
  const pivotRow = position.row - mainPosition.row;
56509
56583
  return pivotCells[pivotCol][pivotRow];
56510
56584
  }
56511
- if (functionName === "PIVOT.HEADER" && args.at(-2) === "measure") {
56512
- const domain = pivot.parseArgsToPivotDomain(args.slice(1, -2).map((value) => ({ value })));
56585
+ try {
56586
+ if (functionName === "PIVOT.HEADER" && args.at(-2) === "measure") {
56587
+ const domain = pivot.parseArgsToPivotDomain(args.slice(1, -2).map((value) => ({ value })));
56588
+ return {
56589
+ type: "MEASURE_HEADER",
56590
+ domain,
56591
+ measure: args.at(-1)?.toString() || "",
56592
+ };
56593
+ }
56594
+ else if (functionName === "PIVOT.HEADER") {
56595
+ const domain = pivot.parseArgsToPivotDomain(args.slice(1).map((value) => ({ value })));
56596
+ return {
56597
+ type: "HEADER",
56598
+ domain,
56599
+ };
56600
+ }
56601
+ const [measure, ...domainArgs] = args.slice(1);
56602
+ const domain = pivot.parseArgsToPivotDomain(domainArgs.map((value) => ({ value })));
56513
56603
  return {
56514
- type: "MEASURE_HEADER",
56604
+ type: "VALUE",
56515
56605
  domain,
56516
- measure: args.at(-1)?.toString() || "",
56606
+ measure: measure?.toString() || "",
56517
56607
  };
56518
56608
  }
56519
- else if (functionName === "PIVOT.HEADER") {
56520
- const domain = pivot.parseArgsToPivotDomain(args.slice(1).map((value) => ({ value })));
56521
- return {
56522
- type: "HEADER",
56523
- domain,
56524
- };
56609
+ catch (_) {
56610
+ return EMPTY_PIVOT_CELL;
56525
56611
  }
56526
- const [measure, ...domainArgs] = args.slice(1);
56527
- const domain = pivot.parseArgsToPivotDomain(domainArgs.map((value) => ({ value })));
56528
- return {
56529
- type: "VALUE",
56530
- domain,
56531
- measure: measure?.toString() || "",
56532
- };
56533
56612
  }
56534
56613
  getPivot(pivotId) {
56535
56614
  return this.pivots[pivotId];
@@ -58397,6 +58476,7 @@ class FormatPlugin extends UIPlugin {
58397
58476
  * evaluated and updated with the number type.
58398
58477
  */
58399
58478
  setDecimal(sheetId, zones, step) {
58479
+ const positionsByFormat = {};
58400
58480
  // Find the each cell with a number value and get the format
58401
58481
  for (const zone of recomputeZones(zones)) {
58402
58482
  for (const position of positions(zone)) {
@@ -58406,15 +58486,20 @@ class FormatPlugin extends UIPlugin {
58406
58486
  // of the format
58407
58487
  this.getters.getLocale();
58408
58488
  const newFormat = changeDecimalPlaces(numberFormat, step);
58409
- // Apply the new format on the whole zone
58410
- this.dispatch("SET_FORMATTING", {
58411
- sheetId,
58412
- target: [positionToZone(position)],
58413
- format: newFormat,
58414
- });
58489
+ positionsByFormat[newFormat] = positionsByFormat[newFormat] || [];
58490
+ positionsByFormat[newFormat].push(position);
58415
58491
  }
58416
58492
  }
58417
58493
  }
58494
+ // consolidate all positions with the same format in bigger zones
58495
+ for (const newFormat in positionsByFormat) {
58496
+ const zones = recomputeZones(positionsByFormat[newFormat].map((position) => positionToZone(position)));
58497
+ this.dispatch("SET_FORMATTING", {
58498
+ sheetId,
58499
+ format: newFormat,
58500
+ target: zones,
58501
+ });
58502
+ }
58418
58503
  }
58419
58504
  /**
58420
58505
  * Take a range of cells and return the format of the first cell containing a
@@ -66680,7 +66765,7 @@ function addBarChart(chart) {
66680
66765
  // overlap and gapWitdh seems to be by default at -20 and 20 in chart.js.
66681
66766
  // See https://www.chartjs.org/docs/latest/charts/bar.html and https://www.chartjs.org/docs/latest/charts/bar.html#barpercentage-vs-categorypercentage
66682
66767
  const dataSetsColors = chart.dataSets.map((ds) => ds.backgroundColor ?? "");
66683
- const colors = new ColorGenerator(dataSetsColors);
66768
+ const colors = new ColorGenerator(chart.dataSets.length, dataSetsColors);
66684
66769
  const leftDataSetsNodes = [];
66685
66770
  const rightDataSetsNodes = [];
66686
66771
  for (const [dsIndex, dataset] of Object.entries(chart.dataSets)) {
@@ -66755,7 +66840,7 @@ function addComboChart(chart) {
66755
66840
  // See https://www.chartjs.org/docs/latest/charts/bar.html and https://www.chartjs.org/docs/latest/charts/bar.html#barpercentage-vs-categorypercentage
66756
66841
  const dataSets = chart.dataSets;
66757
66842
  const dataSetsColors = dataSets.map((ds) => ds.backgroundColor ?? "");
66758
- const colors = new ColorGenerator(dataSetsColors);
66843
+ const colors = new ColorGenerator(dataSets.length, dataSetsColors);
66759
66844
  let dataSet = dataSets[0];
66760
66845
  const firstColor = toXlsxHexColor(colors.next());
66761
66846
  const useRightAxisForBarSerie = dataSet.rightYAxis ?? false;
@@ -66863,7 +66948,7 @@ function addComboChart(chart) {
66863
66948
  }
66864
66949
  function addLineChart(chart) {
66865
66950
  const dataSetsColors = chart.dataSets.map((ds) => ds.backgroundColor ?? "");
66866
- const colors = new ColorGenerator(dataSetsColors);
66951
+ const colors = new ColorGenerator(chart.dataSets.length, dataSetsColors);
66867
66952
  const leftDataSetsNodes = [];
66868
66953
  const rightDataSetsNodes = [];
66869
66954
  for (const [dsIndex, dataset] of Object.entries(chart.dataSets)) {
@@ -66934,7 +67019,7 @@ function addLineChart(chart) {
66934
67019
  }
66935
67020
  function addScatterChart(chart) {
66936
67021
  const dataSetsColors = chart.dataSets.map((ds) => ds.backgroundColor ?? "");
66937
- const colors = new ColorGenerator(dataSetsColors);
67022
+ const colors = new ColorGenerator(chart.dataSets.length, dataSetsColors);
66938
67023
  const leftDataSetsNodes = [];
66939
67024
  const rightDataSetsNodes = [];
66940
67025
  for (const [dsIndex, dataset] of Object.entries(chart.dataSets)) {
@@ -67005,8 +67090,8 @@ function addScatterChart(chart) {
67005
67090
  : ""}`;
67006
67091
  }
67007
67092
  function addDoughnutChart(chart, chartSheetIndex, data, { holeSize } = { holeSize: 50 }) {
67008
- const colors = new ColorGenerator();
67009
67093
  const maxLength = largeMax(chart.dataSets.map((ds) => getRangeSize(ds.range, chartSheetIndex, data)));
67094
+ const colors = new ColorGenerator(maxLength);
67010
67095
  const doughnutColors = range(0, maxLength).map(() => toXlsxHexColor(colors.next()));
67011
67096
  const dataSetsNodes = [];
67012
67097
  for (const [dsIndex, dataset] of Object.entries(chart.dataSets).reverse()) {
@@ -68988,6 +69073,9 @@ const helpers = {
68988
69073
  getDefaultChartJsRuntime,
68989
69074
  chartFontColor,
68990
69075
  getChartAxisTitleRuntime,
69076
+ getChartAxisType,
69077
+ getTrendDatasetForBarChart,
69078
+ getTrendDatasetForLineChart,
68991
69079
  getFillingMode,
68992
69080
  rgbaToHex,
68993
69081
  colorToRGBA,
@@ -69022,6 +69110,7 @@ const helpers = {
69022
69110
  UNDO_REDO_PIVOT_COMMANDS,
69023
69111
  createPivotFormula,
69024
69112
  areDomainArgsFieldsValid,
69113
+ splitReference,
69025
69114
  };
69026
69115
  const links = {
69027
69116
  isMarkdownLink,
@@ -69104,6 +69193,7 @@ const constants = {
69104
69193
  HIGHLIGHT_COLOR,
69105
69194
  PIVOT_TABLE_CONFIG,
69106
69195
  ChartTerms,
69196
+ TREND_LINE_XAXIS_ID,
69107
69197
  };
69108
69198
 
69109
69199
  exports.AbstractCellClipboardHandler = AbstractCellClipboardHandler;
@@ -69152,6 +69242,6 @@ exports.tokenColors = tokenColors;
69152
69242
  exports.tokenize = tokenize;
69153
69243
 
69154
69244
 
69155
- __info__.version = "17.5.0-alpha.4";
69156
- __info__.date = "2024-08-06T12:05:55.642Z";
69157
- __info__.hash = "a941df3";
69245
+ __info__.version = "17.5.0-alpha.5";
69246
+ __info__.date = "2024-08-09T12:24:12.813Z";
69247
+ __info__.hash = "5d4bc65";