clips / pattern

Web mining module for Python, with tools for scraping, natural language processing, machine learning, network analysis and visualization.
https://github.com/clips/pattern/wiki
BSD 3-Clause "New" or "Revised" License
8.73k stars 1.58k forks source link

Extended support for static graphs and exporting graphs #15

Open tcrombez opened 12 years ago

tcrombez commented 12 years ago

In pattern.graph, I'm frequently using the node.fixed=True attribute to get more control of how a graph looks visually. For example, http://theater.ua.ac.be/bih/october.

It would be nice to have some sort of export functionality for this, so the graphs would look nicer when printed. For instance, export to SVG or PDF.

On a related note, when I fix all of the nodes of a graph, it is no longer necessary to animate it, so I set frames=1. However, this does not work out well in Mobile Safari on iOS devices. The graph is rendered, but the nodes and edges are not drawn (only the labels). With an animated graph, this problem does not occur (although animation is very slow with heavily interconnected graphs).

tom-de-smedt commented 12 years ago

SVG is on the to-do list. It is not hard to implement, for graphs we'd only need straight lines, ellipses and text labels. See the SVG spec (http://www.w3.org/TR/SVG/shapes.html). But it would be better in the long run if the whole underlying canvas.js has support for SVG, which might take more time to implement.

Concerning the iOS issue: There appears to be a limit to the size of images (or HTML5 Canvas) that iOS can handle: 3 megapixel for devices with memory < 256 MB, 5 megapixel for devices >= 256 MB. The canvas in your example is 1200 x 5000, which is bigger than 5 x 1024 x 1024.

You can gain a little bit of speed by disabling shadows (set SHADOW=0 in your script).