Can I load .gml in d3? - javascript

I saved a .gml from wolfram mathimatica, does anyone have an example of how to load the file and display on a webpage? I am dealing with d3 at the moment, would another language be more appropriate?
Thanks.

There's a really good post on exactly this at one developer's blog.
The gist of it is that D3, even in its latest version (v4, at the time of writing this), can't import GML files. However, you can convert a GML file into a JSON file, which D3 can read. You can use NetworkX for this conversion.
Alternatively, you may use Gephi to export the edges and nodes to CSV separately.

Related

How do I convert SHP to TopoJSON using command lines on a Mac

I am attempting to make a data visualization map using SHP files from the Census Bureau. I wanted to convert the file to TOPOJSON without losing information associated with each path (i.e. keep the FIPS number associated with each path). I tried converting from SHP to JSON using MapShaper, but it seems like the FIPS info was lost along the way.
I went down a tutorial rabbit hole and found a bunch of examples of people using terminal commands to convert the SHP file. However, the documentation seems to be all over the place. Some are from 2010. Others are from 2017. The version of NPM I am using(6.14.4), the commands to output to JSON have changed I believe.
Could anyone point me to the latest documentation to convert SHP to TOPOJSON using command lines? Or if anyone knows a better way to convert, I am open to that, too. These maps will be used for the web, so the smaller TOPOJSON file, the better. I will eventually be using D3.js to project the map.
Thanks.

Is there anyway to export D3 JS graphs into LaTeX tikz graphs programmatically?

There are many ways of exporting R graphs and R Tables quickly into LaTeX using the R tikzDevice (on the R side) and the LaTeX tikz package (On LaTeX side). Have a look at this blog article for more info.
Are there any automated method or JS library similar to the above concept but transforms a complete visualization in D3.JS to native LaTeX TiKz like graphs. I need that to include good resolution graphs into LaTeX papers and reports.
I know that there many ways and JS code that export visualization into PNG, JPEG, PDF etc... Is there any easy way to export D3.js into TikZ LaTeX?
Thanks for any suggestions.
Not tested but pretty sure you could go: d3js->SVG->TikZ
Export from d3 to SVG, e.g
d3.select(this)
.attr("href", 'data:application/octet-stream;base64,' + btoa(d3.select("#graph").html()))
.attr("download", "graph.svg")
Convert SVG to TikZ (SVG2TikZ, etc).
Import TikZ into LaTeX
If this process works you could easily automate it using python.
I know that there many ways and JS code that export visualization into
PNG, JPEG, PDF etc...
My thinking is that if you can't go direct - then to try and use one of the many ways as an intermediate format (in this case SVG) to get the data from one to the other.

Advansed xlsx spreadsheet formatting

Is there some JavaScript or Golang lib that allows to create xlsx files using some custom heavy formatting?
I'm working on an Electron app and want to generate some reports but
the most popular library doesn't provide cell formatting, that fork looses the ability to define page properties like margins and page orientation and that Golang lib as I see doesn't provide page properties too.
Can anybody show some good alternatives or show me I'm wrong?
(no C-like langs and Python please)
I am myself looking for something similar to format docx documents and I have just started trying out gooxml.
Currently it has following capabilities for Excel:
Read/Write/Edit
Cell formatting including conditional formatting
Cell validation (drop down combobox, rules, etc.)
Retrieve cell values as formatted by Excel (e.g. retrieve a date or number as displayed in Excel)
Formula Evaluation (100+ functions supported currently, more will be added as required)
Embedded Images
All chart types
Edit to answer comment:
As stated in the documentation, you may have to fall back to raw document manipulation should the library's API not cover a specific use case.
See CT_PageMargins.go and CT_PageSetup.go for margin and orientation...
Well it seems I've learned the lesson - after trying to use "super-hard-to-understand-and-use" jsreport-xlsx module I've remembered about one lib that didn't worked in Electron renderer and tried it to work from Electron main process.
And it works! Sometime it may be a little treaky to make it create doc exactly you want but it's much better than XLSX-style I've used before and have all features I want.
(it's second [and last I believe] time I've forget about Electron renderer is not Node.js, the true Node.js is main process)

Convert HTML Report to PDF

I want convert an HTML report to PDF. I know that there are so many libraries are available for this purpose. But the HTML report contains so many graphs created using Jqplot. I want to include these graphs in the PDF also. If you are familiar with any library which also convert graphs to PDF, please give me the reference.
you can use bullzip pdf printer it creates a virtual pdf printer that can transform your HTML content to a pdf file from the browser:
http://www.bullzip.com/
you can also find a lot of useful tools right there!
I don't have experience with Jqplot, but I have successfully converted html pages which contain pie charts from Google Charts (completely javascript generated) to pdf.
I used wkhtmltopdf - it's a commandline tool but there are wrapper classes for php and some others I believe.
I'm sure you could find something applicable with a bit of googling but this looks promising: https://github.com/mikehaertl/phpwkhtmltopdf

draw SVG with javascript online and in terminal

I need to display some data online but I also would like to have nice plots as high-res files for printing. So far I was generating the plots as png, but now I am thinking on changing this to Javascript. This is mainly because I would like my plots to be dynamic.
The WWW part is looks relatively easy for me; I would grab data from a server with AJAX and plot on a webpage - I think SVG would be perfect for my needs. But how can I run the script from terminal with a file name as a parameter to get a myplot.svg (which of course will not be dynamic any longer) file that looks like the plot on the webpage?
Ideally I would like to have a single plotting subroutine in order to avoid duplicate code and to keep both versions looking the same.
So my questions are which framework should I use for SVG generation to make the terminal variant easy ?
You can use ImageMagick to convert a SVG to png:
ImageMagick convert svg to png
You can extract the generated SVG from a virtual DOM (with the same code as on your web page, perhaps with slightly differences regarding environment) when you use Node.js and jsdom
As mentioned in the comment I can recommend D3.js - Data Driven Documents for generating SVG the easy way.
An alternative for Node.js and jsdom might be Phantom.js.
Your task is not an easy one, but it's worth the effort. Good luck!

Categories

Resources