@odoo/o-spreadsheet 17.4.9 → 17.4.10

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.4.9
6
- * @date 2024-10-14T07:53:51.633Z
7
- * @hash b7015b7
5
+ * @version 17.4.10
6
+ * @date 2024-10-24T08:54:56.262Z
7
+ * @hash c82d9c1
8
8
  */
9
9
 
10
10
  (function (exports, owl) {
@@ -10624,67 +10624,108 @@ stores.inject(MyMetaStore, storeInstance);
10624
10624
  ctx.save();
10625
10625
  ctx.textAlign = "center";
10626
10626
  ctx.textBaseline = "middle";
10627
- ctx.fillStyle = chartFontColor(options.background);
10628
- ctx.strokeStyle = chartFontColor(ctx.fillStyle);
10629
- chart._metasets.forEach(function (dataset) {
10630
- switch (dataset.type) {
10631
- case "doughnut":
10632
- case "pie": {
10633
- for (let i = 0; i < dataset._parsed.length; i++) {
10634
- const bar = dataset.data[i];
10635
- const { startAngle, endAngle, innerRadius, outerRadius } = bar;
10636
- const midAngle = (startAngle + endAngle) / 2;
10637
- const midRadius = (innerRadius + outerRadius) / 2;
10638
- const x = bar.x + midRadius * Math.cos(midAngle);
10639
- const y = bar.y + midRadius * Math.sin(midAngle) + 7;
10640
- ctx.fillStyle = chartFontColor(bar.options.backgroundColor);
10641
- ctx.strokeStyle = chartFontColor(ctx.fillStyle);
10642
- const value = options.callback(dataset._parsed[i]);
10643
- ctx.strokeText(value, x, y);
10644
- ctx.fillText(value, x, y);
10645
- }
10646
- break;
10647
- }
10648
- case "bar":
10649
- case "line": {
10650
- const yOffset = dataset.type === "bar" && !options.horizontal ? 0 : 3;
10651
- for (let i = 0; i < dataset._parsed.length; i++) {
10652
- const point = dataset.data[i];
10653
- const value = options.horizontal ? dataset._parsed[i].x : dataset._parsed[i].y;
10654
- const displayedValue = options.callback(value - 0);
10655
- let xPosition = 0, yPosition = 0;
10656
- if (options.horizontal) {
10657
- yPosition = point.y;
10658
- if (value < 0) {
10659
- ctx.textAlign = "right";
10660
- xPosition = point.x - yOffset;
10661
- }
10662
- else {
10663
- ctx.textAlign = "left";
10664
- xPosition = point.x + yOffset;
10665
- }
10666
- }
10667
- else {
10668
- xPosition = point.x;
10669
- if (value < 0) {
10670
- ctx.textBaseline = "top";
10671
- yPosition = point.y + yOffset;
10672
- }
10673
- else {
10674
- ctx.textBaseline = "bottom";
10675
- yPosition = point.y - yOffset;
10676
- }
10677
- }
10678
- ctx.strokeText(displayedValue, xPosition, yPosition);
10679
- ctx.fillText(displayedValue, xPosition, yPosition);
10680
- }
10681
- break;
10682
- }
10683
- }
10684
- });
10627
+ ctx.miterLimit = 1; // Avoid sharp artifacts on strokeText
10628
+ switch (chart.config.type) {
10629
+ case "pie":
10630
+ case "doughnut":
10631
+ drawPieChartValues(chart, options, ctx);
10632
+ break;
10633
+ case "bar":
10634
+ case "line":
10635
+ options.horizontal
10636
+ ? drawHorizontalBarChartValues(chart, options, ctx)
10637
+ : drawLineOrBarChartValues(chart, options, ctx);
10638
+ break;
10639
+ }
10685
10640
  ctx.restore();
10686
10641
  },
10687
10642
  };
10643
+ function drawTextWithBackground(text, x, y, ctx) {
10644
+ ctx.lineWidth = 3; // Stroke the text with a big lineWidth width to have some kind of background
10645
+ ctx.strokeText(text, x, y);
10646
+ ctx.lineWidth = 1;
10647
+ ctx.fillText(text, x, y);
10648
+ }
10649
+ function drawLineOrBarChartValues(chart, options, ctx) {
10650
+ const yMax = chart.chartArea.bottom;
10651
+ const yMin = chart.chartArea.top;
10652
+ const textsPositions = {};
10653
+ for (const dataset of chart._metasets) {
10654
+ for (let i = 0; i < dataset._parsed.length; i++) {
10655
+ const value = dataset._parsed[i].y;
10656
+ const point = dataset.data[i];
10657
+ const xPosition = point.x;
10658
+ let yPosition = 0;
10659
+ if (chart.config.type === "line") {
10660
+ yPosition = point.y - 10;
10661
+ }
10662
+ else {
10663
+ yPosition = value < 0 ? point.y - point.height / 2 : point.y + point.height / 2;
10664
+ }
10665
+ yPosition = Math.min(yPosition, yMax);
10666
+ yPosition = Math.max(yPosition, yMin);
10667
+ // Avoid overlapping texts with same X
10668
+ if (!textsPositions[xPosition]) {
10669
+ textsPositions[xPosition] = [];
10670
+ }
10671
+ for (const otherPosition of textsPositions[xPosition] || []) {
10672
+ if (Math.abs(otherPosition - yPosition) < 13) {
10673
+ yPosition = otherPosition - 13;
10674
+ }
10675
+ }
10676
+ textsPositions[xPosition].push(yPosition);
10677
+ ctx.fillStyle = point.options.backgroundColor;
10678
+ ctx.strokeStyle = options.background || "#ffffff";
10679
+ drawTextWithBackground(options.callback(value - 0), xPosition, yPosition, ctx);
10680
+ }
10681
+ }
10682
+ }
10683
+ function drawHorizontalBarChartValues(chart, options, ctx) {
10684
+ const xMax = chart.chartArea.right;
10685
+ const xMin = chart.chartArea.left;
10686
+ const textsPositions = {};
10687
+ for (const dataset of chart._metasets) {
10688
+ for (let i = 0; i < dataset._parsed.length; i++) {
10689
+ const value = dataset._parsed[i].x;
10690
+ const displayValue = options.callback(value - 0);
10691
+ const point = dataset.data[i];
10692
+ const yPosition = point.y;
10693
+ let xPosition = value < 0 ? point.x + point.width / 2 : point.x - point.width / 2;
10694
+ xPosition = Math.min(xPosition, xMax);
10695
+ xPosition = Math.max(xPosition, xMin);
10696
+ // Avoid overlapping texts with same Y
10697
+ if (!textsPositions[yPosition]) {
10698
+ textsPositions[yPosition] = [];
10699
+ }
10700
+ const textWidth = computeTextWidth(ctx, displayValue, { fontSize: 12 }, "px");
10701
+ for (const otherPosition of textsPositions[yPosition]) {
10702
+ if (Math.abs(otherPosition - xPosition) < textWidth) {
10703
+ xPosition = otherPosition + textWidth + 3;
10704
+ }
10705
+ }
10706
+ textsPositions[yPosition].push(xPosition);
10707
+ ctx.fillStyle = point.options.backgroundColor;
10708
+ ctx.strokeStyle = options.background || "#ffffff";
10709
+ drawTextWithBackground(displayValue, xPosition, yPosition, ctx);
10710
+ }
10711
+ }
10712
+ }
10713
+ function drawPieChartValues(chart, options, ctx) {
10714
+ for (const dataset of chart._metasets) {
10715
+ for (let i = 0; i < dataset._parsed.length; i++) {
10716
+ const bar = dataset.data[i];
10717
+ const { startAngle, endAngle, innerRadius, outerRadius } = bar;
10718
+ const midAngle = (startAngle + endAngle) / 2;
10719
+ const midRadius = (innerRadius + outerRadius) / 2;
10720
+ const x = bar.x + midRadius * Math.cos(midAngle);
10721
+ const y = bar.y + midRadius * Math.sin(midAngle) + 7;
10722
+ ctx.fillStyle = chartFontColor(options.background);
10723
+ ctx.strokeStyle = options.background || "#ffffff";
10724
+ const value = options.callback(dataset._parsed[i]);
10725
+ drawTextWithBackground(value, x, y, ctx);
10726
+ }
10727
+ }
10728
+ }
10688
10729
 
10689
10730
  /** This is a chartJS plugin that will draw connector lines between the bars of a Waterfall chart */
10690
10731
  const waterfallLinesPlugin = {
@@ -23414,7 +23455,7 @@ stores.inject(MyMetaStore, storeInstance);
23414
23455
  const xLabel = tooltipItem.dataset?.label || tooltipItem.label;
23415
23456
  // tooltipItem.parsed can be an object or a number for pie charts
23416
23457
  let yLabel = horizontalChart ? tooltipItem.parsed.x : tooltipItem.parsed.y;
23417
- if (!yLabel) {
23458
+ if (yLabel === undefined || yLabel === null) {
23418
23459
  yLabel = tooltipItem.parsed;
23419
23460
  }
23420
23461
  const toolTipFormat = !format && Math.abs(yLabel) >= 1000 ? "#,##" : format;
@@ -46531,7 +46572,7 @@ stores.inject(MyMetaStore, storeInstance);
46531
46572
  if (!data) {
46532
46573
  return createEmptyWorkbookData();
46533
46574
  }
46534
- console.group("Loading data");
46575
+ console.debug("### Loading data ###");
46535
46576
  const start = performance.now();
46536
46577
  if (data["[Content_Types].xml"]) {
46537
46578
  const reader = new XlsxReader(data);
@@ -46545,13 +46586,13 @@ stores.inject(MyMetaStore, storeInstance);
46545
46586
  // apply migrations, if needed
46546
46587
  if ("version" in data) {
46547
46588
  if (data.version < CURRENT_VERSION) {
46548
- console.info("Migrating data from version", data.version);
46589
+ console.debug("Migrating data from version", data.version);
46549
46590
  data = migrate(data);
46550
46591
  }
46551
46592
  }
46552
46593
  data = repairData(data);
46553
- console.info("Data loaded in", performance.now() - start, "ms");
46554
- console.groupEnd();
46594
+ console.debug("Data loaded in", performance.now() - start, "ms");
46595
+ console.debug("###");
46555
46596
  return data;
46556
46597
  }
46557
46598
  function migrate(data) {
@@ -46560,7 +46601,7 @@ stores.inject(MyMetaStore, storeInstance);
46560
46601
  for (let i = index; i < MIGRATIONS.length; i++) {
46561
46602
  data = MIGRATIONS[i].applyMigration(data);
46562
46603
  }
46563
- console.info("Data migrated in", performance.now() - start, "ms");
46604
+ console.debug("Data migrated in", performance.now() - start, "ms");
46564
46605
  return data;
46565
46606
  }
46566
46607
  const MIGRATIONS = [
@@ -54120,7 +54161,7 @@ stores.inject(MyMetaStore, storeInstance);
54120
54161
  cellsToCompute.addMany(arrayFormulasPositions);
54121
54162
  cellsToCompute.addMany(this.getCellsDependingOn(arrayFormulasPositions));
54122
54163
  this.evaluate(cellsToCompute);
54123
- console.info("evaluate Cells", performance.now() - start, "ms");
54164
+ console.debug("evaluate Cells", performance.now() - start, "ms");
54124
54165
  }
54125
54166
  getArrayFormulasImpactedByChangesOf(positions) {
54126
54167
  const impactedPositions = this.createEmptyPositionSet();
@@ -54159,7 +54200,7 @@ stores.inject(MyMetaStore, storeInstance);
54159
54200
  const start = performance.now();
54160
54201
  this.evaluatedCells = new PositionMap();
54161
54202
  this.evaluate(this.getAllCells());
54162
- console.info("evaluate all cells", performance.now() - start, "ms");
54203
+ console.debug("evaluate all cells", performance.now() - start, "ms");
54163
54204
  }
54164
54205
  evaluateFormulaResult(sheetId, formulaString) {
54165
54206
  try {
@@ -57309,7 +57350,7 @@ stores.inject(MyMetaStore, storeInstance);
57309
57350
  this.onMessageReceived(message);
57310
57351
  }
57311
57352
  this.isReplayingInitialRevisions = false;
57312
- console.info("Replayed", numberOfCommands, "commands in", performance.now() - start, "ms");
57353
+ console.debug("Replayed", numberOfCommands, "commands in", performance.now() - start, "ms");
57313
57354
  }
57314
57355
  /**
57315
57356
  * Notify the server that the user client left the collaborative session
@@ -67919,7 +67960,7 @@ stores.inject(MyMetaStore, storeInstance);
67919
67960
  coreHandlers = [];
67920
67961
  constructor(data = {}, config = {}, stateUpdateMessages = [], uuidGenerator = new UuidGenerator(), verboseImport = true) {
67921
67962
  const start = performance.now();
67922
- console.group("Model creation");
67963
+ console.debug("##### Model creation #####");
67923
67964
  super();
67924
67965
  setDefaultTranslationMethod();
67925
67966
  stateUpdateMessages = repairInitialMessages(data, stateUpdateMessages);
@@ -67991,16 +68032,16 @@ stores.inject(MyMetaStore, storeInstance);
67991
68032
  this.joinSession();
67992
68033
  if (config.snapshotRequested) {
67993
68034
  const startSnapshot = performance.now();
67994
- console.info("Snapshot requested");
68035
+ console.debug("Snapshot requested");
67995
68036
  this.session.snapshot(this.exportData());
67996
68037
  this.garbageCollectExternalResources();
67997
- console.info("Snapshot taken in", performance.now() - startSnapshot, "ms");
68038
+ console.debug("Snapshot taken in", performance.now() - startSnapshot, "ms");
67998
68039
  }
67999
68040
  // mark all models as "raw", so they will not be turned into reactive objects
68000
68041
  // by owl, since we do not rely on reactivity
68001
68042
  owl.markRaw(this);
68002
- console.info("Model created in", performance.now() - start, "ms");
68003
- console.groupEnd();
68043
+ console.debug("Model created in", performance.now() - start, "ms");
68044
+ console.debug("######");
68004
68045
  }
68005
68046
  joinSession() {
68006
68047
  this.session.join(this.config.client);
@@ -68223,7 +68264,7 @@ stores.inject(MyMetaStore, storeInstance);
68223
68264
  this.finalize();
68224
68265
  const time = performance.now() - start;
68225
68266
  if (time > 5) {
68226
- console.info(type, time, "ms");
68267
+ console.debug(type, time, "ms");
68227
68268
  }
68228
68269
  });
68229
68270
  this.session.save(command, commands, changes);
@@ -68609,9 +68650,9 @@ stores.inject(MyMetaStore, storeInstance);
68609
68650
  exports.tokenize = tokenize;
68610
68651
 
68611
68652
 
68612
- __info__.version = "17.4.9";
68613
- __info__.date = "2024-10-14T07:53:51.633Z";
68614
- __info__.hash = "b7015b7";
68653
+ __info__.version = "17.4.10";
68654
+ __info__.date = "2024-10-24T08:54:56.262Z";
68655
+ __info__.hash = "c82d9c1";
68615
68656
 
68616
68657
 
68617
68658
  })(this.o_spreadsheet = this.o_spreadsheet || {}, owl);