Repository navigation
Expand file tree
/
Copy pathbi_demo.js
More file actions
142 lines (123 loc) · 4.44 KB
/
Copy pathbi_demo.js
File metadata and controls
142 lines (123 loc) · 4.44 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
var Charting = MindFusion.Charting;
var Controls = Charting.Controls;
var Collections = MindFusion.Common.Collections;
var Drawing = MindFusion.Drawing;
var Dashboards = MindFusion.Dashboards;
var DataViews = MindFusion.DataViews;
var dash = Dashboards.DashboardView.create(document.getElementById("dashboard"));
dash.theme = "dark";
const mockSource = new MockDataSource('mock-data');
dash.dashboard.dataSources.add(mockSource);
const chartSource = new ChartDataSource('chart-data');
dash.dashboard.dataSources.add(chartSource);
// KPIs (Double-height rowSpan 2 to prevent text cut-outs)
const kpis = [
{ header: "Total Revenue", path: "sales.revenue", format: new Intl.NumberFormat("en-US", { style: "currency", currency: "USD", maximumFractionDigits: 0 }) },
{ header: "Regional Growth", path: "sales.growth", format: new Intl.NumberFormat("en-US", { style: "percent", minimumFractionDigits: 1, maximumFractionDigits: 1 }) },
{ header: "Profit Margin", path: "sales.margin", format: new Intl.NumberFormat("en-US", { style: "percent", minimumFractionDigits: 1, maximumFractionDigits: 1 }) },
{ header: "Active Projects", path: "sales.projects", format: new Intl.NumberFormat("en-US", { maximumFractionDigits: 0 }) }
];
kpis.forEach((k, i) => {
var kpi = new Dashboards.KpiWidget();
kpi.headerText = k.header;
kpi.dataSource = 'mock-data';
kpi.dataPath = k.path;
kpi.valueFormat = k.format;
dash.addWidget(kpi, i, 0, 1, 2);
});
// Branding Logo (1x2 to match KPIs)
var image = new Dashboards.ImageWidget();
image.dataSource = 'mock-data';
image.dataPath = 'branding.logo_url';
dash.addWidget(image, 5, 0, 1, 2);
// Performance Gauges (Stacked in Column 4, 1x1 each)
const gauge1 = new Dashboards.GaugeWidget();
gauge1.gaugeType = Dashboards.GaugeType.Horizontal;
gauge1.dataSource = 'mock-data';
gauge1.dataPath = 'data';
gauge1.valuePath = 'value';
gauge1.minPath = 'min';
gauge1.maxPath = 'max';
gauge1.targetPath = 'target';
dash.addWidget(gauge1, 4, 0, 1, 1);
const gauge2 = new Dashboards.GaugeWidget();
gauge2.gaugeType = Dashboards.GaugeType.Semicircle;
gauge2.dataSource = 'mock-data';
gauge2.dataPath = 'data';
gauge2.valuePath = 'value';
gauge2.minPath = 'min';
gauge2.maxPath = 'max';
gauge2.targetPath = 'target';
dash.addWidget(gauge2, 4, 1, 1, 1);
// Shared series
var biaxialSeries = [
{
name: 'Sales Actual',
dataPath: 'chart.data',
valuePath: 'number',
coordPath: 'value',
labelPath: 'label'
},
{
name: 'Sales Target',
dataPath: 'chart.data',
valuePath: 'price',
coordPath: 'number',
labelPath: 'dept'
}
];
var funnelSeries = [
{
name: 'Pipeline',
dataPath: 'chart.data',
valuePath: 'value',
labelPath: 'dept'
}
];
// Row 1: Primary Trends (3x3 grid cells starting at Row 2)
var area = new Dashboards.ChartWidget();
area.chartType = Dashboards.ChartType.Area;
area.dataSource = 'chart-data';
area.series = biaxialSeries;
area.title = "Revenue Trends by Region";
dash.addWidget(area, 0, 2, 3, 3);
var bar = new Dashboards.ChartWidget();
bar.chartType = Dashboards.ChartType.Bar;
bar.dataSource = 'chart-data';
bar.series = biaxialSeries;
bar.title = "Departmental Breakdown";
dash.addWidget(bar, 3, 2, 3, 3);
// Row 4: Secondary Insights (Starting at Row 5)
var pie = new Dashboards.ChartWidget();
pie.chartType = Dashboards.ChartType.Pie;
pie.dataSource = 'chart-data';
pie.series = funnelSeries;
pie.title = "Market Share";
dash.addWidget(pie, 0, 5, 3, 3);
var funnel = new Dashboards.ChartWidget();
funnel.chartType = Dashboards.ChartType.Funnel;
funnel.dataSource = 'chart-data';
funnel.series = funnelSeries;
funnel.title = "Sales Conversion";
dash.addWidget(funnel, 3, 5, 3, 3);
// Row 7: Deep Dive Grid (Starting at Row 8)
var grid = new Dashboards.GridWidget();
grid.dataSource = 'chart-data';
grid.dataPath = 'chart.data';
grid.keyColumn = "index";
grid.title = "Transaction Details";
dash.addWidget(grid, 0, 8, 6, 4);
mockSource.refresh();
chartSource.refresh();
// Style application (Grid settings with ThemeManager support!)
function applyStyles() {
// Set current theme centrally after widgets have initialized and registered
MindFusion.Controls.ThemeManager.currentTheme = "dark";
MindFusion.Controls.Control.MindFusionControls.forEach(c => {
if (c instanceof Charting.Controls.ChartBase) {
c.gridType = Charting.GridType.Crossed;
c.draw();
}
});
}
applyStyles();