@adaptabletools/adaptable-cjs 22.0.0-canary.13 → 22.0.0-canary.15

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.
@@ -538,8 +538,15 @@ class AgGridColumnAdapter {
538
538
  returnValue = params.value;
539
539
  }
540
540
  if (textOptions.includes('PercentageValue')) {
541
- const clampedValue = Helper_1.default.clamp(params.value, min, max);
542
- const percentageValue = ((clampedValue - min) / (max - min)) * 100;
541
+ let percentageValue;
542
+ if (styledColumn.PercentBarStyle.ColumnComparison) {
543
+ const absMax = Math.abs(max);
544
+ percentageValue = absMax === 0 ? 0 : (Number(params.value) / absMax) * 100;
545
+ }
546
+ else {
547
+ const clampedValue = Helper_1.default.clamp(params.value, min, max);
548
+ percentageValue = ((clampedValue - min) / (max - min)) * 100;
549
+ }
543
550
  returnValue += ' ' + `(${percentageValue.toFixed(0)}%)`;
544
551
  }
545
552
  return returnValue ? returnValue : params.value;
@@ -1,8 +1,8 @@
1
- import { AdaptableAgGrid } from './AdaptableAgGrid';
2
- import { Report, ReportFormatType } from '../AdaptableState/ExportState';
3
1
  import { CsvExportParams, ExcelExportParams, ExcelStyle } from 'ag-grid-enterprise';
4
2
  import { CustomExportParams, ExportDestinationType, ExportResultData } from '../AdaptableOptions/ExportOptions';
3
+ import { Report, ReportFormatType } from '../AdaptableState/ExportState';
5
4
  import { Layout } from '../AdaptableState/LayoutState';
5
+ import { AdaptableAgGrid } from './AdaptableAgGrid';
6
6
  export interface ExportConfig {
7
7
  report: Report;
8
8
  format: ReportFormatType;
@@ -2,15 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AgGridExportAdapter = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const ModuleConstants_1 = require("../Utilities/Constants/ModuleConstants");
6
- const waitForTimeout_1 = require("../Utilities/waitForTimeout");
7
- const StyleHelper_1 = require("../Utilities/Helpers/StyleHelper");
8
- const FormatHelper_1 = tslib_1.__importStar(require("../Utilities/Helpers/FormatHelper"));
9
5
  const tinycolor2_1 = tslib_1.__importDefault(require("tinycolor2"));
10
- const StringExtensions_1 = tslib_1.__importDefault(require("../Utilities/Extensions/StringExtensions"));
11
- const Uuid_1 = require("../AdaptableState/Uuid");
12
6
  const udsv_1 = require("udsv");
7
+ const Uuid_1 = require("../AdaptableState/Uuid");
13
8
  const GeneralConstants_1 = require("../Utilities/Constants/GeneralConstants");
9
+ const ModuleConstants_1 = require("../Utilities/Constants/ModuleConstants");
10
+ const StringExtensions_1 = tslib_1.__importDefault(require("../Utilities/Extensions/StringExtensions"));
11
+ const FormatHelper_1 = tslib_1.__importStar(require("../Utilities/Helpers/FormatHelper"));
12
+ const StyleHelper_1 = require("../Utilities/Helpers/StyleHelper");
13
+ const waitForTimeout_1 = require("../Utilities/waitForTimeout");
14
14
  class AgGridExportAdapter {
15
15
  _adaptableInstance;
16
16
  /**
@@ -91,6 +91,7 @@ class AgGridExportAdapter {
91
91
  this.patchExcelStyles(exportContext);
92
92
  excelStylesWerePatched = true;
93
93
  }
94
+ // see #export_data_synchronously
94
95
  // 1. easiest case, we download the file using AG Grid
95
96
  // these methods will automatically handle the file download
96
97
  if (exportContext.destination === 'Download' && exportContext.isExcelReport) {
@@ -25,10 +25,22 @@ const getPercentBarRendererForColumn = (styledColumn, abColumn, api) => {
25
25
  }
26
26
  return;
27
27
  }
28
- const clampedValue = (0, clamp_1.default)(value, min, max);
29
- const percentageValue = ((clampedValue - min) / (max - min)) * 100;
30
- let cellBackColor;
31
28
  const percentBarStyle = styledColumn.PercentBarStyle;
29
+ let percentageValue;
30
+ let barWidthPercent;
31
+ if (percentBarStyle.ColumnComparison) {
32
+ // Finance convention: (difference / |base|) * 100 — signed %, use |price| when base is negative
33
+ const absMax = Math.abs(max);
34
+ percentageValue = absMax === 0 ? 0 : (Number(value) / absMax) * 100;
35
+ // Bar width uses |percentage| so 50% and -50% have the same visual width
36
+ barWidthPercent = Math.min(100, Math.abs(percentageValue));
37
+ }
38
+ else {
39
+ const clampedValue = (0, clamp_1.default)(value, min, max);
40
+ percentageValue = ((clampedValue - min) / (max - min)) * 100;
41
+ barWidthPercent = percentageValue;
42
+ }
43
+ let cellBackColor;
32
44
  if (percentBarStyle.ColumnComparison) {
33
45
  cellBackColor = percentBarStyle.ColumnComparison.Color;
34
46
  }
@@ -56,7 +68,7 @@ const getPercentBarRendererForColumn = (styledColumn, abColumn, api) => {
56
68
  barInsideEl.className = 'ab-PercentBar__barInside';
57
69
  barInsideEl.style.background = cellBackColor;
58
70
  barInsideEl.style.height = '100%';
59
- barInsideEl.style.width = `${percentageValue.toFixed(0)}%`;
71
+ barInsideEl.style.width = `${barWidthPercent.toFixed(0)}%`;
60
72
  barEl.append(barInsideEl);
61
73
  this.eGui.append(barEl);
62
74
  if (hasCellText) {
package/src/env.js CHANGED
@@ -2,6 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = {
4
4
  NEXT_PUBLIC_INFINITE_TABLE_LICENSE_KEY: "StartDate=2021-06-29|EndDate=2030-01-01|Owner=Adaptable|Type=distribution|TS=1624971462479|C=137829811,1004007071,2756196225,1839832928,3994409405,636616862" || '',
5
- PUBLISH_TIMESTAMP: 1771243592812 || Date.now(),
6
- VERSION: "22.0.0-canary.13" || '--current-version--',
5
+ PUBLISH_TIMESTAMP: 1771596821462 || Date.now(),
6
+ VERSION: "22.0.0-canary.15" || '--current-version--',
7
7
  };