I am trying to do an exercise in data visualization using the browser to plot the contents of a local text file.
Both the html and the txt are local, and it is for prototyping/personal-use only.
Basically, I would want to use, say, javascript, to read a file just like this:
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
0.0, 0.2, 0.3, 0.3, 0.3, 0.2, 0.0
0.0, 0.3, 0.5, 0.6, 0.5, 0.3, 0.0
0.0, 0.3, 0.6, 0.8, 0.6, 0.3, 0.0
0.0, 0.3, 0.5, 0.6, 0.5, 0.3, 0.0
0.0, 0.2, 0.3, 0.3, 0.3, 0.2, 0.0
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
and render as a square grid of colored circles. Each value from the txt would be the opacity of the correspondent circle, like this (made using Python, Numpy, Cairo and PIL):

I am a complete beginner on javascript and HTML5 Canvas, so I would appreciate very much a clue so as to what I should do, which functions to use, etc.
There’s no need to give complete code (but it would be nice!), just the name of the functions and concepts, so that I can look for tutorials and assemble my Frankenstein from a bunch of “Hello Worlds”, or anything like that.
Thanks for reading!
TL;DR : http://bv.iriscouch.com/so/_design/ex/index.html and http://bv.iriscouch.com/so/_design/ex/separate-function.html
This is a slightly verbose answer but I feel like I was in your shoes not too long ago, and would have benefitted from some of the below pointers. I will target it with Python analogies since you mentioned those Python libraries. Also feel like mentioning: I like low-level stuff, I love oscilloscopes, C, etc., but the beautiful, lower-level heart of javascript is its objects and functions — the browser environment is a jungle and I am much happier since handing off as much as possible to jQuery and Underscore.js.
First, regarding csv format, if it’s an absolute requirement use something like d3.csv from the d3.js library. (In fact, regard all data vizualization javascript you learn from now forward as preparation for copying as much as possible from the imagination of Mike Bostock.) But asking about csv in Javascript is a bit like asking “I’m new to Asia, where is the best place to get sushi in Sichuan?” Answer: “You’re in Sichuan!!!“. Use
json. In python in your case I would just do:Here is how you do it in one piece: http://bv.iriscouch.com/so/_design/ex/index.html
Here is how you might break it up into the core function that then gets rendered on the page’s canvas: http://bv.iriscouch.com/so/_design/ex/separate-function.html
(Parenthetically, try iriscouch.com, it is one of the coolest things on the internet, and a good way to get familiar with Javascript. The below examples are there.
sudo pip install couchapp,couchapp generate ex,cp *.js *.html ex/_attachments,cd ex && couchapp push https://user:pass@youraccount.iriscouch.com/somenameis how I put up these examples, totally free. Windows installer here.)If you want to look at the underlying data as reformatted, that’s here.
Finally, you can see more of my personal babysteps in this stuff at http://aguacat.es
Inline of above example: