quartz icon indicating copy to clipboard operation
quartz copied to clipboard

Is it a better choice to use canvas instead of svg for force-directed graphs?

Open iceprosurface opened this issue 9 months ago • 5 comments

The performance is too poor.

When there is a very large number of documents, displaying the entire mind map is extremely laggy.

image

How about considering using WebGL or canvas for drawing? Below is an example of rendering with the same nodes, which is relatively much smoother.

https://stackblitz.com/edit/vitejs-vite-fbexju?file=src%2Fmain.ts

https://github.com/jackyzha0/quartz/assets/16058059/baa9c372-4b2f-4688-8291-0e931fccd44e

iceprosurface avatar May 17 '24 06:05 iceprosurface

Here is a preview:

https://iceprosurface.com/demo/d3-force-directed-graphs/

https://iceprosurface.com/demo/d3-force-directed-graphs-2d/

iceprosurface avatar May 17 '24 06:05 iceprosurface

Code from:

https://github.com/vasturiano/force-graph https://github.com/vasturiano/3d-force-graph

iceprosurface avatar May 17 '24 06:05 iceprosurface

Related to: #1108 #599

iceprosurface avatar May 17 '24 06:05 iceprosurface

I'd welcome a PR if you can reach feature parity with the existing graph! We use d3 right now and I think that d3 has a Canvas mode but not sure how it works

jackyzha0 avatar May 17 '24 16:05 jackyzha0

I implemented one using PixiJS and D3. Although there are still quite a few issues with the styles, it has been verified that it can indeed be integrated into Quartz, and the performance is excellent.

On my Mac, with a DPI of 2, it can run at 60fps with 752 nodes and 3600 links, which is a significant improvement compared to before.

Here is the implementation link: https://github.com/iceprosurface/quartz-blog/tree/feat/graph-test/packages/quartz-graph-plugin

and demo: https://cdn.iceprosurface.com/demo/quartz-graph-plugin/

However, there's a significant issue: currently, Quartz doesn't seem to compile PixiJS and TweenJS very well. Additionally, I think compiling TweenJS and PixiJS into the PostScript would make it too large. Do you have any good solutions for this?

iceprosurface avatar Jun 08 '24 02:06 iceprosurface

closed via https://github.com/jackyzha0/quartz/pull/1328

jackyzha0 avatar Aug 25 '24 07:08 jackyzha0