Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions projects/finance-grid/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
FilteringLogic,
IgrCellTemplateContext,
IgrColumn,
IgrColumnPipeArgs,
IgrFilteringExpressionsTree,
IgrGrid,
IgrGridToolbar,
Expand All @@ -30,6 +31,7 @@ function FinanceGrid() {
const [financeData, setFinanceData] = useState([]);
const gridRef = useRef<IgrGrid>(null);
const intervalRef = useRef<ReturnType<typeof setInterval> | null>(null);

useEffect(() => {
registerIconFromText("trending_up", TRENDING_UP, "material");
registerIconFromText("trending_down", TRENDING_DOWN, "material");
Expand All @@ -51,6 +53,10 @@ function FinanceGrid() {
return `${import.meta.env.BASE_URL}companies/${val.split(" ")[0]}.png`;
};

const currencyDigitsFormat: IgrColumnPipeArgs = {
digitsInfo: '1.2-2'
};

const assetTemplate = (ctx: IgrCellTemplateContext) => {
return (
<div className="assets-container">
Expand Down Expand Up @@ -155,7 +161,6 @@ function FinanceGrid() {
<>
<IgrGrid
primaryKey="id"
rowSelection="multiple"
data={financeData}
ref={gridRef}
isLoading={!financeData.length}
Expand All @@ -181,6 +186,7 @@ function FinanceGrid() {
dataType="string"
header="Symbol"
sortable={true}
minWidth="68px"
width="7%"
></IgrColumn>
<IgrColumn
Expand All @@ -189,33 +195,40 @@ function FinanceGrid() {
header="Asset"
sortable={true}
bodyTemplate={assetTemplate}
minWidth="100px"
width="15%"
></IgrColumn>
<IgrColumn
field="positions"
dataType="number"
header="Position"
sortable={true}
minWidth="80px"
width="6%"
></IgrColumn>
<IgrColumn
field="value.boughtPrice"
dataType="currency"
header="Average Cost/Share"
sortable={true}
pipeArgs={currencyDigitsFormat}
minWidth="100px"
width="10%"
></IgrColumn>
<IgrColumn
field="value.currentPrice"
dataType="currency"
header="Last Price"
sortable={true}
pipeArgs={currencyDigitsFormat}
minWidth="80px"
width="7%"
></IgrColumn>
<IgrColumn
header="Daily Change %"
field="dailyPercentageChange"
sortable={true}
minWidth="85px"
width="10%"
cellClasses={profitLossValueClasses}
dataType="percent"
Expand All @@ -226,6 +239,8 @@ function FinanceGrid() {
field="marketValue"
sortable={true}
dataType="currency"
pipeArgs={currencyDigitsFormat}
minWidth="100px"
width="5%"
></IgrColumn>
<IgrColumn
Expand All @@ -236,6 +251,7 @@ function FinanceGrid() {
bodyTemplate={profitLossValueTemplate}
cellClasses={profitLossValueClasses}
width="10%"
minWidth="90px"
></IgrColumn>
<IgrColumn
field="profitLossPercentage"
Expand All @@ -245,21 +261,23 @@ function FinanceGrid() {
cellClasses={profitLossValueClasses}
bodyTemplate={dailyChangePercentageTemplate}
width="10%"
minWidth="98px"
></IgrColumn>
<IgrColumn
header="Allocation"
sortable={true}
field="allocation"
datatype="percent"
dataType="percent"
width="10%"
minWidth="100px"
bodyTemplate={allocationTemplate}
></IgrColumn>
<IgrColumn
field="holdingPeriod"
header="Holding Period"
sortable={true}
bodyTemplate={holdingPeriodTemplate}
width="8%"
minWidth="50px"
></IgrColumn>
</IgrGrid>
</>
Expand Down
Loading