Data, Maps, Usability, and Performance

API canvas d3 data geo GeoJSON html5 image JavaScript json maps mysql PHP WordPress

Convert CSV to JSON in JavaScript

CSV to JSON convert

I have been dealing with a lot of CSV and TSV files lately and I am a bit surprised at the lack of support for these formats in jQuery. D3.js supports it out of the box which is awesome but often times I need to convert CSV to JSON without loading D3. You could argue that I should just convert the data into JSON before loading it onto the page, especially since at the end of the day I will need to convert it into a JavaScript object. That is an option, and there are many converters out there, but what about transferring more data over the network? CSV and TSV are always going to be smaller than JSON and I like that, so often times, I actually prefer to load a CSV file into the page and convert it into JSON with JavaScript. Also, a TSV or CSV to JSON conversion function in JavaScript is pretty simple.
Read more

Save SVG as an Image

Convert SVG to Image

SVG is awesome but sometimes you want to convert it into an image format like a JPG or PNG. If you created some chart or graph with D3.js, you might want to offer the option of saving that graph in an image format. Looking around, I landed on this Save SVG as PNG article and while it provides a good solutions to the problem, I wanted to expand on it and provide some other options. First of all, I want to go through an example where you are creating something in D3 and then want to make this conversion using a button and a JavaScript function. I think you could provide 3 types of image files: an SVG converted to a dataurl and inserted into an image tag (this is still technically SVG), a SVG converted into a PNG using HTML5 CANVAS and inserting that base64 data into an IMG tag, and finally, converting the SVG into a PNG binary data and loading that into a blob url so that you can provide an actual filename inside of an IMG tag.
Read more

Internet and Website Trends with HTTParchive

website trends

In my last web performance tools article I have mentioned Ilya Grigorik’s Bigqueries forum where people can share and discuss interesting queries on the HTTParchive. These queries can give us some insight into internet trends and the state of the web. Today, I wanted to share two of my favorite queries from that forum and follow up with some of my own queries to identify some interesting website trends. I have decided to execute my queries in MySQL with the latest imported HTTParchive dump. This is mostly because I am constantly running into limits with using the HTTPArchive database on Google BigQuery.
Read more