@mx-cartographer/experiences 9.4.3 → 9.4.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.
- package/CHANGELOG.md +16 -0
- package/dist/core/constants/Investments.d.ts +3 -0
- package/dist/core/constants/Investments.es.js +34 -11
- package/dist/core/constants/Investments.es.js.map +1 -1
- package/dist/core/stores/HoldingStore.d.ts +3 -0
- package/dist/core/stores/HoldingStore.es.js +39 -29
- package/dist/core/stores/HoldingStore.es.js.map +1 -1
- package/dist/core/utils/InvestmentUtil.d.ts +4 -0
- package/dist/core/utils/InvestmentUtil.es.js +71 -58
- package/dist/core/utils/InvestmentUtil.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/layout.es.js +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.es.js +20 -19
- package/dist/insights-v2/blocks/ChartBlocks/BarchartBlock/utils.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/DoubleBarChartBlock.d.ts +8 -0
- package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/DoubleBarChartBlock.es.js +24 -0
- package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/DoubleBarChartBlock.es.js.map +1 -0
- package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils.d.ts +9 -0
- package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils.es.js +43 -0
- package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/comparisonUtils.es.js.map +1 -0
- package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/index.d.ts +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/layout.es.js +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/{blocks/ChartBlocks/DoubleBarChartBlock → components/chartblocks}/ChartLegend.d.ts +1 -1
- package/dist/insights-v2/{blocks/ChartBlocks/DoubleBarChartBlock → components/chartblocks}/ChartLegend.es.js +12 -12
- package/dist/insights-v2/components/chartblocks/ChartLegend.es.js.map +1 -0
- package/dist/insights-v2/{blocks/ChartBlocks/DoubleBarChartBlock → components/chartblocks}/CustomDoubleBar.d.ts +1 -1
- package/dist/insights-v2/components/chartblocks/CustomDoubleBar.es.js.map +1 -0
- package/dist/insights-v2/components/chartblocks/DoubleBarChart.d.ts +17 -0
- package/dist/insights-v2/components/chartblocks/DoubleBarChart.es.js +118 -0
- package/dist/insights-v2/components/chartblocks/DoubleBarChart.es.js.map +1 -0
- package/dist/insights-v2/index.es.js +1 -1
- package/dist/insights-v2/mappings/blocks.es.js +1 -1
- package/dist/investments/InvestmentsWidget.es.js +100 -66
- package/dist/investments/InvestmentsWidget.es.js.map +1 -1
- package/dist/investments/components/allocation/util/createInvestementsAllocationData.es.js +50 -59
- package/dist/investments/components/allocation/util/createInvestementsAllocationData.es.js.map +1 -1
- package/package.json +8 -1
- package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/ChartLegend.es.js.map +0 -1
- package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/CustomDoubleBar.es.js.map +0 -1
- package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/DoubleBarChart.d.ts +0 -2
- package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/DoubleBarChart.es.js +0 -125
- package/dist/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/DoubleBarChart.es.js.map +0 -1
- /package/dist/insights-v2/{blocks/ChartBlocks/DoubleBarChartBlock → components/chartblocks}/CustomDoubleBar.es.js +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { formatCurrency as
|
|
2
|
-
|
|
1
|
+
import { formatCurrency as L, formatPercentage as k } from "../../../../core/utils/NumberFormatting.es.js";
|
|
2
|
+
import { ALLOCATION_KEYS as B } from "../../../../core/constants/Investments.es.js";
|
|
3
|
+
var C = {
|
|
3
4
|
allocations_cash: "#AEDCCC",
|
|
4
5
|
allocations_convertible: "#80CAD0",
|
|
5
6
|
allocations_foreign_bond: "#51B9D4",
|
|
@@ -9,95 +10,85 @@ var L = {
|
|
|
9
10
|
allocations_unknown: "#161D6A",
|
|
10
11
|
allocations_us_bond: "#254995",
|
|
11
12
|
allocations_us_stock: "#1E2D84"
|
|
12
|
-
}, y =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
], C = (e, l, c) => {
|
|
23
|
-
const i = c === void 0 ? 0 : l, t = c === void 0 ? l : c;
|
|
24
|
-
return e >= Math.min(i, t) && e < Math.max(i, t);
|
|
25
|
-
}, h = (e, l, c) => {
|
|
26
|
-
const i = [...new Set(e.map((r) => r.name.toLowerCase()))];
|
|
27
|
-
let t;
|
|
28
|
-
return i.map((r) => {
|
|
29
|
-
const _ = e.reduce((m, o) => {
|
|
30
|
-
const p = o.name;
|
|
31
|
-
return p.toLowerCase() === r ? (t = p, v(o) * o[l] / 100 + m) : m;
|
|
13
|
+
}, y = B.map((t) => ({ name: t })), V = (t, l, r) => {
|
|
14
|
+
const i = r === void 0 ? 0 : l, e = r === void 0 ? l : r;
|
|
15
|
+
return t >= Math.min(i, e) && t < Math.max(i, e);
|
|
16
|
+
}, h = (t, l, r) => {
|
|
17
|
+
const i = [...new Set(t.map((c) => c.name.toLowerCase()))];
|
|
18
|
+
let e;
|
|
19
|
+
return i.map((c) => {
|
|
20
|
+
const _ = t.reduce((m, s) => {
|
|
21
|
+
const p = s.name;
|
|
22
|
+
return p.toLowerCase() === c ? (e = p, d(s) * s[l] / 100 + m) : m;
|
|
32
23
|
}, 0);
|
|
33
24
|
return {
|
|
34
|
-
displayName:
|
|
35
|
-
name:
|
|
25
|
+
displayName: e,
|
|
26
|
+
name: e,
|
|
36
27
|
value: _,
|
|
37
|
-
percentage: _ /
|
|
28
|
+
percentage: _ / r
|
|
38
29
|
};
|
|
39
30
|
});
|
|
40
|
-
},
|
|
41
|
-
const i = Object.values(l.allocations_list),
|
|
42
|
-
let
|
|
43
|
-
const _ =
|
|
31
|
+
}, d = (t) => t.calculated_market_value ? t.calculated_market_value : t.market_value, E = (t, l, r) => {
|
|
32
|
+
const i = Object.values(l.allocations_list), e = [];
|
|
33
|
+
let c = 0;
|
|
34
|
+
const _ = new Set(t.map(({ guid: a }) => a)), m = r.filter(({ account_guid: a }) => _.has(a)).map((a) => ({
|
|
44
35
|
...a,
|
|
45
36
|
name: a.symbol || a.description,
|
|
46
|
-
gainLoss: a.cost_basis || a.cost_basis === 0 ?
|
|
47
|
-
})), { cashBalance:
|
|
37
|
+
gainLoss: a.cost_basis || a.cost_basis === 0 ? d(a) - a.cost_basis : 0
|
|
38
|
+
})), { cashBalance: s, totalAccountBalance: p } = t.reduce((a, n) => ({
|
|
48
39
|
cashBalance: a.cashBalance + (n.cash_balance || 0),
|
|
49
40
|
totalAccountBalance: a.totalAccountBalance + (n.balance || 0)
|
|
50
41
|
}), {
|
|
51
42
|
cashBalance: 0,
|
|
52
43
|
totalAccountBalance: 0
|
|
53
|
-
}), { marketValue:
|
|
54
|
-
marketValue: a.marketValue +
|
|
44
|
+
}), { marketValue: b, totalGainLoss: A } = m.reduce((a, n) => ({
|
|
45
|
+
marketValue: a.marketValue + d(n),
|
|
55
46
|
totalGainLoss: a.totalGainLoss + n.gainLoss
|
|
56
47
|
}), {
|
|
57
48
|
marketValue: 0,
|
|
58
49
|
totalGainLoss: 0
|
|
59
|
-
}), f =
|
|
50
|
+
}), f = b + s;
|
|
60
51
|
return y.forEach((a, n) => {
|
|
61
|
-
const
|
|
62
|
-
let
|
|
63
|
-
const
|
|
64
|
-
if (a.name === "allocations_cash" &&
|
|
65
|
-
|
|
52
|
+
const v = m.filter((u) => !!u[a.name]);
|
|
53
|
+
let o = v.reduce((u, g) => u + d(g) * g[a.name] / 100, 0);
|
|
54
|
+
const D = h(v, a.name, o);
|
|
55
|
+
if (a.name === "allocations_cash" && s > 0) {
|
|
56
|
+
o += s;
|
|
66
57
|
const u = {
|
|
67
58
|
displayName: l.cash_balance_display_name,
|
|
68
59
|
name: "allocations_name",
|
|
69
|
-
value:
|
|
70
|
-
percentage:
|
|
60
|
+
value: s,
|
|
61
|
+
percentage: s / f
|
|
71
62
|
};
|
|
72
|
-
|
|
63
|
+
D.push(u);
|
|
73
64
|
}
|
|
74
|
-
|
|
65
|
+
o > 0 && (e.push({
|
|
75
66
|
name: a.name,
|
|
76
67
|
displayName: i[n],
|
|
77
68
|
guid: `${a.name}-${n}`,
|
|
78
|
-
holdings:
|
|
79
|
-
percentage:
|
|
80
|
-
value:
|
|
81
|
-
color:
|
|
82
|
-
}),
|
|
69
|
+
holdings: D,
|
|
70
|
+
percentage: o / f,
|
|
71
|
+
value: o,
|
|
72
|
+
color: C[a.name]
|
|
73
|
+
}), c += o);
|
|
83
74
|
}), {
|
|
84
|
-
investmentsData:
|
|
85
|
-
donutData:
|
|
75
|
+
investmentsData: e,
|
|
76
|
+
donutData: e.map(({ displayName: a, guid: n, color: v, value: o }) => ({
|
|
86
77
|
id: n,
|
|
87
|
-
color:
|
|
78
|
+
color: v,
|
|
88
79
|
label: a,
|
|
89
|
-
value:
|
|
80
|
+
value: o / c * 100
|
|
90
81
|
})),
|
|
91
|
-
totalAmount:
|
|
92
|
-
totalGainLoss:
|
|
82
|
+
totalAmount: c,
|
|
83
|
+
totalGainLoss: A,
|
|
93
84
|
totalMarketValue: f,
|
|
94
|
-
totalGainLossPercentage:
|
|
85
|
+
totalGainLossPercentage: A / p
|
|
95
86
|
};
|
|
96
|
-
},
|
|
87
|
+
}, N = (t) => t < 1e-3 ? "< 0.1%" : k(t), S = (t) => t === 0 ? L(t, "0,0.00") : V(t, -0.01, 0.01) ? "< $0.01" : L(t, "0,0.00");
|
|
97
88
|
export {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
89
|
+
E as createInvestmentsAllocationData,
|
|
90
|
+
S as currencyDisplay,
|
|
91
|
+
N as percentageDisplay
|
|
101
92
|
};
|
|
102
93
|
|
|
103
94
|
//# sourceMappingURL=createInvestementsAllocationData.es.js.map
|
package/dist/investments/components/allocation/util/createInvestementsAllocationData.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createInvestementsAllocationData.es.js","names":[],"sources":["../../../../../src/investments/components/allocation/util/createInvestementsAllocationData.tsx"],"sourcesContent":["import { Account, Holding } from '../../../../core'\nimport { InvestmentAllocationCopy } from '../../../../core/types/localization/InvestmentsCopy'\nimport type { DonutData } from '../InvestmentsAllocationChart'\nimport { formatCurrency, formatPercentage } from '../../../../core/utils/NumberFormatting'\n\nexport interface InvestmentsAllocationData {\n name: string\n displayName: string\n guid: string\n holdings: InvestmentAllocationTotals[]\n percentage: number\n value: number\n color: string\n}\nexport interface InvestmentAllocationTotals {\n displayName: string\n name: string\n value: number\n percentage: number\n}\n\nconst allocationColors = {\n allocations_cash: '#AEDCCC',\n allocations_convertible: '#80CAD0',\n allocations_foreign_bond: '#51B9D4',\n allocations_foreign_stock: '#3DA0C9',\n allocations_other: '#3583B8',\n allocations_preferred: '#2D66A7',\n allocations_unknown: '#161D6A',\n allocations_us_bond: '#254995',\n allocations_us_stock: '#1E2D84',\n}\nconst allocationsList = [\n {\n name: 'allocations_cash',\n },\n {\n name: 'allocations_convertible',\n },\n {\n name: 'allocations_foreign_bond',\n },\n {\n name: 'allocations_foreign_stock',\n },\n {\n name: 'allocations_other',\n },\n {\n name: 'allocations_preferred',\n },\n {\n name: 'allocations_us_bond',\n },\n {\n name: 'allocations_us_stock',\n },\n {\n name: 'allocations_unknown',\n },\n]\n\nconst inRange = (n: number, start: number, end?: number) => {\n const rangeStart = end === undefined ? 0 : start\n const rangeEnd = end === undefined ? start : end\n return n >= Math.min(rangeStart, rangeEnd) && n < Math.max(rangeStart, rangeEnd)\n}\n\nconst createHoldingsData = (\n holdings: Holding[],\n allocationName: string,\n allocationValue: number,\n) => {\n const uniqueHoldings = [\n ...new Set(holdings.map((holding: Holding) => holding.name.toLowerCase())),\n ]\n let displayName: string\n const investmentAllocationTotals = uniqueHoldings.map((holdingName) => {\n // sum all the holdings with the same \"name\"\n const holdingsTotalValue = holdings.reduce((acc, hold: Holding) => {\n const name = hold.name\n\n if (name.toLowerCase() === holdingName) {\n // Since we lose the capitalization with the unique names, we take it from the last match.\n displayName = name\n return (\n (getHoldingValue(hold) * hold[allocationName as keyof typeof allocationColors]) / 100 +\n acc\n )\n }\n\n return acc\n }, 0)\n\n return {\n displayName,\n name: displayName,\n value: holdingsTotalValue,\n percentage: holdingsTotalValue / allocationValue,\n }\n })\n return investmentAllocationTotals\n}\n\nconst getHoldingValue = (holding: Holding) =>\n holding.calculated_market_value ? holding.calculated_market_value : holding.market_value\n\nexport const createInvestmentsAllocationData = (\n accounts: Account[],\n copy: InvestmentAllocationCopy,\n holdings: Holding[],\n) => {\n const allocationListDisplayNames = Object.values(copy.allocations_list)\n const investementAllocationData: InvestmentsAllocationData[] = []\n\n let totalAmount = 0\n\n const accountGuids = accounts.map(({ guid }) => guid)\n const updatedHoldings: Holding[] = holdings\n .filter(({ account_guid }) => accountGuids.includes(account_guid))\n .map((eachHolding) => {\n return {\n ...eachHolding,\n name: eachHolding.symbol || eachHolding.description,\n gainLoss:\n eachHolding.cost_basis || eachHolding.cost_basis === 0\n ? getHoldingValue(eachHolding) - eachHolding.cost_basis\n : 0,\n }\n })\n\n const { cashBalance, totalAccountBalance } = accounts.reduce(\n (sum, account) => {\n return {\n cashBalance: sum.cashBalance + (account.cash_balance || 0),\n totalAccountBalance: sum.totalAccountBalance + (account.balance || 0),\n }\n },\n { cashBalance: 0, totalAccountBalance: 0 },\n )\n const { marketValue, totalGainLoss } = updatedHoldings.reduce(\n (acc, holding) => {\n return {\n marketValue: acc.marketValue + getHoldingValue(holding),\n totalGainLoss: acc.totalGainLoss + holding.gainLoss,\n }\n },\n { marketValue: 0, totalGainLoss: 0 },\n )\n const totalMarketValue = marketValue + cashBalance\n\n allocationsList.forEach((allocation, index) => {\n const filteredHoldings = updatedHoldings.filter(\n (eachHolding) => !!eachHolding[allocation.name as keyof typeof allocationColors],\n )\n let holdingsTotal = filteredHoldings.reduce(\n (sum, holding) =>\n sum +\n (getHoldingValue(holding) * holding[allocation.name as keyof typeof allocationColors]) /\n 100,\n 0,\n )\n const investmentAllocationTotals = createHoldingsData(\n filteredHoldings,\n allocation.name,\n holdingsTotal,\n )\n if (allocation.name === 'allocations_cash' && cashBalance > 0) {\n // Updating holdingsTotal to include cash balance\n // This affects the holdingsTotal and percentage for this allocation\n holdingsTotal += cashBalance\n\n // Creating a holding item for cash balance\n const cashBalanceHolding = {\n displayName: copy.cash_balance_display_name,\n name: 'allocations_name',\n value: cashBalance,\n percentage: cashBalance / totalMarketValue,\n }\n\n investmentAllocationTotals.push(cashBalanceHolding)\n }\n\n // Shows allocation if holdingsTotal is greater than zero\n if (holdingsTotal > 0) {\n investementAllocationData.push({\n name: allocation.name,\n displayName: allocationListDisplayNames[index],\n guid: `${allocation.name}-${index}`,\n holdings: investmentAllocationTotals,\n percentage: holdingsTotal / totalMarketValue,\n value: holdingsTotal,\n color: allocationColors[allocation.name as keyof typeof allocationColors],\n })\n totalAmount += holdingsTotal\n }\n })\n const donutData: DonutData[] = investementAllocationData.map(\n ({ displayName, guid, color, value }) => ({\n id: guid,\n color: color,\n label: displayName,\n value: (value / totalAmount) * 100,\n }),\n )\n\n return {\n investmentsData: investementAllocationData,\n donutData,\n totalAmount,\n totalGainLoss,\n totalMarketValue,\n totalGainLossPercentage: totalGainLoss / totalAccountBalance,\n }\n}\n\nexport const percentageDisplay = (value: number) =>\n value < 0.001 ? '< 0.1%' : formatPercentage(value)\n\nexport const currencyDisplay = (value: number) => {\n if (value === 0) return formatCurrency(value, '0,0.00')\n return inRange(value, -0.01, 0.01) ? '< $0.01' : formatCurrency(value, '0,0.00')\n}\n"],"mappings":";AAqBA,IAAM,IAAmB;AAAA,EACvB,kBAAkB;AAAA,EAClB,yBAAyB;AAAA,EACzB,0BAA0B;AAAA,EAC1B,2BAA2B;AAAA,EAC3B,mBAAmB;AAAA,EACnB,uBAAuB;AAAA,EACvB,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EACrB,sBAAsB;AACxB,GACM,IAAkB;AAAA,EACtB,EACE,MAAM,mBACR;AAAA,EACA,EACE,MAAM,0BACR;AAAA,EACA,EACE,MAAM,2BACR;AAAA,EACA,EACE,MAAM,4BACR;AAAA,EACA,EACE,MAAM,oBACR;AAAA,EACA,EACE,MAAM,wBACR;AAAA,EACA,EACE,MAAM,sBACR;AAAA,EACA,EACE,MAAM,uBACR;AAAA,EACA,EACE,MAAM,sBACR;AACF,GAEM,IAAA,CAAW,GAAW,GAAe,MAAiB;AAC1D,QAAM,IAAa,MAAQ,SAAY,IAAI,GACrC,IAAW,MAAQ,SAAY,IAAQ;AAC7C,SAAO,KAAK,KAAK,IAAI,GAAY,CAAQ,KAAK,IAAI,KAAK,IAAI,GAAY,CAAQ;AACjF,GAEM,IAAA,CACJ,GACA,GACA,MACG;AACH,QAAM,IAAiB,CACrB,GAAG,IAAI,IAAI,EAAS,IAAA,CAAK,MAAqB,EAAQ,KAAK,YAAY,CAAC,CAAC,CAC3E;AACA,MAAI;AAyBJ,SAxBmC,EAAe,IAAA,CAAK,MAAgB;AAErE,UAAM,IAAqB,EAAS,OAAA,CAAQ,GAAK,MAAkB;AACjE,YAAM,IAAO,EAAK;AAElB,aAAI,EAAK,YAAY,MAAM,KAEzB,IAAc,GAEX,EAAgB,CAAI,IAAI,EAAK,CAAA,IAAoD,MAClF,KAIG;AAAA,IACT,GAAG,CAAC;AAEJ,WAAO;AAAA,MACL,aAAA;AAAA,MACA,MAAM;AAAA,MACN,OAAO;AAAA,MACP,YAA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AQ,EAAW,IAAA,IAC7C,KACJ,CACF;AACA,UAAM,IAA6B,EACjC,GACA,EAAW,MACX,CACF;AACA,QAAI,EAAW,SAAS,sBAAsB,IAAc,GAAG;AAG7D,MAAA,KAAiB;AAGjB,YAAM,IAAqB;AAAA,QACzB,aAAa,EAAK;AAAA,QAClB,MAAM;AAAA,QACN,OAAO;AAAA,QACP,YAAY,IAAc;AAAA,MAC5B;AAEA,MAAA,EAA2B,KAAK,CAAkB;AAAA,IACpD;AAGA,IAAI,IAAgB,MAClB,EAA0B,KAAK;AAAA,MAC7B,MAAM,EAAW;AAAA,MACjB,aAAa,EAA2B,CAAA;AAAA,MACxC,MAAM,GAAG,EAAW,IAAA,IAAQ,CAAA;AAAA,MAC5B,UAAU;AAAA,MACV,YAAY,IAAgB;AAAA,MAC5B,OAAO;AAAA,MACP,OAAO,EAAiB,EAAW,IAAA;AAAA,IACrC,CAAC,GACD,KAAe;AAAA,EAEnB,CAAC,GAUM;AAAA,IACL,iBAAiB;AAAA,IACjB,WAX6B,EAA0B,IAAA,CACtD,EAAE,aAAA,GAAa,MAAA,GAAM,OAAA,GAAO,OAAA,EAAA,OAAa;AAAA,MACxC,IAAI;AAAA,MACG,OAAA;AAAA,MACP,OAAO;AAAA,MACP,OAAQ,IAAQ,IAAe;AAAA,IACjC,EAKA;AAAA,IACA,aAAA;AAAA,IACA,eAAA;AAAA,IACA,kBAAA;AAAA,IACA,yBAAyB,IAAgB;AAAA,EAC3C;AACF,GAEa,IAAA,CAAqB,MAChC,IAAQ,OAAQ,WAAW,EAAiB,CAAK,GAEtC,IAAA,CAAmB,MAC1B,MAAU,IAAU,EAAe,GAAO,QAAQ,IAC/C,EAAQ,GAAO,OAAO,IAAI,IAAI,YAAY,EAAe,GAAO,QAAQ"}
|
|
1
|
+
{"version":3,"file":"createInvestementsAllocationData.es.js","names":[],"sources":["../../../../../src/investments/components/allocation/util/createInvestementsAllocationData.tsx"],"sourcesContent":["import { Account, Holding } from '../../../../core'\nimport { ALLOCATION_KEYS, type AllocationKey } from '../../../../core/constants/Investments'\nimport { InvestmentAllocationCopy } from '../../../../core/types/localization/InvestmentsCopy'\nimport type { DonutData } from '../InvestmentsAllocationChart'\nimport { formatCurrency, formatPercentage } from '../../../../core/utils/NumberFormatting'\n\nexport interface InvestmentsAllocationData {\n name: string\n displayName: string\n guid: string\n holdings: InvestmentAllocationTotals[]\n percentage: number\n value: number\n color: string\n}\nexport interface InvestmentAllocationTotals {\n displayName: string\n name: string\n value: number\n percentage: number\n}\n\nconst allocationColors: Record<AllocationKey, string> = {\n allocations_cash: '#AEDCCC',\n allocations_convertible: '#80CAD0',\n allocations_foreign_bond: '#51B9D4',\n allocations_foreign_stock: '#3DA0C9',\n allocations_other: '#3583B8',\n allocations_preferred: '#2D66A7',\n allocations_unknown: '#161D6A',\n allocations_us_bond: '#254995',\n allocations_us_stock: '#1E2D84',\n}\nconst allocationsList = ALLOCATION_KEYS.map((name) => ({ name }))\n\nconst inRange = (n: number, start: number, end?: number) => {\n const rangeStart = end === undefined ? 0 : start\n const rangeEnd = end === undefined ? start : end\n return n >= Math.min(rangeStart, rangeEnd) && n < Math.max(rangeStart, rangeEnd)\n}\n\nconst createHoldingsData = (\n holdings: Holding[],\n allocationName: string,\n allocationValue: number,\n) => {\n const uniqueHoldings = [\n ...new Set(holdings.map((holding: Holding) => holding.name.toLowerCase())),\n ]\n let displayName: string\n const investmentAllocationTotals = uniqueHoldings.map((holdingName) => {\n // sum all the holdings with the same \"name\"\n const holdingsTotalValue = holdings.reduce((acc, hold: Holding) => {\n const name = hold.name\n\n if (name.toLowerCase() === holdingName) {\n // Since we lose the capitalization with the unique names, we take it from the last match.\n displayName = name\n return (\n (getHoldingValue(hold) * hold[allocationName as keyof typeof allocationColors]) / 100 +\n acc\n )\n }\n\n return acc\n }, 0)\n\n return {\n displayName,\n name: displayName,\n value: holdingsTotalValue,\n percentage: holdingsTotalValue / allocationValue,\n }\n })\n return investmentAllocationTotals\n}\n\nconst getHoldingValue = (holding: Holding) =>\n holding.calculated_market_value ? holding.calculated_market_value : holding.market_value\n\nexport const createInvestmentsAllocationData = (\n accounts: Account[],\n copy: InvestmentAllocationCopy,\n holdings: Holding[],\n) => {\n const allocationListDisplayNames = Object.values(copy.allocations_list)\n const investementAllocationData: InvestmentsAllocationData[] = []\n\n let totalAmount = 0\n\n const accountGuids = new Set(accounts.map(({ guid }) => guid))\n const updatedHoldings: Holding[] = holdings\n .filter(({ account_guid }) => accountGuids.has(account_guid))\n .map((eachHolding) => {\n return {\n ...eachHolding,\n name: eachHolding.symbol || eachHolding.description,\n gainLoss:\n eachHolding.cost_basis || eachHolding.cost_basis === 0\n ? getHoldingValue(eachHolding) - eachHolding.cost_basis\n : 0,\n }\n })\n\n const { cashBalance, totalAccountBalance } = accounts.reduce(\n (sum, account) => {\n return {\n cashBalance: sum.cashBalance + (account.cash_balance || 0),\n totalAccountBalance: sum.totalAccountBalance + (account.balance || 0),\n }\n },\n { cashBalance: 0, totalAccountBalance: 0 },\n )\n const { marketValue, totalGainLoss } = updatedHoldings.reduce(\n (acc, holding) => {\n return {\n marketValue: acc.marketValue + getHoldingValue(holding),\n totalGainLoss: acc.totalGainLoss + holding.gainLoss,\n }\n },\n { marketValue: 0, totalGainLoss: 0 },\n )\n const totalMarketValue = marketValue + cashBalance\n\n allocationsList.forEach((allocation, index) => {\n const filteredHoldings = updatedHoldings.filter(\n (eachHolding) => !!eachHolding[allocation.name as keyof typeof allocationColors],\n )\n let holdingsTotal = filteredHoldings.reduce(\n (sum, holding) =>\n sum +\n (getHoldingValue(holding) * holding[allocation.name as keyof typeof allocationColors]) /\n 100,\n 0,\n )\n const investmentAllocationTotals = createHoldingsData(\n filteredHoldings,\n allocation.name,\n holdingsTotal,\n )\n if (allocation.name === 'allocations_cash' && cashBalance > 0) {\n // Updating holdingsTotal to include cash balance\n // This affects the holdingsTotal and percentage for this allocation\n holdingsTotal += cashBalance\n\n // Creating a holding item for cash balance\n const cashBalanceHolding = {\n displayName: copy.cash_balance_display_name,\n name: 'allocations_name',\n value: cashBalance,\n percentage: cashBalance / totalMarketValue,\n }\n\n investmentAllocationTotals.push(cashBalanceHolding)\n }\n\n // Shows allocation if holdingsTotal is greater than zero\n if (holdingsTotal > 0) {\n investementAllocationData.push({\n name: allocation.name,\n displayName: allocationListDisplayNames[index],\n guid: `${allocation.name}-${index}`,\n holdings: investmentAllocationTotals,\n percentage: holdingsTotal / totalMarketValue,\n value: holdingsTotal,\n color: allocationColors[allocation.name as keyof typeof allocationColors],\n })\n totalAmount += holdingsTotal\n }\n })\n const donutData: DonutData[] = investementAllocationData.map(\n ({ displayName, guid, color, value }) => ({\n id: guid,\n color: color,\n label: displayName,\n value: (value / totalAmount) * 100,\n }),\n )\n\n return {\n investmentsData: investementAllocationData,\n donutData,\n totalAmount,\n totalGainLoss,\n totalMarketValue,\n totalGainLossPercentage: totalGainLoss / totalAccountBalance,\n }\n}\n\nexport const percentageDisplay = (value: number) =>\n value < 0.001 ? '< 0.1%' : formatPercentage(value)\n\nexport const currencyDisplay = (value: number) => {\n if (value === 0) return formatCurrency(value, '0,0.00')\n return inRange(value, -0.01, 0.01) ? '< $0.01' : formatCurrency(value, '0,0.00')\n}\n"],"mappings":";;AAsBA,IAAM,IAAkD;AAAA,EACtD,kBAAkB;AAAA,EAClB,yBAAyB;AAAA,EACzB,0BAA0B;AAAA,EAC1B,2BAA2B;AAAA,EAC3B,mBAAmB;AAAA,EACnB,uBAAuB;AAAA,EACvB,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EACrB,sBAAsB;AACxB,GACM,IAAkB,EAAgB,IAAA,CAAK,OAAU,EAAE,MAAA,EAAK,EAAE,GAE1D,IAAA,CAAW,GAAW,GAAe,MAAiB;AAC1D,QAAM,IAAa,MAAQ,SAAY,IAAI,GACrC,IAAW,MAAQ,SAAY,IAAQ;AAC7C,SAAO,KAAK,KAAK,IAAI,GAAY,CAAQ,KAAK,IAAI,KAAK,IAAI,GAAY,CAAQ;AACjF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G,OAAA;AAAA,MACP,OAAO;AAAA,MACP,OAAQ,IAAQ,IAAe;AAAA,IACjC,EAKA;AAAA,IACA,aAAA;AAAA,IACA,eAAA;AAAA,IACA,kBAAA;AAAA,IACA,yBAAyB,IAAgB;AAAA,EAC3C;AACF,GAEa,IAAA,CAAqB,MAChC,IAAQ,OAAQ,WAAW,EAAiB,CAAK,GAEtC,IAAA,CAAmB,MAC1B,MAAU,IAAU,EAAe,GAAO,QAAQ,IAC/C,EAAQ,GAAO,OAAO,IAAI,IAAI,YAAY,EAAe,GAAO,QAAQ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mx-cartographer/experiences",
|
|
3
|
-
"version": "9.4.
|
|
3
|
+
"version": "9.4.5",
|
|
4
4
|
"description": "Library containing experience widgets",
|
|
5
5
|
"author": "MX",
|
|
6
6
|
"license": "MIT",
|
|
@@ -61,6 +61,10 @@
|
|
|
61
61
|
"import": "./dist/insights/index.es.js",
|
|
62
62
|
"types": "./dist/insights/index.d.ts"
|
|
63
63
|
},
|
|
64
|
+
"./insights-v2": {
|
|
65
|
+
"import": "./dist/insights-v2/index.es.js",
|
|
66
|
+
"types": "./dist/insights-v2/index.d.ts"
|
|
67
|
+
},
|
|
64
68
|
"./investments": {
|
|
65
69
|
"import": "./dist/investments/index.es.js",
|
|
66
70
|
"types": "./dist/investments/index.d.ts"
|
|
@@ -143,6 +147,9 @@
|
|
|
143
147
|
"insights": [
|
|
144
148
|
"./dist/insights/index.d.ts"
|
|
145
149
|
],
|
|
150
|
+
"insights-v2": [
|
|
151
|
+
"./dist/insights-v2/index.d.ts"
|
|
152
|
+
],
|
|
146
153
|
"investments": [
|
|
147
154
|
"./dist/investments/index.d.ts"
|
|
148
155
|
],
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ChartLegend.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/ChartLegend.tsx"],"sourcesContent":["import { Text } from '@mxenabled/mxui'\n\nimport Stack from '@mui/material/Stack'\n\nimport type { SxProps } from '@mui/material/styles'\nimport type { LegendProps } from '../../../../core/types/InsightsInstanceSlotData'\n\nexport interface LegendComponentProps {\n legendItems: LegendProps[]\n legendStyle?: SxProps\n}\n\nexport const Legend = ({ legendItems, legendStyle }: LegendComponentProps) => {\n return (\n <Stack\n sx={{\n alignItems: 'flex-start',\n flexDirection: 'row',\n gap: 24,\n justifyContent: 'flex-start',\n py: 4,\n width: '100%',\n ...legendStyle,\n }}\n >\n {legendItems.map(\n ({ color, label, formattedAmount }, index) =>\n label && (\n <Stack key={index} sx={{ alignItems: 'center', flexDirection: 'row', gap: 8 }}>\n <svg\n aria-hidden=\"true\"\n aria-labelledby={index === 0 ? 'chartLegendLabel' : label}\n fill=\"none\"\n height=\"12\"\n role=\"figure\"\n width=\"12\"\n >\n <rect fill={color} height=\"12\" rx=\"2\" width=\"12\" />\n </svg>\n <Text id={index === 0 ? 'chartLegendLabel' : label} variant=\"caption\">\n {label} {formattedAmount ? `: ${formattedAmount}` : ''}\n </Text>\n </Stack>\n ),\n )}\n </Stack>\n )\n}\n"],"mappings":";;;AAYA,IAAa,IAAA,CAAU,EAAE,aAAA,GAAa,aAAA,EAAA,MAElC,gBAAA,EAAC,GAAD;AAAA,EACE,IAAI;AAAA,IACF,YAAY;AAAA,IACZ,eAAe;AAAA,IACf,KAAK;AAAA,IACL,gBAAgB;AAAA,IAChB,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,GAAG;AAAA,EACL;AAAA,EAEC,UAAA,EAAY,IAAA,CACV,EAAE,OAAA,GAAO,OAAA,GAAO,iBAAA,EAAA,GAAmB,MAClC,KACE,gBAAA,EAAC,GAAD;AAAA,IAAmB,IAAI;AAAA,MAAE,YAAY;AAAA,MAAU,eAAe;AAAA,MAAO,KAAK;AAAA,IAAE;AAAA,IAA5E,UAAA,CACE,gBAAA,EAAC,OAAD;AAAA,MACE,eAAY;AAAA,MACZ,mBAAiB,MAAU,IAAI,qBAAqB;AAAA,MACpD,MAAK;AAAA,MACL,QAAO;AAAA,MACP,MAAK;AAAA,MACL,OAAM;AAAA,MAEN,UAAA,gBAAA,EAAC,QAAD;AAAA,QAAM,MAAM;AAAA,QAAO,QAAO;AAAA,QAAK,IAAG;AAAA,QAAI,OAAM;AAAA,MAAM,CAAA;AAAA,IAC/C,CAAA,GACL,gBAAA,EAAC,GAAD;AAAA,MAAM,IAAI,MAAU,IAAI,qBAAqB;AAAA,MAAO,SAAQ;AAAA,MAA5D,UAAA;AAAA,QACG;AAAA,QAAM;AAAA,QAAE,IAAkB,KAAK,CAAA,KAAoB;AAAA,MAChD;AAAA,IACD,CAAA,CAAA;AAAA,EAdK,GAAA,CAcL,CAEb;AACK,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CustomDoubleBar.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/CustomDoubleBar.tsx"],"sourcesContent":["import React from 'react'\nimport type { DataSet } from '../../../../core/types/InsightsInstanceSlotData'\n\ninterface BarStyleProps extends React.CSSProperties {\n x?: number\n y?: number\n}\n\ninterface CustomDoubleBarPlotMXUIProps {\n color: string\n data: DataSet[]\n series: Series\n style: BarStyleProps\n}\n\ninterface Series {\n index: number\n type: number\n}\n\nexport const CustomDoubleBarPlotMXUI = ({\n color,\n data,\n series,\n style,\n ...restProps\n}: CustomDoubleBarPlotMXUIProps) => {\n const rectRef = React.useRef<SVGRectElement>(null)\n\n React.useLayoutEffect(() => {\n const resizeObserver = new ResizeObserver(() => {\n window.requestAnimationFrame(() => {\n if (rectRef.current) {\n const { width } = rectRef.current.getBoundingClientRect()\n\n const xValue = width / 2\n const textElement = rectRef.current.querySelector('text')\n if (textElement) {\n textElement.setAttribute('transform', `translate(${xValue}, -8)`)\n }\n }\n })\n })\n\n if (rectRef.current) resizeObserver.observe(rectRef.current)\n return () => {\n if (rectRef.current) resizeObserver.unobserve(rectRef.current)\n }\n }, [])\n\n const { ariaLabelComparison, ariaLabelMain } = data[series.index]\n\n const ariaLabel = series.type === 0 ? ariaLabelMain : ariaLabelComparison\n\n const rectStyle = {\n ...style,\n transition: 'all 0.3s ease-in-out',\n }\n\n // Create path with rounded top corners (10px radius) and square bottom corners\n const pathBarWidth = (style.width as number) || 0\n const pathBarHeight = (style.height as number) || 0\n const pathX = (style.x as number) || 0\n const pathY = (style.y as number) || 0\n const radius = 4\n\n const pathData = `\n M ${pathX + radius},${pathY}\n L ${pathX + pathBarWidth - radius},${pathY}\n Q ${pathX + pathBarWidth},${pathY} ${pathX + pathBarWidth},${pathY + radius}\n L ${pathX + pathBarWidth},${pathY + pathBarHeight}\n L ${pathX},${pathY + pathBarHeight}\n L ${pathX},${pathY + radius}\n Q ${pathX},${pathY} ${pathX + radius},${pathY}\n Z\n `.trim()\n\n return (\n <g aria-label={ariaLabel}>\n <path {...restProps} d={pathData} fill={color} style={rectStyle} />\n </g>\n )\n}\n"],"mappings":";;AAoBA,IAAa,IAAA,CAA2B,EACtC,OAAA,GACA,MAAA,GACA,QAAA,GACA,OAAA,GACA,GAAG,EAAA,MAC+B;AAClC,QAAM,IAAU,EAAM,OAAuB,IAAI;AAEjD,EAAA,EAAM,gBAAA,MAAsB;AAC1B,UAAM,IAAiB,IAAI,eAAA,MAAqB;AAC9C,aAAO,sBAAA,MAA4B;AACjC,YAAI,EAAQ,SAAS;AACnB,gBAAM,EAAE,OAAA,EAAA,IAAU,EAAQ,QAAQ,sBAAsB,GAElD,IAAS,IAAQ,GACjB,IAAc,EAAQ,QAAQ,cAAc,MAAM;AACxD,UAAI,KACF,EAAY,aAAa,aAAa,aAAa,CAAA,OAAa;AAAA,QAEpE;AAAA,MACF,CAAC;AAAA,IACH,CAAC;AAED,WAAI,EAAQ,WAAS,EAAe,QAAQ,EAAQ,OAAO,GAC3D,MAAa;AACX,MAAI,EAAQ,WAAS,EAAe,UAAU,EAAQ,OAAO;AAAA,IAC/D;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,QAAM,EAAE,qBAAA,GAAqB,eAAA,EAAA,IAAkB,EAAK,EAAO,KAAA,GAErD,IAAY,EAAO,SAAS,IAAI,IAAgB,GAEhD,IAAY;AAAA,IAChB,GAAG;AAAA,IACH,YAAY;AAAA,EACd,GAGM,IAAgB,EAAM,SAAoB,GAC1C,IAAiB,EAAM,UAAqB,GAC5C,IAAS,EAAM,KAAgB,GAC/B,IAAS,EAAM,KAAgB,GAC/B,IAAS,GAET,IAAW;AAAA,QACX,IAAQ,CAAA,IAAU,CAAA;AAAA,QAClB,IAAQ,IAAe,CAAA,IAAU,CAAA;AAAA,QACjC,IAAQ,CAAA,IAAgB,CAAA,IAAS,IAAQ,CAAA,IAAgB,IAAQ,CAAA;AAAA,QACjE,IAAQ,CAAA,IAAgB,IAAQ,CAAA;AAAA,QAChC,CAAA,IAAS,IAAQ,CAAA;AAAA,QACjB,CAAA,IAAS,IAAQ,CAAA;AAAA,QACjB,CAAA,IAAS,CAAA,IAAS,IAAQ,CAAA,IAAU,CAAA;AAAA;AAAA,IAExC,KAAK;AAEP,SACE,gBAAA,EAAC,KAAD;AAAA,IAAG,cAAY;AAAA,IACb,UAAA,gBAAA,EAAC,QAAD;AAAA,MAAM,GAAI;AAAA,MAAW,GAAG;AAAA,MAAU,MAAM;AAAA,MAAO,OAAO;AAAA,IAAY,CAAA;AAAA,EACjE,CAAA;AAEP"}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { useInsightsV2Store as B } from "../../../../common/context/hooks.es.js";
|
|
2
|
-
import { EmptyBarChart as A } from "../../../components/chartblocks/EmptyBarChart.es.js";
|
|
3
|
-
import { useContainerDimensions as v } from "../../../hooks/useContainerDimensions.es.js";
|
|
4
|
-
import { CustomDoubleBarPlotMXUI as T } from "./CustomDoubleBar.es.js";
|
|
5
|
-
import { Legend as L } from "./ChartLegend.es.js";
|
|
6
|
-
import { getLayoutConfig as R } from "./layout.es.js";
|
|
7
|
-
import D from "react";
|
|
8
|
-
import K from "@mui/material/Stack";
|
|
9
|
-
import { jsx as r, jsxs as d } from "react/jsx-runtime";
|
|
10
|
-
import { useTheme as M } from "@mui/material/styles";
|
|
11
|
-
import j from "@mui/material/Box";
|
|
12
|
-
import { BarPlot as G } from "@mui/x-charts/BarChart";
|
|
13
|
-
import { ChartContainer as N } from "@mui/x-charts/ChartContainer";
|
|
14
|
-
import { ChartsXAxis as P } from "@mui/x-charts/ChartsXAxis";
|
|
15
|
-
var Y = ({ payload: { instance_slot: h, instance_slot_data: s, widget_type: p }, beatGuid: f = "" }) => {
|
|
16
|
-
const { openChartDrilldown: y } = B(), l = p === "mini", { variant: g } = h, { data_series: i, legends: x } = s, a = i.length - 1, b = 5e-3, u = 0.16, C = M(), c = R(C, g).color, m = D.useRef(null), { height: I, width: k } = v(m), w = ({ dataIndex: e, seriesId: t }) => {
|
|
17
|
-
const o = Number(t.split("-").pop());
|
|
18
|
-
y(f, {
|
|
19
|
-
chartBarIndex: e,
|
|
20
|
-
tabIndex: o
|
|
21
|
-
});
|
|
22
|
-
}, n = x?.map((e, t) => ({
|
|
23
|
-
color: c[t],
|
|
24
|
-
...e
|
|
25
|
-
}));
|
|
26
|
-
return i.length > 0 ? /* @__PURE__ */ d(K, {
|
|
27
|
-
sx: {
|
|
28
|
-
mb: 0,
|
|
29
|
-
width: "100%",
|
|
30
|
-
p: 0
|
|
31
|
-
},
|
|
32
|
-
children: [/* @__PURE__ */ r(j, {
|
|
33
|
-
ref: m,
|
|
34
|
-
sx: {
|
|
35
|
-
height: l ? 120 : 172,
|
|
36
|
-
touchAction: "pan-y",
|
|
37
|
-
width: "100%",
|
|
38
|
-
p: 0,
|
|
39
|
-
m: 0,
|
|
40
|
-
"& svg": {
|
|
41
|
-
touchAction: "pan-y",
|
|
42
|
-
userSelect: "none"
|
|
43
|
-
},
|
|
44
|
-
"& .recharts-wrapper": { touchAction: "pan-y" }
|
|
45
|
-
},
|
|
46
|
-
children: /* @__PURE__ */ d(N, {
|
|
47
|
-
colors: c,
|
|
48
|
-
dataset: i,
|
|
49
|
-
height: I,
|
|
50
|
-
margin: {
|
|
51
|
-
bottom: 16,
|
|
52
|
-
left: 24,
|
|
53
|
-
right: 24,
|
|
54
|
-
top: 0
|
|
55
|
-
},
|
|
56
|
-
series: [{
|
|
57
|
-
dataKey: "main",
|
|
58
|
-
type: "bar"
|
|
59
|
-
}, {
|
|
60
|
-
dataKey: "comparison",
|
|
61
|
-
type: "bar"
|
|
62
|
-
}],
|
|
63
|
-
width: k,
|
|
64
|
-
xAxis: [{
|
|
65
|
-
barGapRatio: b,
|
|
66
|
-
categoryGapRatio: u,
|
|
67
|
-
dataKey: "label",
|
|
68
|
-
scaleType: "band"
|
|
69
|
-
}],
|
|
70
|
-
yAxis: [{ width: 0 }],
|
|
71
|
-
children: [/* @__PURE__ */ r(P, {
|
|
72
|
-
disableTicks: !1,
|
|
73
|
-
slots: { axisTickLabel: ({ text: e, ...t }) => {
|
|
74
|
-
const o = a !== void 0 ? s.data_series[a]?.label : void 0;
|
|
75
|
-
return /* @__PURE__ */ r("text", {
|
|
76
|
-
...t,
|
|
77
|
-
style: {
|
|
78
|
-
...t.style,
|
|
79
|
-
fontWeight: o === e ? 700 : 400
|
|
80
|
-
},
|
|
81
|
-
children: e
|
|
82
|
-
});
|
|
83
|
-
} },
|
|
84
|
-
sx: { ".MuiChartsAxis-line": { stroke: "border.darker" } },
|
|
85
|
-
tickLabelStyle: {
|
|
86
|
-
fontSize: 11,
|
|
87
|
-
fill: "text.secondary",
|
|
88
|
-
fontWeight: 400
|
|
89
|
-
}
|
|
90
|
-
}), /* @__PURE__ */ r(G, {
|
|
91
|
-
onItemClick: (e, { dataIndex: t, seriesId: o }) => w({
|
|
92
|
-
dataIndex: t,
|
|
93
|
-
seriesId: o.toString()
|
|
94
|
-
}),
|
|
95
|
-
slots: { bar: (e) => {
|
|
96
|
-
const { ownerState: t, ...o } = e, S = a === void 0 || a === t.dataIndex ? t.color : `${t.color}50`;
|
|
97
|
-
return /* @__PURE__ */ r(T, {
|
|
98
|
-
...o,
|
|
99
|
-
color: S,
|
|
100
|
-
data: i,
|
|
101
|
-
series: {
|
|
102
|
-
index: t.dataIndex,
|
|
103
|
-
type: Number(t.id?.toString().split("-").pop() ?? 0)
|
|
104
|
-
},
|
|
105
|
-
style: {
|
|
106
|
-
height: e.height,
|
|
107
|
-
x: e.x,
|
|
108
|
-
y: e.y,
|
|
109
|
-
width: e.width
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
} }
|
|
113
|
-
})]
|
|
114
|
-
})
|
|
115
|
-
}), n && !l && n.length > 0 && /* @__PURE__ */ r(L, {
|
|
116
|
-
legendItems: n,
|
|
117
|
-
legendStyle: { ml: 24 }
|
|
118
|
-
})]
|
|
119
|
-
}) : /* @__PURE__ */ r(A, {});
|
|
120
|
-
};
|
|
121
|
-
export {
|
|
122
|
-
Y as DoubleBarChartBlock
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
//# sourceMappingURL=DoubleBarChart.es.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DoubleBarChart.es.js","names":[],"sources":["../../../../../src/insights-v2/blocks/ChartBlocks/DoubleBarChartBlock/DoubleBarChart.tsx"],"sourcesContent":["import React from 'react'\n\nimport Box from '@mui/material/Box'\nimport Stack from '@mui/material/Stack'\n\nimport { BarPlot } from '@mui/x-charts/BarChart'\nimport { ChartContainer } from '@mui/x-charts/ChartContainer'\nimport { ChartsXAxis } from '@mui/x-charts/ChartsXAxis'\nimport { useTheme } from '@mui/material/styles'\n\nimport { useInsightsV2Store } from '../../../../common'\nimport { useContainerDimensions } from '../../../hooks/useContainerDimensions'\nimport { BlockProps } from '../../types'\n\nimport { CustomDoubleBarPlotMXUI } from './CustomDoubleBar'\nimport { Legend } from './ChartLegend'\nimport { getLayoutConfig } from './layout'\nimport { EmptyBarChart } from '../../../components/chartblocks/EmptyBarChart'\nimport type { DataSet } from '../../../../core/types/InsightsInstanceSlotData'\nimport type { LegendProps } from '../../../../core/types/InsightsInstanceSlotData'\n\nexport const DoubleBarChartBlock = ({\n payload: { instance_slot, instance_slot_data, widget_type },\n beatGuid = '',\n}: BlockProps) => {\n const { openChartDrilldown } = useInsightsV2Store()\n const isMini = widget_type === 'mini'\n const { variant } = instance_slot\n const { data_series, legends } = instance_slot_data\n const selectedTabIndex = (data_series! as DataSet[]).length - 1\n const barGapRatio = 0.005\n const categoryGapRatio = 0.16\n\n const theme = useTheme()\n const colors = getLayoutConfig(theme, variant).color\n\n const containerRef = React.useRef<HTMLDivElement>(null)\n const { height, width } = useContainerDimensions(containerRef)\n\n const handleBarClick = ({ dataIndex, seriesId }: { dataIndex: number; seriesId: string }) => {\n const seriesType = Number(seriesId.split('-').pop())\n // chartBarIndex carries the clicked date column (same meaning as\n // BarchartBlock's chartBarIndex); tabIndex carries the clicked sub-series\n // within that column (0 = main, 1 = comparison).\n openChartDrilldown(beatGuid, {\n chartBarIndex: dataIndex,\n tabIndex: seriesType,\n })\n }\n\n const legendItems = legends?.map((legend, index) => ({\n color: colors[index],\n ...legend,\n })) as LegendProps[]\n\n //\n return (data_series as DataSet[]).length > 0 ? (\n <Stack sx={{ mb: 0, width: '100%', p: 0 }}>\n <Box\n ref={containerRef}\n sx={{\n height: isMini ? 120 : 172,\n touchAction: 'pan-y',\n width: '100%',\n p: 0,\n m: 0,\n '& svg': {\n touchAction: 'pan-y',\n userSelect: 'none',\n },\n '& .recharts-wrapper': {\n touchAction: 'pan-y',\n },\n }}\n >\n <ChartContainer\n colors={colors}\n dataset={data_series as any[]}\n height={height}\n margin={{\n bottom: 16,\n left: 24,\n right: 24,\n top: 0,\n }}\n series={[\n { dataKey: 'main', type: 'bar' },\n { dataKey: 'comparison', type: 'bar' },\n ]}\n width={width}\n xAxis={[\n {\n barGapRatio,\n categoryGapRatio,\n dataKey: 'label',\n scaleType: 'band',\n },\n ]}\n yAxis={[{ width: 0 }]}\n >\n <ChartsXAxis\n disableTicks={false}\n slots={{\n axisTickLabel: ({ text, ...restProps }) => {\n const selectedLabel =\n selectedTabIndex !== undefined\n ? (instance_slot_data.data_series as DataSet[])[selectedTabIndex]?.label\n : undefined\n return (\n <text\n {...restProps}\n style={\n {\n ...restProps.style,\n fontWeight: selectedLabel === text ? 700 : 400,\n } as React.CSSProperties\n }\n >\n {text}\n </text>\n )\n },\n }}\n sx={{\n '.MuiChartsAxis-line': {\n stroke: 'border.darker',\n },\n }}\n tickLabelStyle={{\n fontSize: 11,\n fill: 'text.secondary',\n fontWeight: 400,\n }}\n />\n <BarPlot\n onItemClick={(_, { dataIndex, seriesId }) =>\n handleBarClick({ dataIndex, seriesId: seriesId.toString() })\n }\n slots={{\n bar: (props) => {\n const { ownerState, ...defaultProps } = props\n const isSelected =\n selectedTabIndex === undefined || selectedTabIndex === ownerState.dataIndex\n const barColor = isSelected ? ownerState.color : `${ownerState.color}50`\n\n return (\n <CustomDoubleBarPlotMXUI\n {...defaultProps}\n color={barColor}\n data={data_series as DataSet[]}\n series={{\n index: ownerState.dataIndex,\n type: Number(ownerState.id?.toString().split('-').pop() ?? 0),\n }}\n style={{\n height: props.height,\n x: props.x,\n y: props.y,\n width: props.width,\n }}\n />\n )\n },\n }}\n />\n </ChartContainer>\n </Box>\n\n {legendItems && !isMini && legendItems.length > 0 && (\n <Legend legendItems={legendItems} legendStyle={{ ml: 24 }} />\n )}\n </Stack>\n ) : (\n <EmptyBarChart />\n )\n}\n"],"mappings":";;;;;;;;;;;;;;AAqBA,IAAa,IAAA,CAAuB,EAClC,SAAS,EAAE,eAAA,GAAe,oBAAA,GAAoB,aAAA,EAAA,GAC9C,UAAA,IAAW,GAAA,MACK;AAChB,QAAM,EAAE,oBAAA,EAAA,IAAuB,EAAmB,GAC5C,IAAS,MAAgB,QACzB,EAAE,SAAA,EAAA,IAAY,GACd,EAAE,aAAA,GAAa,SAAA,EAAA,IAAY,GAC3B,IAAoB,EAA2B,SA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