@finos/legend-lego 2.0.194 → 2.0.195
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.
- package/lib/index.css +2 -2
- package/lib/index.css.map +1 -1
- package/lib/legend-ai/LegendAITypes.d.ts +0 -33
- package/lib/legend-ai/LegendAITypes.d.ts.map +1 -1
- package/lib/legend-ai/LegendAITypes.js +1 -39
- package/lib/legend-ai/LegendAITypes.js.map +1 -1
- package/lib/legend-ai/LegendAI_LegendApplicationPlugin_Extension.d.ts +1 -96
- package/lib/legend-ai/LegendAI_LegendApplicationPlugin_Extension.d.ts.map +1 -1
- package/lib/legend-ai/LegendAI_LegendApplicationPlugin_Extension.js +0 -56
- package/lib/legend-ai/LegendAI_LegendApplicationPlugin_Extension.js.map +1 -1
- package/lib/legend-ai/__test-utils__/LegendAITestUtils.d.ts.map +1 -1
- package/lib/legend-ai/__test-utils__/LegendAITestUtils.js +0 -6
- package/lib/legend-ai/__test-utils__/LegendAITestUtils.js.map +1 -1
- package/lib/legend-ai/components/LegendAIChat.d.ts +1 -2
- package/lib/legend-ai/components/LegendAIChat.d.ts.map +1 -1
- package/lib/legend-ai/components/LegendAIChat.js +10 -14
- package/lib/legend-ai/components/LegendAIChat.js.map +1 -1
- package/lib/legend-ai/index.d.ts +2 -5
- package/lib/legend-ai/index.d.ts.map +1 -1
- package/lib/legend-ai/index.js +2 -5
- package/lib/legend-ai/index.js.map +1 -1
- package/lib/legend-ai/stores/LegendAIChatState.d.ts +5 -12
- package/lib/legend-ai/stores/LegendAIChatState.d.ts.map +1 -1
- package/lib/legend-ai/stores/LegendAIChatState.js +69 -604
- package/lib/legend-ai/stores/LegendAIChatState.js.map +1 -1
- package/package.json +5 -5
- package/src/legend-ai/LegendAITypes.ts +1 -51
- package/src/legend-ai/LegendAI_LegendApplicationPlugin_Extension.ts +0 -169
- package/src/legend-ai/__test-utils__/LegendAITestUtils.ts +0 -9
- package/src/legend-ai/components/LegendAIChat.tsx +26 -74
- package/src/legend-ai/index.ts +0 -18
- package/src/legend-ai/stores/LegendAIChatState.ts +128 -1039
- package/tsconfig.json +0 -3
- package/lib/legend-ai/components/LegendAIAnalysisPanel.d.ts +0 -24
- package/lib/legend-ai/components/LegendAIAnalysisPanel.d.ts.map +0 -1
- package/lib/legend-ai/components/LegendAIAnalysisPanel.js +0 -35
- package/lib/legend-ai/components/LegendAIAnalysisPanel.js.map +0 -1
- package/lib/legend-ai/components/LegendAIAnalysisUtils.d.ts +0 -23
- package/lib/legend-ai/components/LegendAIAnalysisUtils.d.ts.map +0 -1
- package/lib/legend-ai/components/LegendAIAnalysisUtils.js +0 -168
- package/lib/legend-ai/components/LegendAIAnalysisUtils.js.map +0 -1
- package/lib/legend-ai/components/LegendAICharts.d.ts +0 -25
- package/lib/legend-ai/components/LegendAICharts.d.ts.map +0 -1
- package/lib/legend-ai/components/LegendAICharts.js +0 -70
- package/lib/legend-ai/components/LegendAICharts.js.map +0 -1
- package/src/legend-ai/components/LegendAIAnalysisPanel.tsx +0 -102
- package/src/legend-ai/components/LegendAIAnalysisUtils.ts +0 -226
- package/src/legend-ai/components/LegendAICharts.tsx +0 -166
package/tsconfig.json
CHANGED
|
@@ -57,7 +57,6 @@
|
|
|
57
57
|
"./src/legend-ai/LegendAI_LegendApplicationPlugin_Extension.ts",
|
|
58
58
|
"./src/legend-ai/index.ts",
|
|
59
59
|
"./src/legend-ai/__test-utils__/LegendAITestUtils.ts",
|
|
60
|
-
"./src/legend-ai/components/LegendAIAnalysisUtils.ts",
|
|
61
60
|
"./src/legend-ai/stores/LegendAIChatState.ts",
|
|
62
61
|
"./src/model-documentation/ModelDocumentationAnalysis.ts",
|
|
63
62
|
"./src/model-documentation/index.ts",
|
|
@@ -73,8 +72,6 @@
|
|
|
73
72
|
"./src/data-grid/DataGrid.tsx",
|
|
74
73
|
"./src/graph-editor/ElementIconUtils.tsx",
|
|
75
74
|
"./src/graph-editor/PackageableElementOption.tsx",
|
|
76
|
-
"./src/legend-ai/components/LegendAIAnalysisPanel.tsx",
|
|
77
|
-
"./src/legend-ai/components/LegendAICharts.tsx",
|
|
78
75
|
"./src/legend-ai/components/LegendAIChat.tsx",
|
|
79
76
|
"./src/legend-ai/components/LegendAIErrorBoundary.tsx",
|
|
80
77
|
"./src/legend-ai/components/LegendAIResultGrid.tsx",
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2026-present, Goldman Sachs
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import type { LegendAIGridData } from '../LegendAITypes.js';
|
|
17
|
-
export declare const LegendAIAnalysisPanel: (props: {
|
|
18
|
-
gridData: LegendAIGridData;
|
|
19
|
-
summary: string;
|
|
20
|
-
SummaryRenderer: React.ComponentType<{
|
|
21
|
-
value: string;
|
|
22
|
-
}>;
|
|
23
|
-
}) => React.ReactNode;
|
|
24
|
-
//# sourceMappingURL=LegendAIAnalysisPanel.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LegendAIAnalysisPanel.d.ts","sourceRoot":"","sources":["../../../src/legend-ai/components/LegendAIAnalysisPanel.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAS5D,eAAO,MAAM,qBAAqB,GAAI,OAAO;IAC3C,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,KAAK,CAAC,aAAa,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACzD,KAAG,KAAK,CAAC,SAsET,CAAC"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) 2026-present, Goldman Sachs
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
import { useMemo } from 'react';
|
|
18
|
-
import { LegendAIChartType } from '../LegendAI_LegendApplicationPlugin_Extension.js';
|
|
19
|
-
import { computeKeyMetrics, computeChartData, inferChartType, findNumericColumnName, } from './LegendAIAnalysisUtils.js';
|
|
20
|
-
import { LegendAIBarChart, LegendAIDonutChart } from './LegendAICharts.js';
|
|
21
|
-
export const LegendAIAnalysisPanel = (props) => {
|
|
22
|
-
const { gridData, summary, SummaryRenderer } = props;
|
|
23
|
-
const metrics = useMemo(() => computeKeyMetrics(gridData), [gridData]);
|
|
24
|
-
const chartType = useMemo(() => inferChartType(gridData), [gridData]);
|
|
25
|
-
const chartData = useMemo(() => chartType === LegendAIChartType.NONE ? [] : computeChartData(gridData), [gridData, chartType]);
|
|
26
|
-
const numericColName = useMemo(() => findNumericColumnName(gridData), [gridData]);
|
|
27
|
-
const donutTitleProp = useMemo(() => numericColName === undefined
|
|
28
|
-
? {}
|
|
29
|
-
: { title: `${numericColName} Distribution` }, [numericColName]);
|
|
30
|
-
const barTitleProp = useMemo(() => numericColName === undefined
|
|
31
|
-
? {}
|
|
32
|
-
: { title: `Top ${chartData.length} by ${numericColName}` }, [numericColName, chartData.length]);
|
|
33
|
-
return (_jsxs("div", { className: "legend-ai-analysis", children: [metrics.length > 0 && (_jsx("div", { className: "legend-ai-analysis__metrics", children: metrics.map((m) => (_jsxs("div", { className: "legend-ai-analysis__metric-card", children: [_jsx("span", { className: "legend-ai-analysis__metric-value", children: m.value }), _jsx("span", { className: "legend-ai-analysis__metric-label", children: m.label }), m.detail !== undefined && (_jsx("span", { className: "legend-ai-analysis__metric-detail", children: m.detail }))] }, m.label))) })), chartData.length > 0 && (_jsx("div", { className: "legend-ai-analysis__chart-section", children: chartType === LegendAIChartType.PIE ? (_jsx(LegendAIDonutChart, { data: chartData, ...donutTitleProp })) : (_jsx(LegendAIBarChart, { data: chartData, ...barTitleProp })) })), _jsx("div", { className: "legend-ai-analysis__narrative", children: _jsx(SummaryRenderer, { value: summary }) })] }));
|
|
34
|
-
};
|
|
35
|
-
//# sourceMappingURL=LegendAIAnalysisPanel.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LegendAIAnalysisPanel.js","sourceRoot":"","sources":["../../../src/legend-ai/components/LegendAIAnalysisPanel.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kDAAkD,CAAC;AAErF,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,qBAAqB,GACtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE3E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S,EAAC,6BAA6B,YACzC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAClB,eAAmB,SAAS,EAAC,iCAAiC,aAC5D,eAAM,SAAS,EAAC,kCAAkC,YAC/C,CAAC,CAAC,KAAK,GACH,EACP,eAAM,SAAS,EAAC,kCAAkC,YAC/C,CAAC,CAAC,KAAK,GACH,EACN,CAAC,CAAC,MAAM,KAAK,SAAS,IAAI,CACzB,eAAM,SAAS,EAAC,mCAAmC,YAChD,CAAC,CAAC,MAAM,GACJ,CACR,KAXO,CAAC,CAAC,KAAK,CAYX,CACP,CAAC,GACE,CACP,EAEA,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,CACvB,cAAK,SAAS,EAAC,mCAAmC,YAC/C,SAAS,KAAK,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,CACrC,KAAC,kBAAkB,IAAC,IAAI,EAAE,SAAS,KAAM,cAAc,GAAI,CAC5D,CAAC,CAAC,CAAC,CACF,KAAC,gBAAgB,IAAC,IAAI,EAAE,SAAS,KAAM,YAAY,GAAI,CACxD,GACG,CACP,EAED,cAAK,SAAS,EAAC,+BAA+B,YAC5C,KAAC,eAAe,IAAC,KAAK,EAAE,OAAO,GAAI,GAC/B,IACF,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2026-present, Goldman Sachs
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { type LegendAIKeyMetric, type LegendAIChartDataPoint, LegendAIChartType } from '../LegendAI_LegendApplicationPlugin_Extension.js';
|
|
17
|
-
import type { LegendAIGridData } from '../LegendAITypes.js';
|
|
18
|
-
export declare function computeKeyMetrics(gridData: LegendAIGridData): LegendAIKeyMetric[];
|
|
19
|
-
export declare function inferChartType(gridData: LegendAIGridData): LegendAIChartType;
|
|
20
|
-
export declare function computeChartData(gridData: LegendAIGridData): LegendAIChartDataPoint[];
|
|
21
|
-
export declare function computeTopItems(gridData: LegendAIGridData): LegendAIChartDataPoint[];
|
|
22
|
-
export declare function findNumericColumnName(gridData: LegendAIGridData): string | undefined;
|
|
23
|
-
//# sourceMappingURL=LegendAIAnalysisUtils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LegendAIAnalysisUtils.d.ts","sourceRoot":"","sources":["../../../src/legend-ai/components/LegendAIAnalysisUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,iBAAiB,EAClB,MAAM,kDAAkD,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AA4F5D,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,gBAAgB,GACzB,iBAAiB,EAAE,CA4BrB;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,gBAAgB,GAAG,iBAAiB,CAqB5E;AAED,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,gBAAgB,GACzB,sBAAsB,EAAE,CAmC1B;AAED,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,gBAAgB,GACzB,sBAAsB,EAAE,CAE1B;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,gBAAgB,GACzB,MAAM,GAAG,SAAS,CAUpB"}
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2026-present, Goldman Sachs
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { LegendAIChartType, } from '../LegendAI_LegendApplicationPlugin_Extension.js';
|
|
17
|
-
import { isNonNullable, isNumber, isString } from '@finos/legend-shared';
|
|
18
|
-
const CHART_PALETTE_COUNT = 10;
|
|
19
|
-
const MAX_CHART_ITEMS = 10;
|
|
20
|
-
const TOP_N_ITEMS = 5;
|
|
21
|
-
const MAX_PROFILE_SAMPLE = 1000;
|
|
22
|
-
const MAX_KEY_METRICS = 4;
|
|
23
|
-
const MAX_METRIC_COLUMNS = 5;
|
|
24
|
-
const MAX_BAR_CHART_ROWS = 20;
|
|
25
|
-
const MAX_PIE_CHART_ROWS = 6;
|
|
26
|
-
function profileColumns(gridData) {
|
|
27
|
-
const rows = gridData.rowData.length > MAX_PROFILE_SAMPLE
|
|
28
|
-
? gridData.rowData.slice(0, MAX_PROFILE_SAMPLE)
|
|
29
|
-
: gridData.rowData;
|
|
30
|
-
return gridData.columnDefs.map((col) => {
|
|
31
|
-
const field = col.field ?? col.colId ?? '';
|
|
32
|
-
const values = rows.map((r) => r[field]).filter(isNonNullable);
|
|
33
|
-
const numericValues = values.filter(isNumber);
|
|
34
|
-
const unique = new Set(values.map(String));
|
|
35
|
-
return {
|
|
36
|
-
name: field,
|
|
37
|
-
isNumeric: numericValues.length === values.length && values.length > 0,
|
|
38
|
-
isString: values.length > 0 && values.every(isString),
|
|
39
|
-
uniqueCount: unique.size,
|
|
40
|
-
values,
|
|
41
|
-
numericValues,
|
|
42
|
-
};
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
function formatNumber(n) {
|
|
46
|
-
if (Number.isInteger(n) && Math.abs(n) < 1_000_000) {
|
|
47
|
-
return n.toLocaleString();
|
|
48
|
-
}
|
|
49
|
-
if (Math.abs(n) >= 1_000_000) {
|
|
50
|
-
return `${(n / 1_000_000).toFixed(1)}M`;
|
|
51
|
-
}
|
|
52
|
-
if (Math.abs(n) >= 1_000) {
|
|
53
|
-
return `${(n / 1_000).toFixed(1)}K`;
|
|
54
|
-
}
|
|
55
|
-
return n.toFixed(2);
|
|
56
|
-
}
|
|
57
|
-
function computeNumericMetrics(col, metrics) {
|
|
58
|
-
let sum = 0;
|
|
59
|
-
let min = Number.POSITIVE_INFINITY;
|
|
60
|
-
let max = Number.NEGATIVE_INFINITY;
|
|
61
|
-
for (const n of col.numericValues) {
|
|
62
|
-
sum += n;
|
|
63
|
-
if (n < min) {
|
|
64
|
-
min = n;
|
|
65
|
-
}
|
|
66
|
-
if (n > max) {
|
|
67
|
-
max = n;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
const avg = sum / col.numericValues.length;
|
|
71
|
-
if (col.uniqueCount > 1) {
|
|
72
|
-
metrics.push({
|
|
73
|
-
label: `Avg ${col.name}`,
|
|
74
|
-
value: formatNumber(avg),
|
|
75
|
-
...(min === max
|
|
76
|
-
? {}
|
|
77
|
-
: { detail: `${formatNumber(min)} – ${formatNumber(max)}` }),
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
if (col.uniqueCount > 2 && metrics.length < MAX_METRIC_COLUMNS) {
|
|
81
|
-
metrics.push({
|
|
82
|
-
label: `Total ${col.name}`,
|
|
83
|
-
value: formatNumber(sum),
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
export function computeKeyMetrics(gridData) {
|
|
88
|
-
const profiles = profileColumns(gridData);
|
|
89
|
-
const metrics = [];
|
|
90
|
-
const rowCount = gridData.rowData.length;
|
|
91
|
-
metrics.push({
|
|
92
|
-
label: 'Total Rows',
|
|
93
|
-
value: rowCount.toLocaleString(),
|
|
94
|
-
});
|
|
95
|
-
const numericCol = profiles.find((c) => c.isNumeric && c.numericValues.length > 0);
|
|
96
|
-
if (numericCol) {
|
|
97
|
-
computeNumericMetrics(numericCol, metrics);
|
|
98
|
-
}
|
|
99
|
-
const stringCol = profiles.find((c) => c.isString && c.uniqueCount > 1 && c.uniqueCount <= rowCount);
|
|
100
|
-
if (stringCol) {
|
|
101
|
-
metrics.push({
|
|
102
|
-
label: `Unique ${stringCol.name}`,
|
|
103
|
-
value: stringCol.uniqueCount.toLocaleString(),
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
return metrics.slice(0, MAX_KEY_METRICS);
|
|
107
|
-
}
|
|
108
|
-
export function inferChartType(gridData) {
|
|
109
|
-
const profiles = profileColumns(gridData);
|
|
110
|
-
const numericCols = profiles.filter((c) => c.isNumeric);
|
|
111
|
-
const stringCols = profiles.filter((c) => c.isString && c.uniqueCount > 1);
|
|
112
|
-
if (stringCols.length >= 1 &&
|
|
113
|
-
numericCols.length >= 1 &&
|
|
114
|
-
gridData.rowData.length <= MAX_BAR_CHART_ROWS) {
|
|
115
|
-
if (gridData.rowData.length <= MAX_PIE_CHART_ROWS) {
|
|
116
|
-
return LegendAIChartType.PIE;
|
|
117
|
-
}
|
|
118
|
-
return LegendAIChartType.BAR;
|
|
119
|
-
}
|
|
120
|
-
if (numericCols.length >= 1 && gridData.rowData.length > 1) {
|
|
121
|
-
return LegendAIChartType.BAR;
|
|
122
|
-
}
|
|
123
|
-
return LegendAIChartType.NONE;
|
|
124
|
-
}
|
|
125
|
-
export function computeChartData(gridData) {
|
|
126
|
-
const profiles = profileColumns(gridData);
|
|
127
|
-
const numericCol = profiles.find((c) => c.isNumeric);
|
|
128
|
-
const labelCol = profiles.find((c) => c.isString && c.uniqueCount > 1);
|
|
129
|
-
if (!numericCol) {
|
|
130
|
-
return [];
|
|
131
|
-
}
|
|
132
|
-
const field = numericCol.name;
|
|
133
|
-
const labelField = labelCol?.name;
|
|
134
|
-
const rows = gridData.rowData.length > MAX_PROFILE_SAMPLE
|
|
135
|
-
? gridData.rowData.slice(0, MAX_PROFILE_SAMPLE)
|
|
136
|
-
: gridData.rowData;
|
|
137
|
-
const entries = rows
|
|
138
|
-
.map((row) => {
|
|
139
|
-
const rawValue = row[field];
|
|
140
|
-
return {
|
|
141
|
-
label: labelField
|
|
142
|
-
? String(row[labelField] ?? '')
|
|
143
|
-
: String(row[gridData.columnDefs[0]?.field ?? ''] ?? ''),
|
|
144
|
-
value: typeof rawValue === 'number' ? rawValue : 0,
|
|
145
|
-
};
|
|
146
|
-
})
|
|
147
|
-
.filter((e) => e.label.length > 0)
|
|
148
|
-
.sort((a, b) => b.value - a.value)
|
|
149
|
-
.slice(0, MAX_CHART_ITEMS);
|
|
150
|
-
return entries.map((e, i) => ({
|
|
151
|
-
label: e.label,
|
|
152
|
-
value: e.value,
|
|
153
|
-
colorIndex: i % CHART_PALETTE_COUNT,
|
|
154
|
-
}));
|
|
155
|
-
}
|
|
156
|
-
export function computeTopItems(gridData) {
|
|
157
|
-
return computeChartData(gridData).slice(0, TOP_N_ITEMS);
|
|
158
|
-
}
|
|
159
|
-
export function findNumericColumnName(gridData) {
|
|
160
|
-
const profiles = profileColumns(gridData);
|
|
161
|
-
const numericCol = profiles.find((c) => c.isNumeric);
|
|
162
|
-
if (!numericCol) {
|
|
163
|
-
return undefined;
|
|
164
|
-
}
|
|
165
|
-
const colDef = gridData.columnDefs.find((c) => (c.field ?? c.colId ?? '') === numericCol.name);
|
|
166
|
-
return colDef?.headerName ?? colDef?.field;
|
|
167
|
-
}
|
|
168
|
-
//# sourceMappingUR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,CAAC;IACnB,CAAC;IACD,MAAM,MAAM,GAAG,QAAQ,CAAC,UAAU,CAAC,IAAI,CACrC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,KAAK,UAAU,CAAC,IAAI,CACtD,CAAC;IACF,OAAO,MAAM,EAAE,UAAU,IAAI,MAAM,EAAE,KAAK,CAAC;AAC7C,CAAC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2026-present, Goldman Sachs
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import type { LegendAIChartDataPoint } from '../LegendAI_LegendApplicationPlugin_Extension.js';
|
|
17
|
-
export declare const LegendAIBarChart: (props: {
|
|
18
|
-
data: LegendAIChartDataPoint[];
|
|
19
|
-
title?: string;
|
|
20
|
-
}) => React.ReactNode;
|
|
21
|
-
export declare const LegendAIDonutChart: (props: {
|
|
22
|
-
data: LegendAIChartDataPoint[];
|
|
23
|
-
title?: string;
|
|
24
|
-
}) => React.ReactNode;
|
|
25
|
-
//# sourceMappingURL=LegendAICharts.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LegendAICharts.d.ts","sourceRoot":"","sources":["../../../src/legend-ai/components/LegendAICharts.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kDAAkD,CAAC;AAgB/F,eAAO,MAAM,gBAAgB,GAAI,OAAO;IACtC,IAAI,EAAE,sBAAsB,EAAE,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,KAAG,KAAK,CAAC,SA8CT,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,OAAO;IACxC,IAAI,EAAE,sBAAsB,EAAE,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,KAAG,KAAK,CAAC,SA8ET,CAAC"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) 2026-present, Goldman Sachs
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
import { useMemo } from 'react';
|
|
18
|
-
const CHART_PALETTE_SIZE = 10;
|
|
19
|
-
const DONUT_SIZE = 160;
|
|
20
|
-
const DONUT_STROKE = 24;
|
|
21
|
-
const DONUT_RADIUS = (DONUT_SIZE - DONUT_STROKE) / 2;
|
|
22
|
-
const DONUT_CIRCUMFERENCE = 2 * Math.PI * DONUT_RADIUS;
|
|
23
|
-
function getChartColor(index) {
|
|
24
|
-
return `var(--ai-chart-color-${(index % CHART_PALETTE_SIZE) + 1})`;
|
|
25
|
-
}
|
|
26
|
-
function resolveColor(item, index) {
|
|
27
|
-
return item.color ?? getChartColor(item.colorIndex ?? index);
|
|
28
|
-
}
|
|
29
|
-
export const LegendAIBarChart = (props) => {
|
|
30
|
-
const { data, title } = props;
|
|
31
|
-
const maxValue = useMemo(() => data.reduce((m, d) => Math.max(m, d.value), 0) || 1, [data]);
|
|
32
|
-
if (data.length === 0) {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
return (_jsxs("div", { className: "legend-ai-chart legend-ai-chart--bar", children: [title !== undefined && title.length > 0 && (_jsx("div", { className: "legend-ai-chart__title", children: title })), _jsx("div", { className: "legend-ai-chart__bars", children: data.map((item, idx) => {
|
|
36
|
-
const pct = (item.value / maxValue) * 100;
|
|
37
|
-
return (_jsxs("div", { className: "legend-ai-chart__bar-row", children: [_jsx("span", { className: "legend-ai-chart__bar-label", title: item.label, children: item.label }), _jsx("div", { className: "legend-ai-chart__bar-track", children: _jsx("div", { className: "legend-ai-chart__bar-fill", style: {
|
|
38
|
-
width: `${pct}%`,
|
|
39
|
-
backgroundColor: resolveColor(item, idx),
|
|
40
|
-
animationDelay: `${idx * 60}ms`,
|
|
41
|
-
} }) }), _jsx("span", { className: "legend-ai-chart__bar-value", children: Number.isInteger(item.value)
|
|
42
|
-
? item.value.toLocaleString()
|
|
43
|
-
: item.value })] }, item.label));
|
|
44
|
-
}) })] }));
|
|
45
|
-
};
|
|
46
|
-
export const LegendAIDonutChart = (props) => {
|
|
47
|
-
const { data, title } = props;
|
|
48
|
-
const total = useMemo(() => data.reduce((s, d) => s + d.value, 0) || 1, [data]);
|
|
49
|
-
const segments = useMemo(() => {
|
|
50
|
-
let offset = 0;
|
|
51
|
-
return data.map((item) => {
|
|
52
|
-
const pct = item.value / total;
|
|
53
|
-
const dashLen = pct * DONUT_CIRCUMFERENCE;
|
|
54
|
-
const seg = {
|
|
55
|
-
...item,
|
|
56
|
-
dashLen,
|
|
57
|
-
dashOffset: -offset,
|
|
58
|
-
pct,
|
|
59
|
-
};
|
|
60
|
-
offset += dashLen;
|
|
61
|
-
return seg;
|
|
62
|
-
});
|
|
63
|
-
}, [data, total]);
|
|
64
|
-
if (data.length === 0) {
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
const center = DONUT_SIZE / 2;
|
|
68
|
-
return (_jsxs("div", { className: "legend-ai-chart legend-ai-chart--donut", children: [title !== undefined && title.length > 0 && (_jsx("div", { className: "legend-ai-chart__title", children: title })), _jsxs("div", { className: "legend-ai-chart__donut-wrapper", children: [_jsx("svg", { viewBox: `0 0 ${DONUT_SIZE} ${DONUT_SIZE}`, className: "legend-ai-chart__donut-svg", children: segments.map((seg, idx) => (_jsx("circle", { cx: center, cy: center, r: DONUT_RADIUS, fill: "none", stroke: resolveColor(seg, idx), strokeWidth: DONUT_STROKE, strokeDasharray: `${seg.dashLen} ${DONUT_CIRCUMFERENCE - seg.dashLen}`, strokeDashoffset: seg.dashOffset, className: "legend-ai-chart__donut-segment" }, seg.label))) }), _jsxs("div", { className: "legend-ai-chart__donut-center", children: [_jsx("span", { className: "legend-ai-chart__donut-total", children: total.toLocaleString() }), _jsx("span", { className: "legend-ai-chart__donut-total-label", children: "total" })] })] }), _jsx("div", { className: "legend-ai-chart__legend", children: data.map((item, idx) => (_jsxs("div", { className: "legend-ai-chart__legend-item", children: [_jsx("span", { className: "legend-ai-chart__legend-dot", style: { backgroundColor: resolveColor(item, idx) } }), _jsx("span", { className: "legend-ai-chart__legend-label", children: item.label }), _jsx("span", { className: "legend-ai-chart__legend-value", children: item.value.toLocaleString() })] }, item.label))) })] }));
|
|
69
|
-
};
|
|
70
|
-
//# sourceMappingURL=LegendAICharts.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LegendAICharts.js","sourceRoot":"","sources":["../../../src/legend-ai/components/LegendAICharts.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,OA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AAgC,IATrC,GAAG,CAAC,KAAK,CAUd,CACH,CAAC,GACE,EACN,eAAK,SAAS,EAAC,+BAA+B,aAC5C,eAAM,SAAS,EAAC,8BAA8B,YAC3C,KAAK,CAAC,cAAc,EAAE,GAClB,EACP,eAAM,SAAS,EAAC,oCAAoC,sBAAa,IAC7D,IACF,EACN,cAAK,SAAS,EAAC,yBAAyB,YACrC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,CACvB,eAAsB,SAAS,EAAC,8BAA8B,aAC5D,eACE,SAAS,EAAC,6BAA6B,EACvC,KAAK,EAAE,EAAE,eAAe,EAAE,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,GACnD,EACF,eAAM,SAAS,EAAC,+BAA+B,YAAE,IAAI,CAAC,KAAK,GAAQ,EACnE,eAAM,SAAS,EAAC,+BAA+B,YAC5C,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,GACvB,KARC,IAAI,CAAC,KAAK,CASd,CACP,CAAC,GACE,IACF,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2026-present, Goldman Sachs
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import { useMemo } from 'react';
|
|
18
|
-
import { LegendAIChartType } from '../LegendAI_LegendApplicationPlugin_Extension.js';
|
|
19
|
-
import type { LegendAIGridData } from '../LegendAITypes.js';
|
|
20
|
-
import {
|
|
21
|
-
computeKeyMetrics,
|
|
22
|
-
computeChartData,
|
|
23
|
-
inferChartType,
|
|
24
|
-
findNumericColumnName,
|
|
25
|
-
} from './LegendAIAnalysisUtils.js';
|
|
26
|
-
import { LegendAIBarChart, LegendAIDonutChart } from './LegendAICharts.js';
|
|
27
|
-
|
|
28
|
-
export const LegendAIAnalysisPanel = (props: {
|
|
29
|
-
gridData: LegendAIGridData;
|
|
30
|
-
summary: string;
|
|
31
|
-
SummaryRenderer: React.ComponentType<{ value: string }>;
|
|
32
|
-
}): React.ReactNode => {
|
|
33
|
-
const { gridData, summary, SummaryRenderer } = props;
|
|
34
|
-
|
|
35
|
-
const metrics = useMemo(() => computeKeyMetrics(gridData), [gridData]);
|
|
36
|
-
|
|
37
|
-
const chartType = useMemo(() => inferChartType(gridData), [gridData]);
|
|
38
|
-
|
|
39
|
-
const chartData = useMemo(
|
|
40
|
-
() =>
|
|
41
|
-
chartType === LegendAIChartType.NONE ? [] : computeChartData(gridData),
|
|
42
|
-
[gridData, chartType],
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
const numericColName = useMemo(
|
|
46
|
-
() => findNumericColumnName(gridData),
|
|
47
|
-
[gridData],
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
const donutTitleProp = useMemo(
|
|
51
|
-
() =>
|
|
52
|
-
numericColName === undefined
|
|
53
|
-
? {}
|
|
54
|
-
: { title: `${numericColName} Distribution` },
|
|
55
|
-
[numericColName],
|
|
56
|
-
);
|
|
57
|
-
const barTitleProp = useMemo(
|
|
58
|
-
() =>
|
|
59
|
-
numericColName === undefined
|
|
60
|
-
? {}
|
|
61
|
-
: { title: `Top ${chartData.length} by ${numericColName}` },
|
|
62
|
-
[numericColName, chartData.length],
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
return (
|
|
66
|
-
<div className="legend-ai-analysis">
|
|
67
|
-
{metrics.length > 0 && (
|
|
68
|
-
<div className="legend-ai-analysis__metrics">
|
|
69
|
-
{metrics.map((m) => (
|
|
70
|
-
<div key={m.label} className="legend-ai-analysis__metric-card">
|
|
71
|
-
<span className="legend-ai-analysis__metric-value">
|
|
72
|
-
{m.value}
|
|
73
|
-
</span>
|
|
74
|
-
<span className="legend-ai-analysis__metric-label">
|
|
75
|
-
{m.label}
|
|
76
|
-
</span>
|
|
77
|
-
{m.detail !== undefined && (
|
|
78
|
-
<span className="legend-ai-analysis__metric-detail">
|
|
79
|
-
{m.detail}
|
|
80
|
-
</span>
|
|
81
|
-
)}
|
|
82
|
-
</div>
|
|
83
|
-
))}
|
|
84
|
-
</div>
|
|
85
|
-
)}
|
|
86
|
-
|
|
87
|
-
{chartData.length > 0 && (
|
|
88
|
-
<div className="legend-ai-analysis__chart-section">
|
|
89
|
-
{chartType === LegendAIChartType.PIE ? (
|
|
90
|
-
<LegendAIDonutChart data={chartData} {...donutTitleProp} />
|
|
91
|
-
) : (
|
|
92
|
-
<LegendAIBarChart data={chartData} {...barTitleProp} />
|
|
93
|
-
)}
|
|
94
|
-
</div>
|
|
95
|
-
)}
|
|
96
|
-
|
|
97
|
-
<div className="legend-ai-analysis__narrative">
|
|
98
|
-
<SummaryRenderer value={summary} />
|
|
99
|
-
</div>
|
|
100
|
-
</div>
|
|
101
|
-
);
|
|
102
|
-
};
|