-
Notifications
You must be signed in to change notification settings - Fork 0
/
index-create-charts-grid-dom.html
76 lines (67 loc) · 2.93 KB
/
index-create-charts-grid-dom.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Reveal SDK - Web Component</title>
<style>
html,
body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
</style>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dayjs.min.js"></script>
<script src="https://dl.revealbi.io/reveal/libs/1.7.1/infragistics.reveal.js"></script>
<script src="https://cdn.jsdelivr.net/npm/reveal-sdk-wrappers/index.umd.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@revealbi/dom/index.umd.min.js"></script>
<script>
$.ig.RevealSdkSettings.setBaseUrl("https://samples.revealbi.io/upmedia-backend/reveal-api/");
</script>
</head>
<body>
<rv-reveal-view id="viewer"></rv-reveal-view>
<script>
const createDashboard = () => {
// Create a new Reveal document
const document = new dom.RdashDocument("REST Dashboard");
// Define the JSON data source
const jsonDataSourceItem = new dom.RestDataSourceItem(
"Sales by Category",
"https://excel2json.io/api/share/6e0f06b3-72d3-4fec-7984-08da43f56bb9",
new dom.DataSource("JSON DS", "JSON DS Subtitle")
);
// Set properties for the data source
jsonDataSourceItem.subtitle = "JSON Data Source Item";
jsonDataSourceItem.isAnonymous = true;
jsonDataSourceItem.fields = [
new dom.NumberField("CategoryID"),
new dom.TextField("CategoryName"),
new dom.TextField("ProductName"),
new dom.NumberField("ProductSales"),
];
// Create a pie chart visualization
const jsonChart = new dom.PieChartVisualization("JSON", jsonDataSourceItem)
.setLabel("CategoryName")
.setValue("ProductSales");
// Create a pie chart visualization
const jsonChart2 = new dom.BarChartVisualization("JSON", jsonDataSourceItem)
.setLabel("ProductName")
.setValue("ProductSales");
const jsonGrid = new dom.GridVisualization("Grid", jsonDataSourceItem)
.setColumns("CategoryID", "CategoryName", "ProductName", "ProductSales");
// Assign the visualization to the document
document.visualizations = [jsonChart, jsonChart2, jsonGrid];
return document;
};
// Get the Reveal view element
const revealView = document.getElementById("viewer");
// Assign the generated dashboard to the Reveal view
revealView.dashboard = createDashboard();
</script>
</body>
</html>