forked from alexbbrownIntel/g3plot
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added files licenced by intel under the BSD 3-clause licence.
- Loading branch information
1 parent
f4c9b30
commit e0a9fc5
Showing
46 changed files
with
6,507 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.Rproj.user | ||
.Rhistory | ||
.RData |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Copyright (c) 2013, Intel Corporation | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
* Neither the name of Intel Corporation nor the | ||
names of its contributors may be used to endorse or promote products | ||
derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL Intel Corporation BE LIABLE FOR ANY | ||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
The g3 package inludes parts of other open source software components. The | ||
following is a list of these components (full copies of the license agreements | ||
used by these components are included below): | ||
|
||
- d3.js | ||
- Shiny | ||
|
||
d3.js License for content in d3extent.js | ||
---------------------------------------------------------------------- | ||
|
||
Copyright (c) 2013, Michael Bostock | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
* The name Michael Bostock may not be used to endorse or promote products | ||
derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL MICHAEL BOSTOCK BE LIABLE FOR ANY DIRECT, | ||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, | ||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
|
||
Shiny License for content in shiny_extent_d3.R | ||
---------------------------------------------------------------------- | ||
|
||
Copyright (c) 2012-2013 RStudio, Inc. | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
|
||
* Neither the name of RStudio, Inc. nor the names of its contributors | ||
may be used to endorse or promote products derived from this software | ||
without specific prior written permission. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,119 @@ | ||
g3plot | ||
G3Plot | ||
====== | ||
|
||
g3plot release 1 from intel | ||
A demo framework for Shiny + D3 including ggplot-like aesthetic mapping and geoms. | ||
|
||
Written by Alex B Brown at Intel Corp, 2012-2013 | ||
|
||
Core idea: Pick a dataset, then describe how that data is mapped into a graph, using the handy-dangy ggplot2 like format. | ||
|
||
Includes interactive features such as click and drag. | ||
|
||
Add Shiny inputs to the app to control graph filtering and more. | ||
|
||
Licence | ||
------- | ||
|
||
This will shortly receive and open source licence. Please take care not to include | ||
confidential information in this repository. | ||
|
||
Usage as a demo app | ||
------------------- | ||
|
||
To run g3plot in demo mode, | ||
|
||
1) start R in this directory. | ||
2) require(shiny) | ||
3) runApp() | ||
|
||
Note that if you run > require(plyr); require(reshape); require(Hmisc); | ||
then additional datasets will appear in the sidebar, some of which have | ||
plots already created. | ||
|
||
Extending the demo app | ||
---------------------- | ||
|
||
Look in plot.R and add some functions for other data sets. If that gets old, go to plotinputs.R and add some of those. | ||
|
||
If *that* gets old, start to create new graph types in javascript, or fix the html table logic. | ||
|
||
Usage as your own app | ||
--------------------- | ||
|
||
Checkout g3plot as a subdirectory of your Shiny Application and add the line | ||
|
||
addResourcePath("js",tools:::file_path_as_absolute("./g3plot/js")) | ||
|
||
To your server.R. | ||
|
||
Then follow some of the examples in server.R and ui.R and friends to add | ||
javascript plots to your Shiny Application. | ||
|
||
Note that you can still test the demo app by using | ||
|
||
runApp("g3plot") from your application's R console. | ||
|
||
Geoms | ||
----- | ||
|
||
Currently supports: | ||
|
||
point | ||
bar | ||
point_bar | ||
point_range_bar | ||
line | ||
voronoi (doesn't display but makes UI better) | ||
|
||
Layout Structure | ||
---------------- | ||
|
||
Ignoring text output, html, axes, legends | ||
|
||
Common Name | Entity | Arity | Class | File | Message Part | Description | ||
------------|--------|-------|-----------------|-------------|-------------------|------- | ||
Document | HTML | 1 | | UI.R | - | the web page | ||
report | DIV* | n | g3plotMultiPlex | g3widget.js | Array of arrays | the shiny output | ||
section | DIV | n | pane | g3report.js | Array of list(name=?) | a single formatted d3 object - one of "plot" "list" or other text | ||
figure+data | DIV | 1 | plot | g3plot.js | ditto | A combination of a drawing region with linked html table | ||
figure | SVG | 1 | d3svg | g3plot.js | ditto | A single drawing region with any contents | ||
subfigure | G | n | subplot | g3subfigure.js | List(name=?) | container for a plot with distinct axes, data, legends | ||
plot | G | 1 | plot | g3plot.js | ditto | the bit inside the axes | ||
y facet | G | J | facet | g3plot.js | aesthetic(YFacet=?) | the Jth horizontal slice with a personal clone of the Y scale | ||
x facet | G | K | y facet | g3plot.js | aesthetic(XCluster=?)| the Kth vertical slice of the Jth horizontal | ||
geom | ? | many | dot/bar/... | g3geom.js | aesthetic(geom=?) | an actual drawing component | ||
|
||
TODO | ||
---- | ||
|
||
Ideas for things that really need doing to make future work easier | ||
|
||
* Make HTMLtable way better. Right now it consumes data in structure format with grid format applied to it. This is great for some data types (such as long data that needs to go wide) but is hard to persuade to do what you really want | ||
* Muck out (decompose) the functions in g3plot.js - they are a grab bag of junk code | ||
* Clean up the structure and make message passing between layers better | ||
* Make filters smarter - can they be overlaid | ||
* Make zooming work (e.g. transiently zoom on a click) | ||
* Make writing message templates easier. Ideas - some fields can be inferred from others, or have good defaults. Beyond that, a wrapper called d3plot could guess what were good values. | ||
|
||
Fun improvements: | ||
|
||
* Standardised way to add dynamic tooltips | ||
* Standardised way to hover highlight nodes | ||
* Improved click dropzones (voronoi?) | ||
* click drag on axes to scale (near ends) or pan (in middle) | ||
|
||
Some ideas to develop the product | ||
|
||
* Sparklines - providing a very simple 3-layer structure without faceting | ||
* Layers - multiple geoms on top of each other (another layer!) | ||
* g3autoplot - looks at data and does something sensible, then tells you how to repeat / customise it | ||
|
||
|
||
Constraints | ||
----------- | ||
|
||
While this project could go in a number of dimensions, some routes may constrain it. Here are some reasons not to constrain it: | ||
|
||
* geoms may need to sit on top of multiple facets. For instance a summary stat across the second-inner XCluster - e.g. average income for a whole state with subfacets for each county. | ||
* It should be a learning aid; so while it's hard, lets keep things simple, and try to have simple versions of things to build upon. For example, a line-drawer without animation, or exits, may be a whole lot simpler than one with, and animations and exits are far less important than non animated entries. Similarly, abstracting too much d3 away may be a good or bad thing. | ||
* The current layout is very complex - with 12 layers. This is because it was a project goal to show exactly how fancy it could get. Probably only 2 or 3 are actually necessary to make basic plots - let's build an alternate path to get there. For example: a Sparkline with only two layers. By preferring that they keep the same innermost components, this will help keep the project flexible. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
Testing and debugging | ||
===================== | ||
|
||
Running unit tests | ||
================== | ||
|
||
* unit tests currently use assertions (not unit test framework) | ||
* unit tests are tested by node and require tools to be installed (see below) | ||
* unit tests are not currently HTML | ||
* unit tests are held in *_test.js files | ||
|
||
Running unit tests example | ||
-------------------------- | ||
|
||
node structureWalker_tests.js | ||
|
||
If it echoes nothing to the console, it worked. | ||
|
||
Debugging JS | ||
============ | ||
|
||
Options: | ||
|
||
Debug in-browser | ||
---------------- | ||
|
||
Firefox requires firebug plugin | ||
|
||
Chrome/Safari include the webkit debugger | ||
|
||
Testing JS | ||
========== | ||
|
||
Testing using node.js | ||
--------------------- | ||
|
||
node can be debugged on the command line. This is not fun - node-inspector is recommended. | ||
|
||
See also: "building Node" and "node-inspector" below. | ||
|
||
adding the statement: ``debugger;`` causes debug to break on that line | ||
|
||
Type 'help' to get help commands | ||
Type 'restart' to reload the js file | ||
|
||
Common commands: | ||
* r: run | ||
* c: continue | ||
* n: next | ||
* s: step | ||
* repl: open a javascript console | ||
|
||
To evaluate JS | ||
|
||
Type 'repl' to go to a js evaluation console. Type ^D to leave the console | ||
|
||
Debug Tests using node.js and node-inspector | ||
-------------------------------------------- | ||
|
||
Make sure node-inspector is installed (see Building Node and Node modules) | ||
|
||
Running the node-debugger example: | ||
---------------------------------- | ||
|
||
Start the node inspector: | ||
node-inspector | ||
Start node and tell it to pause at the beginning: | ||
node --debug-brk g3.stack_test.js | ||
|
||
Open chrome and browse to http://127.0.0.1:8080/ | ||
|
||
Debug as you would use the webKit debugger. | ||
|
||
https://github.com/dannycoates/node-inspector | ||
|
||
Building Node and Node modules | ||
============================== | ||
|
||
Preparing | ||
--------- | ||
|
||
On windows you can use MINGW - this comes with git for windows and with Rstudio | ||
|
||
Install node.js | ||
Install compile tools | ||
* windows: visual studio express 2012 | ||
|
||
other notes in *_test.js | ||
|
||
To test, install node.js and the required packages: | ||
|
||
npm install underscore | ||
npm install d3 | ||
|
||
For in-browser debugging: | ||
npm install node-inspector | ||
|
||
On windows you will need visual studio express installed to build gyp (required by d3). | ||
|
||
Running the tests | ||
|
||
cd WWW | ||
node structureWalker_tests.js | ||
|
||
Unit Tests | ||
========== | ||
|
||
Some unit tests already exist - run them using node. |
Oops, something went wrong.