-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathForceLayoutGraphChart.razor
65 lines (58 loc) · 1.47 KB
/
ForceLayoutGraphChart.razor
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
@using Vizor.ECharts;
@if (isInitialized)
{
<Vizor.ECharts.EChart Options="@options" ExternalDataSources="@(new[] { graph })" Width="1000px" Height="1000px" />
}
@code {
// see https://echarts.apache.org/examples/en/editor.html?c=graph-force
private ExternalDataSource? graph = null;
private ChartOptions? options = null;
private bool isInitialized = false;
protected override void OnInitialized()
{
graph = new ExternalDataSource("/data/les-miserables.json", ExternalDataFetchAs.Json)
{
AfterLoad = new JavascriptFunction(@"function (graph) {
graph.nodes.forEach(function (node) { node.symbolSize = 5; });
return graph;
}")
};
options = new()
{
Title = new()
{
Text = "Les Miserables",
Subtext = "Default layout",
Top = "top",
Left = "center"
},
Tooltip = new() { },
Legend = new()
{
Top = 100
//Data = new JavascriptFunction("graph.categories.map(function (a) { return a.name; })") //TODO: this won't work, 'graph' is not defined
},
Series = new()
{
new GraphSeries()
{
Name = "Les Miserables",
Layout = GraphLayout.Force,
Data = new ExternalDataSourceRef(graph, "nodes"),
Links = new ExternalDataSourceRef(graph, "links"),
Categories = new ExternalDataSourceRef(graph, "categories"),
Roam = Roam.True,
Label = new()
{
Position = LabelPosition.Right
},
Force = new()
{
Repulsion = 100
}
}
}
};
isInitialized = true;
}
}