Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suitable library for combining with D3js , to allowing drawing to webgl (2D)

Here is what i am trying to do : http://mbostock.github.com/d3/talk/20111116/iris-splom.html

But i want to do that in webgl 2d (because SVG performance is very slow, randering 10k SVG only already drops to 12 fps)

On a quick search i found several webgl-2d libs : cocos2d-html5 , pixijs,Three.js and webgl-2d(abandoned?)

They seems to be pretty easy but what i want to do is data visualization.cocos and pixijs are 2d game libraries. I am new to webgl and those libraries so experts at SO can you guys recommend ?

summary of things i need:

Interaction :

  • Rectangular selection inside plots. Click to select on Some elements.
  • Zoom and Pan Support (Semitic Zooming if possible)

Renderer : WebGL2d (according to benchmarks webgl is fastest)

like image 347
Phyo Arkar Lwin Avatar asked Apr 26 '13 12:04

Phyo Arkar Lwin


People also ask

What is D3 library used for?

D3 is a JavaScript library and framework for creating visualizations. D3 creates visualizations by binding the data and graphical elements to the Document Object Model. D3 associates (binding) the data (stuff you want to visualize) with the DOM. This allows the user to manipulate, change or add to the DOM.

What is the way to include D3 js library into HTML site?

We can use the D3. js library by linking it directly into our HTML page from the Content Delivery Network (CDN). CDN is a network of servers where files are hosted and are delivered to a user based on their geographic location. If we use the CDN, we do not need to download the source code.

What is D3 js library?

D3. js is a JavaScript library used to manipulate documents based on data. It uses HTML, CSS, and SVG to create visual representations of data which can be viewed on any modern browser. It also provides some awesome features for interactions and animations.

Does D3 support WebGL?

With D3FC we have created a suite of components that makes it easier to create charts with D3, extending its vocabulary from SVG paths, rectangles and groups, into series, annotations and charts. Recently we have added support for WebGL, making it really easy to render series using GPU-accelerated graphics.


1 Answers

Based on your requirements and summary, I would recommend the latest release of Cocos2D-html5 which includes WebGL rendering support. This is as simple as changing the rendering setting from Canvas to WebGL in the cocos2d.js settings file. For Example, in HelloHTML5World/cocos2d.js change renderMode to 2 for WebGL based rendering.

renderMode:0,       //Choose of RenderMode: 0(default), 1(Canvas only), 2(WebGL only)

Cocos2d-html5 is more precisely a graphics library and & maybe construed as a complete game library only in combination with the (default) chipmunk or box2d game physics libraries.

Does it support rectangular selection, or zoom and pan? Yes, you can extend the existing libraries to implement these behaviours.

Other advantage of Cocos2d-html5 platform is added support for visual graphics editing with Cocosbuilder and cross-platform native support (iOS, Android etc) for same codebase with Javascript bindings.

If you have specific platform questions, these can be answered in better detail with code.

You may want to look at the JS reference and the cocos2d-html5 forum for getting started.

Update1: Looked at your data visualization code for iris dataset, The plots are housed in a svg element, with tiny circles plotting each datapoint according to x,y coordinates. These can be accomplished in Cocos2d too via x,y coordinates, grids, boxes with varying opacity and the tiny circles for the data points. Import your iris dataset in json/xmll/csv format via javascript code and plot via above cocos2d methods. Rectangle selection via javascript event callbacks & mousehandler methods and corresponding update of canvas scene.

Update2: On second thoughts, if you find the learning curve for cocos2d steep, you may better restrict yourself to a charting only library which is WebGL based. This project VivaGraphJS seems suitable with high performance being WebGL based.

Also, please ask questions preferably in this format, what you tried in code, what was the expected output, what you got instead. SO is not meant for comparison of libraries. WebGL is a rendering method. The switch, for example in three.js is as simple as

renderer = new THREE.WebGLRenderer();

instead of the canvas one:

renderer = new THREE.CanvasRenderer();

resulting in higher performance.

like image 148
S G Avatar answered Sep 30 '22 22:09

S G