-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#14: redesigned the external data source system to optimize JsonSeria…
…lizer memory usage
- Loading branch information
Showing
20 changed files
with
456 additions
and
265 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 50 additions & 38 deletions
88
src/Vizor.ECharts.Samples/Areas/Graph/ForceLayoutGraphChart.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 1,65 @@ | ||
@using Vizor.ECharts; | ||
|
||
<Vizor.ECharts.EChart Options="@options" Width="1000px" Height="1000px" /> | ||
@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 | ||
// see https://echarts.apache.org/examples/en/editor.html?c=graph-force | ||
private static ExternalDataSource graph = new ExternalDataSource("/data/les-miserables.json", ExternalDataFetchAs.Json) | ||
{ | ||
AfterLoad = new JavascriptFunction(@"function (graph) { | ||
graph.nodes.forEach(function (node) { node.symbolSize = 5; }); | ||
return graph; | ||
}") | ||
}; | ||
private ExternalDataSource? graph = null; | ||
private ChartOptions? options = null; | ||
private bool isInitialized = false; | ||
|
||
private ChartOptions options = new() | ||
protected override void OnInitialized() | ||
{ | ||
Title = new() | ||
graph = new ExternalDataSource("/data/les-miserables.json", ExternalDataFetchAs.Json) | ||
{ | ||
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() | ||
AfterLoad = new JavascriptFunction(@"function (graph) { | ||
graph.nodes.forEach(function (node) { node.symbolSize = 5; }); | ||
return graph; | ||
}") | ||
}; | ||
|
||
options = new() | ||
{ | ||
new GraphSeries() | ||
Title = new() | ||
{ | ||
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() | ||
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() | ||
{ | ||
Repulsion = 100 | ||
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.