@adaptabletools/adaptable 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.
@@ -533,8 +533,15 @@ export class AgGridColumnAdapter {
533
533
  returnValue = params.value;
534
534
  }
535
535
  if (textOptions.includes('PercentageValue')) {
536
- const clampedValue = Helper.clamp(params.value, min, max);
537
- const percentageValue = ((clampedValue - min) / (max - min)) * 100;
536
+ let percentageValue;
537
+ if (styledColumn.PercentBarStyle.ColumnComparison) {
538
+ const absMax = Math.abs(max);
539
+ percentageValue = absMax === 0 ? 0 : (Number(params.value) / absMax) * 100;
540
+ }
541
+ else {
542
+ const clampedValue = Helper.clamp(params.value, min, max);
543
+ percentageValue = ((clampedValue - min) / (max - min)) * 100;
544
+ }
538
545
  returnValue += ' ' + `(${percentageValue.toFixed(0)}%)`;
539
546
  }
540
547
  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;
@@ -1,12 +1,12 @@
1
- import { ExportModuleId } from '../Utilities/Constants/ModuleConstants';
2
- import { waitForTimeout } from '../Utilities/waitForTimeout';
3
- import { convertCSSAbsoluteFontSizeToPt, getVariableColor, sanitizeStyle, } from '../Utilities/Helpers/StyleHelper';
4
- import FormatHelper, { DateFormatter } from '../Utilities/Helpers/FormatHelper';
5
1
  import tinycolor from 'tinycolor2';
6
- import StringExtensions from '../Utilities/Extensions/StringExtensions';
7
- import { createUuid } from '../AdaptableState/Uuid';
8
2
  import { inferSchema, initParser } from 'udsv';
3
+ import { createUuid } from '../AdaptableState/Uuid';
9
4
  import { AG_GRID_GROUPED_COLUMN, AG_GRID_SELECTION_COLUMN, } from '../Utilities/Constants/GeneralConstants';
5
+ import { ExportModuleId } from '../Utilities/Constants/ModuleConstants';
6
+ import StringExtensions from '../Utilities/Extensions/StringExtensions';
7
+ import FormatHelper, { DateFormatter } from '../Utilities/Helpers/FormatHelper';
8
+ import { convertCSSAbsoluteFontSizeToPt, getVariableColor, sanitizeStyle, } from '../Utilities/Helpers/StyleHelper';
9
+ import { waitForTimeout } from '../Utilities/waitForTimeout';
10
10
  export class AgGridExportAdapter {
11
11
  _adaptableInstance;
12
12
  /**
@@ -87,6 +87,7 @@ export class AgGridExportAdapter {
87
87
  this.patchExcelStyles(exportContext);
88
88
  excelStylesWerePatched = true;
89
89
  }
90
+ // see #export_data_synchronously
90
91
  // 1. easiest case, we download the file using AG Grid
91
92
  // these methods will automatically handle the file download
92
93
  if (exportContext.destination === 'Download' && exportContext.isExcelReport) {
@@ -21,10 +21,22 @@ export const getPercentBarRendererForColumn = (styledColumn, abColumn, api) => {
21
21
  }
22
22
  return;
23
23
  }
24
- const clampedValue = clamp(value, min, max);
25
- const percentageValue = ((clampedValue - min) / (max - min)) * 100;
26
- let cellBackColor;
27
24
  const percentBarStyle = styledColumn.PercentBarStyle;
25
+ let percentageValue;
26
+ let barWidthPercent;
27
+ if (percentBarStyle.ColumnComparison) {
28
+ // Finance convention: (difference / |base|) * 100 — signed %, use |price| when base is negative
29
+ const absMax = Math.abs(max);
30
+ percentageValue = absMax === 0 ? 0 : (Number(value) / absMax) * 100;
31
+ // Bar width uses |percentage| so 50% and -50% have the same visual width
32
+ barWidthPercent = Math.min(100, Math.abs(percentageValue));
33
+ }
34
+ else {
35
+ const clampedValue = clamp(value, min, max);
36
+ percentageValue = ((clampedValue - min) / (max - min)) * 100;
37
+ barWidthPercent = percentageValue;
38
+ }
39
+ let cellBackColor;
28
40
  if (percentBarStyle.ColumnComparison) {
29
41
  cellBackColor = percentBarStyle.ColumnComparison.Color;
30
42
  }
@@ -52,7 +64,7 @@ export const getPercentBarRendererForColumn = (styledColumn, abColumn, api) => {
52
64
  barInsideEl.className = 'ab-PercentBar__barInside';
53
65
  barInsideEl.style.background = cellBackColor;
54
66
  barInsideEl.style.height = '100%';
55
- barInsideEl.style.width = `${percentageValue.toFixed(0)}%`;
67
+ barInsideEl.style.width = `${barWidthPercent.toFixed(0)}%`;
56
68
  barEl.append(barInsideEl);
57
69
  this.eGui.append(barEl);
58
70
  if (hasCellText) {
package/src/env.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export default {
2
2
  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" || '',
3
- PUBLISH_TIMESTAMP: 1771243557027 || Date.now(),
4
- VERSION: "22.0.0-canary.13" || '--current-version--',
3
+ PUBLISH_TIMESTAMP: 1771596783510 || Date.now(),
4
+ VERSION: "22.0.0-canary.15" || '--current-version--',
5
5
  };