Stata D3 Examples
These examples are being updated little by little to reflect changes in the jsonio and in preparation for the 2016 North American Stata Users Group Meeting in Chicago.
Recently, D3.js released a new major version (4.0). This library does not reflect any of the changes to the new API, but may be modified overtime to use the newer API or include capabilities to manage the code generation in a way that will allow the library to handle the version 3 or 4 APIs.
The examples page will evolve over time, but there is currently a single example that shows output generated by the d3scatterTip Mata function defined in this repository. After converting the auto.dta dataset to JSON using jsonio and defining the d3scatterTip Mata function, the graph was created using the code:
mata: d3scatterTip("~/Desktop/Programs/StataPrograms/d/d3/examples//index.html", /// "data/auto.json", "length", "gear_ratio", "foreign", "make")
The example above can be viewed on the project page. If, for example, we wanted to generate the points colored based on the number of repairs in the
rep78 variable, it would be as simple as:
mata: d3scatterTip("~/Desktop/Programs/StataPrograms/d/d3/examples//index.html", /// "data/auto.json", "length", "gear_ratio", "rep78", "make")