Git Product home page Git Product logo

visnetwork.blazor's People

Contributors

adrien426 avatar cavallialexander avatar jbgh2 avatar stiankroknes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

visnetwork.blazor's Issues

AddVisNetwork doesn't work on Blazor server websites

AddVisNetwork adds a singleton IJsModule which has a dependency on IJsRuntime therefore requiring that IJsRuntime also be a singleton

On Blazor server IJsRuntime is scoped (see https://learn.microsoft.com/en-us/aspnet/core/blazor/fundamentals/dependency-injection?view=aspnetcore-7.0#default-services)

Current workaround:

  1. Create a new class that derives from IVersionProvider
    • This step is required because VersionProvider is internal not public
  2. Add the services manually

Suggestions:

  1. Create a version of AddVisNetwork for scoped used
  2. Make VersionProvider public, this makes it easier to build the equivalent to AddVisNetwork

[Discussion] Handling json that doesn't encode the full object

@stiankroknes I've come up with a potential solution to the problem that the output of the DOT parser isn't necessarily complete objects since vis.js supports simplified form for some of it's parameters.

Example with tests in #29

The basic problem is that the default JsonConverter is expecting an json object and throws an exception when it gets something else.
The standard way around this to to write a custom JsonConverter<T> (which I did, see ArrowsJsonConverter in the PR)
However, we want the default converter when there is an object but to do something special when there isn't.

Proposed solution:
For types that have a simplified format (like Arrows and Font) create a class that derives from the proper object and knows how to construct a full object from the simplified form.
Then create a converter for the wrapper class (and when it detects the simplified form it constructs from that), otherwise it can get the default converter and use that to deserialize the full object.

In the branch the Arrows and Font classes are now the wrapper classes around ArrowsInternal and FontInternal.
I gave the wrapper classes the original names so when you are constructing the network in code it looks correct and you don't have to worry about the wrapper/internal versions unless you are deserializing from the simplified format.

I tried to add some high level checks where it looks for either a string or number token to convert from but this might be overkill and it should just take the string output and try and work with that.

Have a look and I'm happy to take any feedback, I feel like there are some ways to simplify it but my C# isn't quite good enough to know how to.

Updating the nodes and edges

Hi, I'm trying create a graph where nodes and edges can be automatically updated via the users actions. I can create a graph if I set the NetworkData in the constructor but I'm unable to change it. if you see my code I've simplified it to add a new node when a button is pressed. I can see the new data in the network object in the debugger but it never refreshes on the display?

I've tried various ways of updating the Network data and the last try was to instantiate a new NetworkData object as you can see below.

I only appear to be able to set the data for the graph in the constructor. If i do it through the ValidFormSubmitted click for example nothing shows on the page.

....various html bits n bobs
<div>
	<Network Id="mynetwork" @ref="network" Data="data" class="vis-network-container" />
</div>

@code {
	private Network network;
	private NetworkData data;
	private HashSet<Node> nodes = new HashSet<Node>();
	private HashSet<Edge> edges = new HashSet<Edge>();
	public Analyze()
	{
		nodes.Add(new Node("1", "Node 100", 1, "circle"));
		nodes.Add(new Node("2", "Node 200", 2, "circle"));
		edges.Add(new Edge("1", "2"));
		nodes.Add(new Node("3", "Node 300", 4, "circle"));
		edges.Add(new Edge("2", "3"));
		data = new NetworkData
		{
			Nodes = nodes,
			Edges = edges
		};
	}

	protected async Task ValidFormSubmitted()
	{
	

		nodes.Add(new Node("4", "Node 400", 5, "circle"));
		data = new NetworkData
		{
			Nodes = nodes,
			Edges = edges
		};
		await network.Redraw();
		StateHasChanged();
	}
}

I'm new to Blazor so I might be missing something really obvious.

Destroying VisNetwork

Hello,

thanks you for work. I would like to ask you how can i destroy the visnetwork. Actually, i have a modal that includes the Network and when i close it, the console have the following error

Microsoft.JSInterop.JSException: Cannot read properties of null (reading 'id')
TypeError: Cannot read properties of null (reading 'id')
    at Module.hR (https://localhost:7114/_content/VisNetwork.Blazor/BlazorVisNetwork.js?v=2.0.0.0:2:697560)
    at https://localhost:7114/_framework/blazor.webassembly.js:1:3332
    at new Promise (<anonymous>)
    at Object.beginInvokeJSFromDotNet (https://localhost:7114/_framework/blazor.webassembly.js:1:3306)
    at Object.St [as invokeJSFromDotNet] (https://localhost:7114/_framework/blazor.webassembly.js:1:59960)
    at _mono_wasm_invoke_js_blazor (https://localhost:7114/_framework/dotnet.6.0.15.33m2xdwuzc.js:1:195300)
    at wasm://wasm/00971dfa:wasm-function[219]:0x1a4c1
    at wasm://wasm/00971dfa:wasm-function[167]:0xce8f
    at wasm://wasm/00971dfa:wasm-function[166]:0xbd73
    at wasm://wasm/00971dfa:wasm-function[2815]:0xabef3
   at Microsoft.JSInterop.JSRuntime.<InvokeAsync>d__16`1[[Microsoft.JSInterop.Infrastructure.IJSVoidResult, Microsoft.JSInterop, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].MoveNext()
   at Microsoft.JSInterop.JSObjectReferenceExtensions.InvokeVoidAsync(IJSObjectReference jsObjectReference, String identifier, Object[] args)
   at VisNetwork.Blazor.JSModule.InvokeVoidAsync(String identifier, Object[] args)
   at VisNetwork.Blazor.Network.System.IAsyncDisposable.DisposeAsync()
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.<ProcessDisposalQueueInExistingBatch>g__GetHandledAsynchronousDisposalErrorsTask|64_0(Task result)

I assume that is searching for the Id when the StateHasChanged (the modal has changed).

Can you tell me if there is any way to solve this error ?

Thank you in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.