Created
June 13, 2019 15:02
-
-
Save mzsima/c1ac4c1c0eb62e2220a04db8d47b7420 to your computer and use it in GitHub Desktop.
blazor_hello_sigma_js
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<meta name="viewport" content="width=device-width" /> | |
<title>sigmajs_graph</title> | |
<base href="/" /> | |
<link href="css/bootstrap/bootstrap.min.css" rel="stylesheet" /> | |
<link href="css/site.css" rel="stylesheet" /> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/sigma.js/1.2.1/sigma.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/sigma.js/1.2.1/plugins/sigma.parsers.json.min.js"></script> | |
<script> | |
window.myHelper = { | |
setup: function (props) { | |
var s = new sigma('container'); | |
// Then, let's add some data to display: | |
s.graph.addNode({ | |
// Main attributes: | |
id: 'n0', | |
label: 'Hello', | |
// Display attributes: | |
x: 0, | |
y: 0, | |
size: 1, | |
color: '#f00' | |
}).addNode({ | |
// Main attributes: | |
id: 'n1', | |
label: 'World !', | |
// Display attributes: | |
x: 1, | |
y: 1, | |
size: 1, | |
color: '#00f' | |
}).addEdge({ | |
id: 'e0', | |
// Reference extremities: | |
source: 'n0', | |
target: 'n1' | |
}); | |
// Finally, let's ask our sigma instance to refresh: | |
s.refresh(); | |
} | |
} | |
</script> | |
</head> | |
<body> | |
<app>Loading...</app> | |
<script src="_framework/blazor.webassembly.js"></script> | |
</body> | |
</html> |
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
@page "/" | |
@inject IJSRuntime JsRuntime; | |
<h1>Hello, sigma.js</h1> | |
<div id='container' style="width:100px;height:100px"></div> | |
@code { | |
protected override async Task OnAfterRenderAsync() { | |
await JsRuntime.InvokeAsync<Object> ("myHelper.setup", ""); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment