Repository navigation
Expand file tree
/
Copy pathvc_dashboard.js
More file actions
261 lines (218 loc) · 11.3 KB
/
Copy pathvc_dashboard.js
File metadata and controls
261 lines (218 loc) · 11.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
document.addEventListener("DOMContentLoaded", async function () {
const Charting = MindFusion.Charting;
const Controls = Charting.Controls;
const Collections = MindFusion.Common.Collections;
const Drawing = MindFusion.Drawing;
const Dashboards = MindFusion.Dashboards;
const DataViews = MindFusion.DataViews;
const Scheduling = MindFusion.Scheduling;
// 1. Initialize Mock Data Source
const vcSource = new VCMockDataSource('vc-data');
const data = await vcSource.load();
// 2. Render Top 8 KPI Cards with dynamic update capability
const kpiContainer = document.getElementById("kpi-container");
function renderKpis(portfolioSubset, isAll) {
let kpiDefs;
if (isAll) {
kpiDefs = [
{ title: "Closed amount", value: "$38.12M", change: "+13.76%", class: "dark gain" },
{ title: "Win rate", value: "10.11%", change: "-25.32%", class: "positive" },
{ title: "Won deals", value: "9", change: "-30.77%", class: "positive" },
{ title: "Avg days to close", value: "73.89", change: "+63.08%", class: "dark gain" },
{ title: "Pipeline value", value: "$94.5M", change: "-1.75%", class: "dark negative" },
{ title: "Open deals", value: "225", change: "-11.07%", class: "positive" },
{ title: "Projected amount", value: "$48.2M", change: "+8.71%", class: "positive" },
{ title: "Avg open deal age", value: "31.10", change: "-64.83%", class: "dark gain" }
];
} else {
const totalInvested = portfolioSubset.reduce((sum, c) => sum + c.invested, 0);
const totalValuation = portfolioSubset.reduce((sum, c) => sum + c.valuation, 0);
const dealsCount = portfolioSubset.length;
const avgMoic = dealsCount > 0 ? (portfolioSubset.reduce((sum, c) => sum + c.moic, 0) / dealsCount).toFixed(1) : 0;
const avgDays = (60 + dealsCount * 4.5).toFixed(1);
kpiDefs = [
{ title: "Closed amount", value: "$" + (totalInvested / 1000000).toFixed(2) + "M", change: "+18.2%", class: "dark gain" },
{ title: "Portfolio MOIC", value: avgMoic + "x", change: "+0.4x", class: "positive" },
{ title: "Won deals", value: dealsCount.toString(), change: "Active", class: "positive" },
{ title: "Avg days to close", value: avgDays.toString(), change: "-12.4%", class: "dark gain" },
{ title: "Hold Valuation", value: "$" + (totalValuation / 1000000).toFixed(1) + "M", change: "+24.5%", class: "dark gain" },
{ title: "Active Deals", value: dealsCount.toString(), change: "Filtered", class: "positive" },
{ title: "Projected exits", value: "$" + ((totalValuation * 0.45) / 1000000).toFixed(1) + "M", change: "+15.0%", class: "positive" },
{ title: "Avg deal age", value: "28.40", change: "-14.2%", class: "dark gain" }
];
}
kpiContainer.innerHTML = "";
kpiDefs.forEach(k => {
const box = document.createElement("div");
box.className = "kpi-box";
box.innerHTML = `
<div class="kpi-title">${k.title}</div>
<div class="kpi-bottom">
<div class="kpi-value ${k.class.includes('dark') ? 'dark' : ''}">${k.value}</div>
<div class="kpi-change ${k.class.includes('gain') ? 'gain' : (k.change.startsWith('+') ? 'gain' : 'negative')}">${k.change}</div>
</div>
`;
kpiContainer.appendChild(box);
});
}
renderKpis(data.portfolio, true);
// 3. Render Trend Line Chart (Dual Series)
const chartCanvas = document.getElementById("trendChartCanvas");
const chart = new Controls.LineChart(chartCanvas);
chart.title = "";
chart.showLegend = false;
chart.lineType = Charting.LineType.Polyline;
// Apply clean modern light styling matching the image
chart.theme.gridColor1 = new Drawing.Color("#ffffff");
chart.theme.gridColor2 = new Drawing.Color("#ffffff");
chart.theme.gridLineColor = new Drawing.Color("#e2e8f0");
chart.theme.axisStroke = new Drawing.Brush("#94a3b8");
chart.theme.axisLabelsBrush = new Drawing.Brush("#64748b");
const stroke1 = new Drawing.Brush("#0284c7");
const stroke2 = new Drawing.Brush("#38bdf8");
chart.theme.seriesStrokes = new Collections.List([
new Collections.List([stroke1]),
new Collections.List([stroke2])
]);
chart.theme.commonSeriesStrokeThickness = 2.5;
chart.gridType = Charting.GridType.Horizontal;
chart.showXCoordinates = false;
const months = ["Nov 2025", "Jan 2026", "Mar 2026", "May 2026", "Jul 2026", "Sep 2026", "Nov 2026"];
function renderChart(portfolioSubset, isAll) {
const investedVals = new Collections.List();
const dealsVals = new Collections.List();
const xLabels = new Collections.List();
months.forEach((m, idx) => {
let monthInvested = 0;
let monthDeals = 0;
if (isAll) {
monthInvested = data.timeline.months[idx].invested;
monthDeals = data.timeline.months[idx].deals;
} else {
portfolioSubset.forEach(c => {
if (c.deployments && c.deployments[m] > 0) {
monthInvested += c.deployments[m];
monthDeals += 1;
}
});
}
investedVals.add(monthInvested);
dealsVals.add(monthDeals * 5); // Scaled for dual visibility
xLabels.add(m);
});
const series1 = new Charting.Series2D(new Collections.List([0, 1, 2, 3, 4, 5, 6]), investedVals, xLabels);
series1.title = "Capital Deployed ($M)";
series1.supportedLabels = Charting.LabelKinds.XAxisLabel;
const series2 = new Charting.Series2D(new Collections.List([0, 1, 2, 3, 4, 5, 6]), dealsVals, null);
series2.title = "Deals Closed";
series2.supportedLabels = Charting.LabelKinds.None;
chart.series = new Collections.ObservableCollection([series1, series2]);
chart.draw();
}
renderChart(data.portfolio, true);
// 4. Render Portfolio Grid
const gridContainer = document.getElementById("portfolio-grid-container");
const grid = new DataViews.Grid(gridContainer);
grid.theme = "generic";
const tableData = data.portfolio.map(p => ({
company: p.company,
round: p.round,
sector: p.sector,
invested: new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', maximumFractionDigits: 0 }).format(p.invested),
valuation: new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', maximumFractionDigits: 0 }).format(p.valuation),
moic: p.moic + "x",
partner: p.partner,
status: p.status
}));
const columns = [];
const col1 = new DataViews.GridColumn("company");
col1.dataType = DataViews.StringType;
col1.caption = "Company";
columns.push(col1);
const col2 = new DataViews.GridColumn("round");
col2.dataType = DataViews.StringType;
col2.caption = "Round";
columns.push(col2);
const col3 = new DataViews.GridColumn("sector");
col3.dataType = DataViews.StringType;
col3.caption = "Sector";
columns.push(col3);
const col4 = new DataViews.GridColumn("invested");
col4.dataType = DataViews.StringType;
col4.caption = "Invested";
columns.push(col4);
const col5 = new DataViews.GridColumn("valuation");
col5.dataType = DataViews.StringType;
col5.caption = "Valuation";
columns.push(col5);
const col6 = new DataViews.GridColumn("moic");
col6.dataType = DataViews.StringType;
col6.caption = "MOIC";
columns.push(col6);
const col7 = new DataViews.GridColumn("partner");
col7.dataType = DataViews.StringType;
col7.caption = "Lead Partner";
columns.push(col7);
grid.model = new DataViews.ArrayModel(tableData, columns, "company");
grid.render();
// 5. Sidebar Filter Integration (Filtering Grid, Chart, and KPIs)
const sectorFilter = document.getElementById("sectorFilter");
const stageFilter = document.getElementById("stageFilter");
const partnerFilter = document.getElementById("partnerFilter");
function applyFilters() {
const selectedSector = sectorFilter.value;
const selectedStage = stageFilter.value;
const selectedPartner = partnerFilter.value;
const isAll = (selectedSector === "All" && selectedStage === "All" && selectedPartner === "All");
// A. Filter DataViews Grid using native grid.filter API
grid.filter = function (row, model) {
const item = data.portfolio[row];
if (!item) return true;
if (selectedSector !== "All" && item.sector !== selectedSector) return false;
if (selectedStage !== "All" && item.round !== selectedStage) return false;
if (selectedPartner !== "All" && item.partner !== selectedPartner) return false;
return true;
};
// B. Filter matching portfolio items
const filtered = data.portfolio.filter(item => {
if (selectedSector !== "All" && item.sector !== selectedSector) return false;
if (selectedStage !== "All" && item.round !== selectedStage) return false;
if (selectedPartner !== "All" && item.partner !== selectedPartner) return false;
return true;
});
// C. Update Trend Line Chart
renderChart(filtered, isAll);
// D. Update Top 8 KPI Cards
renderKpis(filtered, isAll);
}
sectorFilter.addEventListener("change", applyFilters);
stageFilter.addEventListener("change", applyFilters);
partnerFilter.addEventListener("change", applyFilters);
// 6. Render Sidebar MindFusion Calendar
const calendarEl = document.getElementById("calendar-view");
const calendar = new Scheduling.Calendar(calendarEl);
calendar.currentView = Scheduling.CalendarView.List;
calendar.theme = "generic";
// Span exactly 1 day per view: fits 100% width, no horizontal scrollbar, navigation arrows visible
calendar.listSettings.cellUnits = Scheduling.TimeUnit.Day;
calendar.listSettings.numberOfCells = 1;
calendar.listSettings.visibleCells = 1;
const now = new Date();
calendar.date = new Scheduling.DateTime(now);
// Add VC meetings/events relative to current date so they appear immediately
const scheduleEvents = [
{ subject: "NeuralGrid Series B Board Meeting", hour: 10, minute: 0, duration: 90, dayOffset: 0 },
{ subject: "QuantumPay Due Diligence Sync", hour: 14, minute: 0, duration: 60, dayOffset: 0 },
{ subject: "Pitch: Autonomous Mobility AI", hour: 11, minute: 30, duration: 45, dayOffset: 1 },
{ subject: "Investment Committee Final Vote", hour: 15, minute: 0, duration: 120, dayOffset: 2 }
];
scheduleEvents.forEach(ev => {
const item = new Scheduling.Item();
item.subject = ev.subject;
const d = new Date(now.getFullYear(), now.getMonth(), now.getDate() + ev.dayOffset, ev.hour, ev.minute);
item.startTime = new Scheduling.DateTime(d);
item.endTime = new Scheduling.DateTime(new Date(d.getTime() + ev.duration * 60000));
calendar.schedule.items.add(item);
});
calendar.render();
});