-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustomVisual.js
More file actions
57 lines (51 loc) · 1.61 KB
/
customVisual.js
File metadata and controls
57 lines (51 loc) · 1.61 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
// customVisual.js
// Função para criar a tabela
function createTable(data) {
// Seleciona o elemento body e adiciona uma tabela
var table = d3.select("body").append("table").attr("class", "fund-facts-table");
// Adiciona o cabeçalho
table.append("thead").append("tr")
.selectAll("th")
.data(["Metric", "Value"])
.enter()
.append("th")
.text(function(d) { return d; });
// Adiciona as linhas da tabela
var rows = table.append("tbody")
.selectAll("tr")
.data(data)
.enter()
.append("tr");
// Adiciona as células
rows.selectAll("td")
.data(function(d) { return [d.Metric, d.Value]; })
.enter()
.append("td")
.text(function(d) { return d; });
// Adiciona estilo básico
d3.select("head").append("style").text(`
.fund-facts-table {
width: 100%;
border-collapse: collapse;
}
.fund-facts-table th, .fund-facts-table td {
border: 1px solid #ddd;
padding: 8px;
}
.fund-facts-table th {
background-color: #f2f2f2;
text-align: left;
}
`);
}
// Dados de exemplo
var exampleData = [
{Metric: "Benchmark", Value: "MSCI Emerging Markets Index (USD)"},
{Metric: "Inception Date", Value: "Apr 2018"},
{Metric: "Share Class", Value: "Early II"},
{Metric: "Firm AUM ($M)", Value: "$7,274"},
{Metric: "Emerging Markets AUM ($M)", Value: "$3,349"},
{Metric: "Fund AUM ($M)", Value: "$204"}
];
// Chama a função com os dados de exemplo
createTable(exampleData);