In [1]:
%autosave 10


Autosaving every 10 seconds

Summary

  • Working in a web browser avoid dependencies, wider audience
  • Python and JavaScript complement each other.
  • Avoid JavaScript's dodgy parts.

Reality

  • You need to know JavaScript for the best web visualisations.
  • Trick is to use Python to clean and deliver data to JavaScript's tools (D3, Raphael, Leaflet, Crossfilter).

JavaScript is rough and terrible defaults

  • Default global variables.
  • No namespacing.
  • Religious wars surrounding imports, confused.
  • Crockford's "JavaScript: The Good Parts"
  • Use a linter, e.g. JSLint, or preferably JSHint.
  • JavaScript frameworks are unlike buses - there are always three frameworks coming at once.
  • People's default answer to "how do I get this to work in X?" is "but Y is far better, use that".

..and the good

  • 100% installation base.
  • Orders of magnitude faster than Python, arms race to make it faster.
  • Visualization libraries written by real programmers.

d3

  • Learning curve is worth it

Crossfilter

  • Large multivariate datasets, pairs with d3 and visualises large complex data sets well

Server-side JavaScript

  • Compared to Python there is no compelling use-case.
  • Maybe Node.js for massively concurrently traffic.
  • But JavaScript has no standard imports, missing NumPy and SciPy.

Python server to JavaScript client

  • JSON, as:
    1. static file, sure works but not dynamic.
    2. API call, most common. RESTful recommended.
    3. Web sockets, realtime but still esoteric.

 What Python server?

  • SimpleHTTPServer for static, starts off fine.
  • Flask, lightweight when something very simple is all you need.

 Websockets use-case

  • Move from Python -> QT, OpenGL GUI, to
  • Python -> Flask -> WebGL / Angular / Bootstrap
  • Wider audience, no dependencies

 Project to visualise Met Office weather data

  • Very, very dirty data. Arbitrarily change delimiters and null values over time.
  • Python makes short work of this.
  • Geo-JSON: scipy, geojson.
  • scipy.interpolate.interp2d to put coordinates onto 2D grid for front-end.
  • key thing about D3, as opposed to Bokeh or Vega, is to be able to interact with the visualisation.

In [ ]: